* Fixed typos in syslogd-listfiles(1), thanks to Francesco Potorti`

<F.Potorti@cnuce.cnr.it> (closes: Bug#20903)
  * Corrected email address for Shane Alderton (closes: Bug#20765)
  * Fixed manpage to not reflect reverse implementated SIGALRM signal
    handler (closes: Bug#20647)
  * Modified behaviour with including <sys/module.h> (closes: Bug#20556)
  * Added correct prototype for llseek() (closes: Bug#20507, Bug#20220)
  * Added more log information if problems occurr while reading a system
    map file.
  * Modified System.map read function to try all possible map files until
    a file with matching version is found.
  * Added Debian release to klogd
  * Switched to fgets() as gets() is not buffer overrun secure.
  * Modified loop for detecting the correct system map.
This commit is contained in:
Joey Schulze 1998-04-13 23:27:37 +00:00
parent 92fe2ad65d
commit 1f3d627188
7 changed files with 151 additions and 90 deletions

View File

@ -3,7 +3,7 @@
CC= gcc
#CFLAGS= -g -DSYSV -Wall
#LDFLAGS= -g
CFLAGS= -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce
CFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce
LDFLAGS= -s
# Look where your install program is.

View File

@ -63,7 +63,7 @@ Juha Virtanen
jiivee@hut.fi
Shane Alderton
shane@scs.apana.org.au
shane@ion.apana.org.au
Martin Schulze
Infodrom Oldenburg

15
klogd.c
View File

@ -196,6 +196,11 @@
* As the bug covering the %'s introduced a problem with
* unevaluated priorities I've worked out a real fix that strips
* %'s to an even number which is harmless for printf.
*
* Mon Apr 13 18:18:45 CEST 1998: Martin Schulze <joey@infodrom.north.de>
* Modified System.map read function to try all possible map
* files until a file with matching version is found. Added support for
* Debian release.
*/
@ -475,8 +480,13 @@ static enum LOGSRC GetKernelLogSrc(void)
{
/* Initialize kernel logging. */
ksyslog(1, NULL, 0);
#ifdef DEBRELEASE
Syslog(LOG_INFO, "klogd %s-%s#%s, log source = ksyslog "
"started.", VERSION, PATCHLEVEL, DEBRELEASE);
#else
Syslog(LOG_INFO, "klogd %s-%s, log source = ksyslog "
"started.", VERSION, PATCHLEVEL);
#endif
return(kernel);
}
@ -488,8 +498,13 @@ static enum LOGSRC GetKernelLogSrc(void)
exit(1);
}
#ifdef DEBRELEASE
Syslog(LOG_INFO, "klogd %s-%s#%s, log source = %s started.", \
VERSION, PATCHLEVEL, DEBRELEASE, _PATH_KLOG);
#else
Syslog(LOG_INFO, "klogd %s-%s, log source = %s started.", \
VERSION, PATCHLEVEL, _PATH_KLOG);
#endif
return(proc);
}

195
ksym.c
View File

@ -83,6 +83,14 @@
*
* Fri Jan 9 23:00:08 CET 1998: Martin Schulze <joey@infodrom.north.de>
* Fixed bug that caused klogd to die if there is no System.map available.
*
* Sun 29 Mar 18:14:07 BST 1998: Mark Simon Phillips <msp@mail.virgin.net>
* Switched to fgets() as gets() is not buffer overrun secure.
*
* Mon Apr 13 18:18:45 CEST 1998: Martin Schulze <joey@infodrom.north.de>
* Modified loop for detecting the correct system map. Now it won't
* stop if a file has been found but doesn't contain the correct map.
* Special thanks go go Mark Simon Phillips for the hint.
*/
@ -131,6 +139,7 @@ static char * FindSymbolFile(void);
static int AddSymbol(unsigned long, char*);
static void FreeSymbols(void);
static int CheckVersion(char *);
static int CheckMapVersion(char *);
/**************************************************************************
@ -294,17 +303,12 @@ extern int InitKsyms(mapfile)
static char * FindSymbolFile()
{
auto char type,
*file = (char *) 0,
**mf = system_maps,
sym[512];
auto char *file = (char *) 0,
**mf = system_maps;
auto int version;
auto struct utsname utsname;
static char symfile[100];
auto unsigned long int address;
auto FILE *sym_file = (FILE *) 0;
if ( uname(&utsname) < 0 )
@ -316,78 +320,31 @@ static char * FindSymbolFile()
if ( debugging )
fputs("Searching for symbol map.\n", stderr);
for (mf = system_maps; *mf != (char *) 0 && sym_file == (FILE *) 0; ++mf)
for (mf = system_maps; *mf != (char *) 0 && file == (char *) 0; ++mf)
{
sprintf (symfile, "%s-%s", *mf, utsname.release);
if ( debugging )
fprintf(stderr, "Trying %s.\n", symfile);
if ( (sym_file = fopen(symfile, "r")) == (FILE *) 0 ) {
sprintf (symfile, "%s", *mf);
if ( debugging )
fprintf(stderr, "Trying %s.\n", symfile);
if ( (sym_file = fopen(symfile, "r")) == (FILE *) 0 )
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
* version information.
*/
version = 0;
while ( !feof(sym_file) && (version == 0) )
{
if ( fscanf(sym_file, "%lx %c %s\n", &address, \
&type, sym) != 3 )
{
Syslog(LOG_ERR, "Error in symbol table input (#2).");
fclose(sym_file);
return((char *) 0);
}
if ( VERBOSE_DEBUGGING && debugging )
fprintf(stderr, "Address: %lx, Type: %c, " \
"Symbol: %s\n", address, type, sym);
version = CheckVersion(sym);
}
fclose(sym_file);
switch ( version )
{
case -1:
Syslog(LOG_ERR, "Symbol table has incorrect " \
"version number.\n");
break;
case 0:
if ( debugging )
fprintf(stderr, "No version information " \
"found.\n");
if ( file == (char *) 0 )
{
if ( debugging )
fputs("Saving filename.\n", stderr);
if ( (sym_file = fopen(symfile, "r")) != (FILE *) 0 ) {
if (CheckMapVersion(symfile) == 1)
file = symfile;
}
break;
case 1:
if ( debugging )
fprintf(stderr, "Found table with " \
"matching version number.\n");
return(symfile);
break;
}
if (sym_file == (FILE *) 0 || file == (char *) 0) {
sprintf (symfile, "%s", *mf);
if ( debugging )
fprintf(stderr, "Trying %s.\n", symfile);
if ( (sym_file = fopen(symfile, "r")) != (FILE *) 0 ) {
if (CheckMapVersion(symfile) == 1)
file = symfile;
}
}
}
/*
* At this stage of the game we are at the end of the symbol
* tables. We have evidently not found a symbol map whose version
* information matches the currently executing kernel. If possible
* we return a pointer to the first valid symbol map that was
* encountered.
* tables.
*/
if ( debugging )
fprintf(stderr, "End of search list encountered.\n");
@ -400,7 +357,7 @@ static char * FindSymbolFile()
*
* Purpose: This function is responsible for determining whether or
* the system map being loaded matches the version of the
* currently running kernrel.
* currently running kernel.
*
* The kernel version is checked by examing a variable which
* is of the form: _Version_66347 (a.out) or Version_66437 (ELF).
@ -499,6 +456,95 @@ static int CheckVersion(version)
}
/**************************************************************************
* Function: CheckMapVersion
*
* Purpose: This function is responsible for determining whether or
* the system map being loaded matches the version of the
* currently running kernel. It uses CheckVersion as
* backend.
*
* Arguements: (char *) fname
*
* fname:-> A pointer to the string which
* references the system map file to
* be used.
*
* Return: int
*
* -1:-> The currently running kernel version does
* not match the version in the given file.
*
* 0:-> No system map file or no version information.
*
* 1:-> The executing kernel is of the same version
* as the version of the map file.
**************************************************************************/
static int CheckMapVersion(fname)
char *fname;
{
int version;
FILE *sym_file;
auto unsigned long int address;
auto char type,
sym[512];
if ( (sym_file = fopen(fname, "r")) != (FILE *) 0 ) {
/*
* At this point a map file was successfully opened. We
* now need to search this file and look for version
* information.
*/
Syslog(LOG_INFO, "Inspecting %s", fname);
version = 0;
while ( !feof(sym_file) && (version == 0) )
{
if ( fscanf(sym_file, "%lx %c %s\n", &address, \
&type, sym) != 3 )
{
Syslog(LOG_ERR, "Error in symbol table input (#2).");
fclose(sym_file);
return(0);
}
if ( VERBOSE_DEBUGGING && debugging )
fprintf(stderr, "Address: %lx, Type: %c, " \
"Symbol: %s\n", address, type, sym);
version = CheckVersion(sym);
}
fclose(sym_file);
switch ( version )
{
case -1:
Syslog(LOG_ERR, "Symbol table has incorrect " \
"version number.\n");
break;
case 0:
if ( debugging )
fprintf(stderr, "No version information " \
"found.\n");
break;
case 1:
if ( debugging )
fprintf(stderr, "Found table with " \
"matching version number.\n");
break;
}
return(version);
}
return(0);
}
/**************************************************************************
* Function: AddSymbol
*
@ -658,7 +704,7 @@ extern char * ExpandKadds(line, el)
*symbol;
char num[15];
auto int value;
auto unsigned long int value;
auto struct symbol sym;
@ -711,14 +757,14 @@ extern char * ExpandKadds(line, el)
dlm = *kp;
strncpy(num,sl+1,kp-sl-1);
num[kp-sl-1] = '\0';
value = strtol(num, (char **) 0, 16);
value = strtoul(num, (char **) 0, 16);
if ( (symbol = LookupSymbol(value, &sym)) == (char *) 0 )
symbol = sl;
strcat(elp, symbol);
elp += strlen(symbol);
if ( debugging )
fprintf(stderr, "Symbol: %s = %x = %s, %d/%d\n", \
fprintf(stderr, "Symbol: %s = %lx = %s, %x/%d\n", \
sl+1, value, \
(sym.size==0) ? symbol+1 : symbol, \
sym.offset, sym.size);
@ -728,7 +774,7 @@ extern char * ExpandKadds(line, el)
{
--value;
++kp;
elp += sprintf(elp, "+%d/%d", sym.offset, sym.size);
elp += sprintf(elp, "+%x/%d", sym.offset, sym.size);
}
strncat(elp, kp, value);
elp += value;
@ -796,7 +842,8 @@ extern int main(int argc, char *argv[])
while ( !feof(stdin) )
{
gets(line);
fgets(line, sizeof(line), stdin);
if (line[strlen(line)-1] == '\n') line[strlen(line)-1] = '\0'; /* Trash NL char */
memset(eline, '\0', sizeof(eline));
ExpandKadds(line, eline);
fprintf(stdout, "%s\n", eline);

View File

@ -63,6 +63,13 @@
* Thu Mar 19 23:39:29 CET 1998: Manuel Rodrigues <pmanuel@cindy.fe.up.pt>
* Changed lseek() to llseek() in order to support > 2GB address
* space which provided by kernels > 2.1.70.
*
* Mon Apr 13 18:18:45 CEST 1998: Martin Schulze <joey@infodrom.north.de>
* Removed <sys/module.h> as it's no longer part of recent glibc
* versions. Added prototyp for llseek() which has been
* forgotton in <unistd.h> from glibc. Added more log
* information if problems occurred while reading a system map
* file, by submission from Mark Simon Phillips <msp@mail.virgin.net>.
*/
@ -78,11 +85,9 @@
#include <linux/time.h>
#include <linux/module.h>
#else /* __GLIBC__ */
#if !defined(__alpha)
#include <sys/module.h>
#else
#include <linux/module.h>
#endif /* __alpha */
extern loff_t llseek __P ((int __fd, loff_t __offset, int __whence));
extern int get_kernel_syms __P ((struct kernel_sym *__table));
#endif /* __GLIBC__ */
#include <stdarg.h>
#include <paths.h>
@ -393,6 +398,7 @@ static int AddModule(address, symbol)
if ( llseek(memfd, address, SEEK_SET) < 0 )
{
Syslog(LOG_WARNING, "Error seeking in /dev/kmem\n");
Syslog(LOG_WARNING, "Symbol %s, value %08x\n", symbol, address);
return(0);
}
if ( read(memfd, \

View File

@ -169,13 +169,6 @@ debug option.
.TP
.B SIGCHLD
Wait for childs if some were born, because of wall'ing messages.
.TP
.B SIGALRM
Every time
.B syslogd
receives this signal it will log the mark line. Normally this is done
by
.BR alarm (2).
.LP
.SH CONFIGURATION FILE SYNTAX DIFFERENCES
.B Syslogd
@ -578,7 +571,7 @@ jiivee@hut.fi
.TP
Shane Alderton
.TP
shane@scs.apana.org.au
shane@ion.apana.org.au
.TP
Martin Schulze

View File

@ -113,7 +113,7 @@ static char sccsid[] = "@(#)syslogd.c 5.27 (Berkeley) 10/10/88";
* priority information is encoded as a leader on the messages this
* was causing lines to be placed in erroneous files.
*
* Also added a patch from Shane Alderton (shane@scs.apana.org.au) to
* Also added a patch from Shane Alderton (shane@ion.apana.org.au) to
* correct a problem with syslogd dumping core when an attempt was made
* to write log messages to a logged-on user. Thank you.
*