mirror of
https://github.com/javalsai/lidm.git
synced 2025-07-03 14:25:03 +02:00
fix: keep pam session alive
This commit is contained in:
parent
e8ec94e150
commit
12207ee4a9
19
src/auth.c
19
src/auth.c
@ -101,11 +101,11 @@ bool launch(char *user, char *passwd, struct session session,
|
||||
if (cb != NULL)
|
||||
cb();
|
||||
|
||||
if(setgid(pw->pw_gid) == -1) {
|
||||
if (setgid(pw->pw_gid) == -1) {
|
||||
perror("setgid");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if(initgroups(user, pw->pw_gid) == -1) {
|
||||
if (initgroups(user, pw->pw_gid) == -1) {
|
||||
perror("init groups");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -133,10 +133,10 @@ bool launch(char *user, char *passwd, struct session session,
|
||||
free(envlist);
|
||||
moarEnv(user, session, pw);
|
||||
|
||||
pam_setcred(pamh, PAM_DELETE_CRED);
|
||||
pam_close_session(pamh, 0);
|
||||
pam_end(pamh, PAM_SUCCESS);
|
||||
|
||||
uint pid = fork();
|
||||
if (pid == 0) { // child
|
||||
// TODO: these will be different due to TryExec
|
||||
// and, Exec/TryExec might contain spaces as args
|
||||
if (session.type == SHELL) {
|
||||
system("clear");
|
||||
execlp(session.exec, session.exec, NULL);
|
||||
@ -146,6 +146,13 @@ bool launch(char *user, char *passwd, struct session session,
|
||||
}
|
||||
perror("execl error");
|
||||
fprintf(stderr, "failure calling session");
|
||||
} else {
|
||||
waitpid(pid, NULL, 0);
|
||||
|
||||
pam_setcred(pamh, PAM_DELETE_CRED);
|
||||
pam_close_session(pamh, 0);
|
||||
pam_end(pamh, PAM_SUCCESS);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user