# HG changeset patch
# User Ray Strode <rstrode@redhat.com>

worker: get PATH from parent instead of #define

If no PATH is set, then the session worker tries to set one up,
based on guess. This commit changes GDM to just use the PATH given
to GDM itself, rather than guessing (and getting it wrong).

https://bugzilla.gnome.org/show_bug.cgi?id=727980

diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 691c939..6944baa 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -14,17 +14,16 @@ AM_CPPFLAGS = \
 	-DLOCALSTATEDIR=\"$(localstatedir)\"		\
 	-DLOGDIR=\"$(logdir)\"				\
 	-DSBINDIR=\"$(sbindir)\"			\
 	-DGNOMELOCALEDIR=\""$(datadir)/locale"\"	\
 	-DGDM_RUN_DIR=\"$(GDM_RUN_DIR)\"		\
 	-DGDM_XAUTH_DIR=\"$(GDM_XAUTH_DIR)\"		\
 	-DGDM_SCREENSHOT_DIR=\"$(GDM_SCREENSHOT_DIR)\"		\
 	-DGDM_CACHE_DIR=\""$(localstatedir)/cache/gdm"\"	\
-	-DGDM_SESSION_DEFAULT_PATH=\"$(GDM_SESSION_DEFAULT_PATH)\" \
 	-DCONSOLEKIT_DIR=\"$(CONSOLEKIT_DIR)\" \
 	$(DISABLE_DEPRECATED_CFLAGS)			\
 	$(DAEMON_CFLAGS)				\
 	$(XLIB_CFLAGS)					\
 	$(WARN_CFLAGS)					\
 	$(DEBUG_CFLAGS)					\
 	$(SYSTEMD_CFLAGS)				\
 	$(JOURNALD_CFLAGS)				\
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index 8493fbd..5fc42c6 100644
--- a/daemon/gdm-session-worker.c
+++ b/daemon/gdm-session-worker.c
@@ -85,20 +85,16 @@
 #define GDM_SESSION_DBUS_ERROR_CANCEL "org.gnome.DisplayManager.Session.Error.Cancel"
 
 #define GDM_WORKER_DBUS_PATH "/org/gnome/DisplayManager/Worker"
 
 #ifndef GDM_PASSWD_AUXILLARY_BUFFER_SIZE
 #define GDM_PASSWD_AUXILLARY_BUFFER_SIZE 1024
 #endif
 
-#ifndef GDM_SESSION_DEFAULT_PATH
-#define GDM_SESSION_DEFAULT_PATH "/usr/local/bin:/usr/bin:/bin"
-#endif
-
 #ifndef GDM_SESSION_ROOT_UID
 #define GDM_SESSION_ROOT_UID 0
 #endif
 
 #ifndef GDM_SESSION_LOG_FILENAME
 #define GDM_SESSION_LOG_FILENAME "session.log"
 #endif
 
@@ -1502,23 +1498,20 @@ gdm_session_worker_accredit_user (GdmSessionWorker  *worker,
                                                                 uid,
                                                                 gid,
                                                                 home,
                                                                 shell);
 
         /* Let's give the user a default PATH if he doesn't already have one
          */
         if (!gdm_session_worker_environment_variable_is_set (worker, "PATH")) {
-                if (strcmp (BINDIR, "/usr/bin") == 0) {
-                        gdm_session_worker_set_environment_variable (worker, "PATH",
-                                                                     GDM_SESSION_DEFAULT_PATH);
-                } else {
-                        gdm_session_worker_set_environment_variable (worker, "PATH",
-                                                                     BINDIR ":" GDM_SESSION_DEFAULT_PATH);
-                }
+                const char *path;
+
+                path = g_getenv ("PATH");
+                gdm_session_worker_set_environment_variable (worker, "PATH", path);
         }
 
         if (! _change_user (worker, uid, gid)) {
                 g_debug ("GdmSessionWorker: Unable to change to user");
                 error_code = PAM_SYSTEM_ERR;
                 g_set_error (error, GDM_SESSION_WORKER_ERROR,
                              GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS,
                              "%s", _("Unable to change to user"));
