Fixing an issue to do with setting of correct groups for tasks. Contributed by Aaron T Myers.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1301820 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Devaraj Das 2012-03-16 23:16:19 +00:00
parent f58e3c8b12
commit be5181ff2d

View File

@ -526,6 +526,17 @@ int set_user(const char *user) {
if (user_detail == NULL) { if (user_detail == NULL) {
return -1; 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); return change_effective_user(user_detail->pw_uid, user_detail->pw_gid);
} }