hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cnaur...@apache.org
Subject svn commit: r1567784 - in /hadoop/common/branches/HDFS-4685/hadoop-common-project/hadoop-common/src: main/java/org/apache/hadoop/fs/permission/ main/java/org/apache/hadoop/fs/shell/ test/java/org/apache/hadoop/fs/permission/
Date Wed, 12 Feb 2014 22:54:49 GMT
Author: cnauroth
Date: Wed Feb 12 22:54:49 2014
New Revision: 1567784

URL: http://svn.apache.org/r1567784
Log:
HDFS-5923. Do not persist the ACL bit in the FsPermission. Contributed by Haohui Mai.

Modified:
    hadoop/common/branches/HDFS-4685/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java
    hadoop/common/branches/HDFS-4685/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java
    hadoop/common/branches/HDFS-4685/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java

Modified: hadoop/common/branches/HDFS-4685/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-4685/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java?rev=1567784&r1=1567783&r2=1567784&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-4685/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java
(original)
+++ hadoop/common/branches/HDFS-4685/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java
Wed Feb 12 22:54:49 2014
@@ -58,7 +58,6 @@ public class FsPermission implements Wri
   private FsAction groupaction = null;
   private FsAction otheraction = null;
   private boolean stickyBit = false;
-  private boolean aclBit = false;
 
   private FsPermission() {}
 
@@ -73,20 +72,7 @@ public class FsPermission implements Wri
   }
 
   public FsPermission(FsAction u, FsAction g, FsAction o, boolean sb) {
-    this(u, g, o, sb, false);
-  }
-
-  /**
-   * Construct by the given {@link FsAction} and special bits.
-   * @param u user action
-   * @param g group action
-   * @param o other action
-   * @param sb sticky bit
-   * @param ab ACL bit
-   */
-  public FsPermission(FsAction u, FsAction g, FsAction o, boolean sb,
-      boolean ab) {
-    set(u, g, o, sb, ab);
+    set(u, g, o, sb);
   }
 
   /**
@@ -106,7 +92,6 @@ public class FsPermission implements Wri
     this.groupaction = other.groupaction;
     this.otheraction = other.otheraction;
     this.stickyBit = other.stickyBit;
-    this.aclBit = other.aclBit;
   }
   
   /**
@@ -127,18 +112,16 @@ public class FsPermission implements Wri
   /** Return other {@link FsAction}. */
   public FsAction getOtherAction() {return otheraction;}
 
-  private void set(FsAction u, FsAction g, FsAction o, boolean sb, boolean ab) {
+  private void set(FsAction u, FsAction g, FsAction o, boolean sb) {
     useraction = u;
     groupaction = g;
     otheraction = o;
     stickyBit = sb;
-    aclBit = ab;
   }
 
   public void fromShort(short n) {
     FsAction[] v = FSACTION_VALUES;
-    set(v[(n >>> 6) & 7], v[(n >>> 3) & 7], v[n & 7], (((n
>>> 9) & 1) == 1),
-      (((n >>> 10) & 1) == 1) );
+    set(v[(n >>> 6) & 7], v[(n >>> 3) & 7], v[n & 7], (((n
>>> 9) & 1) == 1) );
   }
 
   @Override
@@ -164,8 +147,7 @@ public class FsPermission implements Wri
    * Encode the object to a short.
    */
   public short toShort() {
-    int s =  (aclBit ? 1 << 10 : 0)       |
-             (stickyBit ? 1 << 9 : 0)     |
+    int s =  (stickyBit ? 1 << 9 : 0)     |
              (useraction.ordinal() << 6)  |
              (groupaction.ordinal() << 3) |
              otheraction.ordinal();
@@ -180,8 +162,7 @@ public class FsPermission implements Wri
       return this.useraction == that.useraction
           && this.groupaction == that.groupaction
           && this.otheraction == that.otheraction
-          && this.stickyBit == that.stickyBit
-          && this.aclBit == that.aclBit;
+          && this.stickyBit == that.stickyBit;
     }
     return false;
   }
@@ -191,19 +172,15 @@ public class FsPermission implements Wri
 
   @Override
   public String toString() {
-    StringBuilder sb = new StringBuilder();
-    sb.append(useraction.SYMBOL);
-    sb.append(groupaction.SYMBOL);
-    sb.append(otheraction.SYMBOL);
-    if (stickyBit) {
-      sb.replace(sb.length() - 1, sb.length(),
+    String str = useraction.SYMBOL + groupaction.SYMBOL + otheraction.SYMBOL;
+    if(stickyBit) {
+      StringBuilder str2 = new StringBuilder(str);
+      str2.replace(str2.length() - 1, str2.length(),
            otheraction.implies(FsAction.EXECUTE) ? "t" : "T");
-    }
-    if (aclBit) {
-      sb.append('+');
+      str = str2.toString();
     }
 
-    return sb.toString();
+    return str;
   }
 
   /**
@@ -293,15 +270,6 @@ public class FsPermission implements Wri
     return stickyBit;
   }
 
-  /**
-   * Returns true if there is also an ACL (access control list).
-   *
-   * @return boolean true if there is also an ACL (access control list).
-   */
-  public boolean getAclBit() {
-    return aclBit;
-  }
-
   /** Set the user file creation mask (umask) */
   public static void setUMask(Configuration conf, FsPermission umask) {
     conf.set(UMASK_LABEL, String.format("%1$03o", umask.toShort()));
@@ -351,14 +319,13 @@ public class FsPermission implements Wri
     if (unixSymbolicPermission == null) {
       return null;
     }
-    else if (unixSymbolicPermission.length() != 10 &&
-        unixSymbolicPermission.length() != 11) {
-      throw new IllegalArgumentException("invalid length(unixSymbolicPermission="
+    else if (unixSymbolicPermission.length() != 10) {
+      throw new IllegalArgumentException("length != 10(unixSymbolicPermission="
           + unixSymbolicPermission + ")");
     }
 
     int n = 0;
-    for(int i = 1; i < 10; i++) {
+    for(int i = 1; i < unixSymbolicPermission.length(); i++) {
       n = n << 1;
       char c = unixSymbolicPermission.charAt(i);
       n += (c == '-' || c == 'T' || c == 'S') ? 0: 1;
@@ -369,11 +336,6 @@ public class FsPermission implements Wri
         unixSymbolicPermission.charAt(9) == 'T')
       n += 01000;
 
-    // Add ACL bit value if set
-    if (unixSymbolicPermission.length() == 11 &&
-         unixSymbolicPermission.charAt(10) == '+')
-      n += (1 << 10);
-
     return new FsPermission((short)n);
   }
   

Modified: hadoop/common/branches/HDFS-4685/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-4685/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java?rev=1567784&r1=1567783&r2=1567784&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-4685/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java
(original)
+++ hadoop/common/branches/HDFS-4685/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java
Wed Feb 12 22:54:49 2014
@@ -92,11 +92,12 @@ class AclCommands extends FsCommand {
       }
 
       FsPermission perm = item.stat.getPermission();
-      if (perm.getAclBit()) {
-        printExtendedAcl(perm, entries);
-      } else {
+      if (entries.isEmpty()) {
         printMinimalAcl(perm);
+      } else {
+        printExtendedAcl(perm, entries);
       }
+
       out.println();
     }
 

Modified: hadoop/common/branches/HDFS-4685/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-4685/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java?rev=1567784&r1=1567783&r2=1567784&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-4685/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java
(original)
+++ hadoop/common/branches/HDFS-4685/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java
Wed Feb 12 22:54:49 2014
@@ -54,7 +54,7 @@ public class TestFsPermission extends Te
    * the expected values back out for all combinations
    */
   public void testConvertingPermissions() {
-    for(short s = 0; s <= 03777; s++) {
+    for(short s = 0; s <= 01777; s++) {
       assertEquals(s, new FsPermission(s).toShort());
     }
 
@@ -70,15 +70,6 @@ public class TestFsPermission extends Te
             FsPermission f2 = new FsPermission(f);
             assertEquals(s, f2.toShort());
 
-            // Cover constructor with sticky bit and ACL bit.
-            for(boolean ab : new boolean [] { false, true }) {
-              short s2 = (short)(ab ? s | (1 << 10) : s);
-              FsPermission f3 = new FsPermission(u, g, o, sb, ab);
-              assertEquals(s2, f3.toShort());
-              FsPermission f4 = new FsPermission(f3);
-              assertEquals(s2, f4.toShort());
-            }
-
             s++;
           }
         }
@@ -87,34 +78,27 @@ public class TestFsPermission extends Te
   }
 
   public void testSpecialBitsToString() {
-    for(boolean ab : new boolean [] { false, true }) {
-      for(boolean sb : new boolean [] { false, true }) {
-        for(FsAction u : FsAction.values()) {
-          for(FsAction g : FsAction.values()) {
-            for(FsAction o : FsAction.values()) {
-              FsPermission f = new FsPermission(u, g, o, sb, ab);
-              String fString = f.toString();
-
-              // Check that sticky bit is represented correctly.
-              if(f.getStickyBit() && f.getOtherAction().implies(EXECUTE))
-                assertEquals('t', fString.charAt(8));
-              else if(f.getStickyBit() && !f.getOtherAction().implies(EXECUTE))
-                assertEquals('T', fString.charAt(8));
-              else if(!f.getStickyBit()  && f.getOtherAction().implies(EXECUTE))
-                assertEquals('x', fString.charAt(8));
-              else
-                assertEquals('-', fString.charAt(8));
-
-              // Check that ACL bit is represented correctly.
-              if (f.getAclBit()) {
-                assertEquals(10, fString.length());
-                assertEquals('+', fString.charAt(9));
-              } else {
-                assertEquals(9, fString.length());
-              }
-            }
+    for (boolean sb : new boolean[] { false, true }) {
+      for (FsAction u : FsAction.values()) {
+        for (FsAction g : FsAction.values()) {
+          for (FsAction o : FsAction.values()) {
+            FsPermission f = new FsPermission(u, g, o, sb);
+            String fString = f.toString();
+
+            // Check that sticky bit is represented correctly.
+            if (f.getStickyBit() && f.getOtherAction().implies(EXECUTE))
+              assertEquals('t', fString.charAt(8));
+            else if (f.getStickyBit() && !f.getOtherAction().implies(EXECUTE))
+              assertEquals('T', fString.charAt(8));
+            else if (!f.getStickyBit() && f.getOtherAction().implies(EXECUTE))
+              assertEquals('x', fString.charAt(8));
+            else
+              assertEquals('-', fString.charAt(8));
+
+            assertEquals(9, fString.length());
           }
         }
+
       }
     }
   }
@@ -122,7 +106,7 @@ public class TestFsPermission extends Te
   public void testFsPermission() {
     String symbolic = "-rwxrwxrwx";
 
-    for(int i = 0; i < (1 << 11); i++) {
+    for(int i = 0; i < (1 << 10); i++) {
       StringBuilder b = new StringBuilder("----------");
       String binary = String.format("%11s", Integer.toBinaryString(i));
       String permBinary = binary.substring(2, binary.length());
@@ -141,11 +125,6 @@ public class TestFsPermission extends Te
         b.setCharAt(9, replacement);
       }
 
-      // Check for ACL bit.
-      if (binary.charAt(0) == '1') {
-        b.append('+');
-      }
-
       assertEquals(i, FsPermission.valueOf(b.toString()).toShort());
     }
   }



Mime
View raw message