|
@@ -57,15 +57,18 @@ public class FSDirAttrOp {
|
|
throw new InvalidPathException(src);
|
|
throw new InvalidPathException(src);
|
|
}
|
|
}
|
|
INodesInPath iip;
|
|
INodesInPath iip;
|
|
|
|
+ boolean changed;
|
|
fsd.writeLock();
|
|
fsd.writeLock();
|
|
try {
|
|
try {
|
|
iip = fsd.resolvePath(pc, src, DirOp.WRITE);
|
|
iip = fsd.resolvePath(pc, src, DirOp.WRITE);
|
|
fsd.checkOwner(pc, iip);
|
|
fsd.checkOwner(pc, iip);
|
|
- unprotectedSetPermission(fsd, iip, permission);
|
|
|
|
|
|
+ changed = unprotectedSetPermission(fsd, iip, permission);
|
|
} finally {
|
|
} finally {
|
|
fsd.writeUnlock();
|
|
fsd.writeUnlock();
|
|
}
|
|
}
|
|
- fsd.getEditLog().logSetPermissions(iip.getPath(), permission);
|
|
|
|
|
|
+ if (changed) {
|
|
|
|
+ fsd.getEditLog().logSetPermissions(iip.getPath(), permission);
|
|
|
|
+ }
|
|
return fsd.getAuditFileInfo(iip);
|
|
return fsd.getAuditFileInfo(iip);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -76,6 +79,7 @@ public class FSDirAttrOp {
|
|
throw new InvalidPathException(src);
|
|
throw new InvalidPathException(src);
|
|
}
|
|
}
|
|
INodesInPath iip;
|
|
INodesInPath iip;
|
|
|
|
+ boolean changed;
|
|
fsd.writeLock();
|
|
fsd.writeLock();
|
|
try {
|
|
try {
|
|
iip = fsd.resolvePath(pc, src, DirOp.WRITE);
|
|
iip = fsd.resolvePath(pc, src, DirOp.WRITE);
|
|
@@ -90,11 +94,13 @@ public class FSDirAttrOp {
|
|
"User " + pc.getUser() + " does not belong to " + group);
|
|
"User " + pc.getUser() + " does not belong to " + group);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- unprotectedSetOwner(fsd, iip, username, group);
|
|
|
|
|
|
+ changed = unprotectedSetOwner(fsd, iip, username, group);
|
|
} finally {
|
|
} finally {
|
|
fsd.writeUnlock();
|
|
fsd.writeUnlock();
|
|
}
|
|
}
|
|
- fsd.getEditLog().logSetOwner(iip.getPath(), username, group);
|
|
|
|
|
|
+ if (changed) {
|
|
|
|
+ fsd.getEditLog().logSetOwner(iip.getPath(), username, group);
|
|
|
|
+ }
|
|
return fsd.getAuditFileInfo(iip);
|
|
return fsd.getAuditFileInfo(iip);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -256,28 +262,32 @@ public class FSDirAttrOp {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- static void unprotectedSetPermission(
|
|
|
|
|
|
+ static boolean unprotectedSetPermission(
|
|
FSDirectory fsd, INodesInPath iip, FsPermission permissions)
|
|
FSDirectory fsd, INodesInPath iip, FsPermission permissions)
|
|
throws FileNotFoundException, UnresolvedLinkException,
|
|
throws FileNotFoundException, UnresolvedLinkException,
|
|
QuotaExceededException, SnapshotAccessControlException {
|
|
QuotaExceededException, SnapshotAccessControlException {
|
|
assert fsd.hasWriteLock();
|
|
assert fsd.hasWriteLock();
|
|
final INode inode = FSDirectory.resolveLastINode(iip);
|
|
final INode inode = FSDirectory.resolveLastINode(iip);
|
|
int snapshotId = iip.getLatestSnapshotId();
|
|
int snapshotId = iip.getLatestSnapshotId();
|
|
|
|
+ long oldPerm = inode.getPermissionLong();
|
|
inode.setPermission(permissions, snapshotId);
|
|
inode.setPermission(permissions, snapshotId);
|
|
|
|
+ return oldPerm != inode.getPermissionLong();
|
|
}
|
|
}
|
|
|
|
|
|
- static void unprotectedSetOwner(
|
|
|
|
|
|
+ static boolean unprotectedSetOwner(
|
|
FSDirectory fsd, INodesInPath iip, String username, String groupname)
|
|
FSDirectory fsd, INodesInPath iip, String username, String groupname)
|
|
throws FileNotFoundException, UnresolvedLinkException,
|
|
throws FileNotFoundException, UnresolvedLinkException,
|
|
QuotaExceededException, SnapshotAccessControlException {
|
|
QuotaExceededException, SnapshotAccessControlException {
|
|
assert fsd.hasWriteLock();
|
|
assert fsd.hasWriteLock();
|
|
final INode inode = FSDirectory.resolveLastINode(iip);
|
|
final INode inode = FSDirectory.resolveLastINode(iip);
|
|
|
|
+ long oldPerm = inode.getPermissionLong();
|
|
if (username != null) {
|
|
if (username != null) {
|
|
inode.setUser(username, iip.getLatestSnapshotId());
|
|
inode.setUser(username, iip.getLatestSnapshotId());
|
|
}
|
|
}
|
|
if (groupname != null) {
|
|
if (groupname != null) {
|
|
inode.setGroup(groupname, iip.getLatestSnapshotId());
|
|
inode.setGroup(groupname, iip.getLatestSnapshotId());
|
|
}
|
|
}
|
|
|
|
+ return oldPerm != inode.getPermissionLong();
|
|
}
|
|
}
|
|
|
|
|
|
static boolean setTimes(
|
|
static boolean setTimes(
|