]> git.ipfire.org Git - thirdparty/sarg.git/blob - getconf.c
Plot the bytes graphs with the same scale as the text report
[thirdparty/sarg.git] / getconf.c
1 /*
2 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
3 * 1998, 2010
4 *
5 * SARG donations:
6 * please look at http://sarg.sourceforge.net/donations.php
7 * Support:
8 * http://sourceforge.net/projects/sarg/forums/forum/363374
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"
28 #include "include/defs.h"
29
30 #define SET_LIST(list) list,sizeof(list)/sizeof(list[0])
31
32 extern numlist hours, weekdays;
33
34 struct param_list
35 {
36 //! The name of the value of the parameter.
37 const char *name;
38 //! The bit to set if the value is found.
39 unsigned long int value;
40 //! The value is invalid if any bit of this mask is set in the parameter.
41 unsigned long int exclude;
42 };
43
44 static struct param_list report_type_values[]=
45 {
46 {"users_sites",REPORT_TYPE_USERS_SITES,0},
47 {"topusers",REPORT_TYPE_TOPUSERS,0},
48 {"topsites",REPORT_TYPE_TOPSITES,0},
49 {"sites_users",REPORT_TYPE_SITES_USERS,0},
50 {"date_time",REPORT_TYPE_DATE_TIME,0},
51 {"denied",REPORT_TYPE_DENIED,0},
52 {"auth_failures",REPORT_TYPE_AUTH_FAILURES,0},
53 {"site_user_time_date",REPORT_TYPE_SITE_USER_TIME_DATE,0},
54 {"downloads",REPORT_TYPE_DOWNLOADS,0},
55 };
56
57 static struct param_list data_field_values[]=
58 {
59 {"user",DATA_FIELD_USER,0},
60 {"date",DATA_FIELD_DATE,0},
61 {"time",DATA_FIELD_TIME,0},
62 {"url",DATA_FIELD_URL,0},
63 {"connect",DATA_FIELD_CONNECT,0},
64 {"bytes",DATA_FIELD_BYTES,0},
65 {"in_cache",DATA_FIELD_IN_CACHE,0},
66 {"out_cache",DATA_FIELD_OUT_CACHE,0},
67 {"elapsed",DATA_FIELD_ELAPSED,0},
68 };
69
70 static struct param_list topuserfields_values[]=
71 {
72 {"NUM",TOPUSERFIELDS_NUM,0},
73 {"DATE_TIME",TOPUSERFIELDS_DATE_TIME,0},
74 {"USERID",TOPUSERFIELDS_USERID,0},
75 {"CONNECT",TOPUSERFIELDS_CONNECT,0},
76 {"BYTES",TOPUSERFIELDS_BYTES,0},
77 {"%BYTES",TOPUSERFIELDS_SETYB,0},
78 {"SETYB",TOPUSERFIELDS_SETYB,0},
79 {"IN-CACHE-OUT",TOPUSERFIELDS_IN_CACHE_OUT,0},
80 {"USED_TIME",TOPUSERFIELDS_USED_TIME,0},
81 {"MILISEC",TOPUSERFIELDS_MILISEC,0},
82 {"%TIME",TOPUSERFIELDS_PTIME,0},
83 {"TOTAL",TOPUSERFIELDS_TOTAL,0},
84 {"AVERAGE",TOPUSERFIELDS_AVERAGE,0},
85 };
86
87 static struct param_list userreportfields_values[]=
88 {
89 {"CONNECT",USERREPORTFIELDS_CONNECT,0},
90 {"BYTES",USERREPORTFIELDS_BYTES,0},
91 {"%BYTES",USERREPORTFIELDS_SETYB,0},
92 {"SETYB",USERREPORTFIELDS_SETYB,0},
93 {"IN-CACHE-OUT",USERREPORTFIELDS_IN_CACHE_OUT,0},
94 {"USED_TIME",USERREPORTFIELDS_USED_TIME,0},
95 {"MILISEC",USERREPORTFIELDS_MILISEC,0},
96 {"%TIME",USERREPORTFIELDS_PTIME,0},
97 {"TOTAL",USERREPORTFIELDS_TOTAL,0},
98 {"AVERAGE",USERREPORTFIELDS_AVERAGE,0},
99 };
100
101 static struct param_list index_values[]=
102 {
103 {"yes",INDEX_YES,~INDEX_YES},
104 {"no",INDEX_NO,~INDEX_NO},
105 {"only",INDEX_ONLY,~INDEX_ONLY},
106 };
107
108 static struct param_list index_tree_values[]=
109 {
110 {"date",INDEX_TREE_DATE,~INDEX_TREE_DATE},
111 {"file",INDEX_TREE_FILE,~INDEX_TREE_FILE},
112 };
113
114 static struct param_list ntml_userformat_values[]=
115 {
116 {"user",NTLMUSERFORMAT_USER,~NTLMUSERFORMAT_USER},
117 {"domainname+username",NTLMUSERFORMAT_DOMAINUSER,~NTLMUSERFORMAT_DOMAINUSER},
118 };
119
120 static struct param_list recnouser_values[]=
121 {
122 {"ip",RECORDWITHOUTUSER_IP,~RECORDWITHOUTUSER_IP},
123 {"ignore",RECORDWITHOUTUSER_IGNORE,~RECORDWITHOUTUSER_IGNORE},
124 {"everybody",RECORDWITHOUTUSER_EVERYBODY,~RECORDWITHOUTUSER_EVERYBODY},
125 };
126
127 static struct param_list datafileurl_values[]=
128 {
129 {"ip",DATAFILEURL_IP,~DATAFILEURL_IP},
130 {"name",DATAFILEURL_NAME,~DATAFILEURL_NAME},
131 };
132
133 static struct param_list displayvalue_values[]=
134 {
135 {"bytes",DISPLAY_BYTES,~DISPLAY_BYTES},
136 {"abbreviation",DISPLAY_ABBREV,~DISPLAY_ABBREV},
137 };
138
139 static struct param_list datetime_values[]=
140 {
141 {"elap",DATETIME_ELAP,0},
142 {"bytes",DATETIME_BYTE,0},
143 };
144
145 static struct param_list realtime_unauth_values[]=
146 {
147 {"show",REALTIME_UNAUTH_REC_SHOW,~REALTIME_UNAUTH_REC_SHOW},
148 {"ignore",REALTIME_UNAUTH_REC_IGNORE,~REALTIME_UNAUTH_REC_IGNORE},
149 };
150
151 static int is_param(const char *param,const char *buf)
152 {
153 int plen;
154
155 plen=strlen(param);
156 if (strncmp(buf,param,plen) != 0) return(0);
157 buf+=plen;
158 if ((unsigned char)*buf>' ') return(0);
159 return(1);
160 }
161
162 static int getparam_string(const char *param,char *buf,char *value,int value_size)
163 {
164 int plen;
165
166 plen=strlen(param);
167 if (strncmp(buf,param,plen) != 0) return(0);
168 buf+=plen;
169 if ((unsigned char)*buf>' ') return(0);
170 while (*buf && (unsigned char)*buf<=' ') buf++;
171
172 if (strlen(buf)>=value_size) {
173 debuga(_("The string value of parameter \"%s\" is too long\n"),param);
174 exit(EXIT_FAILURE);
175 }
176 strcpy(value,buf);
177 fixnone(value);
178 return(1);
179 }
180
181 static int getparam_quoted(const char *param,char *buf,char *value,int value_size)
182 {
183 int plen;
184 int i;
185
186 plen=strlen(param);
187 if (strncmp(buf,param,plen) != 0) return(0);
188 buf+=plen;
189 if ((unsigned char)*buf>' ') return(0);
190 while (*buf && (unsigned char)*buf<=' ') buf++;
191
192 if (*buf != '\"') {
193 debuga(_("Missing double quote after parameter \"%s\"\n"),param);
194 exit(EXIT_FAILURE);
195 }
196 buf++;
197
198 value_size--;
199 for (i=0 ; i<value_size && *buf && *buf!='\"' ; i++) {
200 value[i]=*buf++;
201 }
202 value[i]='\0';
203
204 if (*buf != '\"') {
205 debuga(_("Missing double quote after parameter \"%s\" or value is more than %d bytes long\n"),param,value_size);
206 exit(EXIT_FAILURE);
207 }
208 fixnone(value);
209 return(1);
210 }
211
212 static int getparam_2words(const char *param,char *buf,char *word1,int word1_size,char *word2,int word2_size)
213 {
214 int plen;
215 int i;
216
217 plen=strlen(param);
218 if (strncmp(buf,param,plen) != 0) return(0);
219 buf+=plen;
220 if ((unsigned char)*buf>' ') return(0);
221 while (*buf && (unsigned char)*buf<=' ') buf++;
222
223 for (i=0 ; i<word1_size && *buf && (unsigned char)*buf>' ' ; i++)
224 word1[i]=*buf++;
225 if (i>=word1_size) {
226 debuga(_("The first word of parameter \"%s\" is more than %d bytes long\n"),param,word1_size-1);
227 exit(EXIT_FAILURE);
228 }
229 if (*buf!=' ') {
230 debuga(_("Missing second word for parameter \"%s\"\n"),param);
231 exit(EXIT_FAILURE);
232 }
233 word1[i]=0;
234
235 while (*buf && (unsigned char)*buf<=' ') buf++;
236
237 for (i=0 ; i<word2_size && *buf && (unsigned char)*buf>' ' ; i++)
238 word2[i]=*buf++;
239 if (i>=word2_size) {
240 debuga(_("The second word of parameter \"%s\" is more than %d bytes long\n"),param,word2_size-1);
241 exit(EXIT_FAILURE);
242 }
243 word2[i]=0;
244
245 fixnone(word1);
246 fixnone(word2);
247 return(1);
248 }
249
250 static int getparam_int(const char *param,char *buf,int *value)
251 {
252 int plen;
253 int next;
254
255 plen=strlen(param);
256 if (strncmp(buf,param,plen) != 0) return(0);
257 buf+=plen;
258 if ((unsigned char)*buf>' ') return(0);
259 while (*buf && (unsigned char)*buf<=' ') buf++;
260
261 next=0;
262 if (sscanf(buf,"%d%n",value,&next) != 1 || (unsigned char)buf[next] > ' ') {
263 debuga(_("The integer value of parameter \"%s\" is invalid\n"),param);
264 exit(EXIT_FAILURE);
265 }
266 return(1);
267 }
268
269 static int getparam_bool(const char *param,char *buf,bool *value)
270 {
271 int plen;
272 int i;
273 const char *bool_str="yes,true,on,1";
274
275 plen=strlen(param);
276 if (strncmp(buf,param,plen) != 0) return(0);
277 buf+=plen;
278 if ((unsigned char)*buf>' ') return(0);
279 while (*buf && (unsigned char)*buf<=' ') buf++;
280
281 *value=false;
282 for ( ; *bool_str ; bool_str+=i) {
283 for (i=0 ; bool_str[i] && bool_str[i]!=',' ; i++);
284 if (strncasecmp(bool_str,buf,i)==0) {
285 *value=true;
286 break;
287 }
288 if (bool_str[i]==',') i++;
289 }
290 return(1);
291 }
292
293 static int getparam_list(const char *param,struct param_list *options,int noptions,char *buf,unsigned long int *value)
294 {
295 int plen;
296 char *str;
297 int i;
298
299 plen=strlen(param);
300 if (strncmp(buf,param,plen) != 0) return(0);
301 buf+=plen;
302 if ((unsigned char)*buf>' ') return(0);
303 while (*buf && (unsigned char)*buf<=' ') buf++;
304
305 *value=0UL;
306 while (*buf) {
307 str=buf;
308 while (*str && (unsigned char)*str>' ' && *str!=';') str++;
309 if (*str) {
310 *str++='\0';
311 while (*str && ((unsigned char)*str<=' ' || *str==';')) str++;
312 }
313 for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++);
314 if (i>=noptions) {
315 debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),buf,param);
316 exit(EXIT_FAILURE);
317 }
318 if ((*value & options[i].exclude)!=0) {
319 debuga(_("Value \"%s\" conflicts with other selected values for parameter \"%s\"\n"),buf,param);
320 exit(EXIT_FAILURE);
321 }
322 *value|=options[i].value;
323 buf=str;
324 }
325 return(1);
326 }
327
328 static void parmtest(char *buf)
329 {
330 char wbuf[2048];
331 struct getwordstruct gwarea;
332
333 while (*buf && (unsigned char)*buf<=' ') buf++;
334
335 if(*buf == '#' || *buf == '\0')
336 return;
337
338 if(debugz)
339 printf(_("SARG: TAG: %s\n"),buf);
340
341 if (getparam_string("background_color",buf,BgColor,sizeof(BgColor))>0) return;
342
343 if (getparam_string("text_color",buf,TxColor,sizeof(TxColor))>0) return;
344
345 if (getparam_string("text_bgcolor",buf,TxBgColor,sizeof(TxBgColor))>0) return;
346
347 if (getparam_string("title_color",buf,TiColor,sizeof(TiColor))>0) return;
348
349 if (getparam_string("logo_image",buf,LogoImage,sizeof(LogoImage))>0) return;
350
351 if (getparam_quoted("logo_text",buf,LogoText,sizeof(LogoText))>0) return;
352
353 if (getparam_string("logo_text_color",buf,LogoTextColor,sizeof(LogoTextColor))>0) return;
354
355 if (getparam_string("background_image",buf,BgImage,sizeof(BgImage))>0) return;
356
357 if (getparam_bool("show_sarg_info",buf,&ShowSargInfo)>0) return;
358
359 if (getparam_bool("show_sarg_logo",buf,&ShowSargLogo)>0) return;
360
361 if (getparam_string("font_face",buf,FontFace,sizeof(FontFace))>0) return;
362
363 if (getparam_string("header_color",buf,HeaderColor,sizeof(HeaderColor))>0) return;
364
365 if (getparam_string("header_bgcolor",buf,HeaderBgColor,sizeof(HeaderBgColor))>0) return;
366
367 if (getparam_string("font_size",buf,FontSize,sizeof(FontSize))>0) return;
368
369 if (getparam_string("header_font_size",buf,HeaderFontSize,sizeof(HeaderFontSize))>0) return;
370
371 if (getparam_string("title_font_size",buf,TitleFontSize,sizeof(TitleFontSize))>0) return;
372
373 if (getparam_2words("image_size",buf,Width,sizeof(Width),Height,sizeof(Height))>0) return;
374
375 if (getparam_quoted("title",buf,Title,sizeof(Title))>0) return;
376
377 if (getparam_bool("resolve_ip",buf,&Ip2Name)>0) return;
378
379 if (getparam_bool("user_ip",buf,&UserIp)>0) return;
380
381 if (getparam_string("max_elapsed",buf,MaxElapsed,sizeof(MaxElapsed))>0) return;
382
383 if (is_param("date_format",buf)) {
384 getword_start(&gwarea,buf);
385 if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
386 debuga(_("Maybe you have a broken record or garbage in \"date_format\" parameter\n"));
387 exit(EXIT_FAILURE);
388 }
389 strncpy(DateFormat,gwarea.current,1);
390 fixnone(DateFormat);
391 return;
392 }
393
394 if (is_param("hours",buf)) {
395 if( getnumlist( buf, &hours, 24, 24 ) ) {
396 debuga(_("Error: Invalid syntax in hours tag!\n"));
397 exit( 1 );
398 }
399 }
400
401 if (is_param("weekdays",buf)) {
402 if( getnumlist( buf, &weekdays, 7, 7 ) ) {
403 debuga(_("Error: Invalid syntax in weekdays tag!\n"));
404 exit( 1 );
405 }
406 }
407
408 if (getparam_2words("topuser_sort_field",buf,TopuserSortField,sizeof(TopuserSortField),TopuserSortOrder,sizeof(TopuserSortOrder))>0) return;
409
410 if (getparam_2words("user_sort_field",buf,UserSortField,sizeof(UserSortField),UserSortOrder,sizeof(UserSortOrder))>0) return;
411
412 if (is_param("access_log",buf)>0) {
413 if (AccessLogFromCmdLine==0) {
414 if (NAccessLog>=MAXLOGS) {
415 debuga(_("Too many log files in configuration file\n"));
416 exit(EXIT_FAILURE);
417 }
418 getparam_string("access_log",buf,AccessLog[NAccessLog],MAX_LOG_FILELEN);
419 NAccessLog++;
420 }
421 return;
422 }
423
424 if (is_param("redirector_log",buf)>0) {
425 if (RedirectorLogFromCmdLine==0) {
426 if (NRedirectorLogs>=MAX_REDIRECTOR_LOGS) {
427 debuga(_("Too many redirector log files in configuration file\n"));
428 exit(EXIT_FAILURE);
429 }
430 getparam_string("redirector_log",buf,RedirectorLogs[NRedirectorLogs],MAX_REDIRECTOR_FILELEN);
431 NRedirectorLogs++;
432 }
433 return;
434 }
435
436 if (getparam_string("useragent_log",buf,UserAgentLog,sizeof(UserAgentLog))>0) return;
437
438 if (getparam_string("exclude_hosts",buf,ExcludeHosts,sizeof(ExcludeHosts))>0) return;
439
440 if (getparam_string("exclude_codes",buf,ExcludeCodes,sizeof(ExcludeCodes))>0) return;
441
442 if (getparam_string("exclude_users",buf,ExcludeUsers,sizeof(ExcludeUsers))>0) return;
443
444 if (getparam_string("password",buf,PasswdFile,sizeof(PasswdFile))>0) return;
445
446 if (getparam_string("temporary_dir",buf,TempDir,sizeof(TempDir))>0) return;
447
448 if (getparam_list("report_type",SET_LIST(report_type_values),buf,&ReportType)>0) return;
449
450 if (getparam_string("output_dir",buf,OutputDir,sizeof(OutputDir))>0) return;
451
452 if (getparam_string("output_email",buf,OutputEmail,sizeof(OutputEmail))>0) return;
453
454 if (getparam_2words("per_user_limit",buf,PerUserLimitFile,sizeof(PerUserLimitFile),wbuf,sizeof(wbuf))>0) {
455 PerUserLimit=atoi(wbuf);
456 return;
457 }
458
459 if (getparam_int("lastlog",buf,&LastLog)>0) return;
460
461 if (getparam_bool("remove_temp_files",buf,&RemoveTempFiles)>0) return;
462
463 if (getparam_string("replace_index",buf,ReplaceIndex,sizeof(ReplaceIndex))>0) return;
464
465 if (getparam_list("index_tree",SET_LIST(index_tree_values),buf,&IndexTree)>0) return;
466
467 if (getparam_list("index",SET_LIST(index_values),buf,&Index)>0) return;
468
469 if (getparam_bool("overwrite_report",buf,&OverwriteReport)>0) return;
470
471 if (getparam_list("records_without_userid",SET_LIST(recnouser_values),buf,&RecordsWithoutUser)>0) return;
472
473 if (getparam_bool("use_comma",buf,&UseComma)>0) return;
474
475 if (getparam_string("mail_utility",buf,MailUtility,sizeof(MailUtility))>0) return;
476
477 if (getparam_int("topsites_num",buf,&TopSitesNum)>0) return;
478
479 if (getparam_int("topuser_num",buf,&TopUsersNum)>0) return;
480
481 if (getparam_string("usertab",buf,UserTabFile,sizeof(UserTabFile))>0) return;
482
483 if (getparam_string("index_sort_order",buf,IndexSortOrder,sizeof(IndexSortOrder))>0) return;
484
485 if (getparam_2words("topsites_sort_order",buf,TopsitesSortField,sizeof(TopsitesSortField),TopsitesSortType,sizeof(TopsitesSortType))>0) return;
486
487 if (getparam_bool("long_url",buf,&LongUrl)>0) return;
488
489 if (getparam_string("dansguardian_conf",buf,DansGuardianConf,sizeof(DansGuardianConf))>0) return;
490
491 if (getparam_string("squidguard_conf",buf,SquidGuardConf,sizeof(SquidGuardConf))>0) return;
492
493 if (getparam_list("date_time_by",SET_LIST(datetime_values),buf,&datetimeby)>0) return;
494
495 if (getparam_string("charset",buf,CharSet,sizeof(CharSet))>0) {
496 ccharset(CharSet);
497 return;
498 }
499
500 if (getparam_quoted("user_invalid_char",buf,UserInvalidChar,sizeof(UserInvalidChar))>0) return;
501
502 if (getparam_quoted("include_users",buf,IncludeUsers+1,sizeof(IncludeUsers)-2)>0) {
503 IncludeUsers[0]=':';
504 strcat(IncludeUsers,":");
505 return;
506 }
507
508 if (getparam_quoted("exclude_string",buf,ExcludeString,sizeof(ExcludeString))>0) return;
509
510 if (getparam_bool("privacy",buf,&Privacy)>0) return;
511
512 if (getparam_quoted("privacy_string",buf,PrivacyString,sizeof(PrivacyString))>0) return;
513
514 if (getparam_string("privacy_string_color",buf,PrivacyStringColor,sizeof(PrivacyStringColor))>0) return;
515
516 if (getparam_bool("show_successful_message",buf,&SuccessfulMsg)>0) return;
517
518 if (getparam_bool("show_read_statistics",buf,&ShowReadStatistics)>0) return;
519
520 if (getparam_list("topuser_fields",SET_LIST(topuserfields_values),buf,&TopUserFields)>0) return;
521
522 if (getparam_bool("bytes_in_sites_users_report",buf,&BytesInSitesUsersReport)>0) return;
523
524 if (getparam_list("user_report_fields",SET_LIST(userreportfields_values),buf,&UserReportFields)>0) return;
525
526 if (getparam_string("datafile",buf,DataFile,sizeof(DataFile))>0) return;
527
528 if (getparam_quoted("datafile_delimiter",buf,DataFileDelimiter,sizeof(DataFileDelimiter))>0) return;
529
530 if (getparam_list("datafile_fields",SET_LIST(data_field_values),buf,&DataFileFields)>0) return;
531
532 if (getparam_list("datafile_url",SET_LIST(datafileurl_values),buf,&DataFileUrl)>0) return;
533
534 if (getparam_string("parsed_output_log",buf,ParsedOutputLog,sizeof(ParsedOutputLog))>0) return;
535
536 if (getparam_string("parsed_output_log_compress",buf,ParsedOutputLogCompress,sizeof(ParsedOutputLogCompress))>0) return;
537
538 if (getparam_list("displayed_values",SET_LIST(displayvalue_values),buf,&DisplayedValues)>0) return;
539
540 if (getparam_int("authfail_report_limit",buf,&AuthfailReportLimit)>0) return;
541
542 if (getparam_int("denied_report_limit",buf,&DeniedReportLimit)>0) return;
543
544 if (getparam_int("siteusers_report_limit",buf,&SiteUsersReportLimit)>0) return;
545
546 if (getparam_int("dansguardian_report_limit",buf,&DansGuardianReportLimit)>0) return;
547
548 if (getparam_int("squidguard_report_limit",buf,&SquidGuardReportLimit)>0) return;
549
550 if (getparam_int("user_report_limit",buf,&UserReportLimit)>0) return;
551
552 if (getparam_int("download_report_limit",buf,&DownloadReportLimit)>0) return;
553
554 if (getparam_string("www_document_root",buf,wwwDocumentRoot,sizeof(wwwDocumentRoot))>0) return;
555
556 if (getparam_string("block_it",buf,BlockIt,sizeof(BlockIt))>0) return;
557
558 if (getparam_string("external_css_file",buf,ExternalCSSFile,sizeof(ExternalCSSFile))>0) return;
559
560 if (getparam_bool("user_authentication",buf,&UserAuthentication)>0) return;
561
562 if (getparam_string("AuthUserTemplateFile",buf,wbuf,sizeof(wbuf))>0) {
563 char dir[MAXLEN];
564
565 if (is_absolute(wbuf)) {
566 if (strlen(wbuf)>=sizeof(AuthUserTemplateFile)) {
567 debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
568 exit(EXIT_FAILURE);
569 }
570 strcpy(AuthUserTemplateFile,wbuf);
571 } else {
572 strcpy(dir,ConfigFile);
573 if (snprintf(AuthUserTemplateFile,sizeof(AuthUserTemplateFile),"%s/%s",dirname(dir),wbuf)>=sizeof(AuthUserTemplateFile)) {
574 debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
575 exit(EXIT_FAILURE);
576 }
577 }
578 return;
579 }
580
581 if (is_param("download_suffix",buf)) {
582 char warea[MAXLEN];
583
584 getparam_quoted("download_suffix",buf,warea,sizeof(warea));
585 set_download_suffix(warea);
586 return;
587 }
588
589 if (getparam_bool("graphs",buf,&Graphs)>0) return;
590
591 if (getparam_string("graph_days_bytes_bar_color",buf,GraphDaysBytesBarColor,sizeof(GraphDaysBytesBarColor))>0) return;
592
593 if (getparam_string("redirector_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) return;
594 if (getparam_string("squidguard_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) {
595 debuga(_("squidguard_log_format is deprecated and has been replaced by redirector_log_format. Please update your configuration file.\n"));
596 return;
597 }
598
599 if (getparam_bool("redirector_ignore_date",buf,&RedirectorIgnoreDate)>0) return;
600 if (getparam_bool("squidguard_ignore_date",buf,&RedirectorIgnoreDate)>0) {
601 debuga(_("squidguard_ignore_date is deprecated and has been replaced by redirector_ignore_date. Please update your configuration file.\n"));
602 return;
603 }
604
605 if (getparam_bool("dansguardian_ignore_date",buf,&DansguardianIgnoreDate)>0) return;
606
607 if (getparam_string("ulimit",buf,Ulimit,sizeof(Ulimit))>0) return;
608
609 if (getparam_list("ntlm_user_format",SET_LIST(ntml_userformat_values),buf,&NtlmUserFormat)>0) return;
610
611 if (getparam_string("realtime_types",buf,RealtimeTypes,sizeof(RealtimeTypes))>0) return;
612
613 if (getparam_list("realtime_unauthenticated_records",SET_LIST(realtime_unauth_values),buf,&RealtimeUnauthRec)>0) return;
614
615 if (getparam_int("realtime_refresh_time",buf,&realtime_refresh)>0) return;
616
617 if (getparam_int("realtime_access_log_lines",buf,&realtime_access_log_lines)>0) return;
618
619 if (getparam_string("LDAPHost",buf,LDAPHost,sizeof(LDAPHost))>0) return;
620
621 if (getparam_int("LDAPPort",buf,&LDAPPort)>0) return;
622
623 if (getparam_int("LDAPProtocolVersion",buf,&LDAPProtocolVersion)>0) return;
624
625 if (getparam_string("LDAPBindDN",buf,LDAPBindDN,sizeof(LDAPBindDN))>0) return;
626
627 if (getparam_string("LDAPBindPW",buf,LDAPBindPW,sizeof(LDAPBindPW))>0) return;
628
629 if (getparam_string("LDAPBaseSearch",buf,LDAPBaseSearch,sizeof(LDAPBaseSearch))>0) return;
630
631 if (getparam_string("LDAPFilterSearch",buf,LDAPFilterSearch,sizeof(LDAPFilterSearch))>0) return;
632
633 if (getparam_string("LDAPTargetAttr",buf,LDAPTargetAttr,sizeof(LDAPTargetAttr))>0) return;
634
635 if (getparam_string("graph_font",buf,GraphFont,sizeof(GraphFont))>0) return;
636
637 if(strstr(buf,"squid24") != 0) {
638 squid24=true;
639 return;
640 }
641
642 if(strstr(buf,"byte_cost") != 0) {
643 getword_start(&gwarea,buf);
644 if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
645 debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
646 exit(EXIT_FAILURE);
647 }
648 cost=atol(gwarea.current);
649 if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
650 debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
651 exit(EXIT_FAILURE);
652 }
653 nocost=my_atoll(gwarea.current);
654 return;
655 }
656
657 printf(_("SARG: Unknown option %s\n"),buf);
658 }
659
660 void getconf(void)
661 {
662
663 FILE *fp_in;
664 char buf[MAXLEN];
665
666 if(debug)
667 debuga(_("Loading configuration from %s\n"),ConfigFile);
668
669 if ((fp_in = fopen(ConfigFile, "r")) == NULL) {
670 debuga(_("(getconf) Cannot open file %s\n"),ConfigFile);
671 exit(EXIT_FAILURE);
672 }
673
674 while (fgets(buf, sizeof(buf), fp_in) != NULL) {
675 fixendofline(buf);
676
677 if(debugm)
678 printf("SYSCONFDIR %s\n",buf);
679
680 parmtest(buf);
681
682 }
683
684 fclose(fp_in);
685 return;
686 }