diff options
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 6 |
1 files changed, 6 insertions, 0 deletions
| @@ -47,7 +47,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |||
| 47 | #include "device.h" | 47 | #include "device.h" |
| 48 | #include "client.h" | 48 | #include "client.h" |
| 49 | 49 | ||
| 50 | #ifdef HAVE_LIBIMOBILEDEVICE | ||
| 50 | extern const char* userpref_get_config_dir(); | 51 | extern const char* userpref_get_config_dir(); |
| 52 | #endif | ||
| 51 | 53 | ||
| 52 | static const char *socket_path = "/var/run/usbmuxd"; | 54 | static const char *socket_path = "/var/run/usbmuxd"; |
| 53 | static const char *lockfile = "/var/run/usbmuxd.pid"; | 55 | static const char *lockfile = "/var/run/usbmuxd.pid"; |
| @@ -530,6 +532,7 @@ int main(int argc, char *argv[]) | |||
| 530 | if(listenfd < 0) | 532 | if(listenfd < 0) |
| 531 | goto terminate; | 533 | goto terminate; |
| 532 | 534 | ||
| 535 | #ifdef HAVE_LIBIMOBILEDEVICE | ||
| 533 | const char* userprefdir = userpref_get_config_dir(); | 536 | const char* userprefdir = userpref_get_config_dir(); |
| 534 | 537 | ||
| 535 | struct stat fst; | 538 | struct stat fst; |
| @@ -538,6 +541,7 @@ int main(int argc, char *argv[]) | |||
| 538 | mkdir(userprefdir, 0775); | 541 | mkdir(userprefdir, 0775); |
| 539 | userprefdir_created = 1; | 542 | userprefdir_created = 1; |
| 540 | } | 543 | } |
| 544 | #endif | ||
| 541 | 545 | ||
| 542 | // drop elevated privileges | 546 | // drop elevated privileges |
| 543 | if (drop_privileges && (getuid() == 0 || geteuid() == 0)) { | 547 | if (drop_privileges && (getuid() == 0 || geteuid() == 0)) { |
| @@ -556,6 +560,7 @@ int main(int argc, char *argv[]) | |||
| 556 | if (pw->pw_uid == 0) { | 560 | if (pw->pw_uid == 0) { |
| 557 | usbmuxd_log(LL_INFO, "Not dropping privileges to root"); | 561 | usbmuxd_log(LL_INFO, "Not dropping privileges to root"); |
| 558 | } else { | 562 | } else { |
| 563 | #ifdef HAVE_LIBIMOBILEDEVICE | ||
| 559 | if (userprefdir_created) { | 564 | if (userprefdir_created) { |
| 560 | if (chown(userprefdir, pw->pw_uid, pw->pw_gid) < 0) { | 565 | if (chown(userprefdir, pw->pw_uid, pw->pw_gid) < 0) { |
| 561 | usbmuxd_log(LL_WARNING, "chown(%s, %d, %d) failed", userprefdir, pw->pw_uid, pw->pw_gid); | 566 | usbmuxd_log(LL_WARNING, "chown(%s, %d, %d) failed", userprefdir, pw->pw_uid, pw->pw_gid); |
| @@ -564,6 +569,7 @@ int main(int argc, char *argv[]) | |||
| 564 | usbmuxd_log(LL_WARNING, "chmod %s failed", userprefdir); | 569 | usbmuxd_log(LL_WARNING, "chmod %s failed", userprefdir); |
| 565 | } | 570 | } |
| 566 | } | 571 | } |
| 572 | #endif | ||
| 567 | 573 | ||
| 568 | if ((res = initgroups(drop_user, pw->pw_gid)) < 0) { | 574 | if ((res = initgroups(drop_user, pw->pw_gid)) < 0) { |
| 569 | usbmuxd_log(LL_FATAL, "Failed to drop privileges (cannot set supplementary groups)"); | 575 | usbmuxd_log(LL_FATAL, "Failed to drop privileges (cannot set supplementary groups)"); |
