diff --git a/klogd.8 b/klogd.8 index 107ec66..eaa102d 100644 --- a/klogd.8 +++ b/klogd.8 @@ -26,6 +26,7 @@ klogd \- kernel log daemon. .I fname ] .RB [ " \-v " ] +.RB [ " \-x " ] .LP .SH DESCRIPTION .B klogd @@ -76,6 +77,9 @@ Use the specified file as the source of kernel symbol information. .TP .B "\-v" Print version and exit. +.TP +.B "\-x" +Omits EIP translation and there doesn't read the System.map. .LP .SH OVERVIEW The functionality of klogd has been typically incorporated into other diff --git a/klogd.c b/klogd.c index 278d6d7..ce02998 100644 --- a/klogd.c +++ b/klogd.c @@ -182,6 +182,15 @@ * call. The old behaveiour could result in klogd being * recognized as being undead, because it'll only die after a * message has been received. + * + * Fri Jan 9 11:03:48 CET 1998: Martin Schulze + * Corrected some code that caused klogd to dump core when + * receiving messages containing '%', some of them exist in + * 2.1.78. Thanks to Chu-yeon Park for + * informing me. + * + * Fri Jan 9 23:38:19 CET 1998: Florian La Roche + * Added -x switch to omit EIP translation and System.map evaluation. */ @@ -230,7 +239,8 @@ static int kmsg, static int use_syscall = 0, one_shot = 0, - NoFork = 0; /* don't fork - don't run in daemon mode */ + symbol_lookup = 1, + no_fork = 0; /* don't fork - don't run in daemon mode */ static char *symfile = (char *) 0, log_buffer[LOG_BUFFER_SIZE]; @@ -370,9 +380,11 @@ static void SignalDaemon(sig) static void ReloadSymbols() { - if ( reload_symbols > 1 ) - InitKsyms(symfile); - InitMsyms(); + if (symbol_lookup) { + if ( reload_symbols > 1 ) + InitKsyms(symfile); + InitMsyms(); + } reload_symbols = change_state = 0; return; } @@ -497,7 +509,8 @@ extern void Syslog(int priority, char *fmt, ...) va_end(ap); fputc('\n', output_file); fflush(output_file); - fsync(fileno(output_file)); + if (!one_shot) + fsync(fileno(output_file)); return; } @@ -611,7 +624,7 @@ static void LogLine(char *ptr, int len) fprintf(stderr, "\tLine: %s\n", line); } - Syslog( LOG_INFO, line_buff ); + Syslog( LOG_INFO, "%s", line_buff ); line = line_buff; space = sizeof(line_buff)-1; parse_state = PARSING_TEXT; @@ -638,7 +651,7 @@ static void LogLine(char *ptr, int len) len -= 1; *line = 0; /* force null terminator */ - Syslog( LOG_INFO, line_buff ); + Syslog( LOG_INFO, "%s", line_buff ); line = line_buff; space = sizeof(line_buff)-1; break; @@ -721,7 +734,8 @@ static void LogLine(char *ptr, int len) *(line-1) = '>'; /* put back delim */ symbol = LookupSymbol(value, &sym); - if ( symbol == (char *) 0 ) + if ( !symbol_lookup || symbol == (char *) 0 ) + { parse_state = PARSING_TEXT; break; @@ -823,7 +837,7 @@ int main(argc, argv) *output = (char *) 0; /* Parse the command-line. */ - while ((ch = getopt(argc, argv, "c:df:iIk:nopsv")) != EOF) + while ((ch = getopt(argc, argv, "c:df:iIk:nopsvx")) != EOF) switch((char)ch) { case 'c': /* Set console message level. */ @@ -846,7 +860,7 @@ int main(argc, argv) symfile = optarg; break; case 'n': /* don't fork */ - NoFork++; + no_fork++; break; case 'o': /* One-shot mode. */ one_shot = 1; @@ -860,6 +874,9 @@ int main(argc, argv) case 'v': printf("klogd %s-%s\n", VERSION, PATCHLEVEL); exit (1); + case 'x': + symbol_lookup = 0; + break; } @@ -888,7 +905,7 @@ int main(argc, argv) * not disabled with the command line argument and there's no * such process running. */ - if ( (!one_shot) && (!NoFork) ) + if ( (!one_shot) && (!no_fork) ) { if (!check_pid(PidFile)) { @@ -964,8 +981,10 @@ int main(argc, argv) /* Handle one-shot logging. */ if ( one_shot ) { - InitKsyms(symfile); - InitMsyms(); + if (symbol_lookup) { + InitKsyms(symfile); + InitMsyms(); + } if ( (logsrc = GetKernelLogSrc()) == kernel ) LogKernelLine(); else @@ -978,8 +997,10 @@ int main(argc, argv) sleep(KLOGD_DELAY); #endif logsrc = GetKernelLogSrc(); - InitKsyms(symfile); - InitMsyms(); + if (symbol_lookup) { + InitKsyms(symfile); + InitMsyms(); + } /* The main loop. */ while (1) diff --git a/ksym.c b/ksym.c index 17f9f3e..e8a72df 100644 --- a/ksym.c +++ b/ksym.c @@ -80,6 +80,9 @@ * Fri Jun 13 10:50:23 CST 1997: Martin Schulze * Changed definition of LookupSymbol to non-static because it is * used in klogd.c, too. + * + * Fri Jan 9 23:00:08 CET 1998: Martin Schulze + * Fixed bug that caused klogd to die if there is no System.map available. */ @@ -327,7 +330,8 @@ static char * FindSymbolFile() continue; } } - + + if (sym_file) { /* * At this point a map file was successfully opened. We * now need to search this file and look for a version @@ -376,7 +380,7 @@ static char * FindSymbolFile() return(symfile); break; } - + } /* * At this stage of the game we are at the end of the symbol diff --git a/ksym_mod.c b/ksym_mod.c index b77543e..54ce47c 100644 --- a/ksym_mod.c +++ b/ksym_mod.c @@ -49,6 +49,12 @@ * * Sun Jun 15 16:23:29 MET DST 1997: Michael Alan Dorman * Some more glibc patches made by . + * + * Sat Jan 10 15:00:18 CET 1998: Martin Schulze + * Fixed problem with klogd not being able to be built on a kernel + * newer than 2.1.18. It was caused by modified structures + * inside the kernel that were included. I have worked in a + * patch from Alessandro Suardi . */ @@ -68,6 +74,7 @@ #endif /* __GLIBC__ */ #include #include +#include #include "klogd.h" #include "ksyms.h" @@ -104,6 +111,9 @@ struct Module char *name; struct module module; +#if LINUX_VERSION_CODE >= 0x20112 + struct module_info module_info; +#endif }; static int num_modules = 0; @@ -535,9 +545,15 @@ extern char * LookupModuleSymbol(value, sym) * If it is in this range we can at least return the * name of the module. */ +#if LINUX_VERSION_CODE < 0x20112 if ( (void *) value >= mp->module.addr && (void *) value <= (mp->module.addr + \ mp->module.size * 4096) ) +#else + if ( value >= mp->module_info.addr && + value <= (mp->module_info.addr + \ + mp->module.size * 4096) ) +#endif { /* * A special case needs to be checked for. The above @@ -556,8 +572,13 @@ extern char * LookupModuleSymbol(value, sym) if ( mp->num_syms > 0 ) { last = &mp->sym_array[mp->num_syms - 1]; +#if LINUX_VERSION_CODE < 0x20112 sym->size = (int) mp->module.addr + \ (mp->module.size * 4096) - value; +#else + sym->size = (int) mp->module_info.addr + \ + (mp->module.size * 4096) - value; +#endif sym->offset = value - last->value; return(last->name); } @@ -568,7 +589,11 @@ extern char * LookupModuleSymbol(value, sym) * faulting address in the module. */ sym->size = mp->module.size * 4096; +#if LINUX_VERSION_CODE < 0x20112 sym->offset = (void *) value - mp->module.addr; +#else + sym->offset = value - mp->module_info.addr; +#endif return(mp->name); } } diff --git a/syslogd.c b/syslogd.c index 6648a02..3480af9 100644 --- a/syslogd.c +++ b/syslogd.c @@ -208,19 +208,19 @@ static char sccsid[] = "@(#)syslogd.c 5.27 (Berkeley) 10/10/88"; * reception on with the "-r" option. * * Not defining SYSLOG_INET will result in not doing any network - * activity, i.e. not sending or receiving messages. I changed + * activity, i.e. not sending or receiving messages. I changed * this because the old idea is implemented with the "-r" option * and the old thing didn't work anyway. * * Thu Oct 26 13:14:06 MET 1995: Martin Schulze - * Added another logfile type F_FORW_UNKN. The problem I ran into + * Added another logfile type F_FORW_UNKN. The problem I ran into * was a name server that runs on my machine and a forwarder of - * kern.crit to another host. The hosts address can only be - * fetched using the nameserver. But named is started after + * kern.crit to another host. The hosts address can only be + * fetched using the nameserver. But named is started after * syslogd, so syslogd complained. * * This logfile type will retry to get the address of the - * hostname ten times and then complain. This should be enough to + * hostname ten times and then complain. This should be enough to * get the named up and running during boot sequence. * * Fri Oct 27 14:08:15 1995: Dr. Wettstein @@ -330,6 +330,10 @@ static char sccsid[] = "@(#)syslogd.c 5.27 (Berkeley) 10/10/88"; * Reworked one line of the above patch as it prevented syslogd * from binding the socket with the result that no messages were * forwarded to other hosts. + * + * Sat Jan 10 01:33:06 CET 1998: Martin Schulze + * Fixed small bugs in F_FORW_UNKN meachanism. Thanks to Torsten + * Neumann for pointing me to it. */ @@ -795,6 +799,7 @@ int main(argc, argv) hent = gethostbyname(LocalHostName); if ( hent ) sprintf(LocalHostName, "%s", hent->h_name); + if ( (p = index(LocalHostName, '.')) ) { *p++ = '\0'; @@ -1536,6 +1541,7 @@ void fprintlog(f, from, flags, msg) else { dprintf("%s found, resuming.\n", f->f_un.f_forw.f_hname); bcopy(hp->h_addr, (char *) &f->f_un.f_forw.f_addr.sin_addr, hp->h_length); + f->f_prevcount = 0; f->f_type = F_FORW; goto f_forw; } @@ -2316,6 +2322,7 @@ void cfline(line, f) if ( (hp = gethostbyname(p)) == NULL ) { f->f_type = F_FORW_UNKN; f->f_prevcount = INET_RETRY_MAX; + f->f_time = time ( (time_t *)0 ); } else { f->f_type = F_FORW; } @@ -2399,7 +2406,7 @@ int decode(name, codetab) { register struct code *c; register char *p; - char buf[40]; + char buf[80]; dprintf ("symbolic name: %s", name); if (isdigit(*name)) @@ -2407,7 +2414,7 @@ int decode(name, codetab) dprintf ("\n"); return (atoi(name)); } - (void) strcpy(buf, name); + (void) strncpy(buf, name, 79); for (p = buf; *p; p++) if (isupper(*p)) *p = tolower(*p);