diff options
author | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2023-06-15 18:25:43 -0300 |
---|---|---|
committer | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2023-10-19 10:56:54 +0200 |
commit | f3ad53c0ce8676a075af23b108f430a035d78270 (patch) | |
tree | e8169f6b2cce62bdb0998a44da93007ca39d9513 /src | |
parent | 8d697f662cf2e59930f6b79726502cc016cec325 (diff) |
openrc-pam: allow to define runlevels by the arguments
this allows system administrators to define which runlevels to use,
could permit them for example, to include the module in another pam file
to customize when user scripts are auto-started, for example, allowing
users to define a 'remote' runlevel that would be executed in a ssh
login
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
Diffstat (limited to 'src')
-rw-r--r-- | src/openrc-pam/openrc-pam.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/openrc-pam/openrc-pam.c b/src/openrc-pam/openrc-pam.c index 60b517b4..f3ab710c 100644 --- a/src/openrc-pam/openrc-pam.c +++ b/src/openrc-pam/openrc-pam.c @@ -48,15 +48,14 @@ static bool exec_openrc(pam_handle_t *pamh, const char *runlevel) { } PAM_EXTERN int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv) { + const char *runlevel = argc > 0 ? runlevel = argv[0] : "default"; (void)flags; - (void)argc; - (void)argv; setenv("EINFO_LOG", "openrc-pam", 1); elog(LOG_INFO, "Opening openrc session"); setenv("RC_PAM_STARTING", "YES", true); - if (exec_openrc(pamh, "default")) { + if (exec_openrc(pamh, runlevel)) { elog(LOG_INFO, "Openrc session opened"); unsetenv("RC_PAM_STARTING"); unsetenv("EINFO_LOG"); @@ -70,15 +69,14 @@ PAM_EXTERN int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, cons } PAM_EXTERN int pam_sm_close_session(pam_handle_t *pamh, int flags, int argc, const char **argv) { + const char *runlevel = argc > 1 ? argv[1] : "none"; (void)flags; - (void)argc; - (void)argv; setenv("EINFO_LOG", "openrc-pam", 1); elog(LOG_INFO, "Closing openrc session"); setenv("RC_PAM_STOPPING", "YES", true); - if (exec_openrc(pamh, "none")) { + if (exec_openrc(pamh, runlevel)) { elog(LOG_INFO, "Openrc session closed"); unsetenv("RC_PAM_STOPPING"); unsetenv("EINFO_LOG"); |