aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2023-06-13 18:23:58 -0300
committerAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2023-10-19 10:56:54 +0200
commita76ebf4b6e9951cf276ee1483785e4b3f3d54334 (patch)
tree7c2b8429a736858cbfffe8e9f9c2c363d38786ae
parentcfade2f00a88928074f5b95c140e925eb350d463 (diff)
openrc-pam: Grab XDG_RUNTIME_DIR from pam and re-export it for openrc
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
-rw-r--r--src/openrc-pam/openrc-pam.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/openrc-pam/openrc-pam.c b/src/openrc-pam/openrc-pam.c
index eba3846b..60b517b4 100644
--- a/src/openrc-pam/openrc-pam.c
+++ b/src/openrc-pam/openrc-pam.c
@@ -1,13 +1,11 @@
-#include <stdio.h>
+#include <librc.h>
#include <pwd.h>
+#include <security/pam_appl.h>
#include <security/pam_modules.h>
-#include <unistd.h>
-#include <librc.h>
#include <stdbool.h>
+#include <stdio.h>
#include <syslog.h>
-#ifdef __FreeBSD__
-#include <security/pam_appl.h>
-#endif
+#include <unistd.h>
#include "einfo.h"
@@ -15,6 +13,10 @@ static bool exec_openrc(pam_handle_t *pamh, const char *runlevel) {
char *cmd = NULL;
const char *username;
struct passwd *pw = NULL;
+ const char *env = NULL;
+
+ if ((env = pam_getenv(pamh, "XDG_RUNTIME_DIR")) != NULL)
+ setenv("XDG_RUNTIME_DIR", env, 0);
if (pam_get_user(pamh, &username, "username:") != PAM_SUCCESS)
return false;