HADOOP-10945. 4-digit octal umask permissions throws a parse error. Contributed by Chang Li
This commit is contained in:
parent
2b2bd92146
commit
6f0a35724f
|
@ -1023,6 +1023,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
HADOOP-12175. FsShell must load SpanReceierHost to support tracing
|
HADOOP-12175. FsShell must load SpanReceierHost to support tracing
|
||||||
(Masatake Iwasaki via Colin P. McCabe)
|
(Masatake Iwasaki via Colin P. McCabe)
|
||||||
|
|
||||||
|
HADOOP-10945. 4-digit octal umask permissions throws a parse error (Chang
|
||||||
|
Li via jlowe)
|
||||||
|
|
||||||
Release 2.7.2 - UNRELEASED
|
Release 2.7.2 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.apache.hadoop.classification.InterfaceStability;
|
||||||
@InterfaceStability.Unstable
|
@InterfaceStability.Unstable
|
||||||
class UmaskParser extends PermissionParser {
|
class UmaskParser extends PermissionParser {
|
||||||
private static Pattern chmodOctalPattern =
|
private static Pattern chmodOctalPattern =
|
||||||
Pattern.compile("^\\s*[+]?()([0-7]{3})\\s*$"); // no leading 1 for sticky bit
|
Pattern.compile("^\\s*[+]?(0*)([0-7]{3})\\s*$"); // no leading 1 for sticky bit
|
||||||
private static Pattern umaskSymbolicPattern = /* not allow X or t */
|
private static Pattern umaskSymbolicPattern = /* not allow X or t */
|
||||||
Pattern.compile("\\G\\s*([ugoa]*)([+=-]+)([rwx]*)([,\\s]*)\\s*");
|
Pattern.compile("\\G\\s*([ugoa]*)([+=-]+)([rwx]*)([,\\s]*)\\s*");
|
||||||
final short umaskMode;
|
final short umaskMode;
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.security;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -100,6 +101,31 @@ public class TestPermission {
|
||||||
conf = new Configuration();
|
conf = new Configuration();
|
||||||
conf.set(FsPermission.UMASK_LABEL, "022");
|
conf.set(FsPermission.UMASK_LABEL, "022");
|
||||||
assertEquals(18, FsPermission.getUMask(conf).toShort());
|
assertEquals(18, FsPermission.getUMask(conf).toShort());
|
||||||
|
|
||||||
|
// Test 5 - equivalent valid umask
|
||||||
|
conf = new Configuration();
|
||||||
|
conf.set(FsPermission.UMASK_LABEL, "0022");
|
||||||
|
assertEquals(18, FsPermission.getUMask(conf).toShort());
|
||||||
|
|
||||||
|
// Test 6 - invalid umask
|
||||||
|
conf = new Configuration();
|
||||||
|
conf.set(FsPermission.UMASK_LABEL, "1222");
|
||||||
|
try {
|
||||||
|
FsPermission.getUMask(conf);
|
||||||
|
fail("expect IllegalArgumentException happen");
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
//pass, exception successfully trigger
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test 7 - invalid umask
|
||||||
|
conf = new Configuration();
|
||||||
|
conf.set(FsPermission.UMASK_LABEL, "01222");
|
||||||
|
try {
|
||||||
|
FsPermission.getUMask(conf);
|
||||||
|
fail("expect IllegalArgumentException happen");
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
//pass, exception successfully trigger
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue