]> git.donarmstrong.com Git - debbugs.git/blob - Debbugs/Config.pm
* Add obsolete_severities option which was missing
[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($gPackageVersionRe),
54                                  qw($gSummaryList $gMirrorList $gMailer $gBug),
55                                  qw($gBugs $gRemoveAge $gSaveOldBugs $gDefaultSeverity),
56                                  qw($gShowSeverities $gBounceFroms $gConfigDir $gSpoolDir),
57                                  qw($gIncomingDir $gWebDir $gDocDir $gMaintainerFile),
58                                  qw($gMaintainerFileOverride $gPseudoMaintFile $gPseudoDescFile $gPackageSource),
59                                  qw($gVersionPackagesDir $gVersionIndex $gBinarySourceMap $gSourceBinaryMap),
60                                  qw($gVersionTimeIndex),
61                                  qw($gSendmail $gLibPath $gSpamScan @gExcludeFromControl),
62                                  qw(%gSeverityDisplay @gTags @gSeverityList @gStrongSeverities),
63                                  qw(%gSearchEstraier),
64                                  qw(%gDistributionAliases),
65                                  qw(%gObsoleteSeverities),
66                                  qw(@gPostProcessall @gRemovalDefaultDistributionTags @gRemovalDistributionTags @gRemovalArchitectures),
67                                  qw(@gRemovalStrongSeverityDefaultDistributionTags),
68                                  qw(@gDefaultArchitectures),
69                                  qw($gTemplateDir),
70                                  qw($gDefaultPackage),
71                                  qw($gSpamMaxThreads $gSpamSpamsPerThread $gSpamKeepRunning $gSpamScan $gSpamCrossassassinDb),
72                                 ],
73                      text     => [qw($gBadEmailPrefix $gHTMLTail $gHTMLExpireNote),
74                                  ],
75                      config   => [qw(%config)],
76                     );
77      @EXPORT_OK = ();
78      Exporter::export_ok_tags(qw(globals text config));
79      $EXPORT_TAGS{all} = [@EXPORT_OK];
80      $ENV{HOME} = '' if not defined $ENV{HOME};
81 }
82
83 use File::Basename qw(dirname);
84 use IO::File;
85 use Safe;
86
87 =head1 CONFIGURATION VARIABLES
88
89 =head2 General Configuration
90
91 =over
92
93 =cut
94
95 # read in the files;
96 %config = ();
97 # untaint $ENV{DEBBUGS_CONFIG_FILE} if it's owned by us
98 # This enables us to test things that are -T.
99 if (exists $ENV{DEBBUGS_CONFIG_FILE}) {
100      if (${[stat($ENV{DEBBUGS_CONFIG_FILE})]}[4] = $<) {
101           $ENV{DEBBUGS_CONFIG_FILE} =~ /(.+)/;
102           $ENV{DEBBUGS_CONFIG_FILE} = $1;
103      }
104      else {
105           die "Environmental variable DEBBUGS_CONFIG_FILE set, and $ENV{DEBBUGS_CONFIG_FILE} is not owned by the user running this script.";
106      }
107 }
108 read_config(exists $ENV{DEBBUGS_CONFIG_FILE}?$ENV{DEBBUGS_CONFIG_FILE}:'/etc/debbugs/config');
109
110 =item email_domain $gEmailDomain
111
112 The email domain of the bts
113
114 =cut
115
116 set_default(\%config,'email_domain','bugs.something');
117
118 =item list_domain $gListDomain
119
120 The list domain of the bts, defaults to the email domain
121
122 =cut
123
124 set_default(\%config,'list_domain',$config{email_domain});
125
126 =item web_host $gWebHost
127
128 The web host of the bts; defaults to the email domain
129
130 =cut
131
132 set_default(\%config,'web_host',$config{email_domain});
133
134 =item web_host_bug_dir $gWebHostDir
135
136 The directory of the web host on which bugs are kept, defaults to C<''>
137
138 =cut
139
140 set_default(\%config,'web_host_bug_dir','');
141
142 =item web_domain $gWebDomain
143
144 Full path of the web domain where bugs are kept, defaults to the
145 concatenation of L</web_host> and L</web_host_bug_dir>
146
147 =cut
148
149 set_default(\%config,'web_domain',$config{web_host}.($config{web_host}=~m{/$}?'':'/').$config{web_host_bug_dir});
150
151 =item html_suffix $gHTMLSuffix
152
153 Suffix of html pages, defaults to .html
154
155 =cut
156
157 set_default(\%config,'html_suffix','.html');
158
159 =item cgi_domain $gCGIDomain
160
161 Full path of the web domain where cgi scripts are kept. Defaults to
162 the concatentation of L</web_host> and cgi.
163
164 =cut
165
166 set_default(\%config,'cgi_domain',$config{web_domain}.($config{web_domain}=~m{/$}?'':'/').'cgi');
167
168 =item mirrors @gMirrors
169
170 List of mirrors [What these mirrors are used for, no one knows.]
171
172 =cut
173
174
175 set_default(\%config,'mirrors',[]);
176
177 =item package_pages  $gPackagePages
178
179 Domain where the package pages are kept; links should work in a
180 package_pages/foopackage manner. Defaults to undef, which means that
181 package links will not be made.
182
183 =cut
184
185
186 set_default(\%config,'package_pages',undef);
187
188 =item package_pages  $gUsertagPackageDomain
189
190 Domain where where usertags of packages belong; defaults to $gPackagePages
191
192 =cut
193
194 set_default(\%config,'usertag_package_domain',$config{package_pages});
195
196
197 =item subscription_domain $gSubscriptionDomain
198
199 Domain where subscriptions to package lists happen
200
201 =cut
202
203
204 set_default(\%config,'subscription_domain',undef);
205
206 =back
207
208 =cut
209
210
211 =head2 Project Identification
212
213 =over
214
215 =item project $gProject
216
217 Name of the project
218
219 Default: 'Something'
220
221 =cut
222
223 set_default(\%config,'project','Something');
224
225 =item project_title $gProjectTitle
226
227 Name of this install of Debbugs, defaults to "L</project> Debbugs Install"
228
229 Default: "$config{project} Debbugs Install"
230
231 =cut
232
233 set_default(\%config,'project_title',"$config{project} Debbugs Install");
234
235 =item maintainer $gMaintainer
236
237 Name of the maintainer of this debbugs install
238
239 Default: 'Local DebBugs Owner's
240
241 =cut
242
243 set_default(\%config,'maintainer','Local DebBugs Owner');
244
245 =item maintainer_webpage $gMaintainerWebpage
246
247 Webpage of the maintainer of this install of debbugs
248
249 Default: "$config{web_domain}/~owner"
250
251 =cut
252
253 set_default(\%config,'maintainer_webpage',"$config{web_domain}/~owner");
254
255 =item maintainer_email $gMaintainerEmail
256
257 Email address of the maintainer of this Debbugs install
258
259 Default: 'root@'.$config{email_domain}
260
261 =cut
262
263 set_default(\%config,'maintainer_email','root@'.$config{email_domain});
264
265 =item unknown_maintainer_email
266
267 Email address where packages with an unknown maintainer will be sent
268
269 Default: $config{maintainer_email}
270
271 =back
272
273 =cut
274
275 set_default(\%config,'unknown_maintainer_email',$config{maintainer_email});
276
277 =head2 BTS Mailing Lists
278
279
280 =over
281
282 =item submit_list
283
284 =item maint_list
285
286 =item forward_list
287
288 =item done_list
289
290 =item request_list
291
292 =item submitter_list
293
294 =item control_list
295
296 =item summary_list
297
298 =item mirror_list
299
300 =back
301
302 =cut
303
304 set_default(\%config,   'submit_list',   'bug-submit-list');
305 set_default(\%config,    'maint_list',    'bug-maint-list');
306 set_default(\%config,    'quiet_list',    'bug-quiet-list');
307 set_default(\%config,  'forward_list',  'bug-forward-list');
308 set_default(\%config,     'done_list',     'bug-done-list');
309 set_default(\%config,  'request_list',  'bug-request-list');
310 set_default(\%config,'submitter_list','bug-submitter-list');
311 set_default(\%config,  'control_list',  'bug-control-list');
312 set_default(\%config,  'summary_list',  'bug-summary-list');
313 set_default(\%config,   'mirror_list',   'bug-mirror-list');
314 set_default(\%config,   'strong_list',   'bug-strong-list');
315
316 =head2 Misc Options
317
318 =over
319
320 =cut
321
322 set_default(\%config,'mailer','exim');
323 set_default(\%config,'bug','bug');
324 set_default(\%config,'bugs','bugs');
325
326 =item remove_age
327
328 Age at which bugs are archived/removed
329
330 Default: 28
331
332 =cut
333
334 set_default(\%config,'remove_age',28);
335
336 =item save_old_bugs
337
338 Whether old bugs are saved or deleted
339
340 Default: 1
341
342 =cut
343
344 set_default(\%config,'save_old_bugs',1);
345
346 =item distribution_aliases
347
348 Map of distribution aliases to the distribution name
349
350 Default:
351          {experimental => 'experimental',
352           unstable     => 'unstable',
353           testing      => 'testing',
354           stable       => 'stable',
355           oldstable    => 'oldstable',
356           sid          => 'unstable',
357           lenny        => 'testing',
358           etch         => 'stable',
359           sarge        => 'oldstable',
360          }
361
362 =cut
363
364 set_default(\%config,'distribution_aliases',
365             {experimental => 'experimental',
366              unstable     => 'unstable',
367              testing      => 'testing',
368              stable       => 'stable',
369              oldstable    => 'oldstable',
370              sid          => 'unstable',
371              lenny        => 'testing',
372              etch         => 'stable',
373              sarge        => 'oldstable',
374             },
375            );
376
377
378
379 =item distributions
380
381 List of valid distributions
382
383 Default: The values of the distribution aliases map.
384
385 =cut
386
387 my %_distributions_default;
388 @_distributions_default{values %{$config{distribution_aliases}}} = values %{$config{distribution_aliases}};
389 set_default(\%config,'distributions',[keys %_distributions_default]);
390
391
392 =item default_architectures
393
394 List of default architectures to use when architecture(s) are not
395 specified
396
397 Default: i386 amd64 arm ppc sparc alpha
398
399 =cut
400
401 set_default(\%config,'default_architectures',
402             [qw(i386 amd64 arm powerpc sparc alpha)]
403            );
404
405 =item removal_unremovable_tags
406
407 Bugs which have these tags set cannot be archived
408
409 Default: []
410
411 =cut
412
413 set_default(\%config,'removal_unremovable_tags',
414             [],
415            );
416
417 =item removal_distribution_tags
418
419 Tags which specifiy distributions to check
420
421 Default: @{$config{distributions}}
422
423 =cut
424
425 set_default(\%config,'removal_distribution_tags',
426             [@{$config{distributions}}]);
427
428 =item removal_default_distribution_tags
429
430 For removal/archival purposes, all bugs are assumed to have these tags
431 set.
432
433 Default: qw(unstable testing);
434
435 =cut
436
437 set_default(\%config,'removal_default_distribution_tags',
438             [qw(unstable testing)]
439            );
440
441 =item removal_strong_severity_default_distribution_tags
442
443 For removal/archival purposes, all bugs with strong severity are
444 assumed to have these tags set.
445
446 Default: qw(unstable testing stable);
447
448 =cut
449
450 set_default(\%config,'removal_strong_severity_default_distribution_tags',
451             [qw(unstable testing stable)]
452            );
453
454
455 =item removal_architectures
456
457 For removal/archival purposes, these architectures are consulted if
458 there is more than one architecture applicable. If the bug is in a
459 package not in any of these architectures, the architecture actually
460 checked is undefined.
461
462 Default: value of default_architectures
463
464 =cut
465
466 set_default(\%config,'removal_architectures',
467             $config{default_architectures},
468            );
469
470
471 =item package_name_re
472
473 The regex which will match a package name
474
475 Default: '[a-z0-9][a-z0-9\.+-]+'
476
477 =cut
478
479 set_default(\%config,'package_name_re',
480             '[a-z0-9][a-z0-9\.+-]+');
481
482 =item package_version_re
483
484 The regex which will match a package version
485
486 Default: '[A-Za-z0-9:+\.-]+'
487
488 =cut
489
490
491 set_default(\%config,'package_version_re',
492             '[A-Za-z0-9:+\.~-]+');
493
494
495 =item default_package
496
497 This is the name of the default package. If set, bugs assigned to
498 packages without a maintainer and bugs missing a Package: psuedoheader
499 will be assigned to this package instead.
500
501 Defaults to unset, which is the traditional debbugs behavoir
502
503 =cut
504
505 set_default(\%config,'default_package',
506             undef
507            );
508
509
510 =item control_internal_requester
511
512 This address is used by Debbugs::Control as the request address which
513 sent a control request for faked log messages.
514
515 Default:"Debbugs Internal Request <$config{maintainer_email}>"
516
517 =cut
518
519 set_default(\%config,'control_internal_requester',
520             "Debbugs Internal Request <$config{maintainer_email}>",
521            );
522
523 =item control_internal_request_addr
524
525 This address is used by Debbugs::Control as the address to which a
526 faked log message request was sent.
527
528 Default: "internal_control\@$config{email_domain}";
529
530 =cut
531
532 set_default(\%config,'control_internal_request_addr',
533             'internal_control@'.$config{email_domain},
534            );
535
536
537 =item exclude_from_control
538
539 Addresses which are not allowed to send messages to control
540
541 =cut
542
543 set_default(\%config,'exclude_from_control',[]);
544
545
546
547 =item default_severity
548
549 The default severity of bugs which have no severity set
550
551 Default: normal
552
553 =cut
554
555 set_default(\%config,'default_severity','normal');
556
557 =item severity_display
558
559 A hashref of severities and the informative text which describes them.
560
561 Default:
562
563  {critical => "Critical $config{bugs}",
564   grave    => "Grave $config{bugs}",
565   normal   => "Normal $config{bugs}",
566   wishlist => "Wishlist $config{bugs}",
567  }
568
569 =cut
570
571 set_default(\%config,'severity_display',{critical => "Critical $config{bugs}",
572                                          grave    => "Grave $config{bugs}",
573                                          normal   => "Normal $config{bugs}",
574                                          wishlist => "Wishlist $config{bugs}",
575                                         });
576
577 =item show_severities
578
579 A scalar list of the severities to show
580
581 Defaults to the concatenation of the keys of the severity_display
582 hashlist with ', ' above.
583
584 =cut
585
586 set_default(\%config,'show_severities',join(', ',keys %{$config{severity_display}}));
587
588 =item strong_severities
589
590 An arrayref of the serious severities which shoud be emphasized
591
592 Default: [qw(critical grave)]
593
594 =cut
595
596 set_default(\%config,'strong_severities',[qw(critical grave)]);
597
598 =item severity_list
599
600 An arrayref of a list of the severities
601
602 Defaults to the keys of the severity display hashref
603
604 =cut
605
606 set_default(\%config,'severity_list',[keys %{$config{severity_display}}]);
607
608 =item obsolete_severities
609
610 A hashref of obsolete severities with the replacing severity
611
612 Default: {}
613
614 =cut
615
616 set_default(\%config,'obsolete_severities',{});
617
618 =item tags
619
620 An arrayref of the tags used
621
622 Default: [qw(patch wontfix moreinfo unreproducible fixed)] and also
623 includes the distributions.
624
625 =cut
626
627 set_default(\%config,'tags',[qw(patch wontfix moreinfo unreproducible fixed),
628                              @{$config{distributions}}
629                             ]);
630
631 set_default(\%config,'bounce_froms','^mailer|^da?emon|^post.*mast|^root|^wpuser|^mmdf|^smt.*|'.
632             '^mrgate|^vmmail|^mail.*system|^uucp|-maiser-|^mal\@|'.
633             '^mail.*agent|^tcpmail|^bitmail|^mailman');
634
635 set_default(\%config,'config_dir',dirname(exists $ENV{DEBBUGS_CONFIG_FILE}?$ENV{DEBBUGS_CONFIG_FILE}:'/etc/debbugs/config'));
636 set_default(\%config,'spool_dir','/var/lib/debbugs/spool');
637
638 =item usertag_dir
639
640 Directory which contains the usertags
641
642 Default: $config{spool_dir}/user
643
644 =cut
645
646 set_default(\%config,'usertag_dir',$config{spool_dir}.'/user');
647 set_default(\%config,'incoming_dir','incoming');
648 set_default(\%config,'web_dir','/var/lib/debbugs/www');
649 set_default(\%config,'doc_dir','/var/lib/debbugs/www/txt');
650 set_default(\%config,'lib_path','/usr/lib/debbugs');
651
652
653 =item template_dir
654
655 directory of templates; defaults to /usr/share/debbugs/templates.
656
657 =cut
658
659 set_default(\%config,'template_dir','/usr/share/debbugs/templates');
660
661
662 set_default(\%config,'maintainer_file',$config{config_dir}.'/Maintainers');
663 set_default(\%config,'maintainer_file_override',$config{config_dir}.'/Maintainers.override');
664 set_default(\%config,'pseudo_maint_file',$config{config_dir}.'/pseudo-packages.maint');
665 set_default(\%config,'pseudo_desc_file',$config{config_dir}.'/pseudo-packages.description');
666 set_default(\%config,'package_source',$config{config_dir}.'/indices/sources');
667
668
669 =item version_packages_dir
670
671 Location where the version package information is kept; defaults to
672 spool_dir/../versions/pkg
673
674 =cut
675
676 set_default(\%config,'version_packages_dir',$config{spool_dir}.'/../versions/pkg');
677
678 =item version_time_index
679
680 Location of the version/time index file. Defaults to
681 spool_dir/../versions/idx/versions_time.idx if spool_dir/../versions
682 exists; otherwise defaults to undef.
683
684 =cut
685
686
687 set_default(\%config,'version_time_index', -d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/versions_time.idx' : undef);
688
689 =item version_index
690
691 Location of the version index file. Defaults to
692 spool_dir/../versions/indices/versions.idx if spool_dir/../versions
693 exists; otherwise defaults to undef.
694
695 =cut
696
697 set_default(\%config,'version_index',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/versions.idx' : undef);
698
699 =item binary_source_map
700
701 Location of the binary -> source map. Defaults to
702 spool_dir/../versions/indices/bin2src.idx if spool_dir/../versions
703 exists; otherwise defaults to undef.
704
705 =cut
706
707 set_default(\%config,'binary_source_map',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/binsrc.idx' : undef);
708
709 =item source_binary_map
710
711 Location of the source -> binary map. Defaults to
712 spool_dir/../versions/indices/src2bin.idx if spool_dir/../versions
713 exists; otherwise defaults to undef.
714
715 =cut
716
717 set_default(\%config,'source_binary_map',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/srcbin.idx' : undef);
718
719
720
721 set_default(\%config,'post_processall',[]);
722
723 =item sendmail
724
725 Sets the sendmail binary to execute; defaults to /usr/lib/sendmail
726
727 =cut
728
729 set_default(\%config,'sendmail','/usr/lib/sendmail');
730
731 =item spam_scan
732
733 Whether or not spamscan is being used; defaults to 0 (not being used
734
735 =cut
736
737 set_default(\%config,'spam_scan',0);
738
739 =item spam_crossassassin_db
740
741 Location of the crosassassin database, defaults to
742 spool_dir/../CrossAssassinDb
743
744 =cut
745
746 set_default(\%config,'spam_crossassassin_db',$config{spool_dir}.'/../CrossAssassinDb');
747
748 =item spam_max_cross
749
750 Maximum number of cross-posted messages
751
752 =cut
753
754 set_default(\%config,'spam_max_cross',6);
755
756
757 =item spam_spams_per_thread
758
759 Number of spams for each thread (on average). Defaults to 200
760
761 =cut
762
763 set_default(\%config,'spam_spams_per_thread',200);
764
765 =item spam_max_threads
766
767 Maximum number of threads to start. Defaults to 20
768
769 =cut
770
771 set_default(\%config,'spam_max_threads',20);
772
773 =item spam_keep_running
774
775 Maximum number of seconds to run without restarting. Defaults to 3600.
776
777 =cut
778
779 set_default(\%config,'spam_keep_running',3600);
780
781 =item spam_mailbox
782
783 Location to store spam messages; is run through strftime to allow for
784 %d,%m,%Y, et al. Defaults to 'spool_dir/../mail/spam/assassinated.%Y-%m-%d'
785
786 =cut
787
788 set_default(\%config,'spam_mailbox',$config{spool_dir}.'/../mail/spam/assassinated.%Y-%m-%d');
789
790 =item spam_crossassassin_mailbox
791
792 Location to store crossassassinated messages; is run through strftime
793 to allow for %d,%m,%Y, et al. Defaults to
794 'spool_dir/../mail/spam/crossassassinated.%Y-%m-%d'
795
796 =cut
797
798 set_default(\%config,'spam_crossassassin_mailbox',$config{spool_dir}.'/../mail/spam/crossassassinated.%Y-%m-%d');
799
800 =item spam_local_tests_only
801
802 Whether only local tests are run, defaults to 0
803
804 =cut
805
806 set_default(\%config,'spam_local_tests_only',0);
807
808 =item spam_user_prefs
809
810 User preferences for spamassassin, defaults to $ENV{HOME}/.spamassassin/user_prefs
811
812 =cut
813
814 set_default(\%config,'spam_user_prefs',"$ENV{HOME}/.spamassassin/user_prefs");
815
816 =item spam_rules_dir
817
818 Site rules directory for spamassassin, defaults to
819 '/usr/share/spamassassin'
820
821 =cut
822
823 set_default(\%config,'spam_rules_dir','/usr/share/spamassassin');
824
825 =back
826
827
828 =head2 Text Fields
829
830 The following are the only text fields in general use in the scripts;
831 a few additional text fields are defined in text.in, but are only used
832 in db2html and a few other specialty scripts.
833
834 Earlier versions of debbugs defined these values in /etc/debbugs/text,
835 but now they are required to be in the configuration file. [Eventually
836 the longer ones will move out into a fully fledged template system.]
837
838 =cut
839
840 =over
841
842 =item bad_email_prefix
843
844 This prefixes the text of all lines in a bad e-mail message ack.
845
846 =cut
847
848 set_default(\%config,'bad_email_prefix','');
849
850
851 =item text_instructions
852
853 This gives more information about bad e-mails to receive.in
854
855 =cut
856
857 set_default(\%config,'text_instructions',$config{bad_email_prefix});
858
859 =item html_tail
860
861 This shows up at the end of (most) html pages
862
863 In many pages this has been replaced by the html/tail template.
864
865 =cut
866
867 set_default(\%config,'html_tail',<<END);
868  <ADDRESS>$config{maintainer} &lt;<A HREF=\"mailto:$config{maintainer_email}\">$config{maintainer_email}</A>&gt;.
869  Last modified:
870  <!--timestamp-->
871  SUBSTITUTE_DTIME
872  <!--timestamp-->
873  <P>
874  <A HREF=\"http://$config{web_domain}/\">Debian $config{bug} tracking system</A><BR>
875  Copyright (C) 1999 Darren O. Benham,
876  1997,2003 nCipher Corporation Ltd,
877  1994-97 Ian Jackson.
878  </ADDRESS>
879 END
880
881
882 =item html_expire_note
883
884 This message explains what happens to archive/remove-able bugs
885
886 =cut
887
888 set_default(\%config,'html_expire_note',
889             "(Closed $config{bugs} are archived $config{remove_age} days after the last related message is received.)");
890
891 =back
892
893 =cut
894
895
896 sub read_config{
897      my ($conf_file) = @_;
898      # first, figure out what type of file we're reading in.
899      my $fh = new IO::File $conf_file,'r'
900           or die "Unable to open configuration file $conf_file for reading: $!";
901      # A new version configuration file must have a comment as its first line
902      my $first_line = <$fh>;
903      my ($version) = defined $first_line?$first_line =~ /VERSION:\s*(\d+)/i:undef;
904      if (defined $version) {
905           if ($version == 1) {
906                # Do something here;
907                die "Version 1 configuration files not implemented yet";
908           }
909           else {
910                die "Version $version configuration files are not supported";
911           }
912      }
913      else {
914           # Ugh. Old configuration file
915           # What we do here is we create a new Safe compartment
916           # so fucked up crap in the config file doesn't sink us.
917           my $cpt = new Safe or die "Unable to create safe compartment";
918           # perldoc Opcode; for details
919           $cpt->permit('require',':filesys_read','entereval','caller','pack','unpack','dofile');
920           $cpt->reval(qq(require '$conf_file';));
921           die "Error in configuration file: $@" if $@;
922           # Now what we do is check out the contents of %EXPORT_TAGS to see exactly which variables
923           # we want to glob in from the configuration file
924           for my $variable (@{$EXPORT_TAGS{globals}}) {
925                my ($hash_name,$glob_name,$glob_type) = __convert_name($variable);
926                my $var_glob = $cpt->varglob($glob_name);
927                my $value; #= $cpt->reval("return $variable");
928                # print STDERR "$variable $value",qq(\n);
929                if (defined $var_glob) {{
930                     no strict 'refs';
931                     if ($glob_type eq '%') {
932                          $value = {%{*{$var_glob}}} if defined *{$var_glob}{HASH};
933                     }
934                     elsif ($glob_type eq '@') {
935                          $value = [@{*{$var_glob}}] if defined *{$var_glob}{ARRAY};
936                     }
937                     else {
938                          $value = ${*{$var_glob}};
939                     }
940                     # We punt here, because we can't tell if the value was
941                     # defined intentionally, or if it was just left alone;
942                     # this tries to set sane defaults.
943                     set_default(\%config,$hash_name,$value) if defined $value;
944                }}
945           }
946      }
947 }
948
949 sub __convert_name{
950      my ($variable) = @_;
951      my $hash_name = $variable;
952      $hash_name =~ s/^([\$\%\@])g//;
953      my $glob_type = $1;
954      my $glob_name = 'g'.$hash_name;
955      $hash_name =~ s/(HTML|CGI)/ucfirst(lc($1))/ge;
956      $hash_name =~ s/^([A-Z]+)/lc($1)/e;
957      $hash_name =~ s/([A-Z]+)/'_'.lc($1)/ge;
958      return $hash_name unless wantarray;
959      return ($hash_name,$glob_name,$glob_type);
960 }
961
962 # set_default
963
964 # sets the configuration hash to the default value if it's not set,
965 # otherwise doesn't do anything
966 # If $USING_GLOBALS, then sets an appropriate global.
967
968 sub set_default{
969      my ($config,$option,$value) = @_;
970      my $varname;
971      if ($USING_GLOBALS) {
972           # fix up the variable name
973           $varname = 'g'.join('',map {ucfirst $_} split /_/, $option);
974           # Fix stupid HTML names
975           $varname =~ s/(Html|Cgi)/uc($1)/ge;
976      }
977      # update the configuration value
978      if (not $USING_GLOBALS and not exists $config->{$option}) {
979           $config->{$option} = $value;
980      }
981      elsif ($USING_GLOBALS) {{
982           no strict 'refs';
983           # Need to check if a value has already been set in a global
984           if (defined *{"Debbugs::Config::${varname}"}) {
985                $config->{$option} = *{"Debbugs::Config::${varname}"};
986           }
987           else {
988                $config->{$option} = $value;
989           }
990      }}
991      if ($USING_GLOBALS) {{
992           no strict 'refs';
993           *{"Debbugs::Config::${varname}"} = $config->{$option};
994      }}
995 }
996
997
998 ### import magick
999
1000 # All we care about here is whether we've been called with the globals or text option;
1001 # if so, then we need to export some symbols back up.
1002 # In any event, we call exporter.
1003
1004 sub import {
1005      if (grep /^:(?:text|globals)$/, @_) {
1006           $USING_GLOBALS=1;
1007           for my $variable (map {@$_} @EXPORT_TAGS{map{(/^:(text|globals)$/?($1):())} @_}) {
1008                my $tmp = $variable;
1009                no strict 'refs';
1010                # Yes, I don't care if these are only used once
1011                no warnings 'once';
1012                # No, it doesn't bother me that I'm assigning an undefined value to a typeglob
1013                no warnings 'misc';
1014                my ($hash_name,$glob_name,$glob_type) = __convert_name($variable);
1015                $tmp =~ s/^[\%\$\@]//;
1016                *{"Debbugs::Config::${tmp}"} = ref($config{$hash_name})?$config{$hash_name}:\$config{$hash_name};
1017           }
1018      }
1019      Debbugs::Config->export_to_level(1,@_);
1020 }
1021
1022
1023 1;