svlogd: strip leading '!' from processor lines
authorFrancis Rounds <Francis.Rounds@4bridgeworks.com>
Wed, 14 Sep 2016 11:53:51 +0000 (11:53 +0000)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 15 Sep 2016 12:05:04 +0000 (14:05 +0200)
When using svlogd's processor functionality to run arbitrary commands
on log rotation, the line in the config is executed verbatim, i.e. the
exclamation mark is included.

For example, if the config file contains:

    s100
    !cat

then when it's time to rotate the log files after each 100 bytes, sh -c
"!cat" will be run, instead of sh -c "cat" as intended. The result is
svlogd logging

    /bin/bash: !cat: command not found
    svlogd: warning: processor failed, restart: /tmp/svlogd/

over and over again as it keeps attempting to execute the processor and
failing (unless you happen to have a "!cat" binary around :)).

Skipping the exclamation mark when performing the wstrdup() fixes the
issue.

Signed-off-by: Francis Rounds <francis.rounds@4bridgeworks.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
runit/svlogd.c

index 7cae81cb2cd725f2198f35c43dc899bca210bd32..3ed13b67bfb00ee7d6af7d54678f91c8d409cebc 100644 (file)
@@ -784,7 +784,7 @@ static NOINLINE unsigned logdir_open(struct logdir *ld, const char *fn)
                        case '!':
                                if (s[1]) {
                                        free(ld->processor);
-                                       ld->processor = wstrdup(s);
+                                       ld->processor = wstrdup(&s[1]);
                                }
                                break;
                        }