summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2025-09-15 09:58:01 +0200
committerGravatar Nikias Bassen2025-09-15 09:58:01 +0200
commit2efa75a0a9ca73f2a5b6ec71e5ae6cb43cdab580 (patch)
tree9948c2e3d6fcf58433dbab033b0b0406b972b75c /src/main.c
parent08f4cd9ef0e664128bf221cc17d400cbc2650c7f (diff)
downloadusbmuxd-2efa75a0a9ca73f2a5b6ec71e5ae6cb43cdab580.tar.gz
usbmuxd-2efa75a0a9ca73f2a5b6ec71e5ae6cb43cdab580.tar.bz2
Allow specifying configuration directory to useHEADmaster
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 836ac97..b09a187 100644
--- a/src/main.c
+++ b/src/main.c
@@ -517,6 +517,7 @@ static void usage()
#ifdef HAVE_SYSTEMD
printf(" -s, --systemd\t\tRun in systemd operation mode (implies -z and -f).\n");
#endif
+ printf(" -C, --config-dir PATH\tSpecify different configuration directory.\n");
printf(" -S, --socket ADDR:PORT | PATH Specify source ADDR and PORT or a UNIX\n");
printf(" \t\tsocket PATH to use for the listening socket.\n");
printf(" \t\tDefault: %s\n", socket_path);
@@ -549,6 +550,7 @@ static void parse_opts(int argc, char **argv)
#ifdef HAVE_SYSTEMD
{"systemd", no_argument, NULL, 's'},
#endif
+ {"config-dir", required_argument, NULL, 'C'},
{"socket", required_argument, NULL, 'S'},
{"pidfile", required_argument, NULL, 'P'},
{"exit", no_argument, NULL, 'x'},
@@ -560,11 +562,11 @@ static void parse_opts(int argc, char **argv)
int c;
#ifdef HAVE_SYSTEMD
- const char* opts_spec = "hfvVuU:xXsnzl:pS:P:";
+ const char* opts_spec = "hfvVuU:xXsnzl:pC:S:P:";
#elif HAVE_UDEV
- const char* opts_spec = "hfvVuU:xXnzl:pS:P:";
+ const char* opts_spec = "hfvVuU:xXnzl:pC:S:P:";
#else
- const char* opts_spec = "hfvVU:xXnzl:pS:P:";
+ const char* opts_spec = "hfvVU:xXnzl:pC:S:P:";
#endif
while (1) {
@@ -611,6 +613,14 @@ static void parse_opts(int argc, char **argv)
case 'z':
opt_enable_exit = 1;
break;
+ case 'C':
+ if (!*optarg) {
+ usbmuxd_log(LL_FATAL, "ERROR: --config-dir requires an argument");
+ usage();
+ exit(2);
+ }
+ config_set_config_dir(optarg);
+ break;
case 'S':
if (!*optarg || *optarg == '-') {
usbmuxd_log(LL_FATAL, "ERROR: --socket requires an argument");
@@ -796,11 +806,12 @@ int main(int argc, char *argv[])
#ifdef HAVE_LIBIMOBILEDEVICE
const char* userprefdir = config_get_config_dir();
+ usbmuxd_log(LL_NOTICE, "Configuration directory: %s", userprefdir);
struct stat fst;
memset(&fst, '\0', sizeof(struct stat));
if (stat(userprefdir, &fst) < 0) {
if (mkdir(userprefdir, 0775) < 0) {
- usbmuxd_log(LL_FATAL, "Failed to create required directory '%s': %s", userprefdir, strerror(errno));
+ usbmuxd_log(LL_FATAL, "Failed to create configuration directory '%s': %s", userprefdir, strerror(errno));
res = -1;
goto terminate;
}