From 04c67a6bdedceba9771453655898df52f24c7c89 Mon Sep 17 00:00:00 2001 From: Roosembert Palacios Date: Sat, 26 Oct 2019 09:24:25 +0200 Subject: [PATCH] login.c: Do not overwrite the PATH variable if config.path element is empty 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); + } } }