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.
6 # Copyright 2007 by Don Armstrong <don@donarmstrong.com>.
8 package Debbugs::Config;
12 Debbugs::Config -- Configuration information for debbugs
18 # to get the compatiblity interface
20 use Debbugs::Config qw(:globals);
24 This module provides configuration variables for all of debbugs.
26 =head1 CONFIGURATION FILES
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.
36 use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT $USING_GLOBALS %config);
37 use base qw(Exporter);
40 # set the version for version checking
42 $DEBUG = 0 unless defined $DEBUG;
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),
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),
64 qw($gSendmail @gSendmailArguments $gLibPath $gSpamScan @gExcludeFromControl),
65 qw(%gSeverityDisplay @gTags @gSeverityList @gStrongSeverities),
66 qw(%gTagsSingleLetter),
68 qw(%gDistributionAliases),
69 qw(%gObsoleteSeverities),
70 qw(@gPostProcessall @gRemovalDefaultDistributionTags @gRemovalDistributionTags @gRemovalArchitectures),
71 qw(@gRemovalStrongSeverityDefaultDistributionTags),
72 qw(@gAffectsDistributionTags),
73 qw(@gDefaultArchitectures),
77 qw($gSpamMaxThreads $gSpamSpamsPerThread $gSpamKeepRunning $gSpamScan $gSpamCrossassassinDb),
80 text => [qw($gBadEmailPrefix $gHTMLTail $gHTMLExpireNote),
82 cgi => [qw($gLibravatarUri $gLibravatarCacheDir $gLibravatarUriOptions @gLibravatarBlacklist)],
83 config => [qw(%config)],
86 Exporter::export_ok_tags(keys %EXPORT_TAGS);
87 $EXPORT_TAGS{all} = [@EXPORT_OK];
88 $ENV{HOME} = '' if not defined $ENV{HOME};
92 use File::Basename qw(dirname);
96 =head1 CONFIGURATION VARIABLES
98 =head2 General Configuration
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
111 # if (${[stat($ENV{DEBBUGS_CONFIG_FILE})]}[4] == $<) {
112 $ENV{DEBBUGS_CONFIG_FILE} =~ /(.+)/;
113 $ENV{DEBBUGS_CONFIG_FILE} = $1;
116 # die "Environmental variable DEBBUGS_CONFIG_FILE set, and $ENV{DEBBUGS_CONFIG_FILE} is not owned by the user running this script.";
119 read_config(exists $ENV{DEBBUGS_CONFIG_FILE}?$ENV{DEBBUGS_CONFIG_FILE}:'/etc/debbugs/config');
121 =item email_domain $gEmailDomain
123 The email domain of the bts
127 set_default(\%config,'email_domain','bugs.something');
129 =item list_domain $gListDomain
131 The list domain of the bts, defaults to the email domain
135 set_default(\%config,'list_domain',$config{email_domain});
137 =item web_host $gWebHost
139 The web host of the bts; defaults to the email domain
143 set_default(\%config,'web_host',$config{email_domain});
145 =item web_host_bug_dir $gWebHostDir
147 The directory of the web host on which bugs are kept, defaults to C<''>
151 set_default(\%config,'web_host_bug_dir','');
153 =item web_domain $gWebDomain
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>
160 set_default(\%config,'web_domain',$config{web_host}.($config{web_host}=~m{/$}?'':'/').$config{web_host_bug_dir});
162 =item html_suffix $gHTMLSuffix
164 Suffix of html pages, defaults to .html
168 set_default(\%config,'html_suffix','.html');
170 =item cgi_domain $gCGIDomain
172 Full path of the web domain where cgi scripts are kept. Defaults to
173 the concatentation of L</web_host> and cgi.
177 set_default(\%config,'cgi_domain',$config{web_domain}.($config{web_domain}=~m{/$}?'':'/').'cgi');
179 =item mirrors @gMirrors
181 List of mirrors [What these mirrors are used for, no one knows.]
186 set_default(\%config,'mirrors',[]);
188 =item package_pages $gPackagePages
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.
197 set_default(\%config,'package_pages',undef);
199 =item package_pages $gUsertagPackageDomain
201 Domain where where usertags of packages belong; defaults to $gPackagePages
205 set_default(\%config,'usertag_package_domain',$config{package_pages});
208 =item subscription_domain $gSubscriptionDomain
210 Domain where subscriptions to package lists happen
214 set_default(\%config,'subscription_domain',undef);
217 =item cve_tracker $gCVETracker
219 URI to CVE security tracker; in bugreport.cgi, CVE-2001-0002 becomes
220 linked to http://$config{cve_tracker}CVE-2001-002
222 Default: security-tracker.debian.org/tracker/
226 set_default(\%config,'cve_tracker','security-tracker.debian.org/tracker/');
234 =head2 Project Identification
238 =item project $gProject
246 set_default(\%config,'project','Something');
248 =item project_title $gProjectTitle
250 Name of this install of Debbugs, defaults to "L</project> Debbugs Install"
252 Default: "$config{project} Debbugs Install"
256 set_default(\%config,'project_title',"$config{project} Debbugs Install");
258 =item maintainer $gMaintainer
260 Name of the maintainer of this debbugs install
262 Default: 'Local DebBugs Owner's
266 set_default(\%config,'maintainer','Local DebBugs Owner');
268 =item maintainer_webpage $gMaintainerWebpage
270 Webpage of the maintainer of this install of debbugs
272 Default: "$config{web_domain}/~owner"
276 set_default(\%config,'maintainer_webpage',"$config{web_domain}/~owner");
278 =item maintainer_email $gMaintainerEmail
280 Email address of the maintainer of this Debbugs install
282 Default: 'root@'.$config{email_domain}
286 set_default(\%config,'maintainer_email','root@'.$config{email_domain});
288 =item unknown_maintainer_email
290 Email address where packages with an unknown maintainer will be sent
292 Default: $config{maintainer_email}
296 set_default(\%config,'unknown_maintainer_email',$config{maintainer_email});
300 The name of the machine that this instance of debbugs is running on
301 (currently used for debbuging purposes and web page output.)
303 Default: Sys::Hostname::hostname()
309 set_default(\%config,'machine_name',Sys::Hostname::hostname());
311 =head2 BTS Mailing Lists
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');
350 =item bug_subscription_domain
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.
362 set_default(\%config,'bug_subscription_domain',$config{list_domain});
372 Name of the mailer to use
378 set_default(\%config,'mailer','exim');
387 Default: ucfirst($config{bug});
395 Default: ucfirst($config{ubugs});
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}));
406 Age at which bugs are archived/removed
412 set_default(\%config,'remove_age',28);
416 Whether old bugs are saved or deleted
422 set_default(\%config,'save_old_bugs',1);
424 =item distribution_aliases
426 Map of distribution aliases to the distribution name
429 {experimental => 'experimental',
430 unstable => 'unstable',
431 testing => 'testing',
433 oldstable => 'oldstable',
437 sarge => 'oldstable',
442 set_default(\%config,'distribution_aliases',
443 {experimental => 'experimental',
444 unstable => 'unstable',
445 testing => 'testing',
447 oldstable => 'oldstable',
451 sarge => 'oldstable',
459 List of valid distributions
461 Default: The values of the distribution aliases map.
465 my %_distributions_default;
466 @_distributions_default{values %{$config{distribution_aliases}}} = values %{$config{distribution_aliases}};
467 set_default(\%config,'distributions',[keys %_distributions_default]);
470 =item default_architectures
472 List of default architectures to use when architecture(s) are not
475 Default: i386 amd64 arm ppc sparc alpha
479 set_default(\%config,'default_architectures',
480 [qw(i386 amd64 arm powerpc sparc alpha)]
483 =item affects_distribution_tags
485 List of tags which restrict the buggy state to a set of distributions.
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
492 Setting this to [] will remove this feature.
494 Default: @{$config{distributions}}
498 set_default(\%config,'affects_distribution_tags',
499 [@{$config{distributions}}],
502 =item removal_unremovable_tags
504 Bugs which have these tags set cannot be archived
510 set_default(\%config,'removal_unremovable_tags',
514 =item removal_distribution_tags
516 Tags which specifiy distributions to check
518 Default: @{$config{distributions}}
522 set_default(\%config,'removal_distribution_tags',
523 [@{$config{distributions}}]);
525 =item removal_default_distribution_tags
527 For removal/archival purposes, all bugs are assumed to have these tags
530 Default: qw(unstable testing);
534 set_default(\%config,'removal_default_distribution_tags',
535 [qw(unstable testing)]
538 =item removal_strong_severity_default_distribution_tags
540 For removal/archival purposes, all bugs with strong severity are
541 assumed to have these tags set.
543 Default: qw(unstable testing stable);
547 set_default(\%config,'removal_strong_severity_default_distribution_tags',
548 [qw(unstable testing stable)]
552 =item removal_architectures
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.
559 Default: value of default_architectures
563 set_default(\%config,'removal_architectures',
564 $config{default_architectures},
568 =item package_name_re
570 The regex which will match a package name
572 Default: '[a-z0-9][a-z0-9\.+-]+'
576 set_default(\%config,'package_name_re',
577 '[a-z0-9][a-z0-9\.+-]+');
579 =item package_version_re
581 The regex which will match a package version
583 Default: '[A-Za-z0-9:+\.-]+'
588 set_default(\%config,'package_version_re',
589 '[A-Za-z0-9:+\.~-]+');
592 =item default_package
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.
598 Defaults to unset, which is the traditional debbugs behavoir
602 set_default(\%config,'default_package',
607 =item control_internal_requester
609 This address is used by Debbugs::Control as the request address which
610 sent a control request for faked log messages.
612 Default:"Debbugs Internal Request <$config{maintainer_email}>"
616 set_default(\%config,'control_internal_requester',
617 "Debbugs Internal Request <$config{maintainer_email}>",
620 =item control_internal_request_addr
622 This address is used by Debbugs::Control as the address to which a
623 faked log message request was sent.
625 Default: "internal_control\@$config{email_domain}";
629 set_default(\%config,'control_internal_request_addr',
630 'internal_control@'.$config{email_domain},
634 =item exclude_from_control
636 Addresses which are not allowed to send messages to control
640 set_default(\%config,'exclude_from_control',[]);
644 =item default_severity
646 The default severity of bugs which have no severity set
652 set_default(\%config,'default_severity','normal');
654 =item severity_display
656 A hashref of severities and the informative text which describes them.
660 {critical => "Critical $config{bugs}",
661 grave => "Grave $config{bugs}",
662 normal => "Normal $config{bugs}",
663 wishlist => "Wishlist $config{bugs}",
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}",
677 =item show_severities
679 A scalar list of the severities to show
681 Defaults to the concatenation of the keys of the severity_display
682 hashlist with ', ' above.
686 set_default(\%config,'show_severities',join(', ',keys %{$config{severity_display}}));
688 =item strong_severities
690 An arrayref of the serious severities which shoud be emphasized
692 Default: [qw(critical grave)]
696 set_default(\%config,'strong_severities',[qw(critical grave)]);
700 An arrayref of a list of the severities
702 Defaults to the keys of the severity display hashref
706 set_default(\%config,'severity_list',[keys %{$config{severity_display}}]);
708 =item obsolete_severities
710 A hashref of obsolete severities with the replacing severity
716 set_default(\%config,'obsolete_severities',{});
720 An arrayref of the tags used
722 Default: [qw(patch wontfix moreinfo unreproducible fixed)] and also
723 includes the distributions.
727 set_default(\%config,'tags',[qw(patch wontfix moreinfo unreproducible fixed),
728 @{$config{distributions}}
731 set_default(\%config,'tags_single_letter',
735 unreproducible => 'R',
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');
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');
749 Directory which contains the usertags
751 Default: $config{spool_dir}/user
755 set_default(\%config,'usertag_dir',$config{spool_dir}.'/user');
756 set_default(\%config,'incoming_dir','incoming');
758 =item web_dir $gWebDir
760 Directory where base html files are kept. Should normally be the same
761 as the web server's document root.
763 Default: /var/lib/debbugs/www
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');
774 directory of templates; defaults to /usr/share/debbugs/templates.
778 set_default(\%config,'template_dir','/usr/share/debbugs/templates');
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');
790 =item simple_versioning
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.
798 set_default(\%config,'simple_versioning',0);
801 =item version_packages_dir
803 Location where the version package information is kept; defaults to
804 spool_dir/../versions/pkg
808 set_default(\%config,'version_packages_dir',$config{spool_dir}.'/../versions/pkg');
810 =item version_time_index
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.
819 set_default(\%config,'version_time_index', -d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/versions_time.idx' : undef);
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.
829 set_default(\%config,'version_index',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/versions.idx' : undef);
831 =item binary_source_map
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.
839 set_default(\%config,'binary_source_map',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/binsrc.idx' : undef);
841 =item source_binary_map
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.
849 set_default(\%config,'source_binary_map',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/srcbin.idx' : undef);
853 set_default(\%config,'post_processall',[]);
857 Sets the sendmail binary to execute; defaults to /usr/lib/sendmail
861 set_default(\%config,'sendmail','/usr/lib/sendmail');
863 =item sendmail_arguments
865 Default arguments to pass to sendmail. Defaults to C<qw(-oem -oi)>.
869 set_default(\%config,'sendmail_arguments',[qw(-oem -oi)]);
873 Whether or not spamscan is being used; defaults to 0 (not being used
877 set_default(\%config,'spam_scan',0);
879 =item spam_crossassassin_db
881 Location of the crosassassin database, defaults to
882 spool_dir/../CrossAssassinDb
886 set_default(\%config,'spam_crossassassin_db',$config{spool_dir}.'/../CrossAssassinDb');
890 Maximum number of cross-posted messages
894 set_default(\%config,'spam_max_cross',6);
897 =item spam_spams_per_thread
899 Number of spams for each thread (on average). Defaults to 200
903 set_default(\%config,'spam_spams_per_thread',200);
905 =item spam_max_threads
907 Maximum number of threads to start. Defaults to 20
911 set_default(\%config,'spam_max_threads',20);
913 =item spam_keep_running
915 Maximum number of seconds to run without restarting. Defaults to 3600.
919 set_default(\%config,'spam_keep_running',3600);
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'
928 set_default(\%config,'spam_mailbox',$config{spool_dir}.'/../mail/spam/assassinated.%Y-%m-%d');
930 =item spam_crossassassin_mailbox
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'
938 set_default(\%config,'spam_crossassassin_mailbox',$config{spool_dir}.'/../mail/spam/crossassassinated.%Y-%m-%d');
940 =item spam_local_tests_only
942 Whether only local tests are run, defaults to 0
946 set_default(\%config,'spam_local_tests_only',0);
948 =item spam_user_prefs
950 User preferences for spamassassin, defaults to $ENV{HOME}/.spamassassin/user_prefs
954 set_default(\%config,'spam_user_prefs',"$ENV{HOME}/.spamassassin/user_prefs");
958 Site rules directory for spamassassin, defaults to
959 '/usr/share/spamassassin'
963 set_default(\%config,'spam_rules_dir','/usr/share/spamassassin');
971 =item libravatar_uri $gLibravatarUri
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.
979 set_default(\%config,'libravatar_uri','http://'.$config{cgi_domain}.'/libravatar.cgi?email=');
981 =item libravatar_uri_options $gLibravatarUriOptions
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
988 Other options which make sense include ?d=404, ?d=wavatar, etc. See
989 the API of libravatar for details.
993 set_default(\%config,'libravatar_uri_options','');
995 =item libravatar_default_image
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.]
1001 Default: $config{web_dir}/1x1.png
1005 set_default(\%config,'libravatar_default_image',$config{web_dir}.'/1x1.png');
1007 =item libravatar_cache_dir
1009 Directory where cached libravatar images are stored
1011 Default: $config{web_dir}/libravatar/
1015 set_default(\%config,'libravatar_cache_dir',$config{web_dir}.'/libravatar/');
1017 =item libravatar_blacklist
1019 Array of regular expressions to match against emails, domains, or
1020 images to only show the default image
1022 Default: empty array
1026 set_default(\%config,'libravatar_blacklist',[]);
1036 Name of debbugs PostgreSQL database service
1040 set_default(\%config,'debbugs_db',undef);
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.
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.]
1056 =item bad_email_prefix
1058 This prefixes the text of all lines in a bad e-mail message ack.
1062 set_default(\%config,'bad_email_prefix','');
1065 =item text_instructions
1067 This gives more information about bad e-mails to receive.in
1071 set_default(\%config,'text_instructions',$config{bad_email_prefix});
1075 This shows up at the end of (most) html pages
1077 In many pages this has been replaced by the html/tail template.
1081 set_default(\%config,'html_tail',<<END);
1082 <ADDRESS>$config{maintainer} <<A HREF=\"mailto:$config{maintainer_email}\">$config{maintainer_email}</A>>.
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.
1096 =item html_expire_note
1098 This message explains what happens to archive/remove-able bugs
1102 set_default(\%config,'html_expire_note',
1103 "(Closed $config{bugs} are archived $config{remove_age} days after the last related message is received.)");
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;
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";
1128 die "Version $version configuration files are not supported";
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) {{
1149 if ($glob_type eq '%') {
1150 $value = {%{*{$var_glob}}} if defined *{$var_glob}{HASH};
1152 elsif ($glob_type eq '@') {
1153 $value = [@{*{$var_glob}}] if defined *{$var_glob}{ARRAY};
1156 $value = ${*{$var_glob}};
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;
1168 my ($variable) = @_;
1169 my $hash_name = $variable;
1170 $hash_name =~ s/^([\$\%\@])g//;
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);
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.
1187 my ($config,$option,$value) = @_;
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;
1195 # update the configuration value
1196 if (not $USING_GLOBALS and not exists $config->{$option}) {
1197 $config->{$option} = $value;
1199 elsif ($USING_GLOBALS) {{
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}"};
1206 $config->{$option} = $value;
1209 if ($USING_GLOBALS) {{
1211 *{"Debbugs::Config::${varname}"} = $config->{$option};
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.
1223 if (grep /^:(?:text|globals)$/, @_) {
1225 for my $variable (map {@$_} @EXPORT_TAGS{map{(/^:(text|globals)$/?($1):())} @_}) {
1226 my $tmp = $variable;
1228 # Yes, I don't care if these are only used once
1230 # No, it doesn't bother me that I'm assigning an undefined value to a typeglob
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};
1237 Debbugs::Config->export_to_level(1,@_);