From f650e82f935d3b54950ff90c485008ce0478878c Mon Sep 17 00:00:00 2001 From: Roosemberth Palacios Date: Thu, 31 Oct 2019 00:03:35 +0100 Subject: [PATCH] login.c: Do not overwrite the PATH variable if config.path element is empty (#135) This allows disabling the feature if PATH was already set (e.g. by the systemd session slice) and the user wishes to honor that. Signed-off-by: Roosembert Palacios --- src/login.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/login.c b/src/login.c index d64cc3c..8551b39 100644 --- a/src/login.c +++ b/src/login.c @@ -229,12 +229,15 @@ void env_init(struct passwd* pwd, const char* display_name) setenv("DISPLAY", display_name, 1); setenv("LANG", lang, 1); - // path - int ok = setenv("PATH", config.path, 1); - - if (ok != 0) + // Set PATH if specified in the configuration + if (strlen(config.path)) { - dgn_throw(DGN_PATH); + int ok = setenv("PATH", config.path, 1); + + if (ok != 0) + { + dgn_throw(DGN_PATH); + } } }