summaryrefslogtreecommitdiff
path: root/src/login/pam_systemd.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-01-10 09:53:34 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-01-15 14:24:10 +0100
commit055c08ef67c4b2295a185f927dc8d76af3a8deef (patch)
treeec4c3bb56aa77b2d5da68ee5bba1418c4dc87b9a /src/login/pam_systemd.c
parenta1b939dfc74f1f6ac8e8ad41912ac322b5e2438c (diff)
downloadsystemd-055c08ef67c4b2295a185f927dc8d76af3a8deef.tar.gz
pam_systemd: do no allocate the path of fixed length
Diffstat (limited to 'src/login/pam_systemd.c')
-rw-r--r--src/login/pam_systemd.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c
index d466e50969..a33d8f05c5 100644
--- a/src/login/pam_systemd.c
+++ b/src/login/pam_systemd.c
@@ -28,6 +28,7 @@
#include "path-util.h"
#include "process-util.h"
#include "socket-util.h"
+#include "stdio-util.h"
#include "strv.h"
#include "terminal-util.h"
#include "util.h"
@@ -414,11 +415,9 @@ _public_ PAM_EXTERN int pam_sm_open_session(
pam_get_item(handle, PAM_SERVICE, (const void**) &service);
if (streq_ptr(service, "systemd-user")) {
- _cleanup_free_ char *rt = NULL;
-
- if (asprintf(&rt, "/run/user/"UID_FMT, pw->pw_uid) < 0)
- return PAM_BUF_ERR;
+ char rt[STRLEN("/run/user/") + DECIMAL_STR_MAX(uid_t)];
+ xsprintf(rt, "/run/user/"UID_FMT, pw->pw_uid);
if (validate_runtime_directory(handle, rt, pw->pw_uid)) {
r = pam_misc_setenv(handle, "XDG_RUNTIME_DIR", rt, 0);
if (r != PAM_SUCCESS) {