Merge pull request #1983 from matt335672/pam_group_fix
Moved g_initgroups() call to before auth_start_session()
This commit is contained in:
commit
34fe9b60eb
@ -2924,12 +2924,18 @@ g_setgid(int pid)
|
|||||||
/* returns error, zero is success, non zero is error */
|
/* returns error, zero is success, non zero is error */
|
||||||
/* does not work in win32 */
|
/* does not work in win32 */
|
||||||
int
|
int
|
||||||
g_initgroups(const char *user, int gid)
|
g_initgroups(const char *username)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ void g_signal_pipe(void (*func)(int));
|
|||||||
void g_signal_usr1(void (*func)(int));
|
void g_signal_usr1(void (*func)(int));
|
||||||
int g_fork(void);
|
int g_fork(void);
|
||||||
int g_setgid(int pid);
|
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_getuid(void);
|
||||||
int g_getgid(void);
|
int g_getgid(void);
|
||||||
int g_setuid(int pid);
|
int g_setuid(int pid);
|
||||||
|
@ -112,13 +112,11 @@ env_set_user(const char *username, char **passwd_file, int display,
|
|||||||
if (error == 0)
|
if (error == 0)
|
||||||
{
|
{
|
||||||
g_rm_temp_dir();
|
g_rm_temp_dir();
|
||||||
|
/*
|
||||||
|
* Set the primary group. Note that secondary groups should already
|
||||||
|
* have been set */
|
||||||
error = g_setgid(pw_gid);
|
error = g_setgid(pw_gid);
|
||||||
|
|
||||||
if (error == 0)
|
|
||||||
{
|
|
||||||
error = g_initgroups(username, pw_gid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
{
|
{
|
||||||
uid = pw_uid;
|
uid = pw_uid;
|
||||||
|
@ -525,6 +525,16 @@ session_start(long data,
|
|||||||
g_delete_wait_obj(g_sigchld_event);
|
g_delete_wait_obj(g_sigchld_event);
|
||||||
g_delete_wait_obj(g_term_event);
|
g_delete_wait_obj(g_term_event);
|
||||||
|
|
||||||
|
/* Set the secondary groups before starting the session to prevent
|
||||||
|
* problems on PAM-based systems (see pam_setcred(3)) */
|
||||||
|
if (g_initgroups(s->username) != 0)
|
||||||
|
{
|
||||||
|
LOG(LOG_LEVEL_ERROR,
|
||||||
|
"Failed to initialise secondary groups for %s: %s",
|
||||||
|
s->username, g_get_strerror());
|
||||||
|
g_exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
auth_start_session(data, display);
|
auth_start_session(data, display);
|
||||||
sesman_close_all();
|
sesman_close_all();
|
||||||
g_sprintf(geometry, "%dx%d", s->width, s->height);
|
g_sprintf(geometry, "%dx%d", s->width, s->height);
|
||||||
|
Loading…
Reference in New Issue
Block a user