YARN-8622. Fixed container-executor compilation on MacOSX.
Contributed by Siyao Meng
(cherry picked from commit ef97a20831
)
This commit is contained in:
parent
2503409977
commit
4a64dab0dd
|
@ -1381,14 +1381,22 @@ static int check_privileges(const char *user) {
|
||||||
exit(INITIALIZE_USER_FAILED);
|
exit(INITIALIZE_USER_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
int rc = getgrouplist(user, pw->pw_gid, groups, &ngroups);
|
int rc = getgrouplist(user, pw->pw_gid, groups, &ngroups);
|
||||||
|
#else
|
||||||
|
int rc = getgrouplist(user, pw->pw_gid, (int *)groups, &ngroups);
|
||||||
|
#endif
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
groups = (gid_t *) alloc_and_clear_memory(ngroups, sizeof(gid_t));
|
groups = (gid_t *) alloc_and_clear_memory(ngroups, sizeof(gid_t));
|
||||||
if (groups == NULL) {
|
if (groups == NULL) {
|
||||||
fprintf(ERRORFILE, "Failed to allocate buffer for group lookup for user %s.\n", user);
|
fprintf(ERRORFILE, "Failed to allocate buffer for group lookup for user %s.\n", user);
|
||||||
exit(OUT_OF_MEMORY);
|
exit(OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
#ifdef __linux__
|
||||||
if (getgrouplist(user, pw->pw_gid, groups, &ngroups) == -1) {
|
if (getgrouplist(user, pw->pw_gid, groups, &ngroups) == -1) {
|
||||||
|
#else
|
||||||
|
if (getgrouplist(user, pw->pw_gid, (int *)groups, &ngroups) == -1) {
|
||||||
|
#endif
|
||||||
fprintf(ERRORFILE, "Fail to lookup groups for user %s.\n", user);
|
fprintf(ERRORFILE, "Fail to lookup groups for user %s.\n", user);
|
||||||
ret = 2;
|
ret = 2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue