]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/misc-progs/syslogdctrl.c
installer: Intialize part_boot_efi_idx
[ipfire-2.x.git] / src / misc-progs / syslogdctrl.c
index c65a1f0d2a4a992dec50501f7839d70f84c96314..d73c4226518f3082086f993e0681db410d789597 100644 (file)
 
 int main(void)
 {
-   char buffer[STRING_SIZE], command[STRING_SIZE], hostname[STRING_SIZE];
-   const char* protocol;
+   char buffer[STRING_SIZE], command[STRING_SIZE], hostname[STRING_SIZE], protocol[STRING_SIZE];
    char varmessages[STRING_SIZE], asynclog[STRING_SIZE];
    int config_fd,rc,fd,pid;
    struct stat st;
    struct keyvalue *kv = NULL;
    memset(buffer, 0, STRING_SIZE);
    memset(hostname, 0, STRING_SIZE);
+   memset(protocol, 0, STRING_SIZE);
    memset(varmessages, 0, STRING_SIZE);
    memset(asynclog, 0, STRING_SIZE);
 
@@ -71,7 +71,7 @@ int main(void)
    if (!findkey(kv, "REMOTELOG_PROTOCOL", protocol))
    {
       /* fall back to UDP if no protocol was given */
-      protocol = "udp";
+      strcpy(protocol, "udp");
    }
 
    if (strspn(hostname, VALID_FQDN) != strlen(hostname))
@@ -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 */