Author: shv
Date: Tue Jun  5 02:43:50 2012
New Revision: 1346216

URL: http://svn.apache.org/viewvc?rev=1346216&view=rev
Log:
MAPREDUCE-4244. Set supplemental groups correctly. Contributed by Benoy Antony.

Modified:
    hadoop/common/branches/branch-0.22/mapreduce/CHANGES.txt
    
hadoop/common/branches/branch-0.22/mapreduce/src/c++/task-controller/impl/task-controller.c

Modified: hadoop/common/branches/branch-0.22/mapreduce/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.22/mapreduce/CHANGES.txt?rev=1346216&r1=1346215&r2=1346216&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.22/mapreduce/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.22/mapreduce/CHANGES.txt Tue Jun  5 
02:43:50 2012
@@ -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

Modified: 
hadoop/common/branches/branch-0.22/mapreduce/src/c++/task-controller/impl/task-controller.c
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.22/mapreduce/src/c%2B%2B/task-controller/impl/task-controller.c?rev=1346216&r1=1346215&r2=1346216&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-0.22/mapreduce/src/c++/task-controller/impl/task-controller.c
 (original)
+++ 
hadoop/common/branches/branch-0.22/mapreduce/src/c++/task-controller/impl/task-controller.c
 Tue Jun  5 02:43:50 2012
@@ -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);
 }
 


Reply via email to