command line interface: finally remove old -s, -l options

These options generate warning messages that they will go away
for years now. Nobody has complained about this fact (the message
request that). So we assume it is safe to finally remove them.
This helps to clean up rsyslog code and remove unneeded cruft.
This commit is contained in:
Rainer Gerhards 2019-04-17 18:27:33 +02:00
parent 8766a74155
commit 2ac1cfdac2
No known key found for this signature in database
GPG Key ID: 0CB6B2A8BE80B499
3 changed files with 2 additions and 128 deletions

View File

@ -207,7 +207,6 @@ setLocalHostName(dnscache_entry_t *etry)
{
uchar *fqdnLower;
uchar *p;
int count;
int i;
uchar hostbuf[NI_MAXHOST];
@ -229,36 +228,6 @@ setLocalHostName(dnscache_entry_t *etry)
i = p - fqdnLower; /* length of hostname */
memcpy(hostbuf, fqdnLower, i);
hostbuf[i] = '\0';
/* now check if we belong to any of the domain names that were specified
* in the -s command line option. If so, remove and we are done.
*/
if(glbl.GetStripDomains() != NULL) {
count=0;
while(glbl.GetStripDomains()[count]) {
if(strcmp((char*)(p + 1), glbl.GetStripDomains()[count]) == 0) {
prop.CreateStringProp(&etry->localName, hostbuf, i);
goto done;
}
count++;
}
}
/* if we reach this point, we have not found any domain we should strip. Now
* we try and see if the host itself is listed in the -l command line option
* and so should be stripped also. If so, we do it and return. Please note that
* -l list FQDNs, not just the hostname part. If it did just list the hostname, the
* door would be wide-open for all kinds of mixing up of hosts. Because of this,
* you'll see comparison against the full string (pszHostFQDN) below.
*/
if(glbl.GetLocalHosts() != NULL) {
count=0;
while(glbl.GetLocalHosts()[count]) {
if(!strcmp((char*)fqdnLower, (char*)glbl.GetLocalHosts()[count])) {
prop.CreateStringProp(&etry->localName, hostbuf, i);
goto done;
}
count++;
}
}
/* at this point, we have not found anything, so we again use the
* already-created complete full name property.

View File

@ -155,11 +155,6 @@ DEFobjCurrIf(module)
DEFobjCurrIf(datetime)
DEFobjCurrIf(glbl)
/* imports from syslogd.c, these should go away over time (as we
* migrate/replace more and more code to ASL 2.0).
*/
char **syslogd_crunch_list(char *list);
/* end syslogd.c imports */
extern int yydebug; /* interface to flex */
@ -1298,9 +1293,9 @@ initAll(int argc, char **argv)
* rgerhards, 2008-04-04
*/
#if defined(_AIX)
while((ch = getopt(argc, argv, "46ACDdf:hi:l:M:nN:qQs:S:T:u:vwxR")) != EOF) {
while((ch = getopt(argc, argv, "46ACDdf:hi:M:nN:qQS:T:u:vwxR")) != EOF) {
#else
while((ch = getopt(argc, argv, "46ACDdf:hi:l:M:nN:qQs:S:T:u:vwx")) != EOF) {
while((ch = getopt(argc, argv, "46ACDdf:hi:M:nN:qQS:T:u:vwx")) != EOF) {
#endif
switch((char)ch) {
case '4':
@ -1308,12 +1303,10 @@ initAll(int argc, char **argv)
case 'A':
case 'f': /* configuration file */
case 'i': /* pid file name */
case 'l':
case 'n': /* don't fork */
case 'N': /* enable config verify mode */
case 'q': /* add hostname if DNS resolving has failed */
case 'Q': /* dont resolve hostnames in ACL to IPs */
case 's':
case 'S': /* Source IP for local client to be used on multihomed host */
case 'T': /* chroot on startup (primarily for testing) */
case 'u': /* misc user settings */
@ -1426,16 +1419,6 @@ initAll(int argc, char **argv)
free((void*)PidFile);
PidFile = arg;
break;
case 'l':
fprintf (stderr, "rsyslogd: the -l command line option will go away "
"soon.\n Make yourself heard on the rsyslog mailing "
"list if you need it any longer.\n");
if(glbl.GetLocalHosts() != NULL) {
fprintf (stderr, "rsyslogd: Only one -l argument allowed, the first one is taken.\n");
} else {
glbl.SetLocalHosts(syslogd_crunch_list(arg));
}
break;
case 'n': /* don't fork */
doFork = 0;
break;
@ -1454,16 +1437,6 @@ initAll(int argc, char **argv)
"configuration parameter instead.\n");
*(net.pACLDontResolve) = 1;
break;
case 's':
fprintf (stderr, "rsyslogd: the -s command line option will go away "
"soon.\n Make yourself heard on the rsyslog mailing "
"list if you need it any longer.\n");
if(glbl.GetStripDomains() != NULL) {
fprintf (stderr, "rsyslogd: Only one -s argument allowed, the first one is taken.\n");
} else {
glbl.SetStripDomains(syslogd_crunch_list(arg));
}
break;
case 'T':/* chroot() immediately at program startup, but only for testing, NOT security yet */
if(arg == NULL) {
/* note this case should already be handled by getopt,

View File

@ -103,74 +103,6 @@
#include "dnscache.h"
#include "ratelimit.h"
#define LIST_DELIMITER ':' /* delimiter between two hosts */
/* rgerhards, 2005-10-24: crunch_list is called only during option processing. So
* it is never called once rsyslogd is running. This code
* contains some exits, but they are considered safe because they only happen
* during startup. Anyhow, when we review the code here, we might want to
* reconsider the exit()s.
* Note: this stems back to sysklogd, so we cannot put it under ASL 2.0. But
* we may want to check if the code inside the BSD sources is exactly the same
* (remember that sysklogd forked the BSD sources). If so, the BSD license applies
* and permits us to move to ASL 2.0 (but we need to check the fine details).
* Probably it is best just to rewrite this code.
*/
char **syslogd_crunch_list(char *list);
char **syslogd_crunch_list(char *list)
{
int count, i;
char *p, *q;
char **result = NULL;
p = list;
/* strip off trailing delimiters */
while (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 elements */
for (count=i=0; p[i]; i++)
if (p[i] == LIST_DELIMITER) count++;
if ((result = (char **)malloc(sizeof(char *) * (count+2))) == NULL) {
printf ("Sorry, can't get enough memory, exiting.\n");
exit(0); /* safe exit, because only called during startup */
}
/*
* We now can assume that the first and last
* characters are different from any delimiters,
* so we don't have to care about this.
*/
count = 0;
while ((q=strchr(p, LIST_DELIMITER))) {
result[count] = (char *) malloc(q - p + 1);
if (result[count] == NULL) {
printf ("Sorry, can't get enough memory, exiting.\n");
exit(0); /* safe exit, because only called during startup */
}
strncpy(result[count], p, q - p);
result[count][q - p] = '\0';
p = q; p++;
count++;
}
if ((result[count] = \
(char *)malloc(strlen(p) + 1)) == NULL) {
printf ("Sorry, can't get enough memory, exiting.\n");
exit(0); /* safe exit, because only called during startup */
}
strcpy(result[count],p);
result[++count] = NULL;
return result;
}
#ifndef HAVE_SETSID
/* stems back to sysklogd in whole */
void untty(void)