mirror of
https://github.com/SuperBFG7/ympd
synced 2024-11-26 23:07:17 +00:00
apply mg_set listening_port only once, fixes #71
This commit is contained in:
parent
caddebcec0
commit
ade4ee3808
13
src/ympd.c
13
src/ympd.c
@ -70,9 +70,9 @@ int main(int argc, char **argv)
|
|||||||
unsigned int current_timer = 0, last_timer = 0;
|
unsigned int current_timer = 0, last_timer = 0;
|
||||||
char *run_as_user = NULL;
|
char *run_as_user = NULL;
|
||||||
char const *error_msg = NULL;
|
char const *error_msg = NULL;
|
||||||
|
char *webport = "8080";
|
||||||
|
|
||||||
atexit(bye);
|
atexit(bye);
|
||||||
error_msg = mg_set_option(server, "listening_port", "8080");
|
|
||||||
#ifdef WITH_DYNAMIC_ASSETS
|
#ifdef WITH_DYNAMIC_ASSETS
|
||||||
mg_set_option(server, "document_root", SRC_PATH);
|
mg_set_option(server, "document_root", SRC_PATH);
|
||||||
#endif
|
#endif
|
||||||
@ -100,7 +100,7 @@ int main(int argc, char **argv)
|
|||||||
mpd.port = atoi(optarg);
|
mpd.port = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
error_msg = mg_set_option(server, "listening_port", optarg);
|
webport = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
run_as_user = strdup(optarg);
|
run_as_user = strdup(optarg);
|
||||||
@ -131,9 +131,14 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_msg = mg_set_option(server, "listening_port", webport);
|
||||||
|
if(error_msg) {
|
||||||
|
fprintf(stderr, "Mongoose error: %s\n", error_msg);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
/* drop privilges at last to ensure proper port binding */
|
/* drop privilges at last to ensure proper port binding */
|
||||||
if(run_as_user != NULL)
|
if(run_as_user != NULL) {
|
||||||
{
|
|
||||||
error_msg = mg_set_option(server, "run_as_user", run_as_user);
|
error_msg = mg_set_option(server, "run_as_user", run_as_user);
|
||||||
free(run_as_user);
|
free(run_as_user);
|
||||||
if(error_msg)
|
if(error_msg)
|
||||||
|
Loading…
Reference in New Issue
Block a user