mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-09 14:34:43 +00:00
Plugins: Add executable flag to every file in bin/ after install
The PluginManager does not preserve permissions on install. This patch sets the executable flag on every file in bin/ on plugin install. Closes #7177
This commit is contained in:
parent
4d05d1d7b0
commit
6023a3a1a1
@ -43,6 +43,11 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
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.*;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
@ -235,6 +240,16 @@ public class PluginManager {
|
|||||||
if (!binFile.renameTo(toLocation)) {
|
if (!binFile.renameTo(toLocation)) {
|
||||||
throw new IOException("Could not move ["+ binFile.getAbsolutePath() + "] to [" + toLocation.getAbsolutePath() + "]");
|
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());
|
debug("Installed " + name + " into " + toLocation.getAbsolutePath());
|
||||||
potentialSitePlugin = false;
|
potentialSitePlugin = false;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,9 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
|
|||||||
assertThat(plugins.length, is(1));
|
assertThat(plugins.length, is(1));
|
||||||
assertTrue(pluginBinDir.exists());
|
assertTrue(pluginBinDir.exists());
|
||||||
assertTrue(pluginConfigDir.exists());
|
assertTrue(pluginConfigDir.exists());
|
||||||
|
File toolFile = new File(pluginBinDir, "tool");
|
||||||
|
assertThat(toolFile.exists(), is(true));
|
||||||
|
assertThat(toolFile.canExecute(), is(true));
|
||||||
} finally {
|
} finally {
|
||||||
// we need to clean up the copied dirs
|
// we need to clean up the copied dirs
|
||||||
FileSystemUtils.deleteRecursively(pluginBinDir);
|
FileSystemUtils.deleteRecursively(pluginBinDir);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user