]>
Commit | Line | Data |
---|---|---|
25697a35 | 1 | /* |
94ff9470 | 2 | * SARG Squid Analysis Report Generator http://sarg.sourceforge.net |
67302a9e | 3 | * 1998, 2013 |
25697a35 GS |
4 | * |
5 | * SARG donations: | |
6 | * please look at http://sarg.sourceforge.net/donations.php | |
1164c474 FM |
7 | * Support: |
8 | * http://sourceforge.net/projects/sarg/forums/forum/363374 | |
25697a35 GS |
9 | * --------------------------------------------------------------------- |
10 | * | |
11 | * This program is free software; you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License as published by | |
13 | * the Free Software Foundation; either version 2 of the License, or | |
14 | * (at your option) any later version. | |
15 | * | |
16 | * This program is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | * GNU General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU General Public License | |
22 | * along with this program; if not, write to the Free Software | |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
24 | * | |
25 | */ | |
26 | ||
27 | #include "include/conf.h" | |
5f3cfd1d | 28 | #include "include/defs.h" |
6068ae56 | 29 | #include "include/filelist.h" |
25697a35 | 30 | |
085c1e1f FM |
31 | #define SET_LIST(list) list,sizeof(list)/sizeof(list[0]) |
32 | ||
25697a35 | 33 | extern numlist hours, weekdays; |
6068ae56 | 34 | extern FileListObject AccessLog; |
2e29ae23 FM |
35 | extern int PerUserLimitsNumber; |
36 | extern struct PerUserLimitStruct PerUserLimits[MAX_USER_LIMITS]; | |
0b5356bb | 37 | extern enum PerUserFileCreationEnum PerUserFileCreation; |
25697a35 | 38 | |
085c1e1f FM |
39 | struct param_list |
40 | { | |
9bd92830 FM |
41 | //! The name of the value of the parameter. |
42 | const char *name; | |
43 | //! The bit to set if the value is found. | |
44 | unsigned long int value; | |
45 | //! The value is invalid if any bit of this mask is set in the parameter. | |
46 | unsigned long int exclude; | |
085c1e1f FM |
47 | }; |
48 | ||
15d5372b FM |
49 | struct sort_list |
50 | { | |
9bd92830 FM |
51 | //! The name of the value of the parameter. |
52 | const char *name; | |
53 | //! The bit to set if the value is found. | |
54 | unsigned long int value; | |
15d5372b FM |
55 | }; |
56 | ||
0b5356bb FM |
57 | struct select_list |
58 | { | |
59 | //! The name of the value of the parameter. | |
60 | const char *name; | |
61 | //! The value to assign when the name is selected. | |
62 | int value; | |
63 | }; | |
64 | ||
e43854ef | 65 | static struct param_list report_type_values[]= |
085c1e1f | 66 | { |
9bd92830 FM |
67 | {"users_sites",REPORT_TYPE_USERS_SITES,0}, |
68 | {"topusers",REPORT_TYPE_TOPUSERS,0}, | |
69 | {"topsites",REPORT_TYPE_TOPSITES,0}, | |
70 | {"sites_users",REPORT_TYPE_SITES_USERS,0}, | |
71 | {"date_time",REPORT_TYPE_DATE_TIME,0}, | |
72 | {"denied",REPORT_TYPE_DENIED,0}, | |
73 | {"auth_failures",REPORT_TYPE_AUTH_FAILURES,0}, | |
74 | {"site_user_time_date",REPORT_TYPE_SITE_USER_TIME_DATE,0}, | |
75 | {"downloads",REPORT_TYPE_DOWNLOADS,0}, | |
085c1e1f FM |
76 | }; |
77 | ||
e43854ef | 78 | static struct param_list data_field_values[]= |
085c1e1f | 79 | { |
9bd92830 FM |
80 | {"user",DATA_FIELD_USER,0}, |
81 | {"date",DATA_FIELD_DATE,0}, | |
82 | {"time",DATA_FIELD_TIME,0}, | |
83 | {"url",DATA_FIELD_URL,0}, | |
84 | {"connect",DATA_FIELD_CONNECT,0}, | |
85 | {"bytes",DATA_FIELD_BYTES,0}, | |
86 | {"in_cache",DATA_FIELD_IN_CACHE,0}, | |
87 | {"out_cache",DATA_FIELD_OUT_CACHE,0}, | |
88 | {"elapsed",DATA_FIELD_ELAPSED,0}, | |
085c1e1f FM |
89 | }; |
90 | ||
e43854ef | 91 | static struct param_list topuserfields_values[]= |
085c1e1f | 92 | { |
9bd92830 FM |
93 | {"NUM",TOPUSERFIELDS_NUM,0}, |
94 | {"DATE_TIME",TOPUSERFIELDS_DATE_TIME,0}, | |
95 | {"USERID",TOPUSERFIELDS_USERID,0}, | |
96 | {"CONNECT",TOPUSERFIELDS_CONNECT,0}, | |
97 | {"BYTES",TOPUSERFIELDS_BYTES,0}, | |
98 | {"%BYTES",TOPUSERFIELDS_SETYB,0}, | |
99 | {"SETYB",TOPUSERFIELDS_SETYB,0}, | |
100 | {"IN-CACHE-OUT",TOPUSERFIELDS_IN_CACHE_OUT,0}, | |
101 | {"USED_TIME",TOPUSERFIELDS_USED_TIME,0}, | |
102 | {"MILISEC",TOPUSERFIELDS_MILISEC,0}, | |
103 | {"%TIME",TOPUSERFIELDS_PTIME,0}, | |
104 | {"TOTAL",TOPUSERFIELDS_TOTAL,0}, | |
105 | {"AVERAGE",TOPUSERFIELDS_AVERAGE,0}, | |
085c1e1f FM |
106 | }; |
107 | ||
e43854ef | 108 | static struct param_list userreportfields_values[]= |
085c1e1f | 109 | { |
9bd92830 FM |
110 | {"CONNECT",USERREPORTFIELDS_CONNECT,0}, |
111 | {"BYTES",USERREPORTFIELDS_BYTES,0}, | |
112 | {"%BYTES",USERREPORTFIELDS_SETYB,0}, | |
113 | {"SETYB",USERREPORTFIELDS_SETYB,0}, | |
114 | {"IN-CACHE-OUT",USERREPORTFIELDS_IN_CACHE_OUT,0}, | |
115 | {"USED_TIME",USERREPORTFIELDS_USED_TIME,0}, | |
116 | {"MILISEC",USERREPORTFIELDS_MILISEC,0}, | |
117 | {"%TIME",USERREPORTFIELDS_PTIME,0}, | |
118 | {"TOTAL",USERREPORTFIELDS_TOTAL,0}, | |
119 | {"AVERAGE",USERREPORTFIELDS_AVERAGE,0}, | |
085c1e1f FM |
120 | }; |
121 | ||
e43854ef | 122 | static struct param_list index_values[]= |
0349fa24 | 123 | { |
9bd92830 FM |
124 | {"yes",INDEX_YES,~INDEX_YES}, |
125 | {"no",INDEX_NO,~INDEX_NO}, | |
126 | {"only",INDEX_ONLY,~INDEX_ONLY}, | |
0349fa24 FM |
127 | }; |
128 | ||
e43854ef | 129 | static struct param_list index_tree_values[]= |
0349fa24 | 130 | { |
9bd92830 FM |
131 | {"date",INDEX_TREE_DATE,~INDEX_TREE_DATE}, |
132 | {"file",INDEX_TREE_FILE,~INDEX_TREE_FILE}, | |
0349fa24 FM |
133 | }; |
134 | ||
9aaa3361 FM |
135 | static struct param_list indexfields_values[]= |
136 | { | |
137 | {"DIRSIZE",INDEXFIELDS_DIRSIZE,0}, | |
138 | }; | |
139 | ||
e43854ef | 140 | static struct param_list ntml_userformat_values[]= |
f2ec8c75 | 141 | { |
9bd92830 FM |
142 | {"user",NTLMUSERFORMAT_USER,~NTLMUSERFORMAT_USER}, |
143 | {"domainname+username",NTLMUSERFORMAT_DOMAINUSER,~NTLMUSERFORMAT_DOMAINUSER}, | |
f2ec8c75 FM |
144 | }; |
145 | ||
e43854ef | 146 | static struct param_list recnouser_values[]= |
f2ec8c75 | 147 | { |
9bd92830 FM |
148 | {"ip",RECORDWITHOUTUSER_IP,~RECORDWITHOUTUSER_IP}, |
149 | {"ignore",RECORDWITHOUTUSER_IGNORE,~RECORDWITHOUTUSER_IGNORE}, | |
150 | {"everybody",RECORDWITHOUTUSER_EVERYBODY,~RECORDWITHOUTUSER_EVERYBODY}, | |
f2ec8c75 FM |
151 | }; |
152 | ||
e43854ef | 153 | static struct param_list datafileurl_values[]= |
f84a35a3 | 154 | { |
9bd92830 FM |
155 | {"ip",DATAFILEURL_IP,~DATAFILEURL_IP}, |
156 | {"name",DATAFILEURL_NAME,~DATAFILEURL_NAME}, | |
f84a35a3 FM |
157 | }; |
158 | ||
e43854ef FM |
159 | static struct param_list displayvalue_values[]= |
160 | { | |
9bd92830 FM |
161 | {"bytes",DISPLAY_BYTES,~DISPLAY_BYTES}, |
162 | {"abbreviation",DISPLAY_ABBREV,~DISPLAY_ABBREV}, | |
e43854ef FM |
163 | }; |
164 | ||
43cc1649 FM |
165 | static struct param_list datetime_values[]= |
166 | { | |
9bd92830 FM |
167 | {"elap",DATETIME_ELAP,0}, |
168 | {"bytes",DATETIME_BYTE,0}, | |
43cc1649 FM |
169 | }; |
170 | ||
71d78774 FM |
171 | static struct param_list realtime_unauth_values[]= |
172 | { | |
9bd92830 FM |
173 | {"show",REALTIME_UNAUTH_REC_SHOW,~REALTIME_UNAUTH_REC_SHOW}, |
174 | {"ignore",REALTIME_UNAUTH_REC_IGNORE,~REALTIME_UNAUTH_REC_IGNORE}, | |
71d78774 FM |
175 | }; |
176 | ||
15d5372b FM |
177 | struct sort_list topuser_sort[]= |
178 | { | |
9bd92830 FM |
179 | {"BYTES",TOPUSER_SORT_BYTES}, |
180 | {"USER",TOPUSER_SORT_USER}, | |
181 | {"CONNECT",TOPUSER_SORT_CONNECT}, | |
182 | {"TIME",TOPUSER_SORT_TIME}, | |
15d5372b FM |
183 | }; |
184 | ||
185 | struct sort_list topsite_sort[]= | |
186 | { | |
9bd92830 FM |
187 | {"BYTES",TOPSITE_SORT_BYTES}, |
188 | {"CONNECT",TOPSITE_SORT_CONNECT}, | |
189 | {"TIME",TOPSITE_SORT_TIME}, | |
7d82ea1a | 190 | {"USER",TOPSITE_SORT_USER}, |
15d5372b FM |
191 | }; |
192 | ||
193 | struct sort_list user_sort[]= | |
194 | { | |
9bd92830 FM |
195 | {"BYTES",USER_SORT_BYTES}, |
196 | {"SITE",USER_SORT_SITE}, | |
197 | {"CONNECT",USER_SORT_CONNECT}, | |
198 | {"TIME",USER_SORT_TIME}, | |
15d5372b FM |
199 | }; |
200 | ||
0b5356bb FM |
201 | static struct select_list per_user_limit_create_file[]= |
202 | { | |
203 | {"always",PUFC_Always}, //always create an empty file | |
204 | {"as_required",PUFC_AsRequired}, //create the file if necessary (no empty file is created) | |
205 | }; | |
206 | ||
6e792ade | 207 | static int is_param(const char *param,const char *buf) |
0a4e18e1 | 208 | { |
9bd92830 | 209 | int plen; |
0a4e18e1 | 210 | |
9bd92830 FM |
211 | plen=strlen(param); |
212 | if (strncmp(buf,param,plen) != 0) return(0); | |
213 | buf+=plen; | |
214 | if ((unsigned char)*buf>' ') return(0); | |
215 | return(1); | |
0a4e18e1 FM |
216 | } |
217 | ||
4af2f8ff FM |
218 | static int getparam_string(const char *param,char *buf,char *value,int value_size) |
219 | { | |
9bd92830 FM |
220 | int plen; |
221 | ||
222 | plen=strlen(param); | |
223 | if (strncmp(buf,param,plen) != 0) return(0); | |
224 | buf+=plen; | |
225 | if ((unsigned char)*buf>' ') return(0); | |
226 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
227 | ||
228 | if (strlen(buf)>=value_size) { | |
229 | debuga(_("The string value of parameter \"%s\" is too long\n"),param); | |
230 | exit(EXIT_FAILURE); | |
231 | } | |
232 | strcpy(value,buf); | |
233 | fixnone(value); | |
234 | return(1); | |
4af2f8ff | 235 | } |
25697a35 | 236 | |
6068ae56 FM |
237 | /*! |
238 | * Get a pointer to the beginning of the string value defined by the | |
239 | * parameter. The returned value is NULL if the buffer doesn't contain | |
240 | * the parameter. | |
241 | * | |
242 | * \param param The parameter to look for. | |
243 | * \param buf The buffer containing the line read from the configuration | |
244 | * file. | |
245 | * | |
246 | * \return A pointer to the beginning of the parameter value or NULL if | |
247 | * the line is not for the requtested parameter. | |
248 | */ | |
249 | static char *getparam_stringptr(const char *param,char *buf) | |
250 | { | |
251 | int plen; | |
252 | ||
253 | plen=strlen(param); | |
254 | if (strncmp(buf,param,plen) != 0) return(NULL); | |
255 | buf+=plen; | |
256 | if ((unsigned char)*buf>' ') return(NULL); | |
257 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
258 | ||
259 | return(buf); | |
260 | } | |
261 | ||
4af2f8ff | 262 | static int getparam_quoted(const char *param,char *buf,char *value,int value_size) |
25697a35 | 263 | { |
9bd92830 FM |
264 | int plen; |
265 | int i; | |
266 | ||
267 | plen=strlen(param); | |
268 | if (strncmp(buf,param,plen) != 0) return(0); | |
269 | buf+=plen; | |
270 | if ((unsigned char)*buf>' ') return(0); | |
271 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
272 | ||
273 | if (*buf != '\"') { | |
274 | debuga(_("Missing double quote after parameter \"%s\"\n"),param); | |
275 | exit(EXIT_FAILURE); | |
276 | } | |
277 | buf++; | |
278 | ||
279 | value_size--; | |
280 | for (i=0 ; i<value_size && *buf && *buf!='\"' ; i++) { | |
281 | value[i]=*buf++; | |
282 | } | |
283 | value[i]='\0'; | |
284 | ||
285 | if (*buf != '\"') { | |
286 | debuga(_("Missing double quote after parameter \"%s\" or value is more than %d bytes long\n"),param,value_size); | |
287 | exit(EXIT_FAILURE); | |
288 | } | |
289 | fixnone(value); | |
290 | return(1); | |
4af2f8ff | 291 | } |
25697a35 | 292 | |
4af2f8ff FM |
293 | static int getparam_2words(const char *param,char *buf,char *word1,int word1_size,char *word2,int word2_size) |
294 | { | |
9bd92830 FM |
295 | int plen; |
296 | int i; | |
297 | ||
298 | plen=strlen(param); | |
299 | if (strncmp(buf,param,plen) != 0) return(0); | |
300 | buf+=plen; | |
301 | if ((unsigned char)*buf>' ') return(0); | |
302 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
303 | ||
304 | for (i=0 ; i<word1_size && *buf && (unsigned char)*buf>' ' ; i++) | |
305 | word1[i]=*buf++; | |
306 | if (i>=word1_size) { | |
307 | debuga(_("The first word of parameter \"%s\" is more than %d bytes long\n"),param,word1_size-1); | |
308 | exit(EXIT_FAILURE); | |
309 | } | |
310 | if (*buf!=' ') { | |
311 | debuga(_("Missing second word for parameter \"%s\"\n"),param); | |
312 | exit(EXIT_FAILURE); | |
313 | } | |
314 | word1[i]=0; | |
315 | ||
316 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
317 | ||
318 | for (i=0 ; i<word2_size && *buf && (unsigned char)*buf>' ' ; i++) | |
319 | word2[i]=*buf++; | |
320 | if (i>=word2_size) { | |
321 | debuga(_("The second word of parameter \"%s\" is more than %d bytes long\n"),param,word2_size-1); | |
322 | exit(EXIT_FAILURE); | |
323 | } | |
324 | word2[i]=0; | |
325 | ||
326 | fixnone(word1); | |
327 | fixnone(word2); | |
328 | return(1); | |
4af2f8ff | 329 | } |
25697a35 | 330 | |
4af2f8ff FM |
331 | static int getparam_int(const char *param,char *buf,int *value) |
332 | { | |
9bd92830 FM |
333 | int plen; |
334 | int next; | |
335 | ||
336 | plen=strlen(param); | |
337 | if (strncmp(buf,param,plen) != 0) return(0); | |
338 | buf+=plen; | |
339 | if ((unsigned char)*buf>' ') return(0); | |
340 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
341 | ||
342 | next=0; | |
343 | if (sscanf(buf,"%d%n",value,&next) != 1 || (unsigned char)buf[next] > ' ') { | |
344 | debuga(_("The integer value of parameter \"%s\" is invalid\n"),param); | |
345 | exit(EXIT_FAILURE); | |
346 | } | |
347 | return(1); | |
4af2f8ff | 348 | } |
25697a35 | 349 | |
06b39c87 | 350 | static int getparam_bool(const char *param,char *buf,bool *value) |
246c8489 | 351 | { |
9bd92830 FM |
352 | int plen; |
353 | int i; | |
354 | const char *bool_str="yes,true,on,1"; | |
355 | ||
356 | plen=strlen(param); | |
357 | if (strncmp(buf,param,plen) != 0) return(0); | |
358 | buf+=plen; | |
359 | if ((unsigned char)*buf>' ') return(0); | |
360 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
361 | ||
362 | *value=false; | |
363 | for ( ; *bool_str ; bool_str+=i) { | |
364 | for (i=0 ; bool_str[i] && bool_str[i]!=',' ; i++); | |
365 | if (strncasecmp(bool_str,buf,i)==0) { | |
366 | *value=true; | |
367 | break; | |
368 | } | |
369 | if (bool_str[i]==',') i++; | |
370 | } | |
371 | return(1); | |
246c8489 FM |
372 | } |
373 | ||
085c1e1f FM |
374 | static int getparam_list(const char *param,struct param_list *options,int noptions,char *buf,unsigned long int *value) |
375 | { | |
9bd92830 FM |
376 | int plen; |
377 | char *str; | |
378 | int i; | |
379 | ||
380 | plen=strlen(param); | |
381 | if (strncmp(buf,param,plen) != 0) return(0); | |
382 | buf+=plen; | |
383 | if ((unsigned char)*buf>' ') return(0); | |
384 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
385 | ||
386 | *value=0UL; | |
387 | while (*buf) { | |
388 | str=buf; | |
389 | while (*str && (unsigned char)*str>' ' && *str!=';') str++; | |
390 | if (*str) { | |
391 | *str++='\0'; | |
392 | while (*str && ((unsigned char)*str<=' ' || *str==';')) str++; | |
393 | } | |
394 | for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++); | |
395 | if (i>=noptions) { | |
396 | debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),buf,param); | |
397 | exit(EXIT_FAILURE); | |
398 | } | |
399 | if ((*value & options[i].exclude)!=0) { | |
400 | debuga(_("Value \"%s\" conflicts with other selected values for parameter \"%s\"\n"),buf,param); | |
401 | exit(EXIT_FAILURE); | |
402 | } | |
403 | *value|=options[i].value; | |
404 | buf=str; | |
405 | } | |
406 | return(1); | |
085c1e1f FM |
407 | } |
408 | ||
15d5372b FM |
409 | static int getparam_sort(const char *param,struct sort_list *options,int noptions,char *buf,unsigned long int *value) |
410 | { | |
9bd92830 FM |
411 | int plen; |
412 | char *str, *order; | |
413 | int i; | |
414 | ||
415 | plen=strlen(param); | |
416 | if (strncmp(buf,param,plen) != 0) return(0); | |
417 | buf+=plen; | |
418 | if ((unsigned char)*buf>' ') return(0); | |
419 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
420 | ||
421 | str=buf; | |
422 | order=NULL; | |
423 | while (*str && (unsigned char)*str>' ') str++; | |
424 | if (*str) { | |
425 | *str++='\0'; | |
426 | while (*str && (unsigned char)*str<=' ') str++; | |
427 | order=str; | |
428 | } | |
429 | for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++); | |
430 | if (i>=noptions) { | |
431 | debuga(_("Unknown sort criterion \"%s\" for parameter \"%s\"\n"),buf,param); | |
432 | exit(EXIT_FAILURE); | |
433 | } | |
434 | *value=options[i].value; | |
435 | ||
436 | if (order) { | |
437 | str=order; | |
438 | while (*str && (unsigned char)*str>' ') str++; | |
439 | if (*str) { | |
440 | *str++='\0'; | |
441 | while (*str && (unsigned char)*str<=' ') str++; | |
442 | } | |
443 | if (strcasecmp(order,"reverse")==0 || strcasecmp(order,"D")==0) { | |
444 | *value|=SORT_REVERSE; | |
445 | } else if (strcasecmp(order,"normal")!=0 && strcasecmp(order,"A")!=0) { | |
446 | debuga(_("Unknown sort order \"%s\" for parameter \"%s\"\n"),order,param); | |
447 | exit(EXIT_FAILURE); | |
448 | } | |
449 | } | |
450 | ||
451 | buf=str; | |
452 | return(1); | |
15d5372b FM |
453 | } |
454 | ||
0b5356bb FM |
455 | static int getparam_select(const char *param,struct select_list *options,int noptions,char *buf,int *value) |
456 | { | |
457 | int plen; | |
458 | char *str; | |
459 | int i; | |
460 | ||
461 | plen=strlen(param); | |
462 | if (strncmp(buf,param,plen) != 0) return(0); | |
463 | buf+=plen; | |
464 | if ((unsigned char)*buf>' ') return(0); | |
465 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
466 | ||
467 | str=buf; | |
468 | while (*buf && (unsigned char)*buf>' ' && *buf!=';') buf++; | |
469 | *buf='\0'; | |
470 | for (i=0 ; i<noptions && strcasecmp(str,options[i].name) ; i++); | |
471 | if (i>=noptions) { | |
472 | debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),str,param); | |
473 | exit(EXIT_FAILURE); | |
474 | } | |
475 | *value=options[i].value; | |
476 | return(1); | |
477 | } | |
478 | ||
2e29ae23 FM |
479 | static int getparam_userlimit(const char *param,char *buf) |
480 | { | |
481 | int plen; | |
482 | char *file_begin,*file_end; | |
483 | int limit; | |
484 | int digit; | |
3877d630 FM |
485 | char *str; |
486 | int i; | |
487 | enum PerUserOutputEnum output; | |
488 | const struct | |
489 | { | |
490 | const char *name; | |
491 | enum PerUserOutputEnum value; | |
492 | } output_types[]= | |
493 | { | |
494 | {"id",PUOE_UserId}, | |
495 | {"ip",PUOE_UserIp}, | |
496 | }; | |
2e29ae23 FM |
497 | |
498 | plen=strlen(param); | |
499 | if (strncmp(buf,param,plen) != 0) return(0); | |
500 | buf+=plen; | |
501 | if ((unsigned char)*buf>' ') return(0); | |
502 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
503 | ||
504 | /* | |
505 | options are made of a file name, an integer limit and an optional | |
506 | integer flag. The file name may contain spaces. We keep searching | |
507 | until a valid number is found after a space. | |
508 | */ | |
509 | file_begin=buf; | |
510 | do { | |
511 | while (*buf && (unsigned char)*buf>' ') buf++; | |
512 | if (*buf!=' ') { | |
513 | debuga(_("Missing limit in per_user_limit\n")); | |
514 | exit(EXIT_FAILURE); | |
515 | } | |
516 | file_end=buf; | |
517 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
518 | limit=0; | |
519 | while (*buf && isdigit(*buf)) { | |
520 | digit=*buf-'0'; | |
521 | if (limit>=(INT_MAX-digit)/10) break; | |
522 | limit=limit*10+digit; | |
523 | buf++; | |
524 | } | |
525 | } while (*buf && *buf!=' '); | |
526 | ||
3877d630 | 527 | output=PUOE_UserId; |
2e29ae23 FM |
528 | if (*buf==' ') { |
529 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
3877d630 FM |
530 | str=buf; |
531 | while (*buf && (unsigned char)*buf>' ') buf++; | |
532 | *buf='\0'; | |
533 | for (i=sizeof(output_types)/sizeof(output_types[0])-1 ; i>=0 ; i--) | |
534 | if (strcasecmp(output_types[i].name,str)==0) { | |
535 | output=output_types[i].value; | |
536 | break; | |
537 | } | |
538 | if (i<0) { | |
539 | debuga(_("Invalid output type in per_user_limit\n")); | |
2e29ae23 FM |
540 | exit(EXIT_FAILURE); |
541 | } | |
2e29ae23 FM |
542 | } |
543 | ||
544 | if (PerUserLimitsNumber>=MAX_USER_LIMITS) { | |
545 | debuga(_("Too many per_user_limit\n")); | |
546 | exit(EXIT_FAILURE); | |
547 | } | |
548 | *file_end='\0'; | |
549 | safe_strcpy(PerUserLimits[PerUserLimitsNumber].File,file_begin,sizeof(PerUserLimits[PerUserLimitsNumber].File)); | |
550 | PerUserLimits[PerUserLimitsNumber].Limit=limit; | |
3877d630 | 551 | PerUserLimits[PerUserLimitsNumber].Output=output; |
2e29ae23 FM |
552 | PerUserLimitsNumber++; |
553 | ||
554 | return(1); | |
555 | } | |
556 | ||
4af2f8ff FM |
557 | static void parmtest(char *buf) |
558 | { | |
9bd92830 FM |
559 | char wbuf[2048]; |
560 | struct getwordstruct gwarea; | |
0b5356bb | 561 | int iVal; |
25697a35 | 562 | |
9bd92830 | 563 | while (*buf && (unsigned char)*buf<=' ') buf++; |
25697a35 | 564 | |
9bd92830 FM |
565 | if(*buf == '#' || *buf == '\0') |
566 | return; | |
25697a35 | 567 | |
9bd92830 FM |
568 | if(debugz) |
569 | printf(_("SARG: TAG: %s\n"),buf); | |
25697a35 | 570 | |
9bd92830 | 571 | if (getparam_string("background_color",buf,BgColor,sizeof(BgColor))>0) return; |
25697a35 | 572 | |
9bd92830 | 573 | if (getparam_string("text_color",buf,TxColor,sizeof(TxColor))>0) return; |
25697a35 | 574 | |
9bd92830 | 575 | if (getparam_string("text_bgcolor",buf,TxBgColor,sizeof(TxBgColor))>0) return; |
25697a35 | 576 | |
9bd92830 | 577 | if (getparam_string("title_color",buf,TiColor,sizeof(TiColor))>0) return; |
25697a35 | 578 | |
9bd92830 | 579 | if (getparam_string("logo_image",buf,LogoImage,sizeof(LogoImage))>0) return; |
25697a35 | 580 | |
9bd92830 | 581 | if (getparam_quoted("logo_text",buf,LogoText,sizeof(LogoText))>0) return; |
25697a35 | 582 | |
9bd92830 | 583 | if (getparam_string("logo_text_color",buf,LogoTextColor,sizeof(LogoTextColor))>0) return; |
25697a35 | 584 | |
9bd92830 | 585 | if (getparam_string("background_image",buf,BgImage,sizeof(BgImage))>0) return; |
25697a35 | 586 | |
9bd92830 | 587 | if (getparam_bool("show_sarg_info",buf,&ShowSargInfo)>0) return; |
25697a35 | 588 | |
9bd92830 | 589 | if (getparam_bool("show_sarg_logo",buf,&ShowSargLogo)>0) return; |
25697a35 | 590 | |
9bd92830 | 591 | if (getparam_string("font_face",buf,FontFace,sizeof(FontFace))>0) return; |
25697a35 | 592 | |
9bd92830 | 593 | if (getparam_string("header_color",buf,HeaderColor,sizeof(HeaderColor))>0) return; |
25697a35 | 594 | |
9bd92830 | 595 | if (getparam_string("header_bgcolor",buf,HeaderBgColor,sizeof(HeaderBgColor))>0) return; |
25697a35 | 596 | |
9bd92830 | 597 | if (getparam_string("font_size",buf,FontSize,sizeof(FontSize))>0) return; |
25697a35 | 598 | |
9bd92830 | 599 | if (getparam_string("header_font_size",buf,HeaderFontSize,sizeof(HeaderFontSize))>0) return; |
25697a35 | 600 | |
9bd92830 | 601 | if (getparam_string("title_font_size",buf,TitleFontSize,sizeof(TitleFontSize))>0) return; |
25697a35 | 602 | |
9bd92830 | 603 | if (getparam_2words("image_size",buf,Width,sizeof(Width),Height,sizeof(Height))>0) return; |
25697a35 | 604 | |
9bd92830 | 605 | if (getparam_quoted("title",buf,Title,sizeof(Title))>0) return; |
25697a35 | 606 | |
51b166d4 FM |
607 | if (strncasecmp(buf,"resolve_ip",10)==0) { |
608 | if (ip2name_config(buf+10)>0) return; | |
609 | } | |
25697a35 | 610 | |
9bd92830 | 611 | if (getparam_bool("user_ip",buf,&UserIp)>0) return; |
4af2f8ff | 612 | |
9bd92830 | 613 | if (getparam_string("max_elapsed",buf,MaxElapsed,sizeof(MaxElapsed))>0) return; |
25697a35 | 614 | |
9bd92830 FM |
615 | if (is_param("date_format",buf)) { |
616 | getword_start(&gwarea,buf); | |
617 | if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) { | |
618 | debuga(_("Maybe you have a broken record or garbage in \"date_format\" parameter\n")); | |
619 | exit(EXIT_FAILURE); | |
620 | } | |
81a022d8 | 621 | DateFormat=gwarea.current[0]; |
9bd92830 FM |
622 | return; |
623 | } | |
25697a35 | 624 | |
9bd92830 FM |
625 | if (is_param("hours",buf)) { |
626 | if( getnumlist( buf, &hours, 24, 24 ) ) { | |
627 | debuga(_("Error: Invalid syntax in hours tag!\n")); | |
628 | exit( 1 ); | |
629 | } | |
630 | return; | |
631 | } | |
25697a35 | 632 | |
9bd92830 FM |
633 | if (is_param("weekdays",buf)) { |
634 | if( getnumlist( buf, &weekdays, 7, 7 ) ) { | |
635 | debuga(_("Error: Invalid syntax in weekdays tag!\n")); | |
636 | exit( 1 ); | |
637 | } | |
638 | return; | |
639 | } | |
25697a35 | 640 | |
9bd92830 | 641 | if (getparam_sort("topuser_sort_field",SET_LIST(topuser_sort),buf,&TopuserSort)>0) return; |
25697a35 | 642 | |
9bd92830 | 643 | if (getparam_sort("user_sort_field",SET_LIST(user_sort),buf,&UserSort)>0) return; |
25697a35 | 644 | |
9bd92830 FM |
645 | if (is_param("access_log",buf)>0) { |
646 | if (AccessLogFromCmdLine==0) { | |
6068ae56 FM |
647 | char *FileName=getparam_stringptr("access_log",buf); |
648 | if (!AccessLog) | |
649 | AccessLog=FileList_Create(); | |
650 | if (!FileList_AddFile(AccessLog,FileName)) { | |
651 | debuga(_("Not enough memory to store the input log file names\n")); | |
9bd92830 FM |
652 | exit(EXIT_FAILURE); |
653 | } | |
9bd92830 FM |
654 | } |
655 | return; | |
656 | } | |
25697a35 | 657 | |
9bd92830 FM |
658 | if (is_param("redirector_log",buf)>0) { |
659 | if (RedirectorLogFromCmdLine==0) { | |
660 | if (NRedirectorLogs>=MAX_REDIRECTOR_LOGS) { | |
661 | debuga(_("Too many redirector log files in configuration file\n")); | |
662 | exit(EXIT_FAILURE); | |
663 | } | |
664 | getparam_string("redirector_log",buf,RedirectorLogs[NRedirectorLogs],MAX_REDIRECTOR_FILELEN); | |
665 | NRedirectorLogs++; | |
666 | } | |
667 | return; | |
668 | } | |
1f482a8d | 669 | |
9bd92830 | 670 | if (getparam_string("useragent_log",buf,UserAgentLog,sizeof(UserAgentLog))>0) return; |
25697a35 | 671 | |
9bd92830 | 672 | if (getparam_string("exclude_hosts",buf,ExcludeHosts,sizeof(ExcludeHosts))>0) return; |
25697a35 | 673 | |
9bd92830 | 674 | if (getparam_string("exclude_codes",buf,ExcludeCodes,sizeof(ExcludeCodes))>0) return; |
25697a35 | 675 | |
9bd92830 | 676 | if (getparam_string("exclude_users",buf,ExcludeUsers,sizeof(ExcludeUsers))>0) return; |
25697a35 | 677 | |
9bd92830 | 678 | if (getparam_string("password",buf,PasswdFile,sizeof(PasswdFile))>0) return; |
25697a35 | 679 | |
9bd92830 | 680 | if (getparam_string("temporary_dir",buf,TempDir,sizeof(TempDir))>0) return; |
25697a35 | 681 | |
9bd92830 | 682 | if (getparam_list("report_type",SET_LIST(report_type_values),buf,&ReportType)>0) return; |
25697a35 | 683 | |
9bd92830 | 684 | if (getparam_string("output_dir",buf,OutputDir,sizeof(OutputDir))>0) return; |
25697a35 | 685 | |
829a53c2 FM |
686 | if (getparam_bool("anonymous_output_files",buf,&AnonymousOutputFiles)>0) return; |
687 | ||
9bd92830 | 688 | if (getparam_string("output_email",buf,OutputEmail,sizeof(OutputEmail))>0) return; |
25697a35 | 689 | |
2e29ae23 | 690 | if (getparam_userlimit("per_user_limit",buf)>0) return; |
25697a35 | 691 | |
0b5356bb FM |
692 | if (getparam_select("per_user_limit_file_create",SET_LIST(per_user_limit_create_file),buf,&iVal)>0) { |
693 | PerUserFileCreation=(enum PerUserFileCreationEnum)iVal; | |
694 | return; | |
695 | } | |
696 | ||
9bd92830 | 697 | if (getparam_int("lastlog",buf,&LastLog)>0) return; |
25697a35 | 698 | |
9bd92830 | 699 | if (getparam_bool("remove_temp_files",buf,&RemoveTempFiles)>0) return; |
25697a35 | 700 | |
9bd92830 | 701 | if (getparam_string("replace_index",buf,ReplaceIndex,sizeof(ReplaceIndex))>0) return; |
25697a35 | 702 | |
9bd92830 | 703 | if (getparam_list("index_tree",SET_LIST(index_tree_values),buf,&IndexTree)>0) return; |
25697a35 | 704 | |
9bd92830 | 705 | if (getparam_list("index",SET_LIST(index_values),buf,&Index)>0) return; |
25697a35 | 706 | |
9aaa3361 FM |
707 | if (getparam_list("index_fields",SET_LIST(indexfields_values),buf,&IndexFields)>0) return; |
708 | ||
9bd92830 | 709 | if (getparam_bool("overwrite_report",buf,&OverwriteReport)>0) return; |
25697a35 | 710 | |
9bd92830 | 711 | if (getparam_list("records_without_userid",SET_LIST(recnouser_values),buf,&RecordsWithoutUser)>0) return; |
25697a35 | 712 | |
9bd92830 | 713 | if (getparam_bool("use_comma",buf,&UseComma)>0) return; |
25697a35 | 714 | |
9bd92830 | 715 | if (getparam_string("mail_utility",buf,MailUtility,sizeof(MailUtility))>0) return; |
25697a35 | 716 | |
9bd92830 | 717 | if (getparam_int("topsites_num",buf,&TopSitesNum)>0) return; |
25697a35 | 718 | |
9bd92830 | 719 | if (getparam_int("topuser_num",buf,&TopUsersNum)>0) return; |
25697a35 | 720 | |
9bd92830 | 721 | if (getparam_string("usertab",buf,UserTabFile,sizeof(UserTabFile))>0) return; |
25697a35 | 722 | |
9bd92830 | 723 | if (getparam_string("index_sort_order",buf,IndexSortOrder,sizeof(IndexSortOrder))>0) return; |
25697a35 | 724 | |
9bd92830 | 725 | if (getparam_sort("topsites_sort_order",SET_LIST(topsite_sort),buf,&TopsitesSort)>0) return; |
25697a35 | 726 | |
9bd92830 | 727 | if (getparam_bool("long_url",buf,&LongUrl)>0) return; |
25697a35 | 728 | |
9bd92830 | 729 | if (getparam_string("dansguardian_conf",buf,DansGuardianConf,sizeof(DansGuardianConf))>0) return; |
25697a35 | 730 | |
9bd92830 | 731 | if (getparam_string("squidguard_conf",buf,SquidGuardConf,sizeof(SquidGuardConf))>0) return; |
25697a35 | 732 | |
9bd92830 | 733 | if (getparam_list("date_time_by",SET_LIST(datetime_values),buf,&datetimeby)>0) return; |
25697a35 | 734 | |
9bd92830 FM |
735 | if (getparam_string("charset",buf,CharSet,sizeof(CharSet))>0) { |
736 | ccharset(CharSet); | |
737 | return; | |
738 | } | |
25697a35 | 739 | |
9bd92830 | 740 | if (getparam_quoted("user_invalid_char",buf,UserInvalidChar,sizeof(UserInvalidChar))>0) return; |
25697a35 | 741 | |
9bd92830 FM |
742 | if (getparam_quoted("include_users",buf,IncludeUsers+1,sizeof(IncludeUsers)-2)>0) { |
743 | IncludeUsers[0]=':'; | |
744 | strcat(IncludeUsers,":"); | |
745 | return; | |
746 | } | |
491b862f | 747 | |
9bd92830 | 748 | if (getparam_quoted("exclude_string",buf,ExcludeString,sizeof(ExcludeString))>0) return; |
25697a35 | 749 | |
9bd92830 | 750 | if (getparam_bool("privacy",buf,&Privacy)>0) return; |
25697a35 | 751 | |
9bd92830 | 752 | if (getparam_quoted("privacy_string",buf,PrivacyString,sizeof(PrivacyString))>0) return; |
25697a35 | 753 | |
9bd92830 | 754 | if (getparam_string("privacy_string_color",buf,PrivacyStringColor,sizeof(PrivacyStringColor))>0) return; |
25697a35 | 755 | |
9bd92830 | 756 | if (getparam_bool("show_successful_message",buf,&SuccessfulMsg)>0) return; |
25697a35 | 757 | |
9bd92830 | 758 | if (getparam_bool("show_read_statistics",buf,&ShowReadStatistics)>0) return; |
25697a35 | 759 | |
2f4787e6 FM |
760 | if (getparam_bool("show_read_percent",buf,&ShowReadPercent)>0) return; |
761 | ||
9bd92830 | 762 | if (getparam_list("topuser_fields",SET_LIST(topuserfields_values),buf,&TopUserFields)>0) return; |
25697a35 | 763 | |
9bd92830 | 764 | if (getparam_bool("bytes_in_sites_users_report",buf,&BytesInSitesUsersReport)>0) return; |
25697a35 | 765 | |
9bd92830 | 766 | if (getparam_list("user_report_fields",SET_LIST(userreportfields_values),buf,&UserReportFields)>0) return; |
25697a35 | 767 | |
9bd92830 | 768 | if (getparam_string("datafile",buf,DataFile,sizeof(DataFile))>0) return; |
25697a35 | 769 | |
9bd92830 | 770 | if (getparam_quoted("datafile_delimiter",buf,DataFileDelimiter,sizeof(DataFileDelimiter))>0) return; |
25697a35 | 771 | |
9bd92830 | 772 | if (getparam_list("datafile_fields",SET_LIST(data_field_values),buf,&DataFileFields)>0) return; |
25697a35 | 773 | |
9bd92830 | 774 | if (getparam_list("datafile_url",SET_LIST(datafileurl_values),buf,&DataFileUrl)>0) return; |
25697a35 | 775 | |
9bd92830 | 776 | if (getparam_string("parsed_output_log",buf,ParsedOutputLog,sizeof(ParsedOutputLog))>0) return; |
25697a35 | 777 | |
9bd92830 | 778 | if (getparam_string("parsed_output_log_compress",buf,ParsedOutputLogCompress,sizeof(ParsedOutputLogCompress))>0) return; |
25697a35 | 779 | |
9bd92830 | 780 | if (getparam_list("displayed_values",SET_LIST(displayvalue_values),buf,&DisplayedValues)>0) return; |
25697a35 | 781 | |
9bd92830 | 782 | if (getparam_int("authfail_report_limit",buf,&AuthfailReportLimit)>0) return; |
25697a35 | 783 | |
9bd92830 | 784 | if (getparam_int("denied_report_limit",buf,&DeniedReportLimit)>0) return; |
25697a35 | 785 | |
9bd92830 | 786 | if (getparam_int("siteusers_report_limit",buf,&SiteUsersReportLimit)>0) return; |
25697a35 | 787 | |
9bd92830 | 788 | if (getparam_int("dansguardian_report_limit",buf,&DansGuardianReportLimit)>0) return; |
25697a35 | 789 | |
9bd92830 | 790 | if (getparam_int("squidguard_report_limit",buf,&SquidGuardReportLimit)>0) return; |
25697a35 | 791 | |
9bd92830 | 792 | if (getparam_int("user_report_limit",buf,&UserReportLimit)>0) return; |
491b862f | 793 | |
9bd92830 | 794 | if (getparam_int("download_report_limit",buf,&DownloadReportLimit)>0) return; |
491b862f | 795 | |
9bd92830 | 796 | if (getparam_string("www_document_root",buf,wwwDocumentRoot,sizeof(wwwDocumentRoot))>0) return; |
25697a35 | 797 | |
9bd92830 | 798 | if (getparam_string("block_it",buf,BlockIt,sizeof(BlockIt))>0) return; |
491b862f | 799 | |
9bd92830 | 800 | if (getparam_string("external_css_file",buf,ExternalCSSFile,sizeof(ExternalCSSFile))>0) return; |
491b862f | 801 | |
9bd92830 | 802 | if (getparam_bool("user_authentication",buf,&UserAuthentication)>0) return; |
491b862f | 803 | |
9bd92830 FM |
804 | if (getparam_string("AuthUserTemplateFile",buf,wbuf,sizeof(wbuf))>0) { |
805 | char dir[MAXLEN]; | |
491b862f | 806 | |
9bd92830 FM |
807 | if (is_absolute(wbuf)) { |
808 | if (strlen(wbuf)>=sizeof(AuthUserTemplateFile)) { | |
809 | debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n")); | |
810 | exit(EXIT_FAILURE); | |
811 | } | |
a87d4d11 | 812 | safe_strcpy(AuthUserTemplateFile,wbuf,sizeof(AuthUserTemplateFile)); |
9bd92830 | 813 | } else { |
a87d4d11 | 814 | safe_strcpy(dir,ConfigFile,sizeof(dir)); |
9bd92830 FM |
815 | if (snprintf(AuthUserTemplateFile,sizeof(AuthUserTemplateFile),"%s/%s",dirname(dir),wbuf)>=sizeof(AuthUserTemplateFile)) { |
816 | debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n")); | |
817 | exit(EXIT_FAILURE); | |
818 | } | |
819 | } | |
820 | return; | |
821 | } | |
4af2f8ff | 822 | |
9bd92830 FM |
823 | if (is_param("download_suffix",buf)) { |
824 | char warea[MAXLEN]; | |
6e792ade | 825 | |
9bd92830 FM |
826 | getparam_quoted("download_suffix",buf,warea,sizeof(warea)); |
827 | set_download_suffix(warea); | |
828 | return; | |
829 | } | |
d6e703cc | 830 | |
8ddc656a FM |
831 | if (getparam_bool("graphs",buf,&Graphs)>0) { |
832 | #ifndef HAVE_GD | |
833 | if (Graphs) | |
834 | debugaz(_("No graphs available as sarg was not compiled with libgd. Set \"graphs\" to \"no\" in %s to disable this warning\n"), | |
835 | ConfigFile); | |
836 | #endif | |
837 | return; | |
838 | } | |
4af2f8ff | 839 | |
9bd92830 | 840 | if (getparam_string("graph_days_bytes_bar_color",buf,GraphDaysBytesBarColor,sizeof(GraphDaysBytesBarColor))>0) return; |
4af2f8ff | 841 | |
9bd92830 FM |
842 | if (getparam_string("redirector_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) return; |
843 | if (getparam_string("squidguard_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) { | |
844 | debuga(_("squidguard_log_format is deprecated and has been replaced by redirector_log_format. Please update your configuration file.\n")); | |
845 | return; | |
846 | } | |
4af2f8ff | 847 | |
9bd92830 FM |
848 | if (getparam_bool("redirector_filter_out_date",buf,&RedirectorFilterOutDate)>0) return; |
849 | if (getparam_bool("redirector_ignore_date",buf,&RedirectorFilterOutDate)>0) { | |
850 | /* | |
851 | Due to an old bug in sarg before version 2.3, the option was having the opposite action than implied by the name. | |
852 | */ | |
853 | debuga(_("redirector_ignore_date is deprecated and has been replaced by redirector_filter_out_date that does the action implied by its name as opposed to redirector_ignore_date. Please update your configuration file.\n")); | |
854 | RedirectorFilterOutDate=!RedirectorFilterOutDate; | |
855 | return; | |
856 | } | |
857 | if (getparam_bool("squidguard_ignore_date",buf,&RedirectorFilterOutDate)>0) { | |
858 | debuga(_("squidguard_ignore_date is deprecated and has been replaced by redirector_filter_out_date that does the action implied by its name as opposed to squidguard_ignore_date. Please update your configuration file.\n")); | |
859 | RedirectorFilterOutDate=!RedirectorFilterOutDate; | |
860 | return; | |
861 | } | |
4af2f8ff | 862 | |
9bd92830 FM |
863 | if (getparam_bool("dansguardian_filter_out_date",buf,&DansguardianFilterOutDate)>0) return; |
864 | if (getparam_bool("dansguardian_ignore_date",buf,&DansguardianFilterOutDate)>0) { | |
865 | debuga(_("dansguardian_ignore_date is deprecated and has been replaced by dansguardian_filter_out_date that does the action implied by its name as opposed to dansguardian_ignore_date. Please update your configuration file.\n")); | |
866 | DansguardianFilterOutDate=!DansguardianFilterOutDate; | |
867 | return; | |
868 | } | |
4af2f8ff | 869 | |
9bd92830 | 870 | if (getparam_string("ulimit",buf,Ulimit,sizeof(Ulimit))>0) return; |
4af2f8ff | 871 | |
9bd92830 | 872 | if (getparam_list("ntlm_user_format",SET_LIST(ntml_userformat_values),buf,&NtlmUserFormat)>0) return; |
4af2f8ff | 873 | |
9bd92830 | 874 | if (getparam_string("realtime_types",buf,RealtimeTypes,sizeof(RealtimeTypes))>0) return; |
4af2f8ff | 875 | |
9bd92830 | 876 | if (getparam_list("realtime_unauthenticated_records",SET_LIST(realtime_unauth_values),buf,&RealtimeUnauthRec)>0) return; |
4af2f8ff | 877 | |
9bd92830 | 878 | if (getparam_int("realtime_refresh_time",buf,&realtime_refresh)>0) return; |
4af2f8ff | 879 | |
9bd92830 | 880 | if (getparam_int("realtime_access_log_lines",buf,&realtime_access_log_lines)>0) return; |
4af2f8ff | 881 | |
9bd92830 | 882 | if (getparam_string("LDAPHost",buf,LDAPHost,sizeof(LDAPHost))>0) return; |
e3af0ae9 | 883 | |
9bd92830 | 884 | if (getparam_int("LDAPPort",buf,&LDAPPort)>0) return; |
e3af0ae9 | 885 | |
9bd92830 | 886 | if (getparam_int("LDAPProtocolVersion",buf,&LDAPProtocolVersion)>0) return; |
e3af0ae9 | 887 | |
9bd92830 | 888 | if (getparam_string("LDAPBindDN",buf,LDAPBindDN,sizeof(LDAPBindDN))>0) return; |
e3af0ae9 | 889 | |
9bd92830 | 890 | if (getparam_string("LDAPBindPW",buf,LDAPBindPW,sizeof(LDAPBindPW))>0) return; |
e3af0ae9 | 891 | |
9bd92830 | 892 | if (getparam_string("LDAPBaseSearch",buf,LDAPBaseSearch,sizeof(LDAPBaseSearch))>0) return; |
e3af0ae9 | 893 | |
9bd92830 | 894 | if (getparam_string("LDAPFilterSearch",buf,LDAPFilterSearch,sizeof(LDAPFilterSearch))>0) return; |
e3af0ae9 | 895 | |
9bd92830 | 896 | if (getparam_string("LDAPTargetAttr",buf,LDAPTargetAttr,sizeof(LDAPTargetAttr))>0) return; |
e3af0ae9 | 897 | |
fd75cd90 FM |
898 | if (getparam_string("LDAPNativeCharset",buf,LDAPNativeCharset,sizeof(LDAPNativeCharset))>0) return; |
899 | ||
9bd92830 | 900 | if (getparam_string("graph_font",buf,GraphFont,sizeof(GraphFont))>0) return; |
3becf85c | 901 | |
9bd92830 | 902 | if (getparam_string("sorttable",buf,SortTableJs,sizeof(SortTableJs))>0) return; |
ea275279 | 903 | |
22715352 | 904 | if (getparam_string("hostalias",buf,HostAliasFile,sizeof(HostAliasFile))>0) return; |
11767c6a | 905 | |
c4f0ea8f FM |
906 | if (getparam_string("useralias",buf,UserAliasFile,sizeof(UserAliasFile))>0) return; |
907 | ||
11767c6a | 908 | if (getparam_bool("keep_temp_log",buf,&KeepTempLog)>0) return; |
4d62cb0a FM |
909 | |
910 | if (getparam_int("max_successive_log_errors",buf,&NumLogSuccessiveErrors)>0) return; | |
911 | ||
912 | if (getparam_int("max_total_log_errors",buf,&NumLogTotalErrors)>0) return; | |
913 | ||
9bd92830 FM |
914 | if(strstr(buf,"squid24") != 0) { |
915 | squid24=true; | |
916 | return; | |
917 | } | |
4af2f8ff | 918 | |
9bd92830 FM |
919 | if(strstr(buf,"byte_cost") != 0) { |
920 | getword_start(&gwarea,buf); | |
921 | if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) { | |
922 | debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n")); | |
923 | exit(EXIT_FAILURE); | |
924 | } | |
925 | cost=atol(gwarea.current); | |
926 | if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) { | |
927 | debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n")); | |
928 | exit(EXIT_FAILURE); | |
929 | } | |
930 | nocost=my_atoll(gwarea.current); | |
931 | return; | |
932 | } | |
4af2f8ff | 933 | |
9bd92830 | 934 | printf(_("SARG: Unknown option %s\n"),buf); |
d6e703cc FM |
935 | } |
936 | ||
32e71fa4 | 937 | void getconf(void) |
d6e703cc | 938 | { |
9bd92830 FM |
939 | FILE *fp_in; |
940 | char buf[MAXLEN]; | |
d6e703cc | 941 | |
9bd92830 FM |
942 | if(debug) |
943 | debuga(_("Loading configuration from %s\n"),ConfigFile); | |
d6e703cc | 944 | |
9bd92830 FM |
945 | if ((fp_in = fopen(ConfigFile, "r")) == NULL) { |
946 | debuga(_("(getconf) Cannot open file %s\n"),ConfigFile); | |
947 | exit(EXIT_FAILURE); | |
948 | } | |
d6e703cc | 949 | |
9bd92830 FM |
950 | while (fgets(buf, sizeof(buf), fp_in) != NULL) { |
951 | fixendofline(buf); | |
d6e703cc | 952 | |
9bd92830 FM |
953 | if(debugm) |
954 | printf("SYSCONFDIR %s\n",buf); | |
d6e703cc | 955 | |
9bd92830 | 956 | parmtest(buf); |
d6e703cc | 957 | |
9bd92830 | 958 | } |
d6e703cc | 959 | |
9bd92830 FM |
960 | fclose(fp_in); |
961 | return; | |
25697a35 | 962 | } |