From: Vincent Bernat Date: Mon, 26 Dec 2016 09:03:48 +0000 (+0100) Subject: lldpd: don't make lldpcli complain on missing conf files X-Git-Tag: 0.9.6~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e9447d4562c2bed7529e2ba94fc7c235423ed173;p=thirdparty%2Flldpd.git lldpd: don't make lldpcli complain on missing conf files Only complain if the user has directly provided additional configuration files. This is done through an hidden option (-C) for lldpcli. --- diff --git a/src/client/lldpcli.c b/src/client/lldpcli.c index e534343c..9f1380a4 100644 --- a/src/client/lldpcli.c +++ b/src/client/lldpcli.c @@ -381,12 +381,17 @@ filter(const struct dirent *dir) * @param acceptdir 1 if we accept a directory, 0 otherwise */ static void -input_append(const char *arg, struct inputs *inputs, int acceptdir) +input_append(const char *arg, struct inputs *inputs, int acceptdir, int warn) { struct stat statbuf; if (stat(arg, &statbuf) == -1) { - log_warn("lldpctl", "cannot find configuration file/directory %s", - arg); + if (warn) { + log_warn("lldpctl", "cannot find configuration file/directory %s", + arg); + } else { + log_debug("lldpctl", "cannot find configuration file/directory %s", + arg); + } return; } @@ -418,7 +423,7 @@ input_append(const char *arg, struct inputs *inputs, int acceptdir) for (int i=0; i < n; i++) { char *fullname; if (asprintf(&fullname, "%s/%s", arg, namelist[i]->d_name) != -1) { - input_append(fullname, inputs, 0); + input_append(fullname, inputs, 0, 1); free(fullname); } free(namelist[i]); @@ -432,7 +437,7 @@ main(int argc, char *argv[]) int ch, debug = 0, use_syslog = 0, rc = EXIT_FAILURE; const char *fmt = "plain"; lldpctl_conn_t *conn = NULL; - const char *options = is_lldpctl(argv[0])?"hdvf:u:":"hdsvf:c:u:"; + const char *options = is_lldpctl(argv[0])?"hdvf:u:":"hdsvf:c:C:u:"; int gotinputs = 0, version = 0; struct inputs inputs; @@ -470,13 +475,14 @@ main(int argc, char *argv[]) case 'f': fmt = optarg; break; + case 'C': case 'c': if (!gotinputs) { log_init(use_syslog, debug, __progname); lldpctl_log_level(debug + 1); gotinputs = 1; } - input_append(optarg, &inputs, 1); + input_append(optarg, &inputs, 1, ch == 'c'); break; default: usage(); diff --git a/src/daemon/lldpd.c b/src/daemon/lldpd.c index b66ca744..d0b47b5f 100644 --- a/src/daemon/lldpd.c +++ b/src/daemon/lldpd.c @@ -1272,8 +1272,8 @@ lldpd_configure(int use_syslog, int debug, const char *path, const char *ctlname execl(path, "lldpcli", sdebug, "-u", ctlname, - "-c", SYSCONFDIR "/lldpd.conf", - "-c", SYSCONFDIR "/lldpd.d", + "-C", SYSCONFDIR "/lldpd.conf", + "-C", SYSCONFDIR "/lldpd.d", "resume", (char *)NULL); log_warn("main", "unable to execute %s", path);