mirror of
https://github.com/javalsai/lidm.git
synced 2025-07-03 22:38:41 +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)
|
if (cb != NULL)
|
||||||
cb();
|
cb();
|
||||||
|
|
||||||
if(setgid(pw->pw_gid) == -1) {
|
if (setgid(pw->pw_gid) == -1) {
|
||||||
perror("setgid");
|
perror("setgid");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if(initgroups(user, pw->pw_gid) == -1) {
|
if (initgroups(user, pw->pw_gid) == -1) {
|
||||||
perror("init groups");
|
perror("init groups");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -133,10 +133,10 @@ bool launch(char *user, char *passwd, struct session session,
|
|||||||
free(envlist);
|
free(envlist);
|
||||||
moarEnv(user, session, pw);
|
moarEnv(user, session, pw);
|
||||||
|
|
||||||
pam_setcred(pamh, PAM_DELETE_CRED);
|
uint pid = fork();
|
||||||
pam_close_session(pamh, 0);
|
if (pid == 0) { // child
|
||||||
pam_end(pamh, PAM_SUCCESS);
|
// TODO: these will be different due to TryExec
|
||||||
|
// and, Exec/TryExec might contain spaces as args
|
||||||
if (session.type == SHELL) {
|
if (session.type == SHELL) {
|
||||||
system("clear");
|
system("clear");
|
||||||
execlp(session.exec, session.exec, NULL);
|
execlp(session.exec, session.exec, NULL);
|
||||||
@ -146,6 +146,13 @@ bool launch(char *user, char *passwd, struct session session,
|
|||||||
}
|
}
|
||||||
perror("execl error");
|
perror("execl error");
|
||||||
fprintf(stderr, "failure calling session");
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user