summaryrefslogtreecommitdiff
path: root/src/login/pam_systemd.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-05-07 12:53:51 +0200
committerLennart Poettering <lennart@poettering.net>2020-05-20 00:47:37 +0200
commite945dd9eedb4feb8fbc94f3e8579586f98fe10f2 (patch)
tree541dd2c8cdd8f3d4db0e14eaeba5a57f83f69def /src/login/pam_systemd.c
parent764ae4dd51dc343600415b0b8fef33f546ee4946 (diff)
downloadsystemd-e945dd9eedb4feb8fbc94f3e8579586f98fe10f2.tar.gz
pam_systemd: clean up success path
Let's make sure we always apply the process properties from the user record, in all our three successful paths: 1. when we register a regular session 2. when we run for the systemd --user session 3. when we have no logind (but might still have complex user records from elsewhere) and thus exit early
Diffstat (limited to 'src/login/pam_systemd.c')
-rw-r--r--src/login/pam_systemd.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c
index 96ce4742f0..64771153cd 100644
--- a/src/login/pam_systemd.c
+++ b/src/login/pam_systemd.c
@@ -647,10 +647,6 @@ _public_ PAM_EXTERN int pam_sm_open_session(
assert(handle);
- /* Make this a NOP on non-logind systems */
- if (!logind_running())
- return PAM_SUCCESS;
-
if (parse_argv(handle,
argc, argv,
&class_pam,
@@ -666,6 +662,10 @@ _public_ PAM_EXTERN int pam_sm_open_session(
if (r != PAM_SUCCESS)
return r;
+ /* Make most of this a NOP on non-logind systems */
+ if (!logind_running())
+ goto success;
+
/* Make sure we don't enter a loop by talking to
* systemd-logind when it is actually waiting for the
* background to finish start-up. If the service is
@@ -689,11 +689,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
if (r != PAM_SUCCESS)
return r;
- r = apply_user_record_settings(handle, ur, debug);
- if (r != PAM_SUCCESS)
- return r;
-
- return PAM_SUCCESS;
+ goto success;
}
/* Otherwise, we ask logind to create a session for us */
@@ -847,7 +843,9 @@ _public_ PAM_EXTERN int pam_sm_open_session(
if (sd_bus_error_has_name(&error, BUS_ERROR_SESSION_BUSY)) {
if (debug)
pam_syslog(handle, LOG_DEBUG, "Not creating session: %s", bus_error_message(&error, r));
- return PAM_SUCCESS;
+
+ /* We are already in a session, don't do anything */
+ goto success;
} else {
pam_syslog(handle, LOG_ERR, "Failed to create session: %s", bus_error_message(&error, r));
return PAM_SESSION_ERR;
@@ -944,6 +942,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
}
}
+success:
r = apply_user_record_settings(handle, ur, debug);
if (r != PAM_SUCCESS)
return r;