HDFS-3309. HttpFS (Hoop) chmod not supporting octal and sticky bit permissions. (tucu)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1331493 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Alejandro Abdelnur 2012-04-27 16:30:22 +00:00
parent 500dc61523
commit 84b36cfd80
4 changed files with 22 additions and 11 deletions

View File

@ -43,8 +43,8 @@ import java.util.Map;
public class FSOperations {
/**
* Converts a Unix permission octal & symbolic representation
* (i.e. 655 or -rwxr--r--) into a FileSystemAccess permission.
* Converts a Unix permission octal
* (i.e. 655 or 1777) into a FileSystemAccess permission.
*
* @param str Unix permission symbolic representation.
*
@ -55,10 +55,8 @@ public class FSOperations {
FsPermission permission;
if (str.equals(HttpFSFileSystem.DEFAULT_PERMISSION)) {
permission = FsPermission.getDefault();
} else if (str.length() == 3) {
permission = new FsPermission(Short.parseShort(str, 8));
} else {
permission = FsPermission.valueOf(str);
permission = new FsPermission(Short.parseShort(str, 8));
}
return permission;
}

View File

@ -446,7 +446,7 @@ public class HttpFSParams {
* Symbolic Unix permissions regular expression pattern.
*/
private static final Pattern PERMISSION_PATTERN =
Pattern.compile(DEFAULT + "|(-[-r][-w][-x][-r][-w][-x][-r][-w][-x])" + "|[0-7][0-7][0-7]");
Pattern.compile(DEFAULT + "|[0-1]?[0-7][0-7][0-7]");
/**
* Constructor.

View File

@ -310,11 +310,8 @@ public class TestHttpFSFileSystem extends HFSTestCase {
private void testSetPermission() throws Exception {
FileSystem fs = FileSystem.get(TestHdfsHelper.getHdfsConf());
Path path = new Path(TestHdfsHelper.getHdfsTestDir(), "foo.txt");
OutputStream os = fs.create(path);
os.write(1);
os.close();
fs.close();
Path path = new Path(TestHdfsHelper.getHdfsTestDir(), "foodir");
fs.mkdirs(path);
fs = getHttpFileSystem();
FsPermission permission1 = new FsPermission(FsAction.READ_WRITE, FsAction.NONE, FsAction.NONE);
@ -326,6 +323,19 @@ public class TestHttpFSFileSystem extends HFSTestCase {
fs.close();
FsPermission permission2 = status1.getPermission();
Assert.assertEquals(permission2, permission1);
//sticky bit
fs = getHttpFileSystem();
permission1 = new FsPermission(FsAction.READ_WRITE, FsAction.NONE, FsAction.NONE, true);
fs.setPermission(path, permission1);
fs.close();
fs = FileSystem.get(TestHdfsHelper.getHdfsConf());
status1 = fs.getFileStatus(path);
fs.close();
permission2 = status1.getPermission();
Assert.assertTrue(permission2.getStickyBit());
Assert.assertEquals(permission2, permission1);
}
private void testSetOwner() throws Exception {

View File

@ -567,6 +567,9 @@ Release 2.0.0 - UNRELEASED
HDFS-3181. Fix a test case in TestLeaseRecovery2. (szetszwo)
HDFS-3309. HttpFS (Hoop) chmod not supporting octal and sticky bit
permissions. (tucu)
BREAKDOWN OF HDFS-1623 SUBTASKS
HDFS-2179. Add fencing framework and mechanisms for NameNode HA. (todd)