summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2017-09-01 11:42:07 (GMT)
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2017-09-01 11:42:07 (GMT)
commit3afe532af59cc54f0d9461880bfbf5ae9024a061 (patch)
treecd44972d81bd21ac80d67f87ccdec78a14b63bf0
parent5661a82b5c9921e372a1c9cdd9a381e2bfd91c74 (diff)
downloaduser-session-launcher-3afe532af59cc54f0d9461880bfbf5ae9024a061.tar.gz
user-session-launcher-3afe532af59cc54f0d9461880bfbf5ae9024a061.tar.xz
session-run: Extend environment for the launcher
The compositor is executed directly by the session runner (as opposed to the user systemd daemon). Add some common environment variables which the compositor might want to use (HOME, LOGNAME, SHELL and USER). Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
-rw-r--r--src/session-run.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/session-run.c b/src/session-run.c
index 45e8c31..28ece44 100644
--- a/src/session-run.c
+++ b/src/session-run.c
@@ -10,6 +10,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
+#include <pwd.h>
#include <gio/gio.h>
#include <glib.h>
@@ -37,6 +38,7 @@ main (int argc, char **argv)
gchar *launcher;
int launcher_argc;
gchar **launcher_argv;
+ struct passwd *pw;
dbus_path = g_build_filename (g_get_user_runtime_dir(), "bus", NULL);
@@ -105,6 +107,19 @@ main (int argc, char **argv)
goto fail;
}
+
+ /* Setup common environment variables for current user */
+ pw = getpwuid(getuid());
+ if (pw == NULL) {
+ g_error ("Couldn't get password information for current user");
+ goto fail;
+ }
+
+ setenv ("HOME", pw->pw_dir, 1);
+ setenv ("LOGNAME", pw->pw_name, 1);
+ setenv ("USER", pw->pw_name, 1);
+ setenv ("SHELL", pw->pw_shell, 1);
+
launcher = g_key_file_get_string (key_file,
"Launcher", "Exec", &error);
if (launcher == NULL)