diff options
author | matt335672 <30179339+matt335672@users.noreply.github.com> | 2021-09-02 13:44:51 +0300 |
---|---|---|
committer | matt335672 <30179339+matt335672@users.noreply.github.com> | 2022-04-05 18:07:26 +0300 |
commit | 4183d8ddbfd1399a1c7255f6de31298bea18655b (patch) | |
tree | 5df19c8b49bb9c22d14f2e5a1e0a80bf96fb7983 /common | |
parent | cd1af4772cb6223c1348b0c6af953e45a533c2d1 (diff) |
Moved initgroups call to before auth_start_session()
This is required for PAM systems that depend on group membership being
available during PAM processing. This is used by pam_group on FreeBSD
and pam_group on Linux-PAM, although the functionality of both is
different.
Diffstat (limited to 'common')
-rw-r--r-- | common/os_calls.c | 10 | ||||
-rw-r--r-- | common/os_calls.h | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/common/os_calls.c b/common/os_calls.c index 2fdbea4a..e3561ebb 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -2875,12 +2875,18 @@ g_setgid(int pid) /* returns error, zero is success, non zero is error */ /* does not work in win32 */ int -g_initgroups(const char *user, int gid) +g_initgroups(const char *username) { #if defined(_WIN32) return 0; #else - return initgroups(user, gid); + int gid; + int error = g_getuser_info(username, &gid, NULL, NULL, NULL, NULL); + if (error == 0) + { + error = initgroups(username, gid); + } + return error; #endif } diff --git a/common/os_calls.h b/common/os_calls.h index 3511d7cc..3550b68d 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -159,7 +159,7 @@ void g_signal_pipe(void (*func)(int)); void g_signal_usr1(void (*func)(int)); int g_fork(void); int g_setgid(int pid); -int g_initgroups(const char *user, int gid); +int g_initgroups(const char *user); int g_getuid(void); int g_getgid(void); int g_setuid(int pid); |