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

Implemented option --userdump

This commit is contained in:
Klaus Schmidinger 2008-02-08 15:55:30 +01:00
parent f54c810bcd
commit e6f806d602
4 changed files with 20 additions and 7 deletions

View File

@ -2270,3 +2270,7 @@ Benjamin Hess <benjamin.h@gmx.ch>
Winfried Koehler <w_koehl@gmx.de> Winfried Koehler <w_koehl@gmx.de>
for fixing finding new transponders for fixing finding new transponders
Hans-Werner Hilse <hilse@web.de>
for adding the command line option --userdump to enable core dumps in case VDR
is run as root with option -u

View File

@ -5589,3 +5589,5 @@ Video Disk Recorder Revision History
in version 1.7.0. in version 1.7.0.
Note that you may need to switch back to an older version of your channels.conf Note that you may need to switch back to an older version of your channels.conf
file if you have already used version 1.5.14, because it introduced new parameters. file if you have already used version 1.5.14, because it introduced new parameters.
- Added the new command line option --userdump to enable core dumps in case VDR
is run as root with option -u (thanks to Hans-Werner Hilse).

5
vdr.1
View File

@ -8,7 +8,7 @@
.\" License as specified in the file COPYING that comes with the .\" License as specified in the file COPYING that comes with the
.\" vdr distribution. .\" vdr distribution.
.\" .\"
.\" $Id: vdr.1 1.29 2007/02/24 17:40:20 kls Exp $ .\" $Id: vdr.1 1.30 2008/02/08 15:55:26 kls Exp $
.\" .\"
.TH vdr 1 "07 Jan 2007" "1.4.5" "Video Disk Recorder" .TH vdr 1 "07 Jan 2007" "1.4.5" "Video Disk Recorder"
.SH NAME .SH NAME
@ -139,6 +139,9 @@ be set from the transponder data, but for security reasons
vdr can switch to a lesser privileged user id during normal vdr can switch to a lesser privileged user id during normal
operation. operation.
.TP .TP
.BI \-\-userdump
allow coredumps if -u is given (only for debugging).
.TP
.BI \-\-vfat .BI \-\-vfat
Encode special characters in recording names to avoid problems Encode special characters in recording names to avoid problems
with VFAT file systems. with VFAT file systems.

16
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/vdr * The project's page is at http://www.cadsoft.de/vdr
* *
* $Id: vdr.c 1.307 2008/01/27 14:38:45 kls Exp $ * $Id: vdr.c 1.308 2008/02/08 15:55:30 kls Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -86,7 +86,7 @@
static int LastSignal = 0; static int LastSignal = 0;
static bool SetUser(const char *UserName) static bool SetUser(const char *UserName, bool UserDump)//XXX name?
{ {
if (UserName) { if (UserName) {
struct passwd *user = getpwnam(UserName); struct passwd *user = getpwnam(UserName);
@ -106,10 +106,8 @@ static bool SetUser(const char *UserName)
fprintf(stderr, "vdr: cannot set user id %u: %s\n", (unsigned int)user->pw_uid, strerror(errno)); fprintf(stderr, "vdr: cannot set user id %u: %s\n", (unsigned int)user->pw_uid, strerror(errno));
return false; return false;
} }
if (prctl(PR_SET_DUMPABLE, 2, 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));
// always non-fatal, and will not work with kernel < 2.6.13
}
} }
return true; return true;
} }
@ -187,6 +185,7 @@ int main(int argc, char *argv[])
bool StartedAsRoot = false; bool StartedAsRoot = false;
const char *VdrUser = NULL; const char *VdrUser = NULL;
bool UserDump = false;
int SVDRPport = DEFAULTSVDRPPORT; int SVDRPport = DEFAULTSVDRPPORT;
const char *AudioCommand = NULL; const char *AudioCommand = NULL;
const char *ConfigDirectory = NULL; const char *ConfigDirectory = NULL;
@ -241,6 +240,7 @@ int main(int argc, char *argv[])
{ "shutdown", required_argument, NULL, 's' }, { "shutdown", required_argument, NULL, 's' },
{ "terminal", required_argument, NULL, 't' }, { "terminal", required_argument, NULL, 't' },
{ "user", required_argument, NULL, 'u' }, { "user", required_argument, NULL, 'u' },
{ "userdump", no_argument, NULL, 'u' | 0x100 },
{ "version", no_argument, NULL, 'V' }, { "version", no_argument, NULL, 'V' },
{ "vfat", no_argument, NULL, 'v' | 0x100 }, { "vfat", no_argument, NULL, 'v' | 0x100 },
{ "video", required_argument, NULL, 'v' }, { "video", required_argument, NULL, 'v' },
@ -346,6 +346,9 @@ int main(int argc, char *argv[])
case 'u': if (*optarg) case 'u': if (*optarg)
VdrUser = optarg; VdrUser = optarg;
break; break;
case 'u' | 0x100:
UserDump = true;
break;
case 'V': DisplayVersion = true; case 'V': DisplayVersion = true;
break; break;
case 'v' | 0x100: case 'v' | 0x100:
@ -376,7 +379,7 @@ int main(int argc, char *argv[])
if (strcmp(VdrUser, "root")) { if (strcmp(VdrUser, "root")) {
if (!SetKeepCaps(true)) if (!SetKeepCaps(true))
return 2; return 2;
if (!SetUser(VdrUser)) if (!SetUser(VdrUser, UserDump))
return 2; return 2;
if (!SetKeepCaps(false)) if (!SetKeepCaps(false))
return 2; return 2;
@ -431,6 +434,7 @@ int main(int argc, char *argv[])
" -t TTY, --terminal=TTY controlling tty\n" " -t TTY, --terminal=TTY controlling tty\n"
" -u USER, --user=USER run as user USER; only applicable if started as\n" " -u USER, --user=USER run as user USER; only applicable if started as\n"
" root\n" " root\n"
" --userdump allow coredumps if -u is given (debugging)\n"
" -v DIR, --video=DIR use DIR as video directory (default: %s)\n" " -v DIR, --video=DIR use DIR as video directory (default: %s)\n"
" -V, --version print version information and exit\n" " -V, --version print version information and exit\n"
" --vfat encode special characters in recording names to\n" " --vfat encode special characters in recording names to\n"