aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2024-07-20 18:25:27 +0200
committerAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2024-07-20 18:25:27 +0200
commit9cde77fb7d360ae6f49c5468d187f7da8a4b90b4 (patch)
tree172459d221e8c46b823b3a13aec62dfc45b6535d
parente849ef385ae37b59636976586db55f0a0917f83a (diff)
openrc-pam: fix session count logic
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
-rw-r--r--src/openrc-pam/openrc-pam.c13
1 files 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) {