summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2009-05-24 13:35:35 +0200
committerGravatar Nikias Bassen2009-05-24 13:35:35 +0200
commitada0443d5c2a71ba580b1ae122d7212e4fb12078 (patch)
treebe5c0361d51574e6450102528cde36fe12aaa02a /src/main.c
parent7feced9e014c6478eca0391685c57d4c3ae2fc91 (diff)
downloadusbmuxd-ada0443d5c2a71ba580b1ae122d7212e4fb12078.tar.gz
usbmuxd-ada0443d5c2a71ba580b1ae122d7212e4fb12078.tar.bz2
Removed parameter -p and added parameter -d to allow to drop privileges.
Default is to NOT drop the privileges as is causes permission problems on some systems.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main.c b/src/main.c
index f672231..99d2a5c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -57,7 +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;
+static int drop_privileges = 0;
struct device_info {
uint32_t device_id;
@@ -1006,7 +1006,7 @@ static void usage()
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("\t-d|--drop-privileges drop privileges after startup\n");
printf("\n");
}
@@ -1017,13 +1017,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'},
+ {"drop-privileges", 0, NULL, 'd'},
{NULL, 0, NULL, 0}
};
int c;
while (1) {
- c = getopt_long(argc, argv, "hfvep", longopts, (int *) 0);
+ c = getopt_long(argc, argv, "hfved", longopts, (int *) 0);
if (c == -1) {
break;
}
@@ -1041,8 +1041,8 @@ static void parse_opts(int argc, char **argv)
case 'e':
exit_on_no_devices = 1;
break;
- case 'p':
- preserve_privileges = 1;
+ case 'd':
+ drop_privileges = 1;
break;
default:
usage();
@@ -1200,7 +1200,7 @@ int main(int argc, char **argv)
}
}
// drop elevated privileges
- if (!preserve_privileges && (getuid() == 0 || geteuid() == 0)) {
+ if (drop_privileges && (getuid() == 0 || geteuid() == 0)) {
struct passwd *pw = getpwnam("nobody");
if (pw) {
setuid(pw->pw_uid);