Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 117593
Collapse All | Expand All

(-)orig/syslog-ng-1.6.7/doc/Makefile.am (-2 / +2 lines)
Lines 4-10 Link Here
4
4
5
EXTRA_DIST = $(man_MANS) stresstest.sh syslog-ng.old.txt	\
5
EXTRA_DIST = $(man_MANS) stresstest.sh syslog-ng.old.txt	\
6
	syslog-ng.conf.demo syslog-ng.conf.sample \
6
	syslog-ng.conf.demo syslog-ng.conf.sample \
7
	syslog-ng.conf.solaris 
7
	syslog-ng.conf.solaris README.syslog-ng-anon \
8
8
	syslog-ng-anon.conf
9
9
10
10
(-)orig/syslog-ng-1.6.7/doc/Makefile.in (-1 / +3 lines)
Lines 116-122 Link Here
116
116
117
EXTRA_DIST = $(man_MANS) stresstest.sh syslog-ng.old.txt	\
117
EXTRA_DIST = $(man_MANS) stresstest.sh syslog-ng.old.txt	\
118
	syslog-ng.conf.demo syslog-ng.conf.sample \
118
	syslog-ng.conf.demo syslog-ng.conf.sample \
119
	syslog-ng.conf.solaris 
119
	syslog-ng.conf.solaris README.syslog-ng-anon \
120
	syslog-ng-anon.conf
121
120
122
121
subdir = doc
123
subdir = doc
122
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
124
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
(-)orig/syslog-ng-1.6.7/doc/README.syslog-ng-anon (+93 lines)
Line 0 Link Here
1
syslog-ng-anon
2
3
 This patch adds the capability to syslog-ng that allows you to strip
4
 out any given regexp or all IP addresses from log messages before
5
 they are written to disk. The goal is to give the system administrator
6
 the means to implement site logging policies, by allowing them easy
7
 control over exactly what data they retain in their logfiles,
8
 regardless of what a particular daemon might think is best.
9
10
Background:
11
12
 Data retention has become a hot legal topic for ISPs and other Online
13
 Service Providers (OSPs). There are many instances where it is preferable
14
 to keep less information on users than is collected by default on many
15
 systems. In the United States it is not currently required to retain
16
 data on users of a server, but you may be required to provide all data
17
 on a user which you have retained. OSPs can protect themselves from legal
18
 hassles and added work by choosing what data they wish to retain.
19
20
 From "Best Practices for Online Service Providers"
21
 (http://www.eff.org/osp):
22
23
  As an intermediary, the OSP [Online Service Provider] finds itself in
24
  a position to collect and store detailed information about its users
25
  and their online activities that may be of great interest to third
26
  parties. The USA PATRIOT Act also provides the government with
27
  expanded powers to request this information. As a result, OSP owners
28
  must deal with requests from law enforcement and lawyers to hand over
29
  private user information and logs. Yet, compliance with these demands
30
  takes away from an OSP's goal of providing users with reliable,
31
  secure network services. In this paper, EFF offers some suggestions,
32
  both legal and technical, for best practices that balance the needs
33
  of OSPs and their users' privacy and civil liberties.
34
 
35
  Rather than scrubbing the information you don't want in logs, this patch
36
  ensures that the information is never written to disk. Also, for those 
37
  daemons which log through syslog facilities, this patch provides a 
38
  convenient single configuration to limit what you wish to log.
39
  
40
  Here are some related links:
41
  
42
  Best Practices for Online Service Providers
43
  http://www.eff.org/osp
44
  http://www.eff.org/osp/20040819_OSPBestPractices.pdf
45
  
46
  EPIC International Data Retention Page
47
  http://www.epic.org/privacy/intl/data_retention.html
48
  
49
  Working Paper on Usage Log Data Management (from Computer, Freedom, and 
50
  Privacy conference) http://cryptome.org/usage-logs.htm
51
  
52
53
Installing syslog-ng-anon 
54
  
55
 Applying the patch
56
57
  This patch has been tested against the following versions of syslog-ng:
58
 	. version 1.6.7
59
 	. Debian package syslog-ng_1.6.7-2
60
61
62
  To use this patch, obtain the source for syslog-ng 
63
  (http://www.balabit.com/downloads/syslog-ng/1.6/src/) and the latest
64
  syslog-ng-anon patch (http://dev.riseup.net/patches/syslog-ng/). 
65
  Uncompress the syslog-ng source and then apply the patch:
66
67
  % tar -zxvf syslog-ng.tar.gz
68
  % cd syslog-ng
69
  % patch -p1 < syslog-ng-anon.diff
70
 
71
  Then compile and install syslog-ng as normal.
72
73
 Debian package
74
75
  Alternately, you can install syslog-ng-anon from this repository:
76
  deb http://deb.riseup.net/debian unstable main
77
78
 How to use it
79
80
  This patch adds the filter "strip". For example:
81
82
 	filter f_strip {strip(<regexp>);};
83
84
  This will strip out all matches of the regular expression on logs to
85
  which the filter is applied and replaces all matches with the fixed length
86
  four dashes ("----").
87
88
  In place of a regular expression, you can put "ips", which will replace all
89
  internet addresses with 0.0.0.0. For example:
90
91
 	filter f_strip {strip(ips);};
92
93
  You can alter what the replacement strings are by using replace:
(-)orig/syslog-ng-1.6.7/doc/syslog-ng-anon.conf (+243 lines)
Line 0 Link Here
1
#
2
# Configuration file for syslog-ng under Debian.
3
# Customized for riseup.net using syslog-ng-anon patch
4
# (http://dev.riseup.net/patches/syslog-ng/)
5
#
6
# see http://www.campin.net/syslog-ng/expanded-syslog-ng.conf
7
# for examples.
8
#
9
# levels: emerg alert crit err warning notice info debug
10
#
11
12
############################################################
13
## global options
14
15
options {
16
    chain_hostnames(0);
17
    time_reopen(10);
18
    time_reap(360);
19
    sync(0);
20
    log_fifo_size(2048);
21
    create_dirs(yes);
22
    group(adm);
23
    perm(0640);
24
    dir_perm(0755);
25
    use_dns(no);
26
};
27
28
############################################################
29
## universal source
30
31
source s_all {
32
    internal();
33
    unix-stream("/dev/log");
34
    file("/proc/kmsg" log_prefix("kernel: "));
35
};
36
37
############################################################
38
## generic destinations
39
40
destination df_facility_dot_info   { file("/var/log/$FACILITY.info");   };
41
destination df_facility_dot_notice { file("/var/log/$FACILITY.notice"); };
42
destination df_facility_dot_warn   { file("/var/log/$FACILITY.warn");   };
43
destination df_facility_dot_err    { file("/var/log/$FACILITY.err");    };
44
destination df_facility_dot_crit   { file("/var/log/$FACILITY.crit");   };
45
46
############################################################
47
## generic filters
48
49
filter f_strip { strip(ips); };
50
filter f_at_least_info   { level(info..emerg);   };
51
filter f_at_least_notice { level(notice..emerg); };
52
filter f_at_least_warn   { level(warn..emerg);   };
53
filter f_at_least_err    { level(err..emerg);    };
54
filter f_at_least_crit   { level(crit..emerg);   };
55
56
############################################################
57
## auth.log
58
59
filter f_auth { facility(auth, authpriv); };
60
destination df_auth { file("/var/log/auth.log"); };
61
log {
62
    source(s_all);
63
    filter(f_auth);
64
    destination(df_auth);
65
};
66
67
############################################################
68
## daemon.log
69
70
filter f_daemon { facility(daemon); };
71
destination df_daemon { file("/var/log/daemon.log"); };
72
log {
73
    source(s_all);
74
    filter(f_daemon);
75
    destination(df_daemon);
76
};
77
78
############################################################
79
## kern.log
80
81
filter f_kern { facility(kern); };
82
destination df_kern { file("/var/log/kern.log"); };
83
log {
84
    source(s_all);
85
    filter(f_kern);
86
    destination(df_kern);
87
};
88
89
############################################################
90
## user.log
91
92
filter f_user { facility(user); };
93
destination df_user { file("/var/log/user.log"); };
94
log {
95
    source(s_all);
96
    filter(f_user);
97
    destination(df_user);
98
};
99
100
############################################################
101
## sympa.log
102
103
filter f_sympa { program("^(sympa|bounced|archived|task_manager)"); };
104
destination d_sympa { file("/var/log/sympa.log"); };
105
log {
106
	source(s_all);
107
	filter(f_sympa);
108
	destination(d_sympa);
109
	flags(final);
110
};
111
112
############################################################
113
## wwsympa.log
114
115
filter f_wwsympa { program("^wwsympa"); };
116
destination d_wwsympa { file("/var/log/wwsympa.log"); };
117
log {
118
	source(s_all);
119
	filter(f_wwsympa);
120
	filter(f_strip);
121
	destination(d_wwsympa);
122
	flags(final);
123
};
124
125
############################################################
126
## ldap.log
127
128
filter f_ldap { program("slapd"); };
129
destination d_ldap { file("/var/log/ldap.log"); };
130
log {
131
	source(s_all);
132
	filter(f_ldap);
133
	destination(d_ldap);
134
	flags(final);
135
};
136
137
############################################################
138
## postfix.log
139
140
# special source because of chroot jail
141
#source s_postfix { unix-stream("/var/spool/postfix/dev/log" keep-alive(yes)); }; 
142
filter f_postfix { program("^postfix/"); };
143
destination d_postfix { file("/var/log/postfix.log"); };
144
log {
145
	source(s_all);
146
	filter(f_postfix);
147
	filter(f_strip);
148
	destination(d_postfix);
149
	flags(final);
150
};
151
152
############################################################
153
## courier.log
154
155
filter f_courier { program("courier|imap|pop"); };
156
destination d_courier { file("/var/log/courier.log"); };
157
log {
158
	source(s_all);
159
	filter(f_courier);
160
	filter(f_strip);
161
	destination(d_courier);
162
	flags(final);
163
};
164
165
############################################################
166
## maildrop.log
167
168
filter f_maildrop { program("^maildrop"); };
169
destination d_maildrop { file("/var/log/maildrop.log"); };
170
log {
171
	source(s_all);
172
	filter(f_maildrop);
173
	destination(d_courier);
174
	flags(final);
175
};
176
177
############################################################
178
## mail.log
179
180
filter f_mail { facility(mail); };
181
destination df_mail { file("/var/log/mail.log"); };
182
183
log {
184
    source(s_all);
185
    filter(f_mail);
186
    destination(df_mail);
187
};
188
189
############################################################
190
## messages.log
191
192
filter f_messages {
193
	level(debug,info,notice)
194
	and not facility(auth,authpriv,daemon,mail,user,kern);
195
};
196
destination df_messages { file("/var/log/messages.log"); };
197
log {
198
    source(s_all);
199
    filter(f_messages);
200
    destination(df_messages);
201
};
202
203
############################################################
204
## errors.log
205
206
filter f_errors {
207
	level(warn,err,crit,alert,emerg)
208
	and not facility(auth,authpriv,daemon,mail,user,kern);
209
};
210
destination df_errors { file("/var/log/errors.log"); };
211
log {
212
	source(s_all);
213
	filter(f_errors);
214
	destination(df_errors);
215
};
216
217
############################################################
218
## emergencies
219
220
filter f_emerg { level(emerg); };
221
destination du_all { usertty("*"); };
222
log {
223
	source(s_all);
224
	filter(f_emerg);
225
	destination(du_all);
226
};
227
228
############################################################
229
## console messages
230
231
filter f_xconsole {
232
    facility(daemon,mail)
233
    or level(debug,info,notice,warn)
234
    or (facility(news)
235
    and level(crit,err,notice));
236
};
237
destination dp_xconsole { pipe("/dev/xconsole"); };
238
log {
239
    source(s_all);
240
    filter(f_xconsole);
241
    destination(dp_xconsole);
242
};
243
(-)orig/syslog-ng-1.6.7/src/cfg-grammar.y (-1 / +3 lines)
Lines 89-95 Link Here
89
%token KW_REMOVE_IF_OLDER KW_LOG_PREFIX KW_PAD_SIZE
89
%token KW_REMOVE_IF_OLDER KW_LOG_PREFIX KW_PAD_SIZE
90
90
91
/* filter items*/
91
/* filter items*/
92
%token KW_FACILITY KW_LEVEL KW_NETMASK KW_HOST KW_MATCH
92
%token KW_FACILITY KW_LEVEL KW_NETMASK KW_HOST KW_MATCH KW_STRIP KW_REPLACE
93
93
94
/* yes/no switches */
94
/* yes/no switches */
95
%token KW_YES KW_NO
95
%token KW_YES KW_NO
Lines 669-674 Link Here
669
	| KW_NETMASK '(' string ')'             { $$ = make_filter_netmask($3); free($3); }
669
	| KW_NETMASK '(' string ')'             { $$ = make_filter_netmask($3); free($3); }
670
	| KW_HOST '(' string ')'		{ $$ = make_filter_host($3); free($3); }	
670
	| KW_HOST '(' string ')'		{ $$ = make_filter_host($3); free($3); }	
671
	| KW_MATCH '(' string ')'		{ $$ = make_filter_match($3); free($3); }
671
	| KW_MATCH '(' string ')'		{ $$ = make_filter_match($3); free($3); }
672
	| KW_STRIP '(' string ')'		{ $$ = make_filter_strip($3); free($3); }
673
	| KW_REPLACE '(' string string ')'		{ $$ = make_filter_replace($3,$4); free($3); free($4); }
672
	| KW_FILTER '(' string ')'		{ $$ = make_filter_call($3); free($3); }
674
	| KW_FILTER '(' string ')'		{ $$ = make_filter_call($3); free($3); }
673
	;
675
	;
674
676
(-)orig/syslog-ng-1.6.7/src/cfg-lex.l (+2 lines)
Lines 140-145 Link Here
140
	{ "netmask",            KW_NETMASK },
140
	{ "netmask",            KW_NETMASK },
141
        { "host",               KW_HOST },
141
        { "host",               KW_HOST },
142
        { "match",		KW_MATCH },
142
        { "match",		KW_MATCH },
143
        { "strip",		KW_STRIP },
144
        { "replace",	KW_REPLACE },
143
145
144
	/* on/off switches */
146
	/* on/off switches */
145
	{ "yes",		KW_YES },
147
	{ "yes",		KW_YES },
(-)orig/syslog-ng-1.6.7/src/filters.c (+73 lines)
Lines 163-168 Link Here
163
     (name filter_expr_re)
163
     (name filter_expr_re)
164
     (super filter_expr_node)
164
     (super filter_expr_node)
165
     (vars
165
     (vars
166
       (replace string)
166
       (regex special-struct regex_t #f free_regexp)))
167
       (regex special-struct regex_t #f free_regexp)))
167
*/
168
*/
168
169
Lines 226-231 Link Here
226
	return &self->super;
227
	return &self->super;
227
}
228
}
228
229
230
struct filter_expr_node *make_filter_strip(const char *re)
231
{
232
	if (strcasecmp(re,"ips") == 0)
233
		return make_filter_replace(re,"0.0.0.0");
234
	else
235
		return make_filter_replace(re,"----");
236
}
237
238
#define FMIN(a,b) (a)<(b) ? (a):(b)
239
240
static int do_filter_replace(struct filter_expr_node *c, 
241
			   struct log_filter *rule UNUSED,
242
			   struct log_info *log)
243
{
244
	CAST(filter_expr_re, self, c);
245
	char * buffer = log->msg->data;
246
	int snippet_size;
247
	regmatch_t pmatch;
248
	char new_msg[2048];
249
	char * new_msg_max = new_msg+2048;
250
	char * new_msg_ptr = new_msg;
251
	int replace_length = strlen(self->replace->data);
252
	
253
	int error = regexec(&self->regex, buffer, 1, &pmatch, 0);
254
	if (error != 0) return 1;
255
	while (error==0) {
256
		/* copy string snippet which preceeds matched text */
257
		snippet_size = FMIN(pmatch.rm_so, new_msg_max-new_msg_ptr);
258
		memcpy(new_msg_ptr, buffer, snippet_size);
259
		new_msg_ptr += snippet_size;
260
261
		/* copy replacement string */
262
		snippet_size = FMIN(replace_length, new_msg_max-new_msg_ptr);
263
		memcpy(new_msg_ptr, self->replace->data, snippet_size);
264
		new_msg_ptr += snippet_size;
265
266
		/* search for next match */
267
		buffer += pmatch.rm_eo;
268
		error = regexec (&self->regex, buffer, 1, &pmatch, REG_NOTBOL);
269
	}
270
	/* copy the rest of the old msg */
271
	snippet_size = FMIN(strlen(buffer),new_msg_max-new_msg_ptr);
272
	memcpy(new_msg_ptr, buffer, snippet_size); 
273
	new_msg_ptr += snippet_size;
274
275
	ol_string_free(log->msg);
276
	log->msg = c_format_cstring("%s", new_msg_ptr-new_msg,new_msg);
277
	return 1;
278
}
279
280
struct filter_expr_node *make_filter_replace(const char *re, const char *replacement)
281
{
282
	int regerr;
283
	NEW(filter_expr_re, self);
284
	self->super.eval = do_filter_replace;
285
	self->replace = format_cstring(replacement);
286
	
287
	if (strcasecmp(re,"ips") == 0) {
288
		re = "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])([\\.\\-](25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])){3}";
289
	}
290
	regerr = regcomp(&self->regex, re, REG_ICASE | REG_EXTENDED);
291
	if (regerr) {
292
		char errorbuf[256];
293
		regerror(regerr, &self->regex, errorbuf, sizeof(errorbuf));
294
		werror("Error compiling regular expression: \"%z\" (%z)\n", re, errorbuf);
295
		KILL(self);
296
		return NULL;
297
	}
298
299
	return &self->super;
300
}
301
229
static int do_filter_prog(struct filter_expr_node *c, 
302
static int do_filter_prog(struct filter_expr_node *c, 
230
			  struct log_filter *rule UNUSED,
303
			  struct log_filter *rule UNUSED,
231
			  struct log_info *log)
304
			  struct log_info *log)
(-)orig/syslog-ng-1.6.7/src/filters.c.x (+2 lines)
Lines 47-52 Link Here
47
struct filter_expr_re
47
struct filter_expr_re
48
{
48
{
49
  struct filter_expr_node super;
49
  struct filter_expr_node super;
50
  struct ol_string *replace;
50
  regex_t regex;
51
  regex_t regex;
51
};
52
};
52
extern struct ol_class filter_expr_re_class;
53
extern struct ol_class filter_expr_re_class;
Lines 56-61 Link Here
56
static void do_filter_expr_re_free(struct ol_object *o)
57
static void do_filter_expr_re_free(struct ol_object *o)
57
{
58
{
58
  struct filter_expr_re *i = (struct filter_expr_re *) o;
59
  struct filter_expr_re *i = (struct filter_expr_re *) o;
60
  ol_string_free(i->replace);
59
  free_regexp(&(i->regex));
61
  free_regexp(&(i->regex));
60
}
62
}
61
63
(-)orig/syslog-ng-1.6.7/src/filters.h (+2 lines)
Lines 66-71 Link Here
66
struct filter_expr_node *make_filter_netmask(const char *nm);
66
struct filter_expr_node *make_filter_netmask(const char *nm);
67
struct filter_expr_node *make_filter_host(const char *re);
67
struct filter_expr_node *make_filter_host(const char *re);
68
struct filter_expr_node *make_filter_match(const char *re);
68
struct filter_expr_node *make_filter_match(const char *re);
69
struct filter_expr_node *make_filter_strip(const char *re);
70
struct filter_expr_node *make_filter_replace(const char *re, const char *replacement);
69
struct filter_expr_node *make_filter_call(const char *name);
71
struct filter_expr_node *make_filter_call(const char *name);
70
72
71
#endif
73
#endif

Return to bug 117593