From 762e09d7e8eeb423f5edcf7951a03afb1b09ffd9 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Tue, 12 Nov 2019 12:05:03 +0100 Subject: [PATCH] syslogd: Drop -l HOST flag, the RFCs are very clear on this point Signed-off-by: Joachim Nilsson --- man/syslogd.8 | 10 ------- src/syslogd.c | 83 ++------------------------------------------------- 2 files changed, 2 insertions(+), 91 deletions(-) diff --git a/man/syslogd.8 b/man/syslogd.8 index 943f825..ccc1ecb 100644 --- a/man/syslogd.8 +++ b/man/syslogd.8 @@ -16,7 +16,6 @@ .Op Fl ?46Adhnv .Op Fl b Ar :SVC .Op Fl f Ar FILE -.Op Fl l Ar HOST[:HOST] .Op Fl m Ar SECONDS .Op Fl P Ar FILE .Op Fl p Ar SOCK @@ -116,10 +115,6 @@ hosts. Specifying this switch on the command line will cause the log daemon to forward any remote messages it receives to forwarding hosts which have been defined. This can cause syslog loops that fill up hard disks quite fast and thus needs to be used with caution. -.It Fl l Ar HOST -Specify a hostname that should be logged only with its simple hostname -and not the fqdn. Multiple hosts may be specified using the colon (':') -separator. .It Fl m Ar SECONDS .Nm logs a mark timestamp regularly. The default interval between two @@ -354,11 +349,6 @@ If the remote host is located in the same domain as the host, is running on, only the simple hostname will be logged instead of the whole FQDN. .Pp -Using the -.Fl l -option it is possibile to define single hosts as local machines. This -also results in logging only their simple hostnames and not the FQDNs. -.Pp The UDP socket used to forward messages to remote hosts or to receive messages from them is only opened when it is needed. In releases prior to 1.3-23 it was opened every time but not opened for reading or diff --git a/src/syslogd.c b/src/syslogd.c index 2722d4d..ab703c2 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -135,7 +135,6 @@ static int KeepKernFac; /* Keep remotely logged kernel facility */ static int LastAlarm = 0; /* last value passed to alarm() (seconds) */ static int DupesPending = 0; /* Number of unflushed duplicate messages */ -static char **LocalHosts = NULL; /* these hosts are logged with their hostname */ static int NoHops = 1; /* Can we bounce syslog messages through an intermediate host. */ static off_t RotateSz = 0; /* Max file size (bytes) before rotating, disabled by default */ static int RotateCnt = 5; /* Max number (count) of log files to keep, set with -c */ @@ -153,7 +152,6 @@ struct peer { static SIMPLEQ_HEAD(, peer) pqueue = SIMPLEQ_HEAD_INITIALIZER(pqueue); /* Function prototypes. */ -char **crunch_list(char *list); void untty(void); static void parsemsg(const char *from, char *msg); void printsys(char *msg); @@ -204,7 +202,6 @@ int usage(int code) " -d Enable debug mode\n" " -f FILE Alternate .conf file, default: /etc/syslog.conf\n" " -h Forward messages from other hosts also to remote syslog host(s)\n" - " -l HOST Host name to log without its FQDN, use ':' for multiple hosts\n" " -m SEC Interval between MARK messages in log, 0 to disable, default: 20 min\n" " -n Run in foreground, required when run from a modern init/supervisor\n" " -P FILE File in which to store the process ID, default: %s\n" @@ -245,7 +242,7 @@ int main(int argc, char *argv[]) KeepKernFac = 1; #endif - while ((ch = getopt(argc, argv, "46Ab:dhHf:l:m:nP:p:R:v?")) != EOF) { + while ((ch = getopt(argc, argv, "46Ab:dhHf:m:nP:p:R:v?")) != EOF) { switch ((char)ch) { case '4': family = PF_INET; @@ -286,14 +283,6 @@ int main(int argc, char *argv[]) NoHops = 0; break; - case 'l': - if (LocalHosts) { - warnx("Only one -l argument allowed, the first one is taken."); - break; - } - LocalHosts = crunch_list(optarg); - break; - case 'm': /* mark interval */ MarkInterval = atoi(optarg) * 60; break; @@ -561,63 +550,6 @@ static void create_inet_socket(struct peer *pe) freeaddrinfo(res); } -char **crunch_list(list) char *list; -{ - char **result = NULL; - char *p, *q; - int i, m, n; - - p = list; - - /* strip off trailing delimiters */ - while (*p && p[strlen(p) - 1] == LIST_DELIMITER) - p[strlen(p) - 1] = '\0'; - /* cut off leading delimiters */ - while (p[0] == LIST_DELIMITER) - p++; - - /* count delimiters to calculate the number of elements */ - for (n = i = 0; p[i]; i++) - if (p[i] == LIST_DELIMITER) - n++; - - if ((result = (char **)malloc(sizeof(char *) * (n + 2))) == NULL) { - printf("Sorry, can't get enough memory, exiting.\n"); - exit(1); - } - - /* - * We now can assume that the first and last - * characters are different from any delimiters, - * so we don't have to care about this. - */ - m = 0; - while ((q = strchr(p, LIST_DELIMITER)) && m < n) { - result[m] = (char *)malloc((q - p + 1) * sizeof(char)); - if (result[m] == NULL) { - printf("Sorry, can't get enough memory, exiting.\n"); - exit(1); - } - memcpy(result[m], p, q - p); - result[m][q - p] = '\0'; - p = q; - p++; - m++; - } - if ((result[m] = strdup(p)) == NULL) { - printf("Sorry, can't get enough memory, exiting.\n"); - exit(1); - } - result[++m] = NULL; - -#if 0 - m = 0; - while (result[m]) - logit("#%d: %s\n", m, result[m++]); -#endif - return result; -} - void untty(void) { if (!Debug) @@ -1810,7 +1742,7 @@ const char *cvthname(struct sockaddr_storage *f, int len) { static char hname[NI_MAXHOST]; char *p; - int err, count; + int err; err = getnameinfo((struct sockaddr *)f, len, hname, NI_MAXHOST, NULL, 0, NI_NAMEREQD); if (err) { @@ -1840,17 +1772,6 @@ const char *cvthname(struct sockaddr_storage *f, int len) if (strcmp(p + 1, LocalDomain) == 0) { *p = '\0'; return hname; - } else { - if (LocalHosts) { - count = 0; - while (LocalHosts[count]) { - if (!strcmp(hname, LocalHosts[count])) { - *p = '\0'; - return hname; - } - count++; - } - } } }