aboutsummaryrefslogtreecommitdiff
path: root/shells/rssh/files/patch-rsshconf.c
blob: 7c9f8e989564c9940deeadf4981cfdcb8c75e75f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
--- ./rsshconf.c.orig	2012-11-27 01:33:27.000000000 +0100
+++ ./rsshconf.c	2013-12-27 09:57:15.000000000 +0100
@@ -78,7 +78,7 @@
 	NULL
 };
 
-int log=0;
+int rsshlog=0;
 
 /* flag to tell config parser to stop processing config file */
 static bool got_user_config = FALSE;
@@ -132,11 +132,11 @@
 	int 	status = TRUE;		/* were all the cfg lines good? */
         char 	line[CFG_LINE_LEN + 1];	/* buffer to hold region */
 
-	log = do_log;
+	rsshlog = do_log;
 	memset(line, 0, CFG_LINE_LEN + 1);
         cfg_file = fopen(filename, "r");
         if (!cfg_file) {
-		if (log){
+		if (rsshlog){
 			log_set_priority(LOG_WARNING);
 			log_msg("config file (%s) missing, using defaults", 
 				filename);
@@ -174,7 +174,7 @@
 		*newline = '\0';
 	else {
 		/* there is no newline - log the error and find the EOL */
-		if (log){
+		if (rsshlog){
 			log_set_priority(LOG_ERR);
 			log_msg("line %d: line too long", lineno);
 		}
@@ -241,12 +241,12 @@
 		return TRUE;
 	default:
 		/* the keyword is unknown */
-		if (log){
+		if (rsshlog){
 			log_set_priority(LOG_ERR);
 			log_msg("line %d: syntax error parsing config file",
 				       	lineno);
 		}
-		if ( keywrd[0] && log )
+		if ( keywrd[0] && rsshlog )
 			log_msg("unknown keyword: %s", keywrd);
 		return FALSE;
 	}
@@ -330,7 +330,7 @@
 	/* initialize strings and pointers */
 	memset(buf, 0, buflen);
 	if ( !(copy = strdup(str)) ){
-		if (log){
+		if (rsshlog){
 			log_set_priority(LOG_ERR);
 			log_msg("OOM error in get_token() (fatal)");
 		}
@@ -433,11 +433,11 @@
 		       const int lineno )
 {
 	if ( !eat_comment(line) ){
-		if (log) log_msg("line %d: syntax error parsing config file",
+		if (rsshlog) log_msg("line %d: syntax error parsing config file",
 				       	lineno);
 		return FALSE;
 	}
-	if (log){
+	if (rsshlog){
 		log_set_priority(LOG_INFO);
 		log_msg("allowing scp to all users");
 	}
@@ -460,11 +460,11 @@
 	int pos;
 
 	if ( !(pos = eat_comment(line)) ){
-		if (log) log_msg("line %d: syntax error parsing config file", 
+		if (rsshlog) log_msg("line %d: syntax error parsing config file", 
 				lineno);
 		return FALSE;
 	}
-	if (log){
+	if (rsshlog){
 		log_set_priority(LOG_INFO);
 		log_msg("allowing sftp to all users");
 	}
@@ -488,11 +488,11 @@
 	int pos;
 
 	if ( !(pos = eat_comment(line)) ){
-		if (log) log_msg("line %d: syntax error parsing config file", 
+		if (rsshlog) log_msg("line %d: syntax error parsing config file", 
 				lineno);
 		return FALSE;
 	}
-	if (log){
+	if (rsshlog){
 		log_set_priority(LOG_INFO);
 		log_msg("allowing cvs to all users");
 	}
@@ -516,12 +516,12 @@
 	int pos;
 
 	if ( !(pos = eat_comment(line)) ){
-		if (log) log_msg("line %d: syntax error parsing config file", 
+		if (rsshlog) log_msg("line %d: syntax error parsing config file", 
 				lineno);
 		return FALSE;
 	}
 	log_set_priority(LOG_INFO);
-	if (log){
+	if (rsshlog){
 		log_msg("allowing rdist to all users");
 		opts->shell_flags |= RSSH_ALLOW_RDIST;
 	}
@@ -544,11 +544,11 @@
 	int pos;
 
 	if ( !(pos = eat_comment(line)) ){
-		if (log) log_msg("line %d: syntax error parsing config file", 
+		if (rsshlog) log_msg("line %d: syntax error parsing config file", 
 				lineno);
 		return FALSE;
 	}
-	if (log){
+	if (rsshlog){
 		log_set_priority(LOG_INFO);
 		log_msg("allowing rsync to all users");
 	}
@@ -573,7 +573,7 @@
 	 */
 
 	if ( !(temp = (char *)malloc(CFG_LINE_LEN + 1)) ){
-		if (log) log_msg("fatal error: can't allocate space for chroot path");
+		if (rsshlog) log_msg("fatal error: can't allocate space for chroot path");
 		exit(1);
 	}
 	/* get_asgn_param() eats trailing comments, so we won't */
@@ -584,7 +584,7 @@
 	
 	/* get rid of any old value for chroot path, assign new one */
 	if ( opts->chroot_path ) free(opts->chroot_path);
-	if (log){
+	if (rsshlog){
 		log_set_priority(LOG_INFO);
 		log_msg("chrooting all users to %s", temp);
 	}
@@ -605,7 +605,7 @@
 	int	pos;
 
 	if ( !(temp = (char *)malloc(CFG_LINE_LEN + 1)) ){
-		if (log){
+		if (rsshlog){
 			log_set_priority(LOG_ERR);
 			log_msg("fatal error: can't allocate space for log facility");
 		}
@@ -778,17 +778,17 @@
 
 	free(temp);
 	if ( !eat_comment(line + pos) ){
-		if (log) log_msg("line %d: syntax error parsing config file", 
+		if (rsshlog) log_msg("line %d: syntax error parsing config file", 
 				lineno);
 		return FALSE;
 	}
 	if ( facname ){
 		log_set_priority(LOG_INFO);
-		if (log) log_msg("setting log facility to %s", facname);
+		if (rsshlog) log_msg("setting log facility to %s", facname);
 		log_set_facility(fac);
 		return TRUE;
 	}
-	if (log){
+	if (rsshlog){
 		log_msg("line %d: unknown log facility specified", lineno);
 		log_set_facility(LOG_USER);
 	}
@@ -804,7 +804,7 @@
 	int	mask;		/* umask */
 
 	if ( !(temp = (char *)malloc(CFG_LINE_LEN + 1)) ){
-		if (log){
+		if (rsshlog){
 			log_set_priority(LOG_ERR);
 			log_msg("fatal error: can't allocate space in process_umask()");
 		}
@@ -818,7 +818,7 @@
 
 	/* convert the umask to a number */
 	if ( !validate_umask(temp, &mask) ){
-		if (log){
+		if (rsshlog){
 			log_set_priority(LOG_WARNING);
 			log_msg("line %d: invalid umask specified, using default 077",
 			lineno);
@@ -827,7 +827,7 @@
 		free(temp);
 		return FALSE;
 	}
-	if (log){
+	if (rsshlog){
 		log_set_priority(LOG_INFO);
 		log_msg("setting umask to %#o", mask);
 	}
@@ -857,7 +857,7 @@
 
 	/* make space for user options */
 	if ( !(temp = (char *)malloc(CFG_LINE_LEN + 1)) ){
-		if (log) log_msg("fatal error: can't allocate space for user options");
+		if (rsshlog) log_msg("fatal error: can't allocate space for user options");
 		exit(1);
 	}
 
@@ -870,7 +870,7 @@
 
 	/* now process individual config bits of temp */
 	if ( !(pos = get_token(temp, user, CFG_LINE_LEN + 1, TRUE, TRUE )) ){
-		if (log){
+		if (rsshlog){
 			log_set_priority(LOG_ERR);
 			log_msg("syntax error parsing config file, line %d", 
 					lineno);
@@ -887,12 +887,12 @@
 	 * user lines we don't care about...
 	 */
 	if ( (strcmp(user, username)) ) return TRUE;
-	if (log){
+	if (rsshlog){
 		log_set_priority(LOG_INFO);
 		log_msg("line %d: configuring user %s", lineno, user);
 	}
 	if ( !(len = eat_colon(temp + pos)) ){
-		if (log) log_msg("syntax error parsing config file: line %d ", 
+		if (rsshlog) log_msg("syntax error parsing config file: line %d ", 
 				lineno);
 		return FALSE;
 	}
@@ -901,7 +901,7 @@
 	/* do the umask, but validate it last, since it's non-fatal */
 	if ( !(len = get_token(temp + pos, mask, CFG_LINE_LEN + 1, 
 			       TRUE, FALSE)) ){
-		if (log){
+		if (rsshlog){
 			log_set_priority(LOG_ERR);
 			log_msg("syntax error parsing user umask, line %d", lineno);
 		}
@@ -911,14 +911,14 @@
 
 	/* do the access bits */
 	if ( !(len = eat_colon(temp + pos)) ){
-		if (log) log_msg("syntax error parsing config file: line %d ", 
+		if (rsshlog) log_msg("syntax error parsing config file: line %d ", 
 				lineno);
 		return FALSE;
 	}
 	pos += len;
 	if ( !(len = get_token(temp + pos, axs, CFG_LINE_LEN + 1, 
 			       TRUE, FALSE)) ){
-		if (log){
+		if (rsshlog){
 			log_set_priority(LOG_ERR);
 			log_msg("syntax error parsing user access, line %d", lineno);
 		}
@@ -926,7 +926,7 @@
 	}
 	if ( !validate_access(axs, &allow_sftp, &allow_scp, &allow_cvs,
 			      &allow_rdist, &allow_rsync) ){
-		if (log){
+		if (rsshlog){
 			log_set_priority(LOG_ERR);
 			log_msg("syntax error parsing access bits, line %d", lineno);
 		}
@@ -938,7 +938,7 @@
 	if ( !(len = eat_colon(temp + pos)) ) goto cleanup;
 	pos += len;
 	if ( !(path = (char *)malloc(CFG_LINE_LEN + 1)) ){
-		if (log) log_msg("fatal error: can't allocate space for chroot path");
+		if (rsshlog) log_msg("fatal error: can't allocate space for chroot path");
 		exit(1);
 	}
 	if ( !(len = get_token(temp + pos, path, CFG_LINE_LEN + 1, 
@@ -952,7 +952,7 @@
 	/* make sure nothing is left */
 	while ( *(temp + pos) != '\0' && isspace(*(temp + pos)) ) pos++;
 	if ( *(temp + pos) != '\0' ){
-		if (log){
+		if (rsshlog){
 			log_set_priority(LOG_ERR);
 			log_msg("syntax error parsing user config: line %d", lineno);
 		}
@@ -961,14 +961,14 @@
 
 	/* now finally validate the umask */
 	if ( !validate_umask(mask, &tmpmask) ){
-		if (log){
+		if (rsshlog){
 			log_set_priority(LOG_WARNING);
 			log_msg("line %d: invalid umask specified, using default",
 			lineno);
 		}
 		tmpmask = 077;
 	} 
-	if (log){
+	if (rsshlog){
 		log_set_priority(LOG_INFO);
 		log_msg("setting %s's umask to %#o", user, tmpmask);
 	}
@@ -980,27 +980,27 @@
 	opts->shell_flags = 0;
 	/* now set the user-specific flags */
 	if ( allow_scp ){
-		if (log) log_msg("allowing scp to user %s", user);
+		if (rsshlog) log_msg("allowing scp to user %s", user);
 		opts->shell_flags |= RSSH_ALLOW_SCP;
 	}
 	if ( allow_sftp ){
-		if (log) log_msg("allowing sftp to user %s", user);
+		if (rsshlog) log_msg("allowing sftp to user %s", user);
 		opts->shell_flags |= RSSH_ALLOW_SFTP;
 	}
 	if ( allow_cvs ){
-		if (log) log_msg("allowing cvs to user %s", user);
+		if (rsshlog) log_msg("allowing cvs to user %s", user);
 		opts->shell_flags |= RSSH_ALLOW_CVS;
 	}
 	if ( allow_rdist ){
-		if (log) log_msg("allowing rdist to user %s", user);
+		if (rsshlog) log_msg("allowing rdist to user %s", user);
 		opts->shell_flags |= RSSH_ALLOW_RDIST;
 	}
 	if ( allow_rsync ){
-		if (log) log_msg("allowing rsync to user %s", user);
+		if (rsshlog) log_msg("allowing rsync to user %s", user);
 		opts->shell_flags |= RSSH_ALLOW_RSYNC;
 	}
 	if ( path ){
-		if (log) log_msg("chrooting %s to %s", user, path);
+		if (rsshlog) log_msg("chrooting %s to %s", user, path);
 		opts->shell_flags |= RSSH_USE_CHROOT;
 	}
 	opts->chroot_path = path;
@@ -1019,7 +1019,7 @@
 
 	/* make sure '=' is next token, otherwise syntax error */
 	if ( (pos = eat_assignment(line)) <= 0 ){
-		if (log){
+		if (rsshlog){
 			log_set_priority(LOG_ERR);
 			log_msg("error parsing config file at line %d: "
 			"assignment expected", lineno);
@@ -1028,7 +1028,7 @@
 	}
 	/* get the string parameter of the assignment */
 	if ( !(len = get_token((line + pos), buf, buflen, FALSE, FALSE)) ){
-		if (log){
+		if (rsshlog){
 			log_set_priority(LOG_ERR);
 			log_msg("syntax error parsing config file, line %d", 
 				lineno);
@@ -1038,7 +1038,7 @@
 	pos += len;
 	/* check for ending comment */
 	if ( !eat_comment(line + pos) ){
-		if (log){
+		if (rsshlog){
 			log_set_priority(LOG_ERR);
 			log_msg("syntax error parsing config file at line %d", 
 				lineno);