aboutsummaryrefslogtreecommitdiff
path: root/src/openrc-pam/openrc-pam.c
diff options
context:
space:
mode:
authorAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2024-07-18 17:29:21 +0200
committerAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2024-07-20 03:15:17 +0200
commitc3ccaeeddc4d92bfe34cedaa6b71cb6e830fe280 (patch)
tree926df7c4c604381f4d7b7b9ebccfa13bacefa3d7 /src/openrc-pam/openrc-pam.c
parent18be0d77dc00d2e9faa7d8718e80a2f137ec0bf7 (diff)
librc, openrc-pam: instantiate user.<username> service automatically
it's created in /run/openrc/dynamic and linked to the service in /etc at login. Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
Diffstat (limited to 'src/openrc-pam/openrc-pam.c')
-rw-r--r--src/openrc-pam/openrc-pam.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/openrc-pam/openrc-pam.c b/src/openrc-pam/openrc-pam.c
index 241b123d..f0556ada 100644
--- a/src/openrc-pam/openrc-pam.c
+++ b/src/openrc-pam/openrc-pam.c
@@ -18,6 +18,7 @@ exec_openrc(pam_handle_t *pamh, bool opening)
char *svc_name = NULL;
char *pam_lock = NULL;
char *logins, *rundir;
+ char *file;
const char *username;
struct passwd *pw;
int count = 0, fd = -1;
@@ -48,17 +49,26 @@ exec_openrc(pam_handle_t *pamh, bool opening)
goto out;
}
+ file = rc_service_resolve(svc_name);
+ if (!file) {
+ file = rc_service_dylink("user", svc_name);
+ if (!file) {
+ svc_unlock(pam_lock, fd);
+ goto out;
+ }
+ }
+
logins = rc_service_value_get(svc_name, "logins");
if (logins)
sscanf(logins, "%d", &count);
free(logins);
if (opening && count == 0) {
- pid = service_start(svc_name);
+ pid = service_start(file);
rc_service_mark(svc_name, RC_SERVICE_HOTPLUGGED);
count++;
} else if (count > 0) {
- pid = service_stop(svc_name);
+ pid = service_stop(file);
count--;
}