]> git.donarmstrong.com Git - debbugs.git/blob - Debbugs/Config.pm
add $gDebbugsDb (debbugs_db) configuration option to specify the debbugs database...
[debbugs.git] / Debbugs / Config.pm
1 # This module is part of debbugs, and is released
2 # under the terms of the GPL version 2, or any later
3 # version at your option.
4 # See the file README and COPYING for more information.
5 #
6 # Copyright 2007 by Don Armstrong <don@donarmstrong.com>.
7
8 package Debbugs::Config;
9
10 =head1 NAME
11
12 Debbugs::Config -- Configuration information for debbugs
13
14 =head1 SYNOPSIS
15
16  use Debbugs::Config;
17
18 # to get the compatiblity interface
19
20  use Debbugs::Config qw(:globals);
21
22 =head1 DESCRIPTION
23
24 This module provides configuration variables for all of debbugs.
25
26 =head1 CONFIGURATION FILES
27
28 The default configuration file location is /etc/debbugs/config; this
29 configuration file location can be set by modifying the
30 DEBBUGS_CONFIG_FILE env variable to point at a different location.
31
32 =cut
33
34 use warnings;
35 use strict;
36 use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT $USING_GLOBALS %config);
37 use base qw(Exporter);
38
39 BEGIN {
40      # set the version for version checking
41      $VERSION     = 1.00;
42      $DEBUG = 0 unless defined $DEBUG;
43      $USING_GLOBALS = 0;
44
45      @EXPORT = ();
46      %EXPORT_TAGS = (globals => [qw($gEmailDomain $gListDomain $gWebHost $gWebHostBugDir),
47                                  qw($gWebDomain $gHTMLSuffix $gCGIDomain $gMirrors),
48                                  qw($gPackagePages $gSubscriptionDomain $gProject $gProjectTitle),
49                                  qw($gMaintainer $gMaintainerWebpage $gMaintainerEmail $gUnknownMaintainerEmail),
50                                  qw($gSubmitList $gMaintList $gQuietList $gForwardList),
51                                  qw($gDoneList $gRequestList $gSubmitterList $gControlList),
52                                  qw($gStrongList),
53                                  qw($gBugSubscriptionDomain),
54                                  qw($gPackageVersionRe),
55                                  qw($gSummaryList $gMirrorList $gMailer $gBug),
56                                  qw($gBugs $gRemoveAge $gSaveOldBugs $gDefaultSeverity),
57                                  qw($gShowSeverities $gBounceFroms $gConfigDir $gSpoolDir),
58                                  qw($gIncomingDir $gWebDir $gDocDir $gMaintainerFile),
59                                  qw($gMaintainerFileOverride $gPseudoMaintFile $gPseudoDescFile $gPackageSource),
60                                  qw($gVersionPackagesDir $gVersionIndex $gBinarySourceMap $gSourceBinaryMap),
61                                  qw($gVersionTimeIndex),
62                                  qw($gSimpleVersioning),
63                                  qw($gCVETracker),
64                                  qw($gSendmail @gSendmailArguments $gLibPath $gSpamScan @gExcludeFromControl),
65                                  qw(%gSeverityDisplay @gTags @gSeverityList @gStrongSeverities),
66                                  qw(%gTagsSingleLetter),
67                                  qw(%gSearchEstraier),
68                                  qw(%gDistributionAliases),
69                                  qw(%gObsoleteSeverities),
70                                  qw(@gPostProcessall @gRemovalDefaultDistributionTags @gRemovalDistributionTags @gRemovalArchitectures),
71                                  qw(@gRemovalStrongSeverityDefaultDistributionTags),
72                                  qw(@gAffectsDistributionTags),
73                                  qw(@gDefaultArchitectures),
74                                  qw($gMachineName),
75                                  qw($gTemplateDir),
76                                  qw($gDefaultPackage),
77                                  qw($gSpamMaxThreads $gSpamSpamsPerThread $gSpamKeepRunning $gSpamScan $gSpamCrossassassinDb),
78                                  qw($gDebbugsDb),
79                                 ],
80                      text     => [qw($gBadEmailPrefix $gHTMLTail $gHTMLExpireNote),
81                                  ],
82                      cgi => [qw($gLibravatarUri $gLibravatarCacheDir $gLibravatarUriOptions @gLibravatarBlacklist)],
83                      config   => [qw(%config)],
84                     );
85      @EXPORT_OK = ();
86      Exporter::export_ok_tags(keys %EXPORT_TAGS);
87      $EXPORT_TAGS{all} = [@EXPORT_OK];
88      $ENV{HOME} = '' if not defined $ENV{HOME};
89 }
90
91 use Sys::Hostname;
92 use File::Basename qw(dirname);
93 use IO::File;
94 use Safe;
95
96 =head1 CONFIGURATION VARIABLES
97
98 =head2 General Configuration
99
100 =over
101
102 =cut
103
104 # read in the files;
105 %config = ();
106 # untaint $ENV{DEBBUGS_CONFIG_FILE} if it's owned by us
107 # This enables us to test things that are -T.
108 if (exists $ENV{DEBBUGS_CONFIG_FILE}) {
109 # This causes all sorts of problems for mirrors of debbugs; disable
110 # it.
111 #     if (${[stat($ENV{DEBBUGS_CONFIG_FILE})]}[4] == $<) {
112           $ENV{DEBBUGS_CONFIG_FILE} =~ /(.+)/;
113           $ENV{DEBBUGS_CONFIG_FILE} = $1;
114 #      }
115 #      else {
116 #         die "Environmental variable DEBBUGS_CONFIG_FILE set, and $ENV{DEBBUGS_CONFIG_FILE} is not owned by the user running this script.";
117 #      }
118 }
119 read_config(exists $ENV{DEBBUGS_CONFIG_FILE}?$ENV{DEBBUGS_CONFIG_FILE}:'/etc/debbugs/config');
120
121 =item email_domain $gEmailDomain
122
123 The email domain of the bts
124
125 =cut
126
127 set_default(\%config,'email_domain','bugs.something');
128
129 =item list_domain $gListDomain
130
131 The list domain of the bts, defaults to the email domain
132
133 =cut
134
135 set_default(\%config,'list_domain',$config{email_domain});
136
137 =item web_host $gWebHost
138
139 The web host of the bts; defaults to the email domain
140
141 =cut
142
143 set_default(\%config,'web_host',$config{email_domain});
144
145 =item web_host_bug_dir $gWebHostDir
146
147 The directory of the web host on which bugs are kept, defaults to C<''>
148
149 =cut
150
151 set_default(\%config,'web_host_bug_dir','');
152
153 =item web_domain $gWebDomain
154
155 Full path of the web domain where bugs are kept, defaults to the
156 concatenation of L</web_host> and L</web_host_bug_dir>
157
158 =cut
159
160 set_default(\%config,'web_domain',$config{web_host}.($config{web_host}=~m{/$}?'':'/').$config{web_host_bug_dir});
161
162 =item html_suffix $gHTMLSuffix
163
164 Suffix of html pages, defaults to .html
165
166 =cut
167
168 set_default(\%config,'html_suffix','.html');
169
170 =item cgi_domain $gCGIDomain
171
172 Full path of the web domain where cgi scripts are kept. Defaults to
173 the concatentation of L</web_host> and cgi.
174
175 =cut
176
177 set_default(\%config,'cgi_domain',$config{web_domain}.($config{web_domain}=~m{/$}?'':'/').'cgi');
178
179 =item mirrors @gMirrors
180
181 List of mirrors [What these mirrors are used for, no one knows.]
182
183 =cut
184
185
186 set_default(\%config,'mirrors',[]);
187
188 =item package_pages  $gPackagePages
189
190 Domain where the package pages are kept; links should work in a
191 package_pages/foopackage manner. Defaults to undef, which means that
192 package links will not be made.
193
194 =cut
195
196
197 set_default(\%config,'package_pages',undef);
198
199 =item package_pages  $gUsertagPackageDomain
200
201 Domain where where usertags of packages belong; defaults to $gPackagePages
202
203 =cut
204
205 set_default(\%config,'usertag_package_domain',$config{package_pages});
206
207
208 =item subscription_domain $gSubscriptionDomain
209
210 Domain where subscriptions to package lists happen
211
212 =cut
213
214 set_default(\%config,'subscription_domain',undef);
215
216
217 =item cve_tracker $gCVETracker
218
219 URI to CVE security tracker; in bugreport.cgi, CVE-2001-0002 becomes
220 linked to http://$config{cve_tracker}CVE-2001-002
221
222 Default: security-tracker.debian.org/tracker/
223
224 =cut
225
226 set_default(\%config,'cve_tracker','security-tracker.debian.org/tracker/');
227
228
229 =back
230
231 =cut
232
233
234 =head2 Project Identification
235
236 =over
237
238 =item project $gProject
239
240 Name of the project
241
242 Default: 'Something'
243
244 =cut
245
246 set_default(\%config,'project','Something');
247
248 =item project_title $gProjectTitle
249
250 Name of this install of Debbugs, defaults to "L</project> Debbugs Install"
251
252 Default: "$config{project} Debbugs Install"
253
254 =cut
255
256 set_default(\%config,'project_title',"$config{project} Debbugs Install");
257
258 =item maintainer $gMaintainer
259
260 Name of the maintainer of this debbugs install
261
262 Default: 'Local DebBugs Owner's
263
264 =cut
265
266 set_default(\%config,'maintainer','Local DebBugs Owner');
267
268 =item maintainer_webpage $gMaintainerWebpage
269
270 Webpage of the maintainer of this install of debbugs
271
272 Default: "$config{web_domain}/~owner"
273
274 =cut
275
276 set_default(\%config,'maintainer_webpage',"$config{web_domain}/~owner");
277
278 =item maintainer_email $gMaintainerEmail
279
280 Email address of the maintainer of this Debbugs install
281
282 Default: 'root@'.$config{email_domain}
283
284 =cut
285
286 set_default(\%config,'maintainer_email','root@'.$config{email_domain});
287
288 =item unknown_maintainer_email
289
290 Email address where packages with an unknown maintainer will be sent
291
292 Default: $config{maintainer_email}
293
294 =cut
295
296 set_default(\%config,'unknown_maintainer_email',$config{maintainer_email});
297
298 =item machine_name
299
300 The name of the machine that this instance of debbugs is running on
301 (currently used for debbuging purposes and web page output.)
302
303 Default: Sys::Hostname::hostname()
304
305 =back
306
307 =cut
308
309 set_default(\%config,'machine_name',Sys::Hostname::hostname());
310
311 =head2 BTS Mailing Lists
312
313
314 =over
315
316 =item submit_list
317
318 =item maint_list
319
320 =item forward_list
321
322 =item done_list
323
324 =item request_list
325
326 =item submitter_list
327
328 =item control_list
329
330 =item summary_list
331
332 =item mirror_list
333
334 =item strong_list
335
336 =cut
337
338 set_default(\%config,   'submit_list',   'bug-submit-list');
339 set_default(\%config,    'maint_list',    'bug-maint-list');
340 set_default(\%config,    'quiet_list',    'bug-quiet-list');
341 set_default(\%config,  'forward_list',  'bug-forward-list');
342 set_default(\%config,     'done_list',     'bug-done-list');
343 set_default(\%config,  'request_list',  'bug-request-list');
344 set_default(\%config,'submitter_list','bug-submitter-list');
345 set_default(\%config,  'control_list',  'bug-control-list');
346 set_default(\%config,  'summary_list',  'bug-summary-list');
347 set_default(\%config,   'mirror_list',   'bug-mirror-list');
348 set_default(\%config,   'strong_list',   'bug-strong-list');
349
350 =item bug_subscription_domain
351
352 Domain of list for messages regarding a single bug; prefixed with
353 bug=${bugnum}@ when bugs are actually sent out. Set to undef or '' to
354 disable sending messages to the bug subscription list.
355
356 Default: list_domain
357
358 =back
359
360 =cut
361
362 set_default(\%config,'bug_subscription_domain',$config{list_domain});
363
364
365
366 =head2 Misc Options
367
368 =over
369
370 =item mailer
371
372 Name of the mailer to use
373
374 Default: exim
375
376 =cut
377
378 set_default(\%config,'mailer','exim');
379
380
381 =item bug
382
383 Default: bug
384
385 =item ubug
386
387 Default: ucfirst($config{bug});
388
389 =item bugs
390
391 Default: bugs
392
393 =item ubugs
394
395 Default: ucfirst($config{ubugs});
396
397 =cut
398
399 set_default(\%config,'bug','bug');
400 set_default(\%config,'ubug',ucfirst($config{bug}));
401 set_default(\%config,'bugs','bugs');
402 set_default(\%config,'ubugs',ucfirst($config{bugs}));
403
404 =item remove_age
405
406 Age at which bugs are archived/removed
407
408 Default: 28
409
410 =cut
411
412 set_default(\%config,'remove_age',28);
413
414 =item save_old_bugs
415
416 Whether old bugs are saved or deleted
417
418 Default: 1
419
420 =cut
421
422 set_default(\%config,'save_old_bugs',1);
423
424 =item distribution_aliases
425
426 Map of distribution aliases to the distribution name
427
428 Default:
429          {experimental => 'experimental',
430           unstable     => 'unstable',
431           testing      => 'testing',
432           stable       => 'stable',
433           oldstable    => 'oldstable',
434           sid          => 'unstable',
435           lenny        => 'testing',
436           etch         => 'stable',
437           sarge        => 'oldstable',
438          }
439
440 =cut
441
442 set_default(\%config,'distribution_aliases',
443             {experimental => 'experimental',
444              unstable     => 'unstable',
445              testing      => 'testing',
446              stable       => 'stable',
447              oldstable    => 'oldstable',
448              sid          => 'unstable',
449              lenny        => 'testing',
450              etch         => 'stable',
451              sarge        => 'oldstable',
452             },
453            );
454
455
456
457 =item distributions
458
459 List of valid distributions
460
461 Default: The values of the distribution aliases map.
462
463 =cut
464
465 my %_distributions_default;
466 @_distributions_default{values %{$config{distribution_aliases}}} = values %{$config{distribution_aliases}};
467 set_default(\%config,'distributions',[keys %_distributions_default]);
468
469
470 =item default_architectures
471
472 List of default architectures to use when architecture(s) are not
473 specified
474
475 Default: i386 amd64 arm ppc sparc alpha
476
477 =cut
478
479 set_default(\%config,'default_architectures',
480             [qw(i386 amd64 arm powerpc sparc alpha)]
481            );
482
483 =item affects_distribution_tags
484
485 List of tags which restrict the buggy state to a set of distributions.
486
487 The set of distributions that are buggy is the intersection of the set
488 of distributions that would be buggy without reference to these tags
489 and the set of these tags that are distributions which are set on a
490 bug.
491
492 Setting this to [] will remove this feature.
493
494 Default: @{$config{distributions}}
495
496 =cut
497
498 set_default(\%config,'affects_distribution_tags',
499             [@{$config{distributions}}],
500            );
501
502 =item removal_unremovable_tags
503
504 Bugs which have these tags set cannot be archived
505
506 Default: []
507
508 =cut
509
510 set_default(\%config,'removal_unremovable_tags',
511             [],
512            );
513
514 =item removal_distribution_tags
515
516 Tags which specifiy distributions to check
517
518 Default: @{$config{distributions}}
519
520 =cut
521
522 set_default(\%config,'removal_distribution_tags',
523             [@{$config{distributions}}]);
524
525 =item removal_default_distribution_tags
526
527 For removal/archival purposes, all bugs are assumed to have these tags
528 set.
529
530 Default: qw(unstable testing);
531
532 =cut
533
534 set_default(\%config,'removal_default_distribution_tags',
535             [qw(unstable testing)]
536            );
537
538 =item removal_strong_severity_default_distribution_tags
539
540 For removal/archival purposes, all bugs with strong severity are
541 assumed to have these tags set.
542
543 Default: qw(unstable testing stable);
544
545 =cut
546
547 set_default(\%config,'removal_strong_severity_default_distribution_tags',
548             [qw(unstable testing stable)]
549            );
550
551
552 =item removal_architectures
553
554 For removal/archival purposes, these architectures are consulted if
555 there is more than one architecture applicable. If the bug is in a
556 package not in any of these architectures, the architecture actually
557 checked is undefined.
558
559 Default: value of default_architectures
560
561 =cut
562
563 set_default(\%config,'removal_architectures',
564             $config{default_architectures},
565            );
566
567
568 =item package_name_re
569
570 The regex which will match a package name
571
572 Default: '[a-z0-9][a-z0-9\.+-]+'
573
574 =cut
575
576 set_default(\%config,'package_name_re',
577             '[a-z0-9][a-z0-9\.+-]+');
578
579 =item package_version_re
580
581 The regex which will match a package version
582
583 Default: '[A-Za-z0-9:+\.-]+'
584
585 =cut
586
587
588 set_default(\%config,'package_version_re',
589             '[A-Za-z0-9:+\.~-]+');
590
591
592 =item default_package
593
594 This is the name of the default package. If set, bugs assigned to
595 packages without a maintainer and bugs missing a Package: psuedoheader
596 will be assigned to this package instead.
597
598 Defaults to unset, which is the traditional debbugs behavoir
599
600 =cut
601
602 set_default(\%config,'default_package',
603             undef
604            );
605
606
607 =item control_internal_requester
608
609 This address is used by Debbugs::Control as the request address which
610 sent a control request for faked log messages.
611
612 Default:"Debbugs Internal Request <$config{maintainer_email}>"
613
614 =cut
615
616 set_default(\%config,'control_internal_requester',
617             "Debbugs Internal Request <$config{maintainer_email}>",
618            );
619
620 =item control_internal_request_addr
621
622 This address is used by Debbugs::Control as the address to which a
623 faked log message request was sent.
624
625 Default: "internal_control\@$config{email_domain}";
626
627 =cut
628
629 set_default(\%config,'control_internal_request_addr',
630             'internal_control@'.$config{email_domain},
631            );
632
633
634 =item exclude_from_control
635
636 Addresses which are not allowed to send messages to control
637
638 =cut
639
640 set_default(\%config,'exclude_from_control',[]);
641
642
643
644 =item default_severity
645
646 The default severity of bugs which have no severity set
647
648 Default: normal
649
650 =cut
651
652 set_default(\%config,'default_severity','normal');
653
654 =item severity_display
655
656 A hashref of severities and the informative text which describes them.
657
658 Default:
659
660  {critical => "Critical $config{bugs}",
661   grave    => "Grave $config{bugs}",
662   normal   => "Normal $config{bugs}",
663   wishlist => "Wishlist $config{bugs}",
664  }
665
666 =cut
667
668 set_default(\%config,'severity_display',{critical => "Critical $config{bugs}",
669                                          grave    => "Grave $config{bugs}",
670                                          serious  => "Serious $config{bugs}",
671                                          important=> "Important $config{bugs}",
672                                          normal   => "Normal $config{bugs}",
673                                          minor    => "Minor $config{bugs}",
674                                          wishlist => "Wishlist $config{bugs}",
675                                         });
676
677 =item show_severities
678
679 A scalar list of the severities to show
680
681 Defaults to the concatenation of the keys of the severity_display
682 hashlist with ', ' above.
683
684 =cut
685
686 set_default(\%config,'show_severities',join(', ',keys %{$config{severity_display}}));
687
688 =item strong_severities
689
690 An arrayref of the serious severities which shoud be emphasized
691
692 Default: [qw(critical grave)]
693
694 =cut
695
696 set_default(\%config,'strong_severities',[qw(critical grave)]);
697
698 =item severity_list
699
700 An arrayref of a list of the severities
701
702 Defaults to the keys of the severity display hashref
703
704 =cut
705
706 set_default(\%config,'severity_list',[keys %{$config{severity_display}}]);
707
708 =item obsolete_severities
709
710 A hashref of obsolete severities with the replacing severity
711
712 Default: {}
713
714 =cut
715
716 set_default(\%config,'obsolete_severities',{});
717
718 =item tags
719
720 An arrayref of the tags used
721
722 Default: [qw(patch wontfix moreinfo unreproducible fixed)] and also
723 includes the distributions.
724
725 =cut
726
727 set_default(\%config,'tags',[qw(patch wontfix moreinfo unreproducible fixed),
728                              @{$config{distributions}}
729                             ]);
730
731 set_default(\%config,'tags_single_letter',
732             {patch => '+',
733              wontfix => '',
734              moreinfo => 'M',
735              unreproducible => 'R',
736              fixed   => 'F',
737             }
738            );
739
740 set_default(\%config,'bounce_froms','^mailer|^da?emon|^post.*mast|^root|^wpuser|^mmdf|^smt.*|'.
741             '^mrgate|^vmmail|^mail.*system|^uucp|-maiser-|^mal\@|'.
742             '^mail.*agent|^tcpmail|^bitmail|^mailman');
743
744 set_default(\%config,'config_dir',dirname(exists $ENV{DEBBUGS_CONFIG_FILE}?$ENV{DEBBUGS_CONFIG_FILE}:'/etc/debbugs/config'));
745 set_default(\%config,'spool_dir','/var/lib/debbugs/spool');
746
747 =item usertag_dir
748
749 Directory which contains the usertags
750
751 Default: $config{spool_dir}/user
752
753 =cut
754
755 set_default(\%config,'usertag_dir',$config{spool_dir}.'/user');
756 set_default(\%config,'incoming_dir','incoming');
757
758 =item web_dir $gWebDir
759
760 Directory where base html files are kept. Should normally be the same
761 as the web server's document root.
762
763 Default: /var/lib/debbugs/www
764
765 =cut
766
767 set_default(\%config,'web_dir','/var/lib/debbugs/www');
768 set_default(\%config,'doc_dir','/var/lib/debbugs/www/txt');
769 set_default(\%config,'lib_path','/usr/lib/debbugs');
770
771
772 =item template_dir
773
774 directory of templates; defaults to /usr/share/debbugs/templates.
775
776 =cut
777
778 set_default(\%config,'template_dir','/usr/share/debbugs/templates');
779
780
781 set_default(\%config,'maintainer_file',$config{config_dir}.'/Maintainers');
782 set_default(\%config,'maintainer_file_override',$config{config_dir}.'/Maintainers.override');
783 set_default(\%config,'source_maintainer_file',$config{config_dir}.'/Source_maintainers');
784 set_default(\%config,'source_maintainer_file_override',undef);
785 set_default(\%config,'pseudo_maint_file',$config{config_dir}.'/pseudo-packages.maintainers');
786 set_default(\%config,'pseudo_desc_file',$config{config_dir}.'/pseudo-packages.description');
787 set_default(\%config,'package_source',$config{config_dir}.'/indices/sources');
788
789
790 =item simple_versioning
791
792 If true this causes debbugs to ignore version information and just
793 look at whether a bug is done or not done. Primarily of interest for
794 debbugs installs which don't track versions. defaults to false.
795
796 =cut
797
798 set_default(\%config,'simple_versioning',0);
799
800
801 =item version_packages_dir
802
803 Location where the version package information is kept; defaults to
804 spool_dir/../versions/pkg
805
806 =cut
807
808 set_default(\%config,'version_packages_dir',$config{spool_dir}.'/../versions/pkg');
809
810 =item version_time_index
811
812 Location of the version/time index file. Defaults to
813 spool_dir/../versions/idx/versions_time.idx if spool_dir/../versions
814 exists; otherwise defaults to undef.
815
816 =cut
817
818
819 set_default(\%config,'version_time_index', -d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/versions_time.idx' : undef);
820
821 =item version_index
822
823 Location of the version index file. Defaults to
824 spool_dir/../versions/indices/versions.idx if spool_dir/../versions
825 exists; otherwise defaults to undef.
826
827 =cut
828
829 set_default(\%config,'version_index',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/versions.idx' : undef);
830
831 =item binary_source_map
832
833 Location of the binary -> source map. Defaults to
834 spool_dir/../versions/indices/bin2src.idx if spool_dir/../versions
835 exists; otherwise defaults to undef.
836
837 =cut
838
839 set_default(\%config,'binary_source_map',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/binsrc.idx' : undef);
840
841 =item source_binary_map
842
843 Location of the source -> binary map. Defaults to
844 spool_dir/../versions/indices/src2bin.idx if spool_dir/../versions
845 exists; otherwise defaults to undef.
846
847 =cut
848
849 set_default(\%config,'source_binary_map',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/srcbin.idx' : undef);
850
851
852
853 set_default(\%config,'post_processall',[]);
854
855 =item sendmail
856
857 Sets the sendmail binary to execute; defaults to /usr/lib/sendmail
858
859 =cut
860
861 set_default(\%config,'sendmail','/usr/lib/sendmail');
862
863 =item sendmail_arguments
864
865 Default arguments to pass to sendmail. Defaults to C<qw(-oem -oi)>.
866
867 =cut
868
869 set_default(\%config,'sendmail_arguments',[qw(-oem -oi)]);
870
871 =item spam_scan
872
873 Whether or not spamscan is being used; defaults to 0 (not being used
874
875 =cut
876
877 set_default(\%config,'spam_scan',0);
878
879 =item spam_crossassassin_db
880
881 Location of the crosassassin database, defaults to
882 spool_dir/../CrossAssassinDb
883
884 =cut
885
886 set_default(\%config,'spam_crossassassin_db',$config{spool_dir}.'/../CrossAssassinDb');
887
888 =item spam_max_cross
889
890 Maximum number of cross-posted messages
891
892 =cut
893
894 set_default(\%config,'spam_max_cross',6);
895
896
897 =item spam_spams_per_thread
898
899 Number of spams for each thread (on average). Defaults to 200
900
901 =cut
902
903 set_default(\%config,'spam_spams_per_thread',200);
904
905 =item spam_max_threads
906
907 Maximum number of threads to start. Defaults to 20
908
909 =cut
910
911 set_default(\%config,'spam_max_threads',20);
912
913 =item spam_keep_running
914
915 Maximum number of seconds to run without restarting. Defaults to 3600.
916
917 =cut
918
919 set_default(\%config,'spam_keep_running',3600);
920
921 =item spam_mailbox
922
923 Location to store spam messages; is run through strftime to allow for
924 %d,%m,%Y, et al. Defaults to 'spool_dir/../mail/spam/assassinated.%Y-%m-%d'
925
926 =cut
927
928 set_default(\%config,'spam_mailbox',$config{spool_dir}.'/../mail/spam/assassinated.%Y-%m-%d');
929
930 =item spam_crossassassin_mailbox
931
932 Location to store crossassassinated messages; is run through strftime
933 to allow for %d,%m,%Y, et al. Defaults to
934 'spool_dir/../mail/spam/crossassassinated.%Y-%m-%d'
935
936 =cut
937
938 set_default(\%config,'spam_crossassassin_mailbox',$config{spool_dir}.'/../mail/spam/crossassassinated.%Y-%m-%d');
939
940 =item spam_local_tests_only
941
942 Whether only local tests are run, defaults to 0
943
944 =cut
945
946 set_default(\%config,'spam_local_tests_only',0);
947
948 =item spam_user_prefs
949
950 User preferences for spamassassin, defaults to $ENV{HOME}/.spamassassin/user_prefs
951
952 =cut
953
954 set_default(\%config,'spam_user_prefs',"$ENV{HOME}/.spamassassin/user_prefs");
955
956 =item spam_rules_dir
957
958 Site rules directory for spamassassin, defaults to
959 '/usr/share/spamassassin'
960
961 =cut
962
963 set_default(\%config,'spam_rules_dir','/usr/share/spamassassin');
964
965 =back
966
967 =head2 CGI Options
968
969 =over
970
971 =item libravatar_uri $gLibravatarUri
972
973 URI to a libravatar configuration. If empty or undefined, libravatar
974 support will be disabled. Defaults to
975 libravatar.cgi, our internal federated libravatar system.
976
977 =cut
978
979 set_default(\%config,'libravatar_uri','http://'.$config{cgi_domain}.'/libravatar.cgi?email=');
980
981 =item libravatar_uri_options $gLibravatarUriOptions
982
983 Options to append to the md5_hex of the e-mail. This sets the default
984 avatar used when an avatar isn't available. Currently defaults to
985 '?d=retro', which causes a bitmap-looking avatar to be displayed for
986 unknown e-mails.
987
988 Other options which make sense include ?d=404, ?d=wavatar, etc. See
989 the API of libravatar for details.
990
991 =cut
992
993 set_default(\%config,'libravatar_uri_options','');
994
995 =item libravatar_default_image
996
997 Default image to serve for libravatar if there is no avatar for an
998 e-mail address. By default, this is a 1x1 png. [This will also be the
999 image served if someone specifies avatar=no.]
1000
1001 Default: $config{web_dir}/1x1.png
1002
1003 =cut
1004
1005 set_default(\%config,'libravatar_default_image',$config{web_dir}.'/1x1.png');
1006
1007 =item libravatar_cache_dir
1008
1009 Directory where cached libravatar images are stored
1010
1011 Default: $config{web_dir}/libravatar/
1012
1013 =cut
1014
1015 set_default(\%config,'libravatar_cache_dir',$config{web_dir}.'/libravatar/');
1016
1017 =item libravatar_blacklist
1018
1019 Array of regular expressions to match against emails, domains, or
1020 images to only show the default image
1021
1022 Default: empty array
1023
1024 =cut
1025
1026 set_default(\%config,'libravatar_blacklist',[]);
1027
1028 =back
1029
1030 =head2 Database
1031
1032 =over
1033
1034 =item debbugs_db
1035
1036 Name of debbugs PostgreSQL database service
1037
1038 =back
1039
1040 set_default(\%config,'debbugs_db',undef);
1041
1042 =head2 Text Fields
1043
1044 The following are the only text fields in general use in the scripts;
1045 a few additional text fields are defined in text.in, but are only used
1046 in db2html and a few other specialty scripts.
1047
1048 Earlier versions of debbugs defined these values in /etc/debbugs/text,
1049 but now they are required to be in the configuration file. [Eventually
1050 the longer ones will move out into a fully fledged template system.]
1051
1052 =cut
1053
1054 =over
1055
1056 =item bad_email_prefix
1057
1058 This prefixes the text of all lines in a bad e-mail message ack.
1059
1060 =cut
1061
1062 set_default(\%config,'bad_email_prefix','');
1063
1064
1065 =item text_instructions
1066
1067 This gives more information about bad e-mails to receive.in
1068
1069 =cut
1070
1071 set_default(\%config,'text_instructions',$config{bad_email_prefix});
1072
1073 =item html_tail
1074
1075 This shows up at the end of (most) html pages
1076
1077 In many pages this has been replaced by the html/tail template.
1078
1079 =cut
1080
1081 set_default(\%config,'html_tail',<<END);
1082  <ADDRESS>$config{maintainer} &lt;<A HREF=\"mailto:$config{maintainer_email}\">$config{maintainer_email}</A>&gt;.
1083  Last modified:
1084  <!--timestamp-->
1085  SUBSTITUTE_DTIME
1086  <!--timestamp-->
1087  <P>
1088  <A HREF=\"http://$config{web_domain}/\">Debian $config{bug} tracking system</A><BR>
1089  Copyright (C) 1999 Darren O. Benham,
1090  1997,2003 nCipher Corporation Ltd,
1091  1994-97 Ian Jackson.
1092  </ADDRESS>
1093 END
1094
1095
1096 =item html_expire_note
1097
1098 This message explains what happens to archive/remove-able bugs
1099
1100 =cut
1101
1102 set_default(\%config,'html_expire_note',
1103             "(Closed $config{bugs} are archived $config{remove_age} days after the last related message is received.)");
1104
1105 =back
1106
1107 =cut
1108
1109
1110 sub read_config{
1111      my ($conf_file) = @_;
1112      if (not -e $conf_file) {
1113          print STDERR "configuration file '$conf_file' doesn't exist; skipping it\n" if $DEBUG;
1114          return;
1115      }
1116      # first, figure out what type of file we're reading in.
1117      my $fh = new IO::File $conf_file,'r'
1118           or die "Unable to open configuration file $conf_file for reading: $!";
1119      # A new version configuration file must have a comment as its first line
1120      my $first_line = <$fh>;
1121      my ($version) = defined $first_line?$first_line =~ /VERSION:\s*(\d+)/i:undef;
1122      if (defined $version) {
1123           if ($version == 1) {
1124                # Do something here;
1125                die "Version 1 configuration files not implemented yet";
1126           }
1127           else {
1128                die "Version $version configuration files are not supported";
1129           }
1130      }
1131      else {
1132           # Ugh. Old configuration file
1133           # What we do here is we create a new Safe compartment
1134           # so fucked up crap in the config file doesn't sink us.
1135           my $cpt = new Safe or die "Unable to create safe compartment";
1136           # perldoc Opcode; for details
1137           $cpt->permit('require',':filesys_read','entereval','caller','pack','unpack','dofile');
1138           $cpt->reval(qq(require '$conf_file';));
1139           die "Error in configuration file: $@" if $@;
1140           # Now what we do is check out the contents of %EXPORT_TAGS to see exactly which variables
1141           # we want to glob in from the configuration file
1142           for my $variable (map {$_ =~ /^(?:config|all)$/ ? () : @{$EXPORT_TAGS{$_}}} keys %EXPORT_TAGS) {
1143                my ($hash_name,$glob_name,$glob_type) = __convert_name($variable);
1144                my $var_glob = $cpt->varglob($glob_name);
1145                my $value; #= $cpt->reval("return $variable");
1146                # print STDERR "$variable $value",qq(\n);
1147                if (defined $var_glob) {{
1148                     no strict 'refs';
1149                     if ($glob_type eq '%') {
1150                          $value = {%{*{$var_glob}}} if defined *{$var_glob}{HASH};
1151                     }
1152                     elsif ($glob_type eq '@') {
1153                          $value = [@{*{$var_glob}}] if defined *{$var_glob}{ARRAY};
1154                     }
1155                     else {
1156                          $value = ${*{$var_glob}};
1157                     }
1158                     # We punt here, because we can't tell if the value was
1159                     # defined intentionally, or if it was just left alone;
1160                     # this tries to set sane defaults.
1161                     set_default(\%config,$hash_name,$value) if defined $value;
1162                }}
1163           }
1164      }
1165 }
1166
1167 sub __convert_name{
1168      my ($variable) = @_;
1169      my $hash_name = $variable;
1170      $hash_name =~ s/^([\$\%\@])g//;
1171      my $glob_type = $1;
1172      my $glob_name = 'g'.$hash_name;
1173      $hash_name =~ s/(HTML|CGI|CVE)/ucfirst(lc($1))/ge;
1174      $hash_name =~ s/^([A-Z]+)/lc($1)/e;
1175      $hash_name =~ s/([A-Z]+)/'_'.lc($1)/ge;
1176      return $hash_name unless wantarray;
1177      return ($hash_name,$glob_name,$glob_type);
1178 }
1179
1180 # set_default
1181
1182 # sets the configuration hash to the default value if it's not set,
1183 # otherwise doesn't do anything
1184 # If $USING_GLOBALS, then sets an appropriate global.
1185
1186 sub set_default{
1187      my ($config,$option,$value) = @_;
1188      my $varname;
1189      if ($USING_GLOBALS) {
1190           # fix up the variable name
1191           $varname = 'g'.join('',map {ucfirst $_} split /_/, $option);
1192           # Fix stupid HTML names
1193           $varname =~ s/(Html|Cgi)/uc($1)/ge;
1194      }
1195      # update the configuration value
1196      if (not $USING_GLOBALS and not exists $config->{$option}) {
1197           $config->{$option} = $value;
1198      }
1199      elsif ($USING_GLOBALS) {{
1200           no strict 'refs';
1201           # Need to check if a value has already been set in a global
1202           if (defined *{"Debbugs::Config::${varname}"}) {
1203                $config->{$option} = *{"Debbugs::Config::${varname}"};
1204           }
1205           else {
1206                $config->{$option} = $value;
1207           }
1208      }}
1209      if ($USING_GLOBALS) {{
1210           no strict 'refs';
1211           *{"Debbugs::Config::${varname}"} = $config->{$option};
1212      }}
1213 }
1214
1215
1216 ### import magick
1217
1218 # All we care about here is whether we've been called with the globals or text option;
1219 # if so, then we need to export some symbols back up.
1220 # In any event, we call exporter.
1221
1222 sub import {
1223      if (grep /^:(?:text|globals)$/, @_) {
1224           $USING_GLOBALS=1;
1225           for my $variable (map {@$_} @EXPORT_TAGS{map{(/^:(text|globals)$/?($1):())} @_}) {
1226                my $tmp = $variable;
1227                no strict 'refs';
1228                # Yes, I don't care if these are only used once
1229                no warnings 'once';
1230                # No, it doesn't bother me that I'm assigning an undefined value to a typeglob
1231                no warnings 'misc';
1232                my ($hash_name,$glob_name,$glob_type) = __convert_name($variable);
1233                $tmp =~ s/^[\%\$\@]//;
1234                *{"Debbugs::Config::${tmp}"} = ref($config{$hash_name})?$config{$hash_name}:\$config{$hash_name};
1235           }
1236      }
1237      Debbugs::Config->export_to_level(1,@_);
1238 }
1239
1240
1241 1;