From 9cde77fb7d360ae6f49c5468d187f7da8a4b90b4 Mon Sep 17 00:00:00 2001 From: "Anna (navi) Figueiredo Gomes" Date: Sat, 20 Jul 2024 18:25:27 +0200 Subject: openrc-pam: fix session count logic Signed-off-by: Anna (navi) Figueiredo Gomes --- src/openrc-pam/openrc-pam.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/openrc-pam/openrc-pam.c b/src/openrc-pam/openrc-pam.c index f0556ada..c2fd9662 100644 --- a/src/openrc-pam/openrc-pam.c +++ b/src/openrc-pam/openrc-pam.c @@ -63,13 +63,16 @@ exec_openrc(pam_handle_t *pamh, bool opening) sscanf(logins, "%d", &count); free(logins); - if (opening && count == 0) { - pid = service_start(file); - rc_service_mark(svc_name, RC_SERVICE_HOTPLUGGED); + if (opening) { + if (count == 0) { + pid = service_start(file); + rc_service_mark(svc_name, RC_SERVICE_HOTPLUGGED); + } count++; - } else if (count > 0) { - pid = service_stop(file); + } else { count--; + if (count == 0) + pid = service_stop(file); } if (pid > 0) { -- cgit v1.2.3