Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 88099 | Differences between
and this patch

Collapse All | Expand All

(-)sysklogd-1.4.1/klogd.c (-9 / +13 lines)
Lines 509-516 Link Here
509
513
510
514
511
	/* Set level of kernel console messaging.. */
515
	/* Set level of kernel console messaging.. */
512
	if ( (console_log_level != -1)
516
	if ( (ksyslog(8, NULL, console_log_level) < 0) && \
513
	&& (ksyslog(8, NULL, console_log_level) < 0) && \
514
	     (errno == EINVAL) )
517
	     (errno == EINVAL) )
515
	{
518
	{
516
		/*
519
		/*
Lines 887-894 Link Here
887
               value  = strtoul(sym_start+1, (char **) 0, 16);
890
               value  = strtoul(sym_start+1, (char **) 0, 16);
888
               *(line-1) = '>';  /* put back delim */
891
               *(line-1) = '>';  /* put back delim */
889
892
890
               symbol = LookupSymbol(value, &sym);
893
               if ( !symbol_lookup || (symbol = LookupSymbol(value, &sym)) == (char *)0 )
891
               if ( !symbol_lookup || symbol == (char *) 0 )
892
               {
894
               {
893
                  parse_state = PARSING_TEXT;
895
                  parse_state = PARSING_TEXT;
894
                  break;
896
                  break;
Lines 938-944 Link Here
938
	 * messages into this fresh buffer.
940
	 * messages into this fresh buffer.
939
	 */
941
	 */
940
	memset(log_buffer, '\0', sizeof(log_buffer));
942
	memset(log_buffer, '\0', sizeof(log_buffer));
941
	if ( (rdcnt = ksyslog(2, log_buffer, sizeof(log_buffer))) < 0 )
943
	if ( (rdcnt = ksyslog(2, log_buffer, sizeof(log_buffer)-1)) < 0 )
942
	{
944
	{
943
		if ( errno == EINTR )
945
		if ( errno == EINTR )
944
			return;
946
			return;
Lines 1143-1150 Link Here
1143
	if ( one_shot )
1145
	if ( one_shot )
1144
	{
1146
	{
1145
		if (symbol_lookup) {
1147
		if (symbol_lookup) {
1146
			InitKsyms(symfile);
1148
			symbol_lookup  = (InitKsyms(symfile) == 1);
1147
			InitMsyms();
1149
			symbol_lookup |= InitMsyms();
1150
			if (symbol_lookup == 0) {
1151
				Syslog(LOG_WARNING, "cannot find any symbols, turning off symbol lookups\n");
1152
			}
1148
		}
1153
		}
1149
		if ( (logsrc = GetKernelLogSrc()) == kernel )
1154
		if ( (logsrc = GetKernelLogSrc()) == kernel )
1150
			LogKernelLine();
1155
			LogKernelLine();
Lines 1159-1166 Link Here
1159
#endif
1164
#endif
1160
	logsrc = GetKernelLogSrc();
1165
	logsrc = GetKernelLogSrc();
1161
	if (symbol_lookup) {
1166
	if (symbol_lookup) {
1162
		InitKsyms(symfile);
1167
		symbol_lookup  = (InitKsyms(symfile) == 1);
1163
		InitMsyms();
1168
		symbol_lookup |= InitMsyms();
1169
		if (symbol_lookup == 0) {
1170
			Syslog(LOG_WARNING, "cannot find any symbols, turning off symbol lookups\n");
1171
		}
1164
	}
1172
	}
1165
1173
1166
        /* The main loop. */
1174
        /* The main loop. */
(-)sysklogd-1.4.1/ksym.c (+3 lines)
Lines 112-117 Link Here
112
#include <stdlib.h>
112
#include <stdlib.h>
113
#include <malloc.h>
113
#include <malloc.h>
114
#include <sys/utsname.h>
114
#include <sys/utsname.h>
115
#include <ctype.h>
115
#include "klogd.h"
116
#include "klogd.h"
116
#include "ksyms.h"
117
#include "ksyms.h"
117
118
Lines 344-349 Link Here
344
		if ( (sym_file = fopen(symfile, "r")) != (FILE *) 0 ) {
345
		if ( (sym_file = fopen(symfile, "r")) != (FILE *) 0 ) {
345
			if (CheckMapVersion(symfile) == 1)
346
			if (CheckMapVersion(symfile) == 1)
346
				file = symfile;
347
				file = symfile;
348
			fclose(sym_file);
347
		}
349
		}
348
		if (sym_file == (FILE *) 0 || file == (char *) 0) {
350
		if (sym_file == (FILE *) 0 || file == (char *) 0) {
349
			sprintf (symfile, "%s", *mf);
351
			sprintf (symfile, "%s", *mf);
Lines 352-357 Link Here
352
			if ( (sym_file = fopen(symfile, "r")) != (FILE *) 0 ) {
354
			if ( (sym_file = fopen(symfile, "r")) != (FILE *) 0 ) {
353
				if (CheckMapVersion(symfile) == 1)
355
				if (CheckMapVersion(symfile) == 1)
354
					file = symfile;
356
					file = symfile;
357
				fclose(sym_file);
355
			}
358
			}
356
		}
359
		}
357
360
(-)sysklogd-1.4.1/ksym_mod.c (-1 / +1 lines)
Lines 93-99 Link Here
93
#include <linux/time.h>
93
#include <linux/time.h>
94
#include <linux/module.h>
94
#include <linux/module.h>
95
#else /* __GLIBC__ */
95
#else /* __GLIBC__ */
96
#include <linux/module.h>
96
#include "module.h"
97
extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
97
extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
98
extern int get_kernel_syms __P ((struct kernel_sym *__table));
98
extern int get_kernel_syms __P ((struct kernel_sym *__table));
99
#endif /* __GLIBC__ */
99
#endif /* __GLIBC__ */
(-)sysklogd-1.4.1/module.h (+62 lines)
Line 0 Link Here
1
2
/* Module definitions for klogd's module support */
3
struct kernel_sym
4
{
5
	        unsigned long value;
6
	        char name[60];
7
};
8
9
struct module_symbol
10
{
11
	unsigned long value;
12
	const char *name;
13
};
14
15
struct module_ref
16
{
17
	struct module *dep;     /* "parent" pointer */
18
	struct module *ref;     /* "child" pointer */
19
	struct module_ref *next_ref;
20
};
21
22
struct module_info
23
{
24
	unsigned long addr;
25
	unsigned long size;
26
	unsigned long flags;
27
	long usecount;
28
};
29
30
31
typedef struct { volatile int counter; } atomic_t;
32
33
struct module
34
{
35
	unsigned long size_of_struct;   /* == sizeof(module) */
36
	struct module *next;
37
	const char *name;
38
	unsigned long size;
39
	
40
	union
41
	{
42
		atomic_t usecount;
43
		long pad;
44
        } uc;                           /* Needs to keep its size - so says rth */
45
	
46
	unsigned long flags;            /* AUTOCLEAN et al */
47
	
48
	unsigned nsyms;
49
	unsigned ndeps;
50
	
51
	struct module_symbol *syms;
52
	struct module_ref *deps;
53
	struct module_ref *refs;
54
	int (*init)(void);
55
	void (*cleanup)(void);
56
	const struct exception_table_entry *ex_table_start;
57
	const struct exception_table_entry *ex_table_end;
58
#ifdef __alpha__
59
	unsigned long gp;
60
#endif
61
};
62
	
(-)sysklogd-1.4.1/sysklogd.8 (+6 lines)
Lines 30-35 Link Here
30
.I domainlist
30
.I domainlist
31
]
31
]
32
.RB [ " \-v " ]
32
.RB [ " \-v " ]
33
.RB [ " \-x " ]
33
.LP
34
.LP
34
.SH DESCRIPTION
35
.SH DESCRIPTION
35
.B Sysklogd
36
.B Sysklogd
Lines 152-157 Link Here
152
.TP
153
.TP
153
.B "\-v"
154
.B "\-v"
154
Print version and exit.
155
Print version and exit.
156
.TP
157
.B "\-x"
158
Disable name lookups when receiving remote messages.
159
This avoids deadlocks when the nameserver is running on
160
the same machine that runs the syslog daemon.
155
.LP
161
.LP
156
.SH SIGNALS
162
.SH SIGNALS
157
.B Syslogd
163
.B Syslogd
(-)sysklogd-1.4.1/syslog_tst.c (-2 / +2 lines)
Lines 42-48 Link Here
42
					if ( (nl = strrchr(bufr, '\n')) != \
42
					if ( (nl = strrchr(bufr, '\n')) != \
43
					    (char *) 0)
43
					    (char *) 0)
44
						*nl = '\0';
44
						*nl = '\0';
45
					syslog(LOG_INFO, bufr);
45
					syslog(LOG_INFO, "%s", bufr);
46
					logged += strlen(bufr);
46
					logged += strlen(bufr);
47
					if ( logged > 1024 )
47
					if ( logged > 1024 )
48
					{
48
					{
Lines 54-60 Link Here
54
		}
54
		}
55
		else
55
		else
56
			while (argc-- > 1)
56
			while (argc-- > 1)
57
				syslog(LOG_INFO, argv++[1]);
57
				syslog(LOG_INFO, "%s", argv++[1]);
58
	}
58
	}
59
	else
59
	else
60
	{
60
	{
(-)sysklogd-1.4.1/syslogd.c (-51 / +46 lines)
Lines 637-644 Link Here
637
 * in seconds after previous message is logged.  After each flush,
637
 * in seconds after previous message is logged.  After each flush,
638
 * we move to the next interval until we reach the largest.
638
 * we move to the next interval until we reach the largest.
639
 */
639
 */
640
int	repeatinterval[] = { 30, 60 };	/* # of secs before flush */
640
time_t	repeatinterval[] = { 30, 60 };	/* # of secs before flush */
641
#define	MAXREPEAT ((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1)
641
#define	MAXREPEAT ((int) ((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1))
642
#define	REPEATTIME(f)	((f)->f_time + repeatinterval[(f)->f_repeatcount])
642
#define	REPEATTIME(f)	((f)->f_time + repeatinterval[(f)->f_repeatcount])
643
#define	BACKOFF(f)	{ if (++(f)->f_repeatcount > MAXREPEAT) \
643
#define	BACKOFF(f)	{ if (++(f)->f_repeatcount > MAXREPEAT) \
644
				 (f)->f_repeatcount = MAXREPEAT; \
644
				 (f)->f_repeatcount = MAXREPEAT; \
Lines 730-735 Link Here
730
int	MarkInterval = 20 * 60;	/* interval between marks in seconds */
730
int	MarkInterval = 20 * 60;	/* interval between marks in seconds */
731
int	MarkSeq = 0;		/* mark sequence number */
731
int	MarkSeq = 0;		/* mark sequence number */
732
int	NoFork = 0; 		/* don't fork - don't run in daemon mode */
732
int	NoFork = 0; 		/* don't fork - don't run in daemon mode */
733
int     DisableDNS = 0;		/* don't look up IP addresses of incoming messages */
733
int	AcceptRemote = 0;	/* receive messages that come via UDP */
734
int	AcceptRemote = 0;	/* receive messages that come via UDP */
734
char	**StripDomains = NULL;	/* these domains may be stripped before writing logs */
735
char	**StripDomains = NULL;	/* these domains may be stripped before writing logs */
735
char	**LocalHosts = NULL;	/* these hosts are logged with their hostname */
736
char	**LocalHosts = NULL;	/* these hosts are logged with their hostname */
Lines 743-749 Link Here
743
char **crunch_list(char *list);
744
char **crunch_list(char *list);
744
int usage(void);
745
int usage(void);
745
void untty(void);
746
void untty(void);
746
void printchopped(const char *hname, char *msg, int len, int fd);
747
void printchopped(const char *hname, char *msg, size_t len, int fd);
747
void printline(const char *hname, char *msg);
748
void printline(const char *hname, char *msg);
748
void printsys(char *msg);
749
void printsys(char *msg);
749
void logmsg(int pri, char *msg, const char *from, int flags);
750
void logmsg(int pri, char *msg, const char *from, int flags);
Lines 786-792 Link Here
786
	int len, num_fds;
787
	int len, num_fds;
787
#else /* __GLIBC__ */
788
#else /* __GLIBC__ */
788
#ifndef TESTING
789
#ifndef TESTING
789
	size_t len;
790
	socklen_t len;
790
#endif
791
#endif
791
	int num_fds;
792
	int num_fds;
792
#endif /* __GLIBC__ */
793
#endif /* __GLIBC__ */
Lines 829-835 Link Here
829
		funix[i]  = -1;
830
		funix[i]  = -1;
830
	}
831
	}
831
832
832
	while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:v")) != EOF)
833
	while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:vx")) != EOF)
833
		switch((char)ch) {
834
		switch((char)ch) {
834
		case 'a':
835
		case 'a':
835
			if (nfunix < MAXFUNIX)
836
			if (nfunix < MAXFUNIX)
Lines 877-882 Link Here
877
		case 'v':
878
		case 'v':
878
			printf("syslogd %s.%s\n", VERSION, PATCHLEVEL);
879
			printf("syslogd %s.%s\n", VERSION, PATCHLEVEL);
879
			exit (0);
880
			exit (0);
881
		case 'x':
882
			DisableDNS = 1;
883
			break;
880
		case '?':
884
		case '?':
881
		default:
885
		default:
882
			usage();
886
			usage();
Lines 890-900 Link Here
890
		dprintf("Checking pidfile.\n");
894
		dprintf("Checking pidfile.\n");
891
		if (!check_pid(PidFile))
895
		if (!check_pid(PidFile))
892
		{
896
		{
897
			signal (SIGTERM, doexit);
893
			if (fork()) {
898
			if (fork()) {
894
				/*
899
				/*
895
				 * Parent process
900
				 * Parent process
896
				 */
901
				 */
897
				signal (SIGTERM, doexit);
898
				sleep(300);
902
				sleep(300);
899
				/*
903
				/*
900
				 * Not reached unless something major went wrong.  5
904
				 * Not reached unless something major went wrong.  5
Lines 906-911 Link Here
906
				 */
910
				 */
907
				exit(1);
911
				exit(1);
908
			}
912
			}
913
			signal (SIGTERM, SIG_DFL);
909
			num_fds = getdtablesize();
914
			num_fds = getdtablesize();
910
			for (i= 0; i < num_fds; i++)
915
			for (i= 0; i < num_fds; i++)
911
				(void) close(i);
916
				(void) close(i);
Lines 1074-1082 Link Here
1074
				  (fd_set *) NULL, (struct timeval *) NULL);
1079
				  (fd_set *) NULL, (struct timeval *) NULL);
1075
		if ( restart )
1080
		if ( restart )
1076
		{
1081
		{
1082
			restart = 0;
1077
			dprintf("\nReceived SIGHUP, reloading syslogd.\n");
1083
			dprintf("\nReceived SIGHUP, reloading syslogd.\n");
1078
			init();
1084
			init();
1079
			restart = 0;
1080
			continue;
1085
			continue;
1081
		}
1086
		}
1082
		if (nfds == 0) {
1087
		if (nfds == 0) {
Lines 1145-1152 Link Here
1145
				dprintf("INET socket error: %d = %s.\n", \
1150
				dprintf("INET socket error: %d = %s.\n", \
1146
					errno, strerror(errno));
1151
					errno, strerror(errno));
1147
				logerror("recvfrom inet");
1152
				logerror("recvfrom inet");
1148
				/* should be harmless now that we set
1153
				/* should be harmless */
1149
				 * BSDCOMPAT on the socket */
1150
				sleep(10);
1154
				sleep(10);
1151
			}
1155
			}
1152
		}
1156
		}
Lines 1174-1180 Link Here
1174
1178
1175
int usage()
1179
int usage()
1176
{
1180
{
1177
	fprintf(stderr, "usage: syslogd [-drvh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \
1181
	fprintf(stderr, "usage: syslogd [-drvxh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \
1178
		" [-s domainlist] [-f conffile]\n");
1182
		" [-s domainlist] [-f conffile]\n");
1179
	exit(1);
1183
	exit(1);
1180
}
1184
}
Lines 1232-1246 Link Here
1232
		close(fd);
1236
		close(fd);
1233
		return -1;
1237
		return -1;
1234
	}
1238
	}
1235
	/* We need to enable BSD compatibility. Otherwise an attacker
1236
	 * could flood our log files by sending us tons of ICMP errors.
1237
	 */
1238
	if (setsockopt(fd, SOL_SOCKET, SO_BSDCOMPAT, \
1239
			(char *) &on, sizeof(on)) < 0) {
1240
		logerror("setsockopt(BSDCOMPAT), suspending inet");
1241
		close(fd);
1242
		return -1;
1243
	}
1244
	if (bind(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
1239
	if (bind(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
1245
		logerror("bind, suspending inet");
1240
		logerror("bind, suspending inet");
1246
		close(fd);
1241
		close(fd);
Lines 1254-1283 Link Here
1254
crunch_list(list)
1249
crunch_list(list)
1255
	char *list;
1250
	char *list;
1256
{
1251
{
1257
	int count, i;
1252
	int i, m, n;
1258
	char *p, *q;
1253
	char *p, *q;
1259
	char **result = NULL;
1254
	char **result = NULL;
1260
1255
1261
	p = list;
1256
	p = list;
1262
	
1257
	
1263
	/* strip off trailing delimiters */
1258
	/* strip off trailing delimiters */
1264
	while (p[strlen(p)-1] == LIST_DELIMITER) {
1259
	while (*p && p[strlen(p)-1] == LIST_DELIMITER)
1265
		count--;
1266
		p[strlen(p)-1] = '\0';
1260
		p[strlen(p)-1] = '\0';
1267
	}
1268
	/* cut off leading delimiters */
1261
	/* cut off leading delimiters */
1269
	while (p[0] == LIST_DELIMITER) {
1262
	while (p[0] == LIST_DELIMITER)
1270
		count--;
1271
		p++; 
1263
		p++; 
1272
	}
1273
	
1264
	
1274
	/* count delimiters to calculate elements */
1265
	/* count delimiters to calculate the number of elements */
1275
	for (count=i=0; p[i]; i++)
1266
	for (n = i = 0; p[i]; i++)
1276
		if (p[i] == LIST_DELIMITER) count++;
1267
		if (p[i] == LIST_DELIMITER) n++;
1277
	
1268
	
1278
	if ((result = (char **)malloc(sizeof(char *) * count+2)) == NULL) {
1269
	if ((result = (char **)malloc(sizeof(char *) * (n + 2))) == NULL) {
1279
		printf ("Sorry, can't get enough memory, exiting.\n");
1270
		printf ("Sorry, can't get enough memory, exiting.\n");
1280
		exit(0);
1271
		exit(1);
1281
	}
1272
	}
1282
	
1273
	
1283
	/*
1274
	/*
Lines 1285-1314 Link Here
1285
	 * characters are different from any delimiters,
1276
	 * characters are different from any delimiters,
1286
	 * so we don't have to care about this.
1277
	 * so we don't have to care about this.
1287
	 */
1278
	 */
1288
	count = 0;
1279
	m = 0;
1289
	while ((q=strchr(p, LIST_DELIMITER))) {
1280
	while ((q = strchr(p, LIST_DELIMITER)) && m < n) {
1290
		result[count] = (char *) malloc((q - p + 1) * sizeof(char));
1281
		result[m] = (char *) malloc((q - p + 1) * sizeof(char));
1291
		if (result[count] == NULL) {
1282
		if (result[m] == NULL) {
1292
			printf ("Sorry, can't get enough memory, exiting.\n");
1283
			printf ("Sorry, can't get enough memory, exiting.\n");
1293
			exit(0);
1284
			exit(1);
1294
		}
1285
		}
1295
		strncpy(result[count], p, q - p);
1286
		memcpy(result[m], p, q - p);
1296
		result[count][q - p] = '\0';
1287
		result[m][q - p] = '\0';
1297
		p = q; p++;
1288
		p = q; p++;
1298
		count++;
1289
		m++;
1299
	}
1290
	}
1300
	if ((result[count] = \
1291
	if ((result[m] = strdup(p)) == NULL) {
1301
	     (char *)malloc(sizeof(char) * strlen(p) + 1)) == NULL) {
1302
		printf ("Sorry, can't get enough memory, exiting.\n");
1292
		printf ("Sorry, can't get enough memory, exiting.\n");
1303
		exit(0);
1293
		exit(1);
1304
	}
1294
	}
1305
	strcpy(result[count],p);
1295
	result[++m] = NULL;
1306
	result[++count] = NULL;
1307
1296
1308
#if 0
1297
#if 0
1309
	count=0;
1298
	m = 0;
1310
	while (result[count])
1299
	while (result[m])
1311
		dprintf ("#%d: %s\n", count, StripDomains[count++]);
1300
		dprintf ("#%d: %s\n", m, result[m++]);
1312
#endif
1301
#endif
1313
	return result;
1302
	return result;
1314
}
1303
}
Lines 1346-1352 Link Here
1346
void printchopped(hname, msg, len, fd)
1335
void printchopped(hname, msg, len, fd)
1347
	const char *hname;
1336
	const char *hname;
1348
	char *msg;
1337
	char *msg;
1349
	int len;
1338
        size_t len;
1350
	int fd;
1339
	int fd;
1351
{
1340
{
1352
	auto int ptlngth;
1341
	auto int ptlngth;
Lines 1446-1451 Link Here
1446
	while ((c = *p++) && q < &line[sizeof(line) - 4]) {
1435
	while ((c = *p++) && q < &line[sizeof(line) - 4]) {
1447
		if (c == '\n')
1436
		if (c == '\n')
1448
			*q++ = ' ';
1437
			*q++ = ' ';
1438
#if 0
1449
		else if (c < 040) {
1439
		else if (c < 040) {
1450
			*q++ = '^';
1440
			*q++ = '^';
1451
			*q++ = c ^ 0100;
1441
			*q++ = c ^ 0100;
Lines 1454-1460 Link Here
1454
			*q++ = '0' + ((c & 0300) >> 6);
1444
			*q++ = '0' + ((c & 0300) >> 6);
1455
			*q++ = '0' + ((c & 0070) >> 3);
1445
			*q++ = '0' + ((c & 0070) >> 3);
1456
			*q++ = '0' + (c & 0007);
1446
			*q++ = '0' + (c & 0007);
1457
		} else
1447
		}
1448
#endif
1449
		else
1458
			*q++ = c;
1450
			*q++ = c;
1459
	}
1451
	}
1460
	*q = '\0';
1452
	*q = '\0';
Lines 1929-1935 Link Here
1929
			/* is this slot used? */
1921
			/* is this slot used? */
1930
			if (ut.ut_name[0] == '\0')
1922
			if (ut.ut_name[0] == '\0')
1931
				continue;
1923
				continue;
1932
			if (ut.ut_type == LOGIN_PROCESS)
1924
			if (ut.ut_type != USER_PROCESS)
1933
			        continue;
1925
			        continue;
1934
			if (!(strcmp (ut.ut_name,"LOGIN"))) /* paranoia */
1926
			if (!(strcmp (ut.ut_name,"LOGIN"))) /* paranoia */
1935
			        continue;
1927
			        continue;
Lines 2013-2019 Link Here
2013
		dprintf("Malformed from address.\n");
2005
		dprintf("Malformed from address.\n");
2014
		return ("???");
2006
		return ("???");
2015
	}
2007
	}
2016
	hp = gethostbyaddr((char *) &f->sin_addr, sizeof(struct in_addr), \
2008
	if (DisableDNS)
2009
	  hp = 0;
2010
	else
2011
	  hp = gethostbyaddr((char *) &f->sin_addr, sizeof(struct in_addr), \
2017
			   f->sin_family);
2012
			   f->sin_family);
2018
	if (hp == 0) {
2013
	if (hp == 0) {
2019
		dprintf("Host name for your address (%s) unknown.\n",
2014
		dprintf("Host name for your address (%s) unknown.\n",

Return to bug 88099