aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 190ede2..5d18d4a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -113,6 +113,7 @@ static pid_t rdr_init(redirector_ctx *ctx[], const size_t siz)
int main(int argc, char *argv[])
{
+ char *value;
const size_t rdr_siz = 3;
const size_t proto_siz = 2;
const size_t jail_siz = 2;
@@ -131,7 +132,7 @@ int main(int argc, char *argv[])
arg0 = argv[0];
if (options_cmdline(argc, argv)) {
- fprintf(stderr, "%s: parsing command line failed\n", argv[0]);
+ fprintf(stderr, "%s: command line parsing failed\n", argv[0]);
exit(EXIT_FAILURE);
}
@@ -141,7 +142,21 @@ int main(int argc, char *argv[])
} else {
LOG_SET_FUNCS_VA(LOG_COLORED_FUNCS);
}
- //log_prio = DEBUG;
+ if (getopt_used(OPT_LOGLEVEL)) {
+ value = getopt_str(OPT_LOGLEVEL);
+ if (!strcasecmp(value, "debug"))
+ log_prio = DEBUG;
+ else if (!strcasecmp(value, "notice"))
+ log_prio = NOTICE;
+ else if (!strcasecmp(value, "warning"))
+ log_prio = WARNING;
+ else if (!strcasecmp(value, "error"))
+ log_prio = ERROR;
+ else {
+ fprintf(stderr, "%s: unknown loglevel '%s'\n", argv[0], value);
+ exit(EXIT_FAILURE);
+ }
+ }
if (log_open())
exit(EXIT_FAILURE);
@@ -161,7 +176,7 @@ int main(int argc, char *argv[])
pseccomp_free(&psc);
D("%s", "Forking into background/foreground");
- daemon_pid = daemonize(1);
+ daemon_pid = daemonize(!getopt_used(OPT_DAEMON));
ABORT_ON_FATAL( daemon_pid > 0, "Forking" );
if (daemon_pid == 0) {
set_procname("[potd] main");