Skip to content

Commit

Permalink
Plugins: Add executable flag to every file in bin/ after install
Browse files Browse the repository at this point in the history
The PluginManager does not preserve permissions on install. This patch
sets the executable flag on every file in bin/ on plugin install.

Closes #7177
  • Loading branch information
spinscale committed Aug 14, 2014
1 parent 4d05d1d commit 6023a3a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/main/java/org/elasticsearch/plugins/PluginManager.java
Expand Up @@ -43,6 +43,11 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
Expand Down Expand Up @@ -235,6 +240,16 @@ public void downloadAndExtract(String name) throws IOException {
if (!binFile.renameTo(toLocation)) {
throw new IOException("Could not move ["+ binFile.getAbsolutePath() + "] to [" + toLocation.getAbsolutePath() + "]");
}
// Make everything in bin/ executable
Files.walkFileTree(toLocation.toPath(), new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (attrs.isRegularFile()) {
file.toFile().setExecutable(true);
}
return FileVisitResult.CONTINUE;
}
});
debug("Installed " + name + " into " + toLocation.getAbsolutePath());
potentialSitePlugin = false;
}
Expand Down
Expand Up @@ -116,7 +116,9 @@ public void testLocalPluginInstallWithBinAndConfig() throws Exception {
assertThat(plugins.length, is(1));
assertTrue(pluginBinDir.exists());
assertTrue(pluginConfigDir.exists());

File toolFile = new File(pluginBinDir, "tool");
assertThat(toolFile.exists(), is(true));
assertThat(toolFile.canExecute(), is(true));
} finally {
// we need to clean up the copied dirs
FileSystemUtils.deleteRecursively(pluginBinDir);
Expand Down

0 comments on commit 6023a3a

Please sign in to comment.