hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iva...@apache.org
Subject svn commit: r1582958 - in /hadoop/common/trunk/hadoop-common-project/hadoop-common: CHANGES.txt src/test/java/org/apache/hadoop/util/TestWinUtils.java
Date Sat, 29 Mar 2014 06:26:55 GMT
Author: ivanmi
Date: Sat Mar 29 06:26:54 2014
New Revision: 1582958

URL: http://svn.apache.org/r1582958
Log:
HADOOP-9525. Add tests that validate winutils chmod behavior on folders. Contributed by Ivan
Mitic.

Modified:
    hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
    hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestWinUtils.java

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1582958&r1=1582957&r2=1582958&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Sat Mar 29 06:26:54
2014
@@ -475,6 +475,9 @@ Release 2.4.0 - UNRELEASED
     HADOOP-10301. AuthenticationFilter should return Forbidden for failed
     authentication. (Daryn Sharp via jing9)
 
+    HADOOP-9525. Add tests that validate winutils chmod behavior on folders
+    (ivanmi)
+
   BREAKDOWN OF HADOOP-10184 SUBTASKS AND RELATED JIRAS
 
     HADOOP-10185. FileSystem API for ACLs. (cnauroth)

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestWinUtils.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestWinUtils.java?rev=1582958&r1=1582957&r2=1582958&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestWinUtils.java
(original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestWinUtils.java
Sat Mar 29 06:26:54 2014
@@ -273,6 +273,85 @@ public class TestWinUtils {
     assertTrue(aExe.delete());
   }
 
+  /** Validate behavior of chmod commands on directories on Windows. */
+  @Test (timeout = 30000)
+  public void testBasicChmodOnDir() throws IOException {
+    // Validate that listing a directory with no read permission fails
+    File a = new File(TEST_DIR, "a");
+    File b = new File(a, "b");
+    a.mkdirs();
+    assertTrue(b.createNewFile());
+
+    // Remove read permissions on directory a
+    chmod("300", a);
+    String[] files = a.list();
+    assertTrue("Listing a directory without read permission should fail",
+        null == files);
+
+    // restore permissions
+    chmod("700", a);
+    // validate that the directory can be listed now
+    files = a.list();
+    assertEquals("b", files[0]);
+
+    // Remove write permissions on the directory and validate the
+    // behavior for adding, deleting and renaming files
+    chmod("500", a);
+    File c = new File(a, "c");
+ 
+    try {
+      // Adding a new file will fail as expected because the
+      // FILE_WRITE_DATA/FILE_ADD_FILE privilege is denied on
+      // the dir.
+      c.createNewFile();
+      assertFalse("writeFile should have failed!", true);
+    } catch (IOException ex) {
+      LOG.info("Expected: Failed to create a file when directory "
+          + "permissions are 577");
+    }
+
+    // Deleting a file will succeed even if write permissions are not present
+    // on the parent dir. Check the following link for additional details:
+    // http://support.microsoft.com/kb/238018
+    assertTrue("Special behavior: deleting a file will succeed on Windows "
+        + "even if a user does not have write permissions on the parent dir",
+        b.delete());
+
+    assertFalse("Renaming a file should fail on the dir where a user does "
+        + "not have write permissions", b.renameTo(new File(a, "d")));
+
+    // restore permissions
+    chmod("700", a);
+
+    // Make sure adding new files and rename succeeds now
+    assertTrue(c.createNewFile());
+    File d = new File(a, "d");
+    assertTrue(c.renameTo(d));
+    // at this point in the test, d is the only remaining file in directory a
+
+    // Removing execute permissions does not have the same behavior on
+    // Windows as on Linux. Adding, renaming, deleting and listing files
+    // will still succeed. Windows default behavior is to bypass directory
+    // traverse checking (BYPASS_TRAVERSE_CHECKING privilege) for all users.
+    // See the following link for additional details:
+    // http://msdn.microsoft.com/en-us/library/windows/desktop/aa364399(v=vs.85).aspx
+    chmod("600", a);
+
+    // validate directory listing
+    files = a.list();
+    assertEquals("d", files[0]);
+    // validate delete
+    assertTrue(d.delete());
+    // validate add
+    File e = new File(a, "e");
+    assertTrue(e.createNewFile());
+    // validate rename
+    assertTrue(e.renameTo(new File(a, "f")));
+
+    // restore permissions
+    chmod("700", a);
+  }
+
   @Test (timeout = 30000)
   public void testChmod() throws IOException {
     testChmodInternal("7", "-------rwx");



Mime
View raw message