|
@@ -404,7 +404,6 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
static int BLOCK_DELETION_INCREMENT = 1000;
|
|
static int BLOCK_DELETION_INCREMENT = 1000;
|
|
private final boolean isPermissionEnabled;
|
|
private final boolean isPermissionEnabled;
|
|
private final UserGroupInformation fsOwner;
|
|
private final UserGroupInformation fsOwner;
|
|
- private final String fsOwnerShortUserName;
|
|
|
|
private final String supergroup;
|
|
private final String supergroup;
|
|
private final boolean standbyShouldCheckpoint;
|
|
private final boolean standbyShouldCheckpoint;
|
|
|
|
|
|
@@ -777,7 +776,6 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
DFS_STORAGE_POLICY_ENABLED_DEFAULT);
|
|
DFS_STORAGE_POLICY_ENABLED_DEFAULT);
|
|
|
|
|
|
this.fsOwner = UserGroupInformation.getCurrentUser();
|
|
this.fsOwner = UserGroupInformation.getCurrentUser();
|
|
- this.fsOwnerShortUserName = fsOwner.getShortUserName();
|
|
|
|
this.supergroup = conf.get(DFS_PERMISSIONS_SUPERUSERGROUP_KEY,
|
|
this.supergroup = conf.get(DFS_PERMISSIONS_SUPERUSERGROUP_KEY,
|
|
DFS_PERMISSIONS_SUPERUSERGROUP_DEFAULT);
|
|
DFS_PERMISSIONS_SUPERUSERGROUP_DEFAULT);
|
|
this.isPermissionEnabled = conf.getBoolean(DFS_PERMISSIONS_ENABLED_KEY,
|
|
this.isPermissionEnabled = conf.getBoolean(DFS_PERMISSIONS_ENABLED_KEY,
|
|
@@ -3922,11 +3920,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
|
|
|
private FSPermissionChecker getPermissionChecker()
|
|
private FSPermissionChecker getPermissionChecker()
|
|
throws AccessControlException {
|
|
throws AccessControlException {
|
|
- try {
|
|
|
|
- return new FSPermissionChecker(fsOwnerShortUserName, supergroup, getRemoteUser());
|
|
|
|
- } catch (IOException ioe) {
|
|
|
|
- throw new AccessControlException(ioe);
|
|
|
|
- }
|
|
|
|
|
|
+ return dir.getPermissionChecker();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -6411,13 +6405,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
|
|
|
private void checkOwner(FSPermissionChecker pc, String path)
|
|
private void checkOwner(FSPermissionChecker pc, String path)
|
|
throws AccessControlException, UnresolvedLinkException {
|
|
throws AccessControlException, UnresolvedLinkException {
|
|
- checkPermission(pc, path, true, null, null, null, null);
|
|
|
|
|
|
+ dir.checkOwner(pc, path);
|
|
}
|
|
}
|
|
|
|
|
|
private void checkPathAccess(FSPermissionChecker pc,
|
|
private void checkPathAccess(FSPermissionChecker pc,
|
|
String path, FsAction access) throws AccessControlException,
|
|
String path, FsAction access) throws AccessControlException,
|
|
UnresolvedLinkException {
|
|
UnresolvedLinkException {
|
|
- checkPermission(pc, path, false, null, null, access, null);
|
|
|
|
|
|
+ dir.checkPathAccess(pc, path, access);
|
|
}
|
|
}
|
|
|
|
|
|
private void checkUnreadableBySuperuser(FSPermissionChecker pc,
|
|
private void checkUnreadableBySuperuser(FSPermissionChecker pc,
|
|
@@ -6438,18 +6432,18 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
private void checkParentAccess(FSPermissionChecker pc,
|
|
private void checkParentAccess(FSPermissionChecker pc,
|
|
String path, FsAction access) throws AccessControlException,
|
|
String path, FsAction access) throws AccessControlException,
|
|
UnresolvedLinkException {
|
|
UnresolvedLinkException {
|
|
- checkPermission(pc, path, false, null, access, null, null);
|
|
|
|
|
|
+ dir.checkParentAccess(pc, path, access);
|
|
}
|
|
}
|
|
|
|
|
|
private void checkAncestorAccess(FSPermissionChecker pc,
|
|
private void checkAncestorAccess(FSPermissionChecker pc,
|
|
String path, FsAction access) throws AccessControlException,
|
|
String path, FsAction access) throws AccessControlException,
|
|
UnresolvedLinkException {
|
|
UnresolvedLinkException {
|
|
- checkPermission(pc, path, false, access, null, null, null);
|
|
|
|
|
|
+ dir.checkAncestorAccess(pc, path, access);
|
|
}
|
|
}
|
|
|
|
|
|
private void checkTraverse(FSPermissionChecker pc, String path)
|
|
private void checkTraverse(FSPermissionChecker pc, String path)
|
|
throws AccessControlException, UnresolvedLinkException {
|
|
throws AccessControlException, UnresolvedLinkException {
|
|
- checkPermission(pc, path, false, null, null, null, null);
|
|
|
|
|
|
+ dir.checkTraverse(pc, path);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -6470,30 +6464,17 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
String path, boolean doCheckOwner, FsAction ancestorAccess,
|
|
String path, boolean doCheckOwner, FsAction ancestorAccess,
|
|
FsAction parentAccess, FsAction access, FsAction subAccess)
|
|
FsAction parentAccess, FsAction access, FsAction subAccess)
|
|
throws AccessControlException, UnresolvedLinkException {
|
|
throws AccessControlException, UnresolvedLinkException {
|
|
- checkPermission(pc, path, doCheckOwner, ancestorAccess,
|
|
|
|
|
|
+ checkPermission(pc, path, doCheckOwner, ancestorAccess,
|
|
parentAccess, access, subAccess, false, true);
|
|
parentAccess, access, subAccess, false, true);
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * Check whether current user have permissions to access the path. For more
|
|
|
|
- * details of the parameters, see
|
|
|
|
- * {@link FSPermissionChecker#checkPermission}.
|
|
|
|
- */
|
|
|
|
private void checkPermission(FSPermissionChecker pc,
|
|
private void checkPermission(FSPermissionChecker pc,
|
|
String path, boolean doCheckOwner, FsAction ancestorAccess,
|
|
String path, boolean doCheckOwner, FsAction ancestorAccess,
|
|
FsAction parentAccess, FsAction access, FsAction subAccess,
|
|
FsAction parentAccess, FsAction access, FsAction subAccess,
|
|
boolean ignoreEmptyDir, boolean resolveLink)
|
|
boolean ignoreEmptyDir, boolean resolveLink)
|
|
throws AccessControlException, UnresolvedLinkException {
|
|
throws AccessControlException, UnresolvedLinkException {
|
|
- if (!pc.isSuperUser()) {
|
|
|
|
- waitForLoadingFSImage();
|
|
|
|
- readLock();
|
|
|
|
- try {
|
|
|
|
- pc.checkPermission(path, dir, doCheckOwner, ancestorAccess,
|
|
|
|
- parentAccess, access, subAccess, ignoreEmptyDir, resolveLink);
|
|
|
|
- } finally {
|
|
|
|
- readUnlock();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ dir.checkPermission(pc, path, doCheckOwner, ancestorAccess, parentAccess,
|
|
|
|
+ access, subAccess, ignoreEmptyDir, resolveLink);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|