Return-Path: Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: (qmail 47735 invoked from network); 4 Mar 2011 04:38:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Mar 2011 04:38:56 -0000 Received: (qmail 71894 invoked by uid 500); 4 Mar 2011 04:38:55 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 71854 invoked by uid 500); 4 Mar 2011 04:38:55 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 71813 invoked by uid 99); 4 Mar 2011 04:38:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Mar 2011 04:38:55 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Mar 2011 04:38:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1DA58238899C; Fri, 4 Mar 2011 04:38:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1077632 - in /hadoop/common/branches/branch-0.20-security-patches/src: mapred/org/apache/hadoop/mapred/JobHistory.java test/org/apache/hadoop/mapred/TestJobHistory.java Date: Fri, 04 Mar 2011 04:38:31 -0000 To: common-commits@hadoop.apache.org From: omalley@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110304043831.1DA58238899C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: omalley Date: Fri Mar 4 04:38:30 2011 New Revision: 1077632 URL: http://svn.apache.org/viewvc?rev=1077632&view=rev Log: commit ef735b317e99351d7a98b11fa48de4dc9a55bd8b Author: Arun C Murthy Date: Tue Aug 3 15:27:20 2010 -0700 MAPREDUCE-323. Fixed job history files' permissions. Modified: hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobHistory.java hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobHistory.java Modified: hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobHistory.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobHistory.java?rev=1077632&r1=1077631&r2=1077632&view=diff ============================================================================== --- hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobHistory.java (original) +++ hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobHistory.java Fri Mar 4 04:38:30 2011 @@ -402,7 +402,7 @@ public class JobHistory { if (!DONEDIR_FS.exists(dir)) { LOG.info("Creating DONE subfolder at "+ dir); - if (!DONEDIR_FS.mkdirs(dir, + if (!FileSystem.mkdirs(DONEDIR_FS, dir, new FsPermission(HISTORY_DIR_PERMISSION))) { throw new IOException("Mkdirs failed to create " + dir.toString()); } Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobHistory.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobHistory.java?rev=1077632&r1=1077631&r2=1077632&view=diff ============================================================================== --- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobHistory.java (original) +++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobHistory.java Fri Mar 4 04:38:30 2011 @@ -32,8 +32,10 @@ import java.util.regex.Pattern; import junit.framework.TestCase; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.PathFilter; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.mapred.JobHistory.*; @@ -885,7 +887,32 @@ public class TestJobHistory extends Test assertTrue("Completed job and config file aren't in the same directory", confFile.getParent().toString().equals(logFile.getParent().toString())); + + // Test that all of the ancestors of the log file have the same + // permissions as the done directory + Path cursor = logFile.getParent(); + + Path doneParent = doneDir.getParent(); + + FsPermission donePermission = getStatus(fileSys, doneDir).getPermission(); + + System.err.println("testDoneFolderOnHDFS: done dir permission = " + + donePermission); + + while (!cursor.equals(doneParent)) { + FileStatus cursorStatus = getStatus(fileSys, cursor); + FsPermission cursorPermission = cursorStatus.getPermission(); + + assertEquals("testDoneFolderOnHDFS: A done directory descendant, " + + cursor + + " does not have the same permisison as the done directory, " + + doneDir, + donePermission, + cursorPermission); + + cursor = cursor.getParent(); + } // check if the job file is removed from the history location Path runningJobsHistoryFolder = logFile.getParent().getParent(); @@ -910,6 +937,26 @@ public class TestJobHistory extends Test } } + private static FileStatus getStatus(FileSystem fs, final Path path) { + Path pathParent = path.getParent(); + + try { + FileStatus[] statuses + = fs.listStatus(pathParent, + new PathFilter() { + @Override + public boolean accept(Path filterPath) { + return filterPath.getName().equals(path.getName()); + } + } + ); + + return statuses[0]; + } catch (IOException e) { + return null; + } + } + /** Run a job that will be succeeded and validate its history file format * and its content. */