syslogd: Drop -l HOST flag, the RFCs are very clear on this point
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
parent
d1035377cc
commit
762e09d7e8
@ -16,7 +16,6 @@
|
|||||||
.Op Fl ?46Adhnv
|
.Op Fl ?46Adhnv
|
||||||
.Op Fl b Ar :SVC
|
.Op Fl b Ar :SVC
|
||||||
.Op Fl f Ar FILE
|
.Op Fl f Ar FILE
|
||||||
.Op Fl l Ar HOST[:HOST]
|
|
||||||
.Op Fl m Ar SECONDS
|
.Op Fl m Ar SECONDS
|
||||||
.Op Fl P Ar FILE
|
.Op Fl P Ar FILE
|
||||||
.Op Fl p Ar SOCK
|
.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
|
daemon to forward any remote messages it receives to forwarding hosts
|
||||||
which have been defined. This can cause syslog loops that fill up hard
|
which have been defined. This can cause syslog loops that fill up hard
|
||||||
disks quite fast and thus needs to be used with caution.
|
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
|
.It Fl m Ar SECONDS
|
||||||
.Nm
|
.Nm
|
||||||
logs a mark timestamp regularly. The default interval between two
|
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
|
is running on, only the simple hostname will be logged instead of the
|
||||||
whole FQDN.
|
whole FQDN.
|
||||||
.Pp
|
.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
|
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
|
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
|
prior to 1.3-23 it was opened every time but not opened for reading or
|
||||||
|
@ -135,7 +135,6 @@ static int KeepKernFac; /* Keep remotely logged kernel facility */
|
|||||||
|
|
||||||
static int LastAlarm = 0; /* last value passed to alarm() (seconds) */
|
static int LastAlarm = 0; /* last value passed to alarm() (seconds) */
|
||||||
static int DupesPending = 0; /* Number of unflushed duplicate messages */
|
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 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 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 <NUM> */
|
static int RotateCnt = 5; /* Max number (count) of log files to keep, set with -c <NUM> */
|
||||||
@ -153,7 +152,6 @@ struct peer {
|
|||||||
static SIMPLEQ_HEAD(, peer) pqueue = SIMPLEQ_HEAD_INITIALIZER(pqueue);
|
static SIMPLEQ_HEAD(, peer) pqueue = SIMPLEQ_HEAD_INITIALIZER(pqueue);
|
||||||
|
|
||||||
/* Function prototypes. */
|
/* Function prototypes. */
|
||||||
char **crunch_list(char *list);
|
|
||||||
void untty(void);
|
void untty(void);
|
||||||
static void parsemsg(const char *from, char *msg);
|
static void parsemsg(const char *from, char *msg);
|
||||||
void printsys(char *msg);
|
void printsys(char *msg);
|
||||||
@ -204,7 +202,6 @@ int usage(int code)
|
|||||||
" -d Enable debug mode\n"
|
" -d Enable debug mode\n"
|
||||||
" -f FILE Alternate .conf file, default: /etc/syslog.conf\n"
|
" -f FILE Alternate .conf file, default: /etc/syslog.conf\n"
|
||||||
" -h Forward messages from other hosts also to remote syslog host(s)\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"
|
" -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"
|
" -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"
|
" -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;
|
KeepKernFac = 1;
|
||||||
#endif
|
#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) {
|
switch ((char)ch) {
|
||||||
case '4':
|
case '4':
|
||||||
family = PF_INET;
|
family = PF_INET;
|
||||||
@ -286,14 +283,6 @@ int main(int argc, char *argv[])
|
|||||||
NoHops = 0;
|
NoHops = 0;
|
||||||
break;
|
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 */
|
case 'm': /* mark interval */
|
||||||
MarkInterval = atoi(optarg) * 60;
|
MarkInterval = atoi(optarg) * 60;
|
||||||
break;
|
break;
|
||||||
@ -561,63 +550,6 @@ static void create_inet_socket(struct peer *pe)
|
|||||||
freeaddrinfo(res);
|
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)
|
void untty(void)
|
||||||
{
|
{
|
||||||
if (!Debug)
|
if (!Debug)
|
||||||
@ -1810,7 +1742,7 @@ const char *cvthname(struct sockaddr_storage *f, int len)
|
|||||||
{
|
{
|
||||||
static char hname[NI_MAXHOST];
|
static char hname[NI_MAXHOST];
|
||||||
char *p;
|
char *p;
|
||||||
int err, count;
|
int err;
|
||||||
|
|
||||||
err = getnameinfo((struct sockaddr *)f, len, hname, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
|
err = getnameinfo((struct sockaddr *)f, len, hname, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -1840,17 +1772,6 @@ const char *cvthname(struct sockaddr_storage *f, int len)
|
|||||||
if (strcmp(p + 1, LocalDomain) == 0) {
|
if (strcmp(p + 1, LocalDomain) == 0) {
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
return hname;
|
return hname;
|
||||||
} else {
|
|
||||||
if (LocalHosts) {
|
|
||||||
count = 0;
|
|
||||||
while (LocalHosts[count]) {
|
|
||||||
if (!strcmp(hname, LocalHosts[count])) {
|
|
||||||
*p = '\0';
|
|
||||||
return hname;
|
|
||||||
}
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user