diff options
author | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2024-07-20 19:28:11 +0200 |
---|---|---|
committer | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2024-07-20 19:28:11 +0200 |
commit | e29e28447041892ea025457d94746b8a9ba9d7e2 (patch) | |
tree | 31d3393327f1c7541dce484b0e27aefc67f7faba /src | |
parent | d5ebe7cc63f4a1c7dcaa6a561369b14b7d678ad6 (diff) |
openrc-pam: add logging
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
Diffstat (limited to 'src')
-rw-r--r-- | src/openrc-pam/openrc-pam.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/openrc-pam/openrc-pam.c b/src/openrc-pam/openrc-pam.c index c2fd9662..9fa33d2f 100644 --- a/src/openrc-pam/openrc-pam.c +++ b/src/openrc-pam/openrc-pam.c @@ -36,12 +36,17 @@ exec_openrc(pam_handle_t *pamh, bool opening) if (pw->pw_uid == 0) return PAM_SUCCESS; + xasprintf(&pam_lock, "openrc-pam.%s", pw->pw_name); + setenv("EINFO_LOG", pam_lock, true); + xasprintf(&svc_name, "user.%s", pw->pw_name); service_status = rc_service_state(svc_name); - if (service_status & RC_SERVICE_STARTED && !(service_status & RC_SERVICE_HOTPLUGGED)) + if (service_status & RC_SERVICE_STARTED && !(service_status & RC_SERVICE_HOTPLUGGED)) { + elog(LOG_INFO, "service started and not hotplugged, skipping session."); goto out; + } - xasprintf(&pam_lock, "openrc-pam.%s", pw->pw_name); + elog(LOG_INFO, opening ? "starting session" : "stopping session"); fd = svc_lock(pam_lock, false); if (fd == -1) { @@ -75,6 +80,8 @@ exec_openrc(pam_handle_t *pamh, bool opening) pid = service_stop(file); } + elog(LOG_INFO, "%d sessions", count); + if (pid > 0) { waitpid(pid, &status, 0); if (status != 0) @@ -99,6 +106,7 @@ exec_openrc(pam_handle_t *pamh, bool opening) out: free(pam_lock); free(svc_name); + unsetenv("EINFO_LOG"); return ret; } |