]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldpd: don't make lldpcli complain on missing conf files
authorVincent Bernat <vincent@bernat.im>
Mon, 26 Dec 2016 09:03:48 +0000 (10:03 +0100)
committerVincent Bernat <vincent@bernat.im>
Mon, 26 Dec 2016 09:03:48 +0000 (10:03 +0100)
Only complain if the user has directly provided additional configuration
files. This is done through an hidden option (-C) for lldpcli.

src/client/lldpcli.c
src/daemon/lldpd.c

index e534343c808349fb7f40d4c5eeeeff6707579131..9f1380a40be22d9ad58050ef550ad6c50a94f0ab 100644 (file)
@@ -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();
index b66ca744120bb9081bf6e642797a968c07a2ddbd..d0b47b5fb4df8a2cdd7295ac92843765ee0ae782 100644 (file)
@@ -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);