|
|
|
@ -233,7 +233,8 @@ static void __help_print(FILE *fso, const char *fmtname)
|
|
|
|
|
/* usage options */
|
|
|
|
|
fprintf(fso, "Usage:\n");
|
|
|
|
|
fprintf(fso, "\t%s -r | --root-x509 <path> -u | --master-x509 <path> "
|
|
|
|
|
" [-p | --listen-port <port>] [-R | --root-dir <directory>]\n", fmtname);
|
|
|
|
|
" [-p | --listen-port <port>] [-R | --root-dir <directory>] "
|
|
|
|
|
" [-d | --daemonize]\n", fmtname);
|
|
|
|
|
|
|
|
|
|
/* defaults */
|
|
|
|
|
fprintf(fso, "\t%s -h | --help\n", fmtname);
|
|
|
|
@ -249,6 +250,7 @@ static void __help_print(FILE *fso, const char *fmtname)
|
|
|
|
|
"-p | --listen-port <port>", DEFAULT_PORT);
|
|
|
|
|
fprintf(fso, "\t%-33s Remote directory becoming root for user [default: %s].\n",
|
|
|
|
|
"-R | --root-dir <directory>", DEFAULT_ROOT_DIR);
|
|
|
|
|
fprintf(fso, "\t%-33s Work as a daemon.\n", "-d | --daemonize");
|
|
|
|
|
fprintf(fso, "\t%-33s Show help screen.\n", "-h | --help");
|
|
|
|
|
fprintf(fso, "\t%-33s Print version information.\n", "-v | --version");
|
|
|
|
|
return;
|
|
|
|
@ -511,6 +513,7 @@ int main(int argc, char **argv)
|
|
|
|
|
sxhub_t *sxmphub = sxhub_create();
|
|
|
|
|
int port = DEFAULT_PORT;
|
|
|
|
|
int opt;
|
|
|
|
|
int is_daemon = 0;
|
|
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
|
int option_index = 0;
|
|
|
|
@ -523,10 +526,11 @@ int main(int argc, char **argv)
|
|
|
|
|
{"master-x509", required_argument, NULL, 'm'},
|
|
|
|
|
{"root-dir", required_argument, NULL, 'R'},
|
|
|
|
|
{"listen-port", required_argument, NULL, 'p'},
|
|
|
|
|
{"daemonize", required_argument, NULL, 'd'},
|
|
|
|
|
{ NULL, 0, NULL, 0 },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if((opt = getopt_long(argc, argv, "hvr:m:R:p:", long_options,
|
|
|
|
|
if((opt = getopt_long(argc, argv, "dhvr:m:R:p:", long_options,
|
|
|
|
|
&option_index)) == -1) break;
|
|
|
|
|
|
|
|
|
|
switch(opt) {
|
|
|
|
@ -550,6 +554,9 @@ int main(int argc, char **argv)
|
|
|
|
|
case 'R':
|
|
|
|
|
root_dir = strdup(optarg);
|
|
|
|
|
break;
|
|
|
|
|
case 'd':
|
|
|
|
|
is_daemon = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -565,6 +572,12 @@ int main(int argc, char **argv)
|
|
|
|
|
return EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* become daemon if it's necessary */
|
|
|
|
|
if (is_daemon && (opt = daemonize())) {
|
|
|
|
|
fprintf(stderr, "daemonize() failed (%d).\n Failure.\n", opt);
|
|
|
|
|
return EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sxmp_init();
|
|
|
|
|
|
|
|
|
|
/* all is fine let's init connection subsystem */
|
|
|
|
|