Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 68077 Details for
Bug 88099
sysklogd: now with ppc64 love
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
rework of omkhar's foo
sysklogd-1.4.1-p.patch (text/plain), 10.86 KB, created by
Tom Gall (RETIRED)
on 2005-09-09 19:53:53 UTC
(
hide
)
Description:
rework of omkhar's foo
Filename:
MIME Type:
Creator:
Tom Gall (RETIRED)
Created:
2005-09-09 19:53:53 UTC
Size:
10.86 KB
patch
obsolete
>diff -Naur sysklogd-1.4.1/klogd.c sysklogd-1.4.1new/klogd.c >--- sysklogd-1.4.1/klogd.c 2001-03-11 14:40:10.000000000 -0500 >+++ sysklogd-1.4.1new/klogd.c 2002-04-17 10:49:34.000000000 -0400 >@@ -509,8 +513,7 @@ > > > /* Set level of kernel console messaging.. */ >- if ( (console_log_level != -1) >- && (ksyslog(8, NULL, console_log_level) < 0) && \ >+ if ( (ksyslog(8, NULL, console_log_level) < 0) && \ > (errno == EINVAL) ) > { > /* >@@ -887,8 +890,7 @@ > value = strtoul(sym_start+1, (char **) 0, 16); > *(line-1) = '>'; /* put back delim */ > >- symbol = LookupSymbol(value, &sym); >- if ( !symbol_lookup || symbol == (char *) 0 ) >+ if ( !symbol_lookup || (symbol = LookupSymbol(value, &sym)) == (char *)0 ) > { > parse_state = PARSING_TEXT; > break; >@@ -938,7 +940,7 @@ > * messages into this fresh buffer. > */ > memset(log_buffer, '\0', sizeof(log_buffer)); >- if ( (rdcnt = ksyslog(2, log_buffer, sizeof(log_buffer))) < 0 ) >+ if ( (rdcnt = ksyslog(2, log_buffer, sizeof(log_buffer)-1)) < 0 ) > { > if ( errno == EINTR ) > return; >@@ -1143,8 +1145,11 @@ > if ( one_shot ) > { > if (symbol_lookup) { >- InitKsyms(symfile); >- InitMsyms(); >+ symbol_lookup = (InitKsyms(symfile) == 1); >+ symbol_lookup |= InitMsyms(); >+ if (symbol_lookup == 0) { >+ Syslog(LOG_WARNING, "cannot find any symbols, turning off symbol lookups\n"); >+ } > } > if ( (logsrc = GetKernelLogSrc()) == kernel ) > LogKernelLine(); >@@ -1159,8 +1164,11 @@ > #endif > logsrc = GetKernelLogSrc(); > if (symbol_lookup) { >- InitKsyms(symfile); >- InitMsyms(); >+ symbol_lookup = (InitKsyms(symfile) == 1); >+ symbol_lookup |= InitMsyms(); >+ if (symbol_lookup == 0) { >+ Syslog(LOG_WARNING, "cannot find any symbols, turning off symbol lookups\n"); >+ } > } > > /* The main loop. */ >diff -Naur sysklogd-1.4.1/ksym.c sysklogd-1.4.1new/ksym.c >--- sysklogd-1.4.1/ksym.c 2000-09-12 17:53:31.000000000 -0400 >+++ sysklogd-1.4.1new/ksym.c 2005-04-05 12:11:33.302898272 -0400 >@@ -112,6 +112,7 @@ > #include <stdlib.h> > #include <malloc.h> > #include <sys/utsname.h> >+#include <ctype.h> > #include "klogd.h" > #include "ksyms.h" > >@@ -344,6 +345,7 @@ > if ( (sym_file = fopen(symfile, "r")) != (FILE *) 0 ) { > if (CheckMapVersion(symfile) == 1) > file = symfile; >+ fclose(sym_file); > } > if (sym_file == (FILE *) 0 || file == (char *) 0) { > sprintf (symfile, "%s", *mf); >@@ -352,6 +354,7 @@ > if ( (sym_file = fopen(symfile, "r")) != (FILE *) 0 ) { > if (CheckMapVersion(symfile) == 1) > file = symfile; >+ fclose(sym_file); > } > } > >diff -Naur sysklogd-1.4.1/sysklogd.8 sysklogd-1.4.1new/sysklogd.8 >--- sysklogd-1.4.1/sysklogd.8 2001-03-11 14:35:51.000000000 -0500 >+++ sysklogd-1.4.1new/sysklogd.8 2001-07-09 00:17:22.000000000 -0400 >@@ -30,6 +30,7 @@ > .I domainlist > ] > .RB [ " \-v " ] >+.RB [ " \-x " ] > .LP > .SH DESCRIPTION > .B Sysklogd >@@ -152,6 +153,11 @@ > .TP > .B "\-v" > Print version and exit. >+.TP >+.B "\-x" >+Disable name lookups when receiving remote messages. >+This avoids deadlocks when the nameserver is running on >+the same machine that runs the syslog daemon. > .LP > .SH SIGNALS > .B Syslogd >diff -Naur sysklogd-1.4.1/syslog_tst.c sysklogd-1.4.1new/syslog_tst.c >--- sysklogd-1.4.1/syslog_tst.c 1997-06-02 13:21:41.000000000 -0400 >+++ sysklogd-1.4.1new/syslog_tst.c 2000-12-11 16:17:38.000000000 -0500 >@@ -42,7 +42,7 @@ > if ( (nl = strrchr(bufr, '\n')) != \ > (char *) 0) > *nl = '\0'; >- syslog(LOG_INFO, bufr); >+ syslog(LOG_INFO, "%s", bufr); > logged += strlen(bufr); > if ( logged > 1024 ) > { >@@ -54,7 +54,7 @@ > } > else > while (argc-- > 1) >- syslog(LOG_INFO, argv++[1]); >+ syslog(LOG_INFO, "%s", argv++[1]); > } > else > { >diff -Naur sysklogd-1.4.1/syslogd.c sysklogd-1.4.1new/syslogd.c >--- sysklogd-1.4.1/syslogd.c 2001-03-11 14:40:10.000000000 -0500 >+++ sysklogd-1.4.1new/syslogd.c 2004-08-02 18:02:35.000000000 -0400 >@@ -637,8 +637,8 @@ > * in seconds after previous message is logged. After each flush, > * we move to the next interval until we reach the largest. > */ >-int repeatinterval[] = { 30, 60 }; /* # of secs before flush */ >-#define MAXREPEAT ((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1) >+time_t repeatinterval[] = { 30, 60 }; /* # of secs before flush */ >+#define MAXREPEAT ((int) ((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1)) > #define REPEATTIME(f) ((f)->f_time + repeatinterval[(f)->f_repeatcount]) > #define BACKOFF(f) { if (++(f)->f_repeatcount > MAXREPEAT) \ > (f)->f_repeatcount = MAXREPEAT; \ >@@ -730,6 +730,7 @@ > int MarkInterval = 20 * 60; /* interval between marks in seconds */ > int MarkSeq = 0; /* mark sequence number */ > int NoFork = 0; /* don't fork - don't run in daemon mode */ >+int DisableDNS = 0; /* don't look up IP addresses of incoming messages */ > int AcceptRemote = 0; /* receive messages that come via UDP */ > char **StripDomains = NULL; /* these domains may be stripped before writing logs */ > char **LocalHosts = NULL; /* these hosts are logged with their hostname */ >@@ -743,7 +744,7 @@ > char **crunch_list(char *list); > int usage(void); > void untty(void); >-void printchopped(const char *hname, char *msg, int len, int fd); >+void printchopped(const char *hname, char *msg, size_t len, int fd); > void printline(const char *hname, char *msg); > void printsys(char *msg); > void logmsg(int pri, char *msg, const char *from, int flags); >@@ -786,7 +787,7 @@ > int len, num_fds; > #else /* __GLIBC__ */ > #ifndef TESTING >- size_t len; >+ socklen_t len; > #endif > int num_fds; > #endif /* __GLIBC__ */ >@@ -829,7 +830,7 @@ > funix[i] = -1; > } > >- while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:v")) != EOF) >+ while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:vx")) != EOF) > switch((char)ch) { > case 'a': > if (nfunix < MAXFUNIX) >@@ -877,6 +878,9 @@ > case 'v': > printf("syslogd %s.%s\n", VERSION, PATCHLEVEL); > exit (0); >+ case 'x': >+ DisableDNS = 1; >+ break; > case '?': > default: > usage(); >@@ -890,11 +894,11 @@ > dprintf("Checking pidfile.\n"); > if (!check_pid(PidFile)) > { >+ signal (SIGTERM, doexit); > if (fork()) { > /* > * Parent process > */ >- signal (SIGTERM, doexit); > sleep(300); > /* > * Not reached unless something major went wrong. 5 >@@ -906,6 +910,7 @@ > */ > exit(1); > } >+ signal (SIGTERM, SIG_DFL); > num_fds = getdtablesize(); > for (i= 0; i < num_fds; i++) > (void) close(i); >@@ -1074,9 +1079,9 @@ > (fd_set *) NULL, (struct timeval *) NULL); > if ( restart ) > { >+ restart = 0; > dprintf("\nReceived SIGHUP, reloading syslogd.\n"); > init(); >- restart = 0; > continue; > } > if (nfds == 0) { >@@ -1145,8 +1150,7 @@ > dprintf("INET socket error: %d = %s.\n", \ > errno, strerror(errno)); > logerror("recvfrom inet"); >- /* should be harmless now that we set >- * BSDCOMPAT on the socket */ >+ /* should be harmless */ > sleep(10); > } > } >@@ -1174,7 +1178,7 @@ > > int usage() > { >- fprintf(stderr, "usage: syslogd [-drvh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \ >+ fprintf(stderr, "usage: syslogd [-drvxh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \ > " [-s domainlist] [-f conffile]\n"); > exit(1); > } >@@ -1232,17 +1236,6 @@ > close(fd); > return -1; > } >- if (should_use_so_bsdcompat()) { >- /* We need to enable BSD compatibility. Otherwise an attacker >- * could flood our log files by sending us tons of ICMP errors. >- */ >- if (setsockopt(fd, SOL_SOCKET, SO_BSDCOMPAT, \ >- (char *) &on, sizeof(on)) < 0) { >- logerror("setsockopt(BSDCOMPAT), suspending inet"); >- close(fd); >- return -1; >- } >- } > if (bind(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0) { > logerror("bind, suspending inet"); > close(fd); >@@ -1254,30 +1249,26 @@ > crunch_list(list) > char *list; > { >- int count, i; >+ int i, m, n; > char *p, *q; > char **result = NULL; > > p = list; > > /* strip off trailing delimiters */ >- while (p[strlen(p)-1] == LIST_DELIMITER) { >- count--; >+ while (*p && p[strlen(p)-1] == LIST_DELIMITER) > p[strlen(p)-1] = '\0'; >- } > /* cut off leading delimiters */ >- while (p[0] == LIST_DELIMITER) { >- count--; >+ while (p[0] == LIST_DELIMITER) > p++; >- } > >- /* count delimiters to calculate elements */ >- for (count=i=0; p[i]; i++) >- if (p[i] == LIST_DELIMITER) count++; >+ /* 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 *) * count+2)) == NULL) { >+ if ((result = (char **)malloc(sizeof(char *) * (n + 2))) == NULL) { > printf ("Sorry, can't get enough memory, exiting.\n"); >- exit(0); >+ exit(1); > } > > /* >@@ -1285,30 +1276,28 @@ > * 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) * sizeof(char)); >- if (result[count] == NULL) { >+ 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(0); >+ exit(1); > } >- strncpy(result[count], p, q - p); >- result[count][q - p] = '\0'; >+ memcpy(result[m], p, q - p); >+ result[m][q - p] = '\0'; > p = q; p++; >- count++; >+ m++; > } >- if ((result[count] = \ >- (char *)malloc(sizeof(char) * strlen(p) + 1)) == NULL) { >+ if ((result[m] = strdup(p)) == NULL) { > printf ("Sorry, can't get enough memory, exiting.\n"); >- exit(0); >+ exit(1); > } >- strcpy(result[count],p); >- result[++count] = NULL; >+ result[++m] = NULL; > > #if 0 >- count=0; >- while (result[count]) >- dprintf ("#%d: %s\n", count, StripDomains[count++]); >+ m = 0; >+ while (result[m]) >+ dprintf ("#%d: %s\n", m, result[m++]); > #endif > return result; > } >@@ -1346,7 +1335,7 @@ > void printchopped(hname, msg, len, fd) > const char *hname; > char *msg; >- int len; >+ size_t len; > int fd; > { > auto int ptlngth; >@@ -1446,6 +1435,7 @@ > while ((c = *p++) && q < &line[sizeof(line) - 4]) { > if (c == '\n') > *q++ = ' '; >+#if 0 > else if (c < 040) { > *q++ = '^'; > *q++ = c ^ 0100; >@@ -1454,7 +1444,9 @@ > *q++ = '0' + ((c & 0300) >> 6); > *q++ = '0' + ((c & 0070) >> 3); > *q++ = '0' + (c & 0007); >- } else >+ } >+#endif >+ else > *q++ = c; > } > *q = '\0'; >@@ -1929,7 +1921,7 @@ > /* is this slot used? */ > if (ut.ut_name[0] == '\0') > continue; >- if (ut.ut_type == LOGIN_PROCESS) >+ if (ut.ut_type != USER_PROCESS) > continue; > if (!(strcmp (ut.ut_name,"LOGIN"))) /* paranoia */ > continue; >@@ -2013,7 +2005,10 @@ > dprintf("Malformed from address.\n"); > return ("???"); > } >- hp = gethostbyaddr((char *) &f->sin_addr, sizeof(struct in_addr), \ >+ if (DisableDNS) >+ hp = 0; >+ else >+ hp = gethostbyaddr((char *) &f->sin_addr, sizeof(struct in_addr), \ > f->sin_family); > if (hp == 0) { > dprintf("Host name for your address (%s) unknown.\n",
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 88099
:
55410
|
55665
|
55666
|
68076
| 68077