diff options
author | Nikias Bassen | 2009-05-21 22:25:21 +0200 |
---|---|---|
committer | Nikias Bassen | 2009-05-21 22:25:21 +0200 |
commit | f8141b55b230dd4c66b39cee843149bdabe13580 (patch) | |
tree | 1c9faa5b8a381ceaa06813062be883ebefef91d9 /src/main.c | |
parent | 0c55afdb315f12b0f2a37f37a3ec711c75507c0d (diff) | |
download | usbmuxd-f8141b55b230dd4c66b39cee843149bdabe13580.tar.gz usbmuxd-f8141b55b230dd4c66b39cee843149bdabe13580.tar.bz2 |
Added parameter -p to prevent usbmuxd from dropping privileges
(see this as a workaround for systems where the usb device access is
restricted)
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -57,6 +57,7 @@ static int fsock = -1; static int verbose = DEBUG_LEVEL; static int foreground = 0; static int exit_on_no_devices = 0; +static int preserve_privileges = 0; struct device_info { uint32_t device_id; @@ -1009,9 +1010,11 @@ static int daemonize() static void usage() { printf("usage: usbmuxd [options]\n"); - printf("\t-h|--help print this message.\n"); - printf("\t-v|--verbose be verbose\n"); - printf("\t-f|--foreground do not daemonize\n"); + printf("\t-h|--help print this message\n"); + printf("\t-v|--verbose be verbose (use twice or more to increase)\n"); + printf("\t-f|--foreground do not daemonize\n"); + printf("\t-e|--exit-on-no-devices exit if no device is attached\n"); + printf("\t-p|--preserve-privileges do not drop privileges\n"); printf("\n"); } @@ -1022,12 +1025,13 @@ static void parse_opts(int argc, char **argv) {"foreground", 0, NULL, 'f'}, {"verbose", 0, NULL, 'v'}, {"exit-on-no-devices", 0, NULL, 'e'}, + {"preserve-privileges", 0, NULL, 'p'}, {NULL, 0, NULL, 0} }; int c; while (1) { - c = getopt_long(argc, argv, "hfve", longopts, (int *) 0); + c = getopt_long(argc, argv, "hfvep", longopts, (int *) 0); if (c == -1) { break; } @@ -1045,6 +1049,9 @@ static void parse_opts(int argc, char **argv) case 'e': exit_on_no_devices = 1; break; + case 'p': + preserve_privileges = 1; + break; default: usage(); exit(2); @@ -1198,7 +1205,7 @@ int main(int argc, char **argv) } } // drop elevated privileges - if (getuid() == 0 || geteuid() == 0) { + if (!preserve_privileges && (getuid() == 0 || geteuid() == 0)) { struct passwd *pw = getpwnam("nobody"); if (pw) { setuid(pw->pw_uid); |