Fix missing default PATH for root and non-root users.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2015-09-02 14:50:46 +02:00
parent f94db7bceb
commit 814ffd9259
2 changed files with 9 additions and 1 deletions
+3
View File
@@ -134,6 +134,9 @@ int main(int argc, char* argv[])
/* Set hostname as soon as possible, for syslog et al. */
set_hostname(&hostname);
/* Set default PATH, for uid 0 */
setenv("PATH", _PATH_STDPATH);
/*
* Mount filesystems
*/
+6 -1
View File
@@ -230,9 +230,14 @@ int service_start(svc_t *svc)
DFLSIG(sa, i, 0);
/* Set desired user */
if (uid >= 0)
if (uid >= 0) {
setuid(uid);
/* Set default path for regular users */
if (uid > 0)
setenv("PATH", _PATH_DEFPATH);
}
/* Serve copy of args to process in case it modifies them. */
for (i = 0; i < (MAX_NUM_SVC_ARGS - 1) && svc->args[i][0] != 0; i++)
args[i] = svc->args[i];