1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

When switching to a less privileged user id, VDR now sets the environment variables HOME, USER, LOGNAME and SHELL accordingly

This commit is contained in:
Klaus Schmidinger 2013-03-14 09:38:06 +01:00
parent 87acd119ce
commit 21b564805d
3 changed files with 10 additions and 2 deletions

View File

@ -2790,6 +2790,8 @@ Manuel Reimer <Manuel.Reimer@gmx.de>
seconds during replay seconds during replay
for suggesting to synchronize system time to the transponder time using adjtime() in for suggesting to synchronize system time to the transponder time using adjtime() in
order to avoid discontinuities order to avoid discontinuities
for setting the environment variables HOME, USER, LOGNAME and SHELL accordingly
when switching to a less privileged user id
Rene van den Braken <rene@vandenbraken.name> Rene van den Braken <rene@vandenbraken.name>
for reporting a bug in writing the PCR pid into the PMT in for reporting a bug in writing the PCR pid into the PMT in

View File

@ -7750,3 +7750,5 @@ Video Disk Recorder Revision History
- Updated the introductory text of the vdr.1 man page. - Updated the introductory text of the vdr.1 man page.
- Added a note to the INSTALL file regarding multiple disk setup becoming deprecated - Added a note to the INSTALL file regarding multiple disk setup becoming deprecated
in a future version of VDR. in a future version of VDR.
- When switching to a less privileged user id, VDR now sets the environment variables
HOME, USER, LOGNAME and SHELL accordingly (thanks to Manuel Reimer).

8
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.tvdr.de * 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> #include <getopt.h>
@ -87,7 +87,7 @@
static int LastSignal = 0; static int LastSignal = 0;
static bool SetUser(const char *UserName, bool UserDump)//XXX name? static bool SetUser(const char *UserName, bool UserDump)
{ {
if (UserName) { if (UserName) {
struct passwd *user = getpwnam(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) if (UserDump && prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0)
fprintf(stderr, "vdr: warning - cannot set dumpable: %s\n", strerror(errno)); 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; return true;
} }