Author: shv Date: Thu Dec 10 00:45:14 2009 New Revision: 889037 URL: http://svn.apache.org/viewvc?rev=889037&view=rev Log: HDFS-185. Merge -r 889034:889035 from trunk to branch-0.20.
Modified: hadoop/common/branches/branch-0.20/CHANGES.txt hadoop/common/branches/branch-0.20/src/core/org/apache/hadoop/fs/FsShellPermissions.java hadoop/common/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/cli/testConf.xml Modified: hadoop/common/branches/branch-0.20/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20/CHANGES.txt?rev=889037&r1=889036&r2=889037&view=diff ============================================================================== --- hadoop/common/branches/branch-0.20/CHANGES.txt (original) +++ hadoop/common/branches/branch-0.20/CHANGES.txt Thu Dec 10 00:45:14 2009 @@ -81,6 +81,9 @@ HADOOP-6386. NameNode's HttpServer can't instantiate InetSocketAddress: IllegalArgumentException is thrown. (cos) + HDFS-185. Disallow chown, chgrp, chmod, setQuota, and setSpaceQuota when + name-node is in safemode. (Ravi Phulari via shv) + Release 0.20.1 - 2009-09-01 INCOMPATIBLE CHANGES Modified: hadoop/common/branches/branch-0.20/src/core/org/apache/hadoop/fs/FsShellPermissions.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20/src/core/org/apache/hadoop/fs/FsShellPermissions.java?rev=889037&r1=889036&r2=889037&view=diff ============================================================================== --- hadoop/common/branches/branch-0.20/src/core/org/apache/hadoop/fs/FsShellPermissions.java (original) +++ hadoop/common/branches/branch-0.20/src/core/org/apache/hadoop/fs/FsShellPermissions.java Thu Dec 10 00:45:14 2009 @@ -182,7 +182,7 @@ new FsPermission((short)newperms)); } catch (IOException e) { System.err.println(getName() + ": changing permissions of '" + - file.getPath() + "':" + e.getMessage()); + file.getPath() + "':" + e.getMessage().split("\n")[0]); } } } @@ -223,7 +223,7 @@ } if (owner == null && group == null) { throw new IOException("'" + ownerStr + "' does not specify " + - " onwer or group."); + " owner or group."); } } @@ -240,7 +240,7 @@ srcFs.setOwner(file.getPath(), newOwner, newGroup); } catch (IOException e) { System.err.println(getName() + ": changing ownership of '" + - file.getPath() + "':" + e.getMessage()); + file.getPath() + "':" + e.getMessage().split("\n")[0]); } } Modified: hadoop/common/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=889037&r1=889036&r2=889037&view=diff ============================================================================== --- hadoop/common/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java (original) +++ hadoop/common/branches/branch-0.20/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java Thu Dec 10 00:45:14 2009 @@ -678,6 +678,8 @@ */ public synchronized void setPermission(String src, FsPermission permission ) throws IOException { + if (isInSafeMode()) + throw new SafeModeException("Cannot set permission for " + src, safeMode); checkOwner(src); dir.setPermission(src, permission); getEditLog().logSync(); @@ -695,6 +697,8 @@ */ public synchronized void setOwner(String src, String username, String group ) throws IOException { + if (isInSafeMode()) + throw new SafeModeException("Cannot set owner for " + src, safeMode); PermissionChecker pc = checkOwner(src); if (!pc.isSuper) { if (username != null && !pc.user.equals(username)) { @@ -1786,7 +1790,9 @@ * contract. */ void setQuota(String path, long nsQuota, long dsQuota) throws IOException { - if (isPermissionEnabled) { + if (isInSafeMode()) + throw new SafeModeException("Cannot set quota on " + path, safeMode); + if (isPermissionEnabled) { checkSuperuserPrivilege(); } Modified: hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/cli/testConf.xml URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/cli/testConf.xml?rev=889037&r1=889036&r2=889037&view=diff ============================================================================== --- hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/cli/testConf.xml (original) +++ hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/cli/testConf.xml Thu Dec 10 00:45:14 2009 @@ -3335,5 +3335,145 @@ </comparators> </test> + + <test> <!--Tested --> + <description>Verifying chmod operation is not permitted in safemode</description> + <test-commands> + <command>-fs NAMENODE -mkdir /test </command> + <command>-fs NAMENODE -touchz /test/file1 </command> + <dfs-admin-command>-fs NAMENODE -safemode enter </dfs-admin-command> + <command>-fs NAMENODE -chmod 777 /test/file1 </command> + </test-commands> + <cleanup-commands> + <dfs-admin-command>-fs NAMENODE -safemode leave </dfs-admin-command> + <dfs-admin-command>-fs NAMENODE -rmr /test </dfs-admin-command> + </cleanup-commands> + <comparators> + <comparator> + <type>SubstringComparator</type> + <expected-output>Cannot set permission for /test/file1. Name node is in safe mode.</expected-output> + </comparator> + </comparators> + </test> + + <test> <!--Tested --> + <description>Verifying chown operation is not permitted in safemode</description> + <test-commands> + <command>-fs NAMENODE -mkdir /test </command> + <command>-fs NAMENODE -touchz /test/file1 </command> + <dfs-admin-command>-fs NAMENODE -safemode enter </dfs-admin-command> + <command>-fs NAMENODE -chown root /test/file1 </command> + </test-commands> + <cleanup-commands> + <dfs-admin-command>-fs NAMENODE -safemode leave </dfs-admin-command> + <dfs-admin-command>-fs NAMENODE -rmr /test </dfs-admin-command> + </cleanup-commands> + <comparators> + <comparator> + <type>SubstringComparator</type> + <expected-output>Cannot set owner for /test/file1. Name node is in safe mode.</expected-output> + </comparator> + </comparators> + </test> + + <test> <!--Tested --> + <description>Verifying chgrp operation is not permitted in safemode</description> + <test-commands> + <command>-fs NAMENODE -mkdir /test </command> + <command>-fs NAMENODE -touchz /test/file1 </command> + <dfs-admin-command>-fs NAMENODE -safemode enter </dfs-admin-command> + <command>-fs NAMENODE -chgrp newgroup /test/file1 </command> + </test-commands> + <cleanup-commands> + <dfs-admin-command>-fs NAMENODE -safemode leave </dfs-admin-command> + <dfs-admin-command>-fs NAMENODE -rmr /test </dfs-admin-command> + </cleanup-commands> + <comparators> + <comparator> + <type>SubstringComparator</type> + <expected-output>Cannot set owner for /test/file1. Name node is in safe mode.</expected-output> + </comparator> + </comparators> + </test> + + + <test> <!--Tested --> + <description>Verifying setQuota operation is not permitted in safemode</description> + <test-commands> + <command>-fs NAMENODE -mkdir /test </command> + <dfs-admin-command>-fs NAMENODE -safemode enter </dfs-admin-command> + <dfs-admin-command>-fs NAMENODE -setQuota 100 /test </dfs-admin-command> + </test-commands> + <cleanup-commands> + <dfs-admin-command>-fs NAMENODE -safemode leave </dfs-admin-command> + <dfs-admin-command>-fs NAMENODE -rmr /test </dfs-admin-command> + </cleanup-commands> + <comparators> + <comparator> + <type>SubstringComparator</type> + <expected-output>setQuota: org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot set quota on /test. Name node is in safe mode.</expected-output> + </comparator> + </comparators> + </test> + + <test> <!--Tested --> + <description>Verifying clrQuota operation is not permitted in safemode</description> + <test-commands> + <command>-fs NAMENODE -mkdir /test </command> + <dfs-admin-command>-fs NAMENODE -safemode enter </dfs-admin-command> + <dfs-admin-command>-fs NAMENODE -clrQuota /test </dfs-admin-command> + </test-commands> + <cleanup-commands> + <dfs-admin-command>-fs NAMENODE -safemode leave </dfs-admin-command> + <dfs-admin-command>-fs NAMENODE -rmr /test </dfs-admin-command> + </cleanup-commands> + <comparators> + <comparator> + <type>SubstringComparator</type> + <expected-output>clrQuota: org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot set quota on /test. Name node is in safe mode.</expected-output> + </comparator> + </comparators> + </test> + + + <test> <!--Tested --> + <description>Verifying setSpaceQuota operation is not permitted in safemode</description> + <test-commands> + <command>-fs NAMENODE -mkdir /test </command> + <dfs-admin-command>-fs NAMENODE -safemode enter </dfs-admin-command> + <dfs-admin-command>-fs NAMENODE -setSpaceQuota 100 /test </dfs-admin-command> + </test-commands> + <cleanup-commands> + <dfs-admin-command>-fs NAMENODE -safemode leave </dfs-admin-command> + <dfs-admin-command>-fs NAMENODE -rmr /test </dfs-admin-command> + </cleanup-commands> + <comparators> + <comparator> + <type>SubstringComparator</type> + <expected-output>setSpaceQuota: org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot set quota on /test. Name node is in safe mode.</expected-output> + </comparator> + </comparators> + </test> + + <test> <!--Tested --> + <description>Verifying clrSpaceQuota operation is not permitted in safemode</description> + <test-commands> + <command>-fs NAMENODE -mkdir /test </command> + <dfs-admin-command>-fs NAMENODE -safemode enter </dfs-admin-command> + <dfs-admin-command>-fs NAMENODE -clrSpaceQuota /test </dfs-admin-command> + </test-commands> + <cleanup-commands> + <dfs-admin-command>-fs NAMENODE -safemode leave </dfs-admin-command> + <dfs-admin-command>-fs NAMENODE -rmr /test </dfs-admin-command> + </cleanup-commands> + <comparators> + <comparator> + <type>SubstringComparator</type> + <expected-output>clrSpaceQuota: org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot set quota on /test. Name node is in safe mode.</expected-output> + </comparator> + </comparators> + </test> + + </tests> </configuration>