summaryrefslogtreecommitdiffstats
path: root/src/login/pam_systemd.c
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2024-01-19 12:57:31 +0100
committerMike Yuan <me@yhndnzj.com>2024-01-19 13:08:39 +0100
commit79f36b64159708cf2b261207f007fe980e6dfaa5 (patch)
treeb9152887d4a9ae76c3588b56baedb47df37544dc /src/login/pam_systemd.c
parentboot: don't print error if device tree fixup protocol isn't supported (diff)
downloadsystemd-79f36b64159708cf2b261207f007fe980e6dfaa5.tar.xz
systemd-79f36b64159708cf2b261207f007fe980e6dfaa5.zip
pam_systemd: close pidfd after use
Diffstat (limited to '')
-rw-r--r--src/login/pam_systemd.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c
index d7814a7275..b8313b92cc 100644
--- a/src/login/pam_systemd.c
+++ b/src/login/pam_systemd.c
@@ -802,13 +802,21 @@ typedef struct SessionContext {
const char *runtime_max_sec;
} SessionContext;
-static int create_session_message(sd_bus *bus, pam_handle_t *handle, const SessionContext *context, bool avoid_pidfd, sd_bus_message **ret) {
+static int create_session_message(
+ sd_bus *bus,
+ pam_handle_t *handle,
+ const SessionContext *context,
+ bool avoid_pidfd,
+ sd_bus_message **ret) {
+
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
- int r, pidfd = -EBADFD;
+ _cleanup_close_ int pidfd = -EBADF;
+ int r;
assert(bus);
assert(handle);
assert(context);
+ assert(ret);
if (!avoid_pidfd) {
pidfd = pidfd_open(getpid_cached(), 0);
@@ -1066,7 +1074,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
r = create_session_message(bus,
handle,
&context,
- false /* avoid_pidfd = */,
+ /* avoid_pidfd = */ false,
&m);
if (r < 0)
return pam_bus_log_create_error(handle, r);