瀏覽代碼

merge -r1301803:1301804 from branch-1 onto branch-1.0. Patch contributed by Aaron T Myers

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.0@1301807 13f79535-47bb-0310-9956-ffa450edef68
Devaraj Das 13 年之前
父節點
當前提交
a6845bc1c0
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. 11 0
      src/c++/task-controller/impl/task-controller.c

+ 11 - 0
src/c++/task-controller/impl/task-controller.c

@@ -583,6 +583,17 @@ int set_user(const char *user) {
   if (user_detail == NULL) {
     return -1;
   }
+
+  if (geteuid() == user_detail->pw_uid) {
+    return 0;
+  }
+
+  if (initgroups(user, user_detail->pw_gid) != 0) {
+    fprintf(LOGFILE, "Error setting supplementary groups for user %s: %s\n",
+        user, strerror(errno));
+    return -1;
+  }
+
   return change_effective_user(user_detail->pw_uid, user_detail->pw_gid);
 }