From ac5dd3380f27a32766722d0de50c811329d7bf63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Wed, 19 Mar 2025 03:53:53 +0100 Subject: [PATCH] Prefix directory name with user- This is a workaround for Alpine where we don't have /run/user, hence we need to create the directory in /run. However, if we just call it /run/$UID that it might be a bit confusing what it is about. Hence, patch the code to call the directory /run/user-$UID. --- pam_dumb_runtime_dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pam_dumb_runtime_dir.c b/pam_dumb_runtime_dir.c index 742b4e0..0e507e9 100644 --- a/pam_dumb_runtime_dir.c +++ b/pam_dumb_runtime_dir.c @@ -50,13 +50,13 @@ int pam_sm_open_session(pam_handle_t *pamh, int flags, /* The bit size of uintmax_t will always be larger than the number of * bytes needed to print it. */ - char buffer[sizeof("XDG_RUNTIME_DIR="RUNTIME_DIR_PARENT"/") + + char buffer[sizeof("XDG_RUNTIME_DIR="RUNTIME_DIR_PARENT"/user-") + sizeof(uintmax_t) * 8]; /* Valid UIDs are always positive even if POSIX allows the uid_t type * itself to be signed. Therefore, we can convert to uintmax_t for * safe formatting. */ int ret = snprintf(buffer, sizeof(buffer), - "XDG_RUNTIME_DIR="RUNTIME_DIR_PARENT"/%ju", (uintmax_t)pw->pw_uid); + "XDG_RUNTIME_DIR="RUNTIME_DIR_PARENT"/user-%ju", (uintmax_t)pw->pw_uid); assert(ret >= 0 && (size_t)ret < sizeof(buffer)); const char *path = buffer + sizeof("XDG_RUNTIME_DIR=") - 1;