Ver código fonte

MAPREDUCE-4244. Set supplemental groups correctly. Contributed by Benoy Antony.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.22@1346216 13f79535-47bb-0310-9956-ffa450edef68
Konstantin Shvachko 13 anos atrás
pai
commit
e6fca6f7ab

+ 2 - 0
mapreduce/CHANGES.txt

@@ -39,6 +39,8 @@ Release 0.22.1 - Unreleased
     MAPREDUCE-2178. Race condition in LinuxTaskController permissions handling.
     (Todd Lipcon, Benoy Antony via shv)
 
+    MAPREDUCE-4244. Set supplemental groups correctly. (Benoy Antony via shv)
+
 Release 0.22.0 - 2011-11-29
 
   INCOMPATIBLE CHANGES

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

@@ -490,6 +490,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);
 }