From 94249757ee20041e84d31c1d3704b326170ff171 Mon Sep 17 00:00:00 2001 From: Devaraj Das Date: Fri, 16 Mar 2012 23:23:13 +0000 Subject: [PATCH] merge -r1301819:1301820 from trunk onto branch-0.23. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1301821 13f79535-47bb-0310-9956-ffa450edef68 --- .../container-executor/impl/container-executor.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c index 47256833964..d08a1d62bf8 100644 --- a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c +++ b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c @@ -526,6 +526,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); }