aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2023-06-13 16:13:49 -0300
committerAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2023-10-19 10:56:54 +0200
commitcfade2f00a88928074f5b95c140e925eb350d463 (patch)
treec843acfea7cf24dfc869d0b976959a719987e7ca /src
parente60d770734170e77ac2d3afd940b2ab06e48e3f5 (diff)
openrc-pam: Add syslog logs for opening, closing and runing a runlevel
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
Diffstat (limited to 'src')
-rw-r--r--src/openrc-pam/openrc-pam.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/openrc-pam/openrc-pam.c b/src/openrc-pam/openrc-pam.c
index 5b480836..eba3846b 100644
--- a/src/openrc-pam/openrc-pam.c
+++ b/src/openrc-pam/openrc-pam.c
@@ -9,6 +9,8 @@
#include <security/pam_appl.h>
#endif
+#include "einfo.h"
+
static bool exec_openrc(pam_handle_t *pamh, const char *runlevel) {
char *cmd = NULL;
const char *username;
@@ -20,6 +22,8 @@ static bool exec_openrc(pam_handle_t *pamh, const char *runlevel) {
if (!pw)
return false;
+ elog(LOG_INFO, "Executing %s runlevel for user %s", runlevel, username);
+
xasprintf(&cmd, "openrc --user %s", runlevel);
switch (fork()) {
case 0:
@@ -46,12 +50,19 @@ PAM_EXTERN int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, cons
(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")) {
+ elog(LOG_INFO, "Openrc session opened");
unsetenv("RC_PAM_STARTING");
+ unsetenv("EINFO_LOG");
return PAM_SUCCESS;
} else {
+ elog(LOG_ERR, "Failed to open session");
unsetenv("RC_PAM_STARTING");
+ unsetenv("EINFO_LOG");
return PAM_SESSION_ERR;
}
}
@@ -61,12 +72,19 @@ PAM_EXTERN int pam_sm_close_session(pam_handle_t *pamh, int flags, int argc, con
(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")) {
+ elog(LOG_INFO, "Openrc session closed");
unsetenv("RC_PAM_STOPPING");
+ unsetenv("EINFO_LOG");
return PAM_SUCCESS;
} else {
+ elog(LOG_ERR, "Failed to close session");
unsetenv("RC_PAM_STOPPING");
+ unsetenv("EINFO_LOG");
return PAM_SESSION_ERR;
}
}