Merge pull request #12157 from rmuir/plugin_permissions
Fix pluginmanager permissions for bin/ scripts
This commit is contained in:
commit
e4b355b790
|
@ -277,14 +277,21 @@ public class PluginManager {
|
|||
throw new IOException("Could not move [" + binFile + "] to [" + toLocation + "]", e);
|
||||
}
|
||||
if (Files.getFileStore(toLocation).supportsFileAttributeView(PosixFileAttributeView.class)) {
|
||||
final Set<PosixFilePermission> perms = new HashSet<>();
|
||||
perms.add(PosixFilePermission.OWNER_EXECUTE);
|
||||
perms.add(PosixFilePermission.GROUP_EXECUTE);
|
||||
perms.add(PosixFilePermission.OTHERS_EXECUTE);
|
||||
// add read and execute permissions to existing perms, so execution will work.
|
||||
// read should generally be set already, but set it anyway: don't rely on umask...
|
||||
final Set<PosixFilePermission> executePerms = new HashSet<>();
|
||||
executePerms.add(PosixFilePermission.OWNER_READ);
|
||||
executePerms.add(PosixFilePermission.GROUP_READ);
|
||||
executePerms.add(PosixFilePermission.OTHERS_READ);
|
||||
executePerms.add(PosixFilePermission.OWNER_EXECUTE);
|
||||
executePerms.add(PosixFilePermission.GROUP_EXECUTE);
|
||||
executePerms.add(PosixFilePermission.OTHERS_EXECUTE);
|
||||
Files.walkFileTree(toLocation, new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
if (attrs.isRegularFile()) {
|
||||
Set<PosixFilePermission> perms = Files.getPosixFilePermissions(file);
|
||||
perms.addAll(executePerms);
|
||||
Files.setPosixFilePermissions(file, perms);
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
|
|
|
@ -116,6 +116,8 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
|
|||
PosixFileAttributes attributes = view.readAttributes();
|
||||
assertTrue("unexpected permissions: " + attributes.permissions(),
|
||||
attributes.permissions().contains(PosixFilePermission.OWNER_EXECUTE));
|
||||
assertTrue("unexpected permissions: " + attributes.permissions(),
|
||||
attributes.permissions().contains(PosixFilePermission.OWNER_READ));
|
||||
}
|
||||
} finally {
|
||||
// we need to clean up the copied dirs
|
||||
|
|
Loading…
Reference in New Issue