]> granicus.if.org Git - vnstat/commitdiff
avoid creating empty dirs when daemon is started with -n parameter
authorTeemu Toivola <git@humdi.net>
Tue, 19 Aug 2014 15:14:13 +0000 (18:14 +0300)
committerTeemu Toivola <git@humdi.net>
Tue, 19 Aug 2014 15:14:13 +0000 (18:14 +0300)
src/daemon.c
tests/daemon_tests.c

index a600cefa0101ad0077b8a82a6410a48252e7da16..8689800d0bfe62ffda264e499ab54e2130d56f21 100644 (file)
@@ -735,7 +735,7 @@ void preparedirs(DSTATE *s)
                updatedirowner(s->dirname, s->user, s->group);
        }
 
-       if (!cfg.createdirs) {
+       if (!cfg.createdirs || !s->rundaemon) {
                return;
        }
 
index 98d54e49b5f129e152dd6e4db560ecc43b50950a..dfc1f6a1ec40f0cc583a22700762fac65fbde22f 100644 (file)
@@ -739,6 +739,7 @@ START_TEST(preparedirs_with_no_dir)
        initdstate(&s);
        defaultcfg();
        cfg.uselogging = 1;
+       s.rundaemon = 1;
        strncpy_nt(s.dirname, TESTDBDIR, 512);
        snprintf(logdir, 512, "%s/log/vnstat", TESTDIR);
        snprintf(piddir, 512, "%s/pid/vnstat", TESTDIR);
@@ -764,6 +765,7 @@ START_TEST(preparedirs_with_dir)
        initdstate(&s);
        defaultcfg();
        cfg.uselogging = 1;
+       s.rundaemon = 1;
        strncpy_nt(s.dirname, TESTDBDIR, 512);
        snprintf(logdir, 512, "%s/log/vnstat", TESTDIR);
        snprintf(piddir, 512, "%s/pid/vnstat", TESTDIR);