remove foreground / verbose from config

set them as global vars; rename foreground -> debug
This commit is contained in:
Omar Polo 2023-06-08 17:29:08 +00:00
parent 85a575a444
commit ca84625a7f
2 changed files with 8 additions and 9 deletions

15
gmid.c
View File

@ -66,6 +66,8 @@ int sock4, sock6;
int privsep_process; int privsep_process;
int pidfd = -1; int pidfd = -1;
int debug, verbose;
const char *config_path = "/etc/gmid.conf"; const char *config_path = "/etc/gmid.conf";
const char *pidfile; const char *pidfile;
@ -193,7 +195,7 @@ main(int argc, char **argv)
optarg); optarg);
break; break;
case 'f': case 'f':
conf.foreground = 1; debug = 1;
break; break;
case 'h': case 'h':
usage(); usage();
@ -220,7 +222,7 @@ main(int argc, char **argv)
puts("Version: " GMID_STRING); puts("Version: " GMID_STRING);
return 0; return 0;
case 'v': case 'v':
conf.verbose++; verbose = 1;
break; break;
default: default:
usage(); usage();
@ -263,17 +265,16 @@ main(int argc, char **argv)
procs[i].p_chroot = conf.chroot; procs[i].p_chroot = conf.chroot;
} }
log_init(conf.foreground, LOG_DAEMON); log_init(debug, LOG_DAEMON);
log_setverbose(conf.verbose); log_setverbose(verbose);
if (title != NULL) if (title != NULL)
log_procinit(title); log_procinit(title);
/* only the parent returns */ /* only the parent returns */
proc_init(ps, procs, nitems(procs), conf.foreground, proc_init(ps, procs, nitems(procs), debug, argc0, argv, proc_id);
argc0, argv, proc_id);
log_procinit("main"); log_procinit("main");
if (!conf.foreground && daemon(0, 0) == -1) if (!debug && daemon(0, 0) == -1)
fatal("daemon"); fatal("daemon");
pidfd = write_pidfile(pidfile); pidfd = write_pidfile(pidfile);

2
gmid.h
View File

@ -207,8 +207,6 @@ struct mime {
struct conf { struct conf {
struct privsep *ps; struct privsep *ps;
int foreground;
int verbose;
int port; int port;
int ipv6; int ipv6;
uint32_t protos; uint32_t protos;