From f3ad53c0ce8676a075af23b108f430a035d78270 Mon Sep 17 00:00:00 2001 From: "Anna (navi) Figueiredo Gomes" Date: Thu, 15 Jun 2023 18:25:43 -0300 Subject: 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 --- src/openrc-pam/openrc-pam.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src') 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"); -- cgit v1.2.3