HDFS-9852. hdfs dfs -setfacl error message is misleading (Wei-Chiu Chuang via aw)
(cherry picked from commitb3649adf6a
) (cherry picked from commit84c785036f
)
This commit is contained in:
parent
8c5101ea6d
commit
35885e9540
|
@ -192,6 +192,9 @@ class AclCommands extends FsCommand {
|
||||||
boolean oneRemoveOption = cf.getOpt("b") || cf.getOpt("k");
|
boolean oneRemoveOption = cf.getOpt("b") || cf.getOpt("k");
|
||||||
boolean oneModifyOption = cf.getOpt("m") || cf.getOpt("x");
|
boolean oneModifyOption = cf.getOpt("m") || cf.getOpt("x");
|
||||||
boolean setOption = cf.getOpt("-set");
|
boolean setOption = cf.getOpt("-set");
|
||||||
|
boolean hasExpectedOptions = cf.getOpt("b") || cf.getOpt("k") ||
|
||||||
|
cf.getOpt("m") || cf.getOpt("x") || cf.getOpt("-set");
|
||||||
|
|
||||||
if ((bothRemoveOptions || bothModifyOptions)
|
if ((bothRemoveOptions || bothModifyOptions)
|
||||||
|| (oneRemoveOption && oneModifyOption)
|
|| (oneRemoveOption && oneModifyOption)
|
||||||
|| (setOption && (oneRemoveOption || oneModifyOption))) {
|
|| (setOption && (oneRemoveOption || oneModifyOption))) {
|
||||||
|
@ -201,8 +204,13 @@ class AclCommands extends FsCommand {
|
||||||
|
|
||||||
// Only -m, -x and --set expects <acl_spec>
|
// Only -m, -x and --set expects <acl_spec>
|
||||||
if (oneModifyOption || setOption) {
|
if (oneModifyOption || setOption) {
|
||||||
|
if (args.isEmpty()) {
|
||||||
|
throw new HadoopIllegalArgumentException(
|
||||||
|
"Missing arguments: <acl_spec> <path>");
|
||||||
|
}
|
||||||
if (args.size() < 2) {
|
if (args.size() < 2) {
|
||||||
throw new HadoopIllegalArgumentException("<acl_spec> is missing");
|
throw new HadoopIllegalArgumentException(
|
||||||
|
"Missing either <acl_spec> or <path>");
|
||||||
}
|
}
|
||||||
aclEntries = AclEntry.parseAclSpec(args.removeFirst(), !cf.getOpt("x"));
|
aclEntries = AclEntry.parseAclSpec(args.removeFirst(), !cf.getOpt("x"));
|
||||||
}
|
}
|
||||||
|
@ -214,6 +222,10 @@ class AclCommands extends FsCommand {
|
||||||
throw new HadoopIllegalArgumentException("Too many arguments");
|
throw new HadoopIllegalArgumentException("Too many arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!hasExpectedOptions) {
|
||||||
|
throw new HadoopIllegalArgumentException(
|
||||||
|
"Expected one of -b, -k, -m, -x or --set options");
|
||||||
|
}
|
||||||
// In recursive mode, save a separate list of just the access ACL entries.
|
// In recursive mode, save a separate list of just the access ACL entries.
|
||||||
// Only directories may have a default ACL. When a recursive operation
|
// Only directories may have a default ACL. When a recursive operation
|
||||||
// encounters a file under the specified path, it must pass only the
|
// encounters a file under the specified path, it must pass only the
|
||||||
|
|
|
@ -64,6 +64,10 @@ public class TestAclCommands {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetfaclValidations() throws Exception {
|
public void testSetfaclValidations() throws Exception {
|
||||||
|
assertFalse("setfacl should fail without options",
|
||||||
|
0 == runCommand(new String[] { "-setfacl", "/" }));
|
||||||
|
assertFalse("setfacl should fail without options -b, -k, -m, -x or --set",
|
||||||
|
0 == runCommand(new String[] { "-setfacl", "-R", "/" }));
|
||||||
assertFalse("setfacl should fail without path",
|
assertFalse("setfacl should fail without path",
|
||||||
0 == runCommand(new String[] { "-setfacl" }));
|
0 == runCommand(new String[] { "-setfacl" }));
|
||||||
assertFalse("setfacl should fail without aclSpec",
|
assertFalse("setfacl should fail without aclSpec",
|
||||||
|
|
Loading…
Reference in New Issue