summaryrefslogtreecommitdiffstats
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
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.
-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;
57static int verbose = DEBUG_LEVEL; 57static int verbose = DEBUG_LEVEL;
58static int foreground = 0; 58static int foreground = 0;
59static int exit_on_no_devices = 0; 59static int exit_on_no_devices = 0;
60static int preserve_privileges = 0; 60static int drop_privileges = 0;
61 61
62struct device_info { 62struct device_info {
63 uint32_t device_id; 63 uint32_t device_id;
@@ -1006,7 +1006,7 @@ static void usage()
1006 printf("\t-v|--verbose be verbose (use twice or more to increase)\n"); 1006 printf("\t-v|--verbose be verbose (use twice or more to increase)\n");
1007 printf("\t-f|--foreground do not daemonize\n"); 1007 printf("\t-f|--foreground do not daemonize\n");
1008 printf("\t-e|--exit-on-no-devices exit if no device is attached\n"); 1008 printf("\t-e|--exit-on-no-devices exit if no device is attached\n");
1009 printf("\t-p|--preserve-privileges do not drop privileges\n"); 1009 printf("\t-d|--drop-privileges drop privileges after startup\n");
1010 printf("\n"); 1010 printf("\n");
1011} 1011}
1012 1012
@@ -1017,13 +1017,13 @@ static void parse_opts(int argc, char **argv)
1017 {"foreground", 0, NULL, 'f'}, 1017 {"foreground", 0, NULL, 'f'},
1018 {"verbose", 0, NULL, 'v'}, 1018 {"verbose", 0, NULL, 'v'},
1019 {"exit-on-no-devices", 0, NULL, 'e'}, 1019 {"exit-on-no-devices", 0, NULL, 'e'},
1020 {"preserve-privileges", 0, NULL, 'p'}, 1020 {"drop-privileges", 0, NULL, 'd'},
1021 {NULL, 0, NULL, 0} 1021 {NULL, 0, NULL, 0}
1022 }; 1022 };
1023 int c; 1023 int c;
1024 1024
1025 while (1) { 1025 while (1) {
1026 c = getopt_long(argc, argv, "hfvep", longopts, (int *) 0); 1026 c = getopt_long(argc, argv, "hfved", longopts, (int *) 0);
1027 if (c == -1) { 1027 if (c == -1) {
1028 break; 1028 break;
1029 } 1029 }
@@ -1041,8 +1041,8 @@ static void parse_opts(int argc, char **argv)
1041 case 'e': 1041 case 'e':
1042 exit_on_no_devices = 1; 1042 exit_on_no_devices = 1;
1043 break; 1043 break;
1044 case 'p': 1044 case 'd':
1045 preserve_privileges = 1; 1045 drop_privileges = 1;
1046 break; 1046 break;
1047 default: 1047 default:
1048 usage(); 1048 usage();
@@ -1200,7 +1200,7 @@ int main(int argc, char **argv)
1200 } 1200 }
1201 } 1201 }
1202 // drop elevated privileges 1202 // drop elevated privileges
1203 if (!preserve_privileges && (getuid() == 0 || geteuid() == 0)) { 1203 if (drop_privileges && (getuid() == 0 || geteuid() == 0)) {
1204 struct passwd *pw = getpwnam("nobody"); 1204 struct passwd *pw = getpwnam("nobody");
1205 if (pw) { 1205 if (pw) {
1206 setuid(pw->pw_uid); 1206 setuid(pw->pw_uid);