]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
syslogdctrl: Fix sed syntax issues
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Jan 2018 20:54:46 +0000 (20:54 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Jan 2018 20:54:46 +0000 (20:54 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/misc-progs/syslogdctrl.c

index 6d7dfacaa2c58b282102e70b6ea361e4323b8543..d73c4226518f3082086f993e0681db410d789597 100644 (file)
@@ -118,18 +118,18 @@ int main(void)
       if (strcmp(protocol, "tcp") == 0)
       {
          /* write line for TCP */
-         snprintf(buffer, STRING_SIZE - 1, "/bin/sed -e 's/^#\\?\\(\\*\\.\\*[[:blank:]]\\+@@\\).\\+$/\\1%s/' /etc/syslog.conf >&%d", hostname, config_fd );
+         snprintf(buffer, STRING_SIZE - 1, "/bin/sed -e 's/^#\\?\\(\\*\\.\\*[[:blank:]]\\+\\)@@\\?.\\+$/\\1@@%s/' /etc/syslog.conf >&%d", hostname, config_fd);
       }
       else
       {
          /* write line for UDP */
-         snprintf(buffer, STRING_SIZE - 1, "/bin/sed -e 's/^#\\?\\(\\*\\.\\*[[:blank:]]\\+@\\).\\+$/\\1%s/' /etc/syslog.conf >&%d", hostname, config_fd );
+         snprintf(buffer, STRING_SIZE - 1, "/bin/sed -e 's/^#\\?\\(\\*\\.\\*[[:blank:]]\\+\\)@@\\?.\\+$/\\1@%s/' /etc/syslog.conf >&%d", hostname, config_fd);
       }
    }
    else
    {
       /* if remote syslog has been disabled */
-      snprintf(buffer, STRING_SIZE - 1, "/bin/sed -e 's/^#\\?\\(\\*\\.\\*[[:blank:]]\\+@.\\+\\)$/#\\1/' /etc/syslog.conf >&%d", config_fd );
+      snprintf(buffer, STRING_SIZE - 1, "/bin/sed -e 's/^#\\?\\(\\*\\.\\*[[:blank:]]\\+@@\\?.\\+\\)$/#\\1/' /etc/syslog.conf >&%d", config_fd );
    }
 
      /* if the return code isn't 0 failsafe */