Sfoglia il codice sorgente

commit 720b051217e4b9a12e6334a90cb9fd8fe6ce1e36
Author: Lee Tucker <ltucker@yahoo-inc.com>
Date: Thu Jul 30 17:40:47 2009 -0700

Applying patch 2886449.5420.patch


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1076960 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 14 anni fa
parent
commit
e07a1030e7

+ 14 - 0
src/c++/task-controller/task-controller.c

@@ -326,6 +326,20 @@ int run_task_as_user(const char * user, const char *jobid, const char *taskid,
     }
     goto cleanup;
   }
+
+  if(chown(pid_path, uid, getgid()) < 0) {
+    fprintf(LOGFILE, "Error changing ownershipt of %s task-pid file : %s\n",
+      pid_path, strerror(errno));
+    errno = 0;
+    if (remove(pid_path) < 0) {
+      fprintf(LOGFILE, "Error deleting %s task-pid file : %s", pid_path,
+          strerror(errno));
+      exit_code = UNABLE_TO_CHANGE_OWNERSHIP_AND_DELETE_PID_FILE;
+    } else {
+      exit_code = UNABLE_TO_CHANGE_OWNERSHIP_OF_PID_FILE;
+    }
+    goto cleanup;
+  }
   //while checking path make sure the target of the path exists otherwise
   //check_paths would fail always. So write out .pid file then check if
   //it correctly resolves. If not delete the pid file and bail out.

+ 3 - 1
src/c++/task-controller/task-controller.h

@@ -61,7 +61,9 @@ enum errorcodes {
   ERROR_RESOLVING_FILE_PATH,
   RELATIVE_PATH_COMPONENTS_IN_FILE_PATH,
   UNABLE_TO_STAT_FILE,
-  FILE_NOT_OWNED_BY_TASKTRACKER
+  FILE_NOT_OWNED_BY_TASKTRACKER,
+  UNABLE_TO_CHANGE_OWNERSHIP_OF_PID_FILE,
+  UNABLE_TO_CHANGE_OWNERSHIP_AND_DELETE_PID_FILE
 };