diff options
| author | 2025-09-15 09:58:01 +0200 | |
|---|---|---|
| committer | 2025-09-15 09:58:01 +0200 | |
| commit | 2efa75a0a9ca73f2a5b6ec71e5ae6cb43cdab580 (patch) | |
| tree | 9948c2e3d6fcf58433dbab033b0b0406b972b75c /src/main.c | |
| parent | 08f4cd9ef0e664128bf221cc17d400cbc2650c7f (diff) | |
| download | usbmuxd-2efa75a0a9ca73f2a5b6ec71e5ae6cb43cdab580.tar.gz usbmuxd-2efa75a0a9ca73f2a5b6ec71e5ae6cb43cdab580.tar.bz2 | |
Allow specifying configuration directory to use
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 19 |
1 files changed, 15 insertions, 4 deletions
| @@ -517,6 +517,7 @@ static void usage() | |||
| 517 | #ifdef HAVE_SYSTEMD | 517 | #ifdef HAVE_SYSTEMD |
| 518 | printf(" -s, --systemd\t\tRun in systemd operation mode (implies -z and -f).\n"); | 518 | printf(" -s, --systemd\t\tRun in systemd operation mode (implies -z and -f).\n"); |
| 519 | #endif | 519 | #endif |
| 520 | printf(" -C, --config-dir PATH\tSpecify different configuration directory.\n"); | ||
| 520 | printf(" -S, --socket ADDR:PORT | PATH Specify source ADDR and PORT or a UNIX\n"); | 521 | printf(" -S, --socket ADDR:PORT | PATH Specify source ADDR and PORT or a UNIX\n"); |
| 521 | printf(" \t\tsocket PATH to use for the listening socket.\n"); | 522 | printf(" \t\tsocket PATH to use for the listening socket.\n"); |
| 522 | printf(" \t\tDefault: %s\n", socket_path); | 523 | printf(" \t\tDefault: %s\n", socket_path); |
| @@ -549,6 +550,7 @@ static void parse_opts(int argc, char **argv) | |||
| 549 | #ifdef HAVE_SYSTEMD | 550 | #ifdef HAVE_SYSTEMD |
| 550 | {"systemd", no_argument, NULL, 's'}, | 551 | {"systemd", no_argument, NULL, 's'}, |
| 551 | #endif | 552 | #endif |
| 553 | {"config-dir", required_argument, NULL, 'C'}, | ||
| 552 | {"socket", required_argument, NULL, 'S'}, | 554 | {"socket", required_argument, NULL, 'S'}, |
| 553 | {"pidfile", required_argument, NULL, 'P'}, | 555 | {"pidfile", required_argument, NULL, 'P'}, |
| 554 | {"exit", no_argument, NULL, 'x'}, | 556 | {"exit", no_argument, NULL, 'x'}, |
| @@ -560,11 +562,11 @@ static void parse_opts(int argc, char **argv) | |||
| 560 | int c; | 562 | int c; |
| 561 | 563 | ||
| 562 | #ifdef HAVE_SYSTEMD | 564 | #ifdef HAVE_SYSTEMD |
| 563 | const char* opts_spec = "hfvVuU:xXsnzl:pS:P:"; | 565 | const char* opts_spec = "hfvVuU:xXsnzl:pC:S:P:"; |
| 564 | #elif HAVE_UDEV | 566 | #elif HAVE_UDEV |
| 565 | const char* opts_spec = "hfvVuU:xXnzl:pS:P:"; | 567 | const char* opts_spec = "hfvVuU:xXnzl:pC:S:P:"; |
| 566 | #else | 568 | #else |
| 567 | const char* opts_spec = "hfvVU:xXnzl:pS:P:"; | 569 | const char* opts_spec = "hfvVU:xXnzl:pC:S:P:"; |
| 568 | #endif | 570 | #endif |
| 569 | 571 | ||
| 570 | while (1) { | 572 | while (1) { |
| @@ -611,6 +613,14 @@ static void parse_opts(int argc, char **argv) | |||
| 611 | case 'z': | 613 | case 'z': |
| 612 | opt_enable_exit = 1; | 614 | opt_enable_exit = 1; |
| 613 | break; | 615 | break; |
| 616 | case 'C': | ||
| 617 | if (!*optarg) { | ||
| 618 | usbmuxd_log(LL_FATAL, "ERROR: --config-dir requires an argument"); | ||
| 619 | usage(); | ||
| 620 | exit(2); | ||
| 621 | } | ||
| 622 | config_set_config_dir(optarg); | ||
| 623 | break; | ||
| 614 | case 'S': | 624 | case 'S': |
| 615 | if (!*optarg || *optarg == '-') { | 625 | if (!*optarg || *optarg == '-') { |
| 616 | usbmuxd_log(LL_FATAL, "ERROR: --socket requires an argument"); | 626 | usbmuxd_log(LL_FATAL, "ERROR: --socket requires an argument"); |
| @@ -796,11 +806,12 @@ int main(int argc, char *argv[]) | |||
| 796 | 806 | ||
| 797 | #ifdef HAVE_LIBIMOBILEDEVICE | 807 | #ifdef HAVE_LIBIMOBILEDEVICE |
| 798 | const char* userprefdir = config_get_config_dir(); | 808 | const char* userprefdir = config_get_config_dir(); |
| 809 | usbmuxd_log(LL_NOTICE, "Configuration directory: %s", userprefdir); | ||
| 799 | struct stat fst; | 810 | struct stat fst; |
| 800 | memset(&fst, '\0', sizeof(struct stat)); | 811 | memset(&fst, '\0', sizeof(struct stat)); |
| 801 | if (stat(userprefdir, &fst) < 0) { | 812 | if (stat(userprefdir, &fst) < 0) { |
| 802 | if (mkdir(userprefdir, 0775) < 0) { | 813 | if (mkdir(userprefdir, 0775) < 0) { |
| 803 | usbmuxd_log(LL_FATAL, "Failed to create required directory '%s': %s", userprefdir, strerror(errno)); | 814 | usbmuxd_log(LL_FATAL, "Failed to create configuration directory '%s': %s", userprefdir, strerror(errno)); |
| 804 | res = -1; | 815 | res = -1; |
| 805 | goto terminate; | 816 | goto terminate; |
| 806 | } | 817 | } |
