confd: fix debug mode regression

In the last major refactor of confd to a stand-alone daemon, new command
line options were added, one of which -v <LEVEL>.  Unfortunately opening
up for a few corner cases where the debug flag or the log_level was not
set properly.

This fixes that and also adds a CONFD_ARGS for /etc/default/confd, which
is customary for all daemons.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2026-06-07 20:50:28 +02:00
parent 060e0ea284
commit 985b694e51
3 changed files with 14 additions and 10 deletions
+4
View File
@@ -1 +1,5 @@
CONFD_TIMEOUT=60
#DEBUG=1
# -v debug
CONFD_ARGS=""
+6 -8
View File
@@ -1,11 +1,9 @@
#set DEBUG=1
# Single daemon handles gen-config, datastore init, config load, and plugins
# log:prio:daemon.err
service log:console env:/etc/default/confd \
service log:console env:/etc/default/confd \
[S12345] <usr/ixinit> confd -f -v warning \
-F /etc/factory-config.cfg \
-S /cfg/startup-config.cfg \
-E /etc/failure-config.cfg \
-t $CONFD_TIMEOUT \
-F /etc/factory-config.cfg \
-S /cfg/startup-config.cfg \
-E /etc/failure-config.cfg \
-t $CONFD_TIMEOUT \
$CONFD_ARGS \
-- Configuration daemon
+4 -2
View File
@@ -656,9 +656,10 @@ int main(int argc, char **argv)
log_level = LOG_WARNING;
else if (!strcmp(optarg, "info"))
log_level = LOG_NOTICE;
else if (!strcmp(optarg, "debug"))
else if (!strcmp(optarg, "debug")) {
log_level = LOG_DEBUG;
else {
debug = 1;
} else {
fprintf(stderr, "confd error: Invalid verbosity \"%s\"\n", optarg);
return EXIT_FAILURE;
}
@@ -696,6 +697,7 @@ int main(int argc, char **argv)
if (getenv("DEBUG")) {
log_opts |= LOG_PERROR;
log_level = LOG_DEBUG;
debug = 1;
}
openlog("confd", log_opts, LOG_DAEMON);