summaryrefslogtreecommitdiff
path: root/vdr.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2013-03-14 09:38:06 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2013-03-14 09:38:06 +0100
commit21b564805d54f5f790d6185823459e823bb43b76 (patch)
tree5d1ec2f691002c2aa261430a7195761b6e81b583 /vdr.c
parent87acd119ceac72301b02105599da069d4ed32b4c (diff)
downloadvdr-21b564805d54f5f790d6185823459e823bb43b76.tar.gz
vdr-21b564805d54f5f790d6185823459e823bb43b76.tar.bz2
When switching to a less privileged user id, VDR now sets the environment variables HOME, USER, LOGNAME and SHELL accordingly
Diffstat (limited to 'vdr.c')
-rw-r--r--vdr.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/vdr.c b/vdr.c
index 742d1699..9231e689 100644
--- a/vdr.c
+++ b/vdr.c
@@ -22,7 +22,7 @@
*
* The project's page is at http://www.tvdr.de
*
- * $Id: vdr.c 2.55 2013/03/12 13:27:40 kls Exp $
+ * $Id: vdr.c 2.56 2013/03/14 09:34:57 kls Exp $
*/
#include <getopt.h>
@@ -87,7 +87,7 @@
static int LastSignal = 0;
-static bool SetUser(const char *UserName, bool UserDump)//XXX name?
+static bool SetUser(const char *UserName, bool UserDump)
{
if (UserName) {
struct passwd *user = getpwnam(UserName);
@@ -109,6 +109,10 @@ static bool SetUser(const char *UserName, bool UserDump)//XXX name?
}
if (UserDump && prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0)
fprintf(stderr, "vdr: warning - cannot set dumpable: %s\n", strerror(errno));
+ setenv("HOME", user->pw_dir, 1);
+ setenv("USER", user->pw_name, 1);
+ setenv("LOGNAME", user->pw_name, 1);
+ setenv("SHELL", user->pw_shell, 1);
}
return true;
}