]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/Config.pm
merge changes from dla source tree
[debbugs.git] / Debbugs / Config.pm
index fe845f52ee0be97f51c1bedb8906718243b32910..484754c45283e16c18f2aaa2aca7352ad1d580cf 100644 (file)
@@ -1,3 +1,9 @@
+# This module is part of debbugs, and is released
+# under the terms of the GPL version 2, or any later
+# version at your option.
+# See the file README and COPYING for more information.
+#
+# Copyright 2007 by Don Armstrong <don@donarmstrong.com>.
 
 package Debbugs::Config;
 
@@ -43,14 +49,19 @@ BEGIN {
                                 qw($gMaintainer $gMaintainerWebpage $gMaintainerEmail $gUnknownMaintainerEmail),
                                 qw($gSubmitList $gMaintList $gQuietList $gForwardList),
                                 qw($gDoneList $gRequestList $gSubmitterList $gControlList),
+                                qw($gStrongList),
+                                qw($gPackageVersionRe),
                                 qw($gSummaryList $gMirrorList $gMailer $gBug),
                                 qw($gBugs $gRemoveAge $gSaveOldBugs $gDefaultSeverity),
                                 qw($gShowSeverities $gBounceFroms $gConfigDir $gSpoolDir),
                                 qw($gIncomingDir $gWebDir $gDocDir $gMaintainerFile),
                                 qw($gMaintainerFileOverride $gPseudoDescFile $gPackageSource),
                                 qw($gVersionPackagesDir $gVersionIndex $gBinarySourceMap $gSourceBinaryMap),
+                                qw($gVersionTimeIndex),
+                                qw($gSendmail $gLibPath $gSpamScan @gExcludeFromControl),
                                 qw(%gSeverityDisplay @gTags @gSeverityList @gStrongSeverities),
                                 qw(%gSearchEstraier),
+                                qw(@gPostProcessall @gRemovalDefaultDistributionTags @gRemovalDistributionTags @gRemovalArchitectures),
                                ],
                     text     => [qw($gBadEmailPrefix $gHTMLTail $gHTMLExpireNote),
                                 ],
@@ -75,9 +86,20 @@ use Safe;
 
 # read in the files;
 %config = ();
+# untaint $ENV{DEBBUGS_CONFIG_FILE} if it's owned by us
+# This enables us to test things that are -T.
+if (exists $ENV{DEBBUGS_CONFIG_FILE}) {
+     if (${[stat($ENV{DEBBUGS_CONFIG_FILE})]}[4] = $<) {
+         $ENV{DEBBUGS_CONFIG_FILE} =~ /(.+)/;
+         $ENV{DEBBUGS_CONFIG_FILE} = $1;
+     }
+     else {
+         die "Environmental variable DEBBUGS_CONFIG_FILE set, and $ENV{DEBBUGS_CONFIG_FILE} is not owned by the user running this script.";
+     }
+}
 read_config(exists $ENV{DEBBUGS_CONFIG_FILE}?$ENV{DEBBUGS_CONFIG_FILE}:'/etc/debbugs/config');
 
-=item email_domain
+=item email_domain $gEmailDomain
 
 The email domain of the bts
 
@@ -85,7 +107,7 @@ The email domain of the bts
 
 set_default(\%config,'email_domain','bugs.something');
 
-=item list_domain
+=item list_domain $gListDomain
 
 The list domain of the bts, defaults to the email domain
 
@@ -93,7 +115,7 @@ The list domain of the bts, defaults to the email domain
 
 set_default(\%config,'list_domain',$config{email_domain});
 
-=item web_host
+=item web_host $gWebHost
 
 The web host of the bts; defaults to the email domain
 
@@ -101,7 +123,7 @@ The web host of the bts; defaults to the email domain
 
 set_default(\%config,'web_host',$config{email_domain});
 
-=item web_host_bug_dir
+=item web_host_bug_dir $gWebHostDir
 
 The directory of the web host on which bugs are kept, defaults to C<''>
 
@@ -109,7 +131,7 @@ The directory of the web host on which bugs are kept, defaults to C<''>
 
 set_default(\%config,'web_host_bug_dir','');
 
-=item web_domain
+=item web_domain $gWebDomain
 
 Full path of the web domain where bugs are kept, defaults to the
 concatenation of L</web_host> and L</web_host_bug_dir>
@@ -118,7 +140,7 @@ concatenation of L</web_host> and L</web_host_bug_dir>
 
 set_default(\%config,'web_domain',$config{web_host}.'/'.$config{web_host_bug_dir});
 
-=item html_suffix
+=item html_suffix $gHTMLSuffix
 
 Suffix of html pages, defaults to .html
 
@@ -126,7 +148,7 @@ Suffix of html pages, defaults to .html
 
 set_default(\%config,'html_suffix','.html');
 
-=item cgi_domain
+=item cgi_domain $gCGIDomain
 
 Full path of the web domain where cgi scripts are kept. Defaults to
 the concatentation of L</web_host> and cgi.
@@ -135,7 +157,7 @@ the concatentation of L</web_host> and cgi.
 
 set_default(\%config,'cgi_domain',$config{web_domain}.($config{web_domain}=~m{/$}?'':'/').'cgi');
 
-=item mirrors
+=item mirrors @gMirrors
 
 List of mirrors [What these mirrors are used for, no one knows.]
 
@@ -144,7 +166,7 @@ List of mirrors [What these mirrors are used for, no one knows.]
 
 set_default(\%config,'mirrors',[]);
 
-=item package_pages
+=item package_pages  $gPackagePages
 
 Domain where the package pages are kept; links should work in a
 package_pages/foopackage manner. Defaults to undef, which means that
@@ -155,7 +177,16 @@ package links will not be made.
 
 set_default(\%config,'package_pages',undef);
 
-=item subscription_domain
+=item package_pages  $gUsertagPackageDomain
+
+Domain where where usertags of packages belong; defaults to $gPackagePages
+
+=cut
+
+set_default(\%config,'usertag_package_domain',$config{package_pages});
+
+
+=item subscription_domain $gSubscriptionDomain
 
 Domain where subscriptions to package lists happen
 
@@ -173,34 +204,42 @@ set_default(\%config,'subscription_domain',undef);
 
 =over
 
-=item project
+=item project $gProject
 
 Name of the project
 
+Default: 'Something'
+
 =cut
 
 set_default(\%config,'project','Something');
 
-=item project_title
+=item project_title $gProjectTitle
 
 Name of this install of Debbugs, defaults to "L</project> Debbugs Install"
 
+Default: "$config{project} Debbugs Install"
+
 =cut
 
 set_default(\%config,'project_title',"$config{project} Debbugs Install");
 
-=item maintainer
+=item maintainer $gMaintainer
 
 Name of the maintainer of this debbugs install
 
+Default: 'Local DebBugs Owner's
+
 =cut
 
 set_default(\%config,'maintainer','Local DebBugs Owner');
 
-=item maintainer_webpage
+=item maintainer_webpage $gMaintainerWebpage
 
 Webpage of the maintainer of this install of debbugs
 
+Default: "$config{web_domain}/~owner"
+
 =cut
 
 set_default(\%config,'maintainer_webpage',"$config{web_domain}/~owner");
@@ -209,6 +248,8 @@ set_default(\%config,'maintainer_webpage',"$config{web_domain}/~owner");
 
 Email address of the maintainer of this Debbugs install
 
+Default: 'root@'.$config{email_domain}
+
 =cut
 
 set_default(\%config,'maintainer_email','root@'.$config{email_domain});
@@ -217,6 +258,10 @@ set_default(\%config,'maintainer_email','root@'.$config{email_domain});
 
 Email address where packages with an unknown maintainer will be sent
 
+Default: $config{maintainer_email}
+
+=back
+
 =cut
 
 set_default(\%config,'unknown_maintainer_email',$config{maintainer_email});
@@ -258,18 +303,149 @@ set_default(\%config,'submitter_list','bug-submitter-list');
 set_default(\%config,  'control_list',  'bug-control-list');
 set_default(\%config,  'summary_list',  'bug-summary-list');
 set_default(\%config,   'mirror_list',   'bug-mirror-list');
+set_default(\%config,   'strong_list',   'bug-strong-list');
 
 =head2 Misc Options
 
+=over
+
 =cut
 
 set_default(\%config,'mailer','exim');
 set_default(\%config,'bug','bug');
 set_default(\%config,'bugs','bugs');
+
+=item remove_age
+
+Age at which bugs are archived/removed
+
+Default: 28
+
+=cut
+
 set_default(\%config,'remove_age',28);
 
+=item save_old_bugs
+
+Whether old bugs are saved or deleted
+
+Default: 1
+
+=cut
+
 set_default(\%config,'save_old_bugs',1);
 
+=item distributions
+
+List of valid distributions
+
+Default: qw(experimental unstable testing stable oldstable);
+
+=cut
+
+set_default(\%config,'distributions',[qw(experimental unstable testing stable oldstable)]);
+
+=item removal_distribution_tags
+
+Tags which specifiy distributions to check
+
+Default: @{$config{distributions}}
+
+=cut
+
+set_default(\%config,'removal_distribution_tags',
+           [@{$config{distributions}}]);
+
+=item removal_default_distribution_tags
+
+For removal/archival purposes, all bugs are assumed to have these tags
+set.
+
+Default: qw(unstable testing);
+
+=cut
+
+set_default(\%config,'removal_default_distribution_tags',
+           [qw(unstable testing)]
+          );
+
+=item removal_architectures
+
+For removal/archival purposes, these architectures are consulted if
+there is more than one architecture applicable. If the bug is in a
+package not in any of these architectures, the architecture actually
+checked is undefined.
+
+Default: qw(i386 amd64 arm ppc sparc alpha);
+
+=cut
+
+set_default(\%config,'removal_architectures',
+           [qw(i386 amd64 arm ppc sparc alpha)]
+          );
+
+
+=item package_name_re
+
+The regex which will match a package name
+
+Default: '[a-z0-9][a-z0-9\.+-]+'
+
+=cut
+
+set_default(\%config,'package_name_re',
+           '[a-z0-9][a-z0-9\.+-]+');
+
+=item package_version_re
+
+The regex which will match a package version
+
+Default: '[A-Za-z0-9:+\.-]+'
+
+=cut
+
+set_default(\%config,'package_version_re',
+           '[A-Za-z0-9:+\.~-]+');
+
+
+=item control_internal_requester
+
+This address is used by Debbugs::Control as the request address which
+sent a control request for faked log messages.
+
+Default:"Debbugs Internal Request <$config{maintainer_email}>"
+
+=cut
+
+set_default(\%config,'control_internal_requester',
+           "Debbugs Internal Request <$config{maintainer_email}>",
+          );
+
+=item control_internal_request_addr
+
+This address is used by Debbugs::Control as the address to which a
+faked log message request was sent.
+
+Default: "internal_control\@$config{email_domain}";
+
+=cut
+
+set_default(\%config,'control_internal_request_addr',
+           'internal_control@'.$config{email_domain},
+          );
+
+
+=item exclude_from_control
+
+Addresses which are not allowed to send messages to control
+
+=cut
+
+set_default(\%config,'exclude_from_control',[]);
+
+
+
+
 set_default(\%config,'default_severity','normal');
 set_default(\%config,'show_severities','critical, grave, normal, minor, wishlist');
 set_default(\%config,'strong_severities',[qw(critical grave)]);
@@ -280,7 +456,9 @@ set_default(\%config,'severity_display',{critical => "Critical $config{bugs}",
                                         wishlist => "Wishlist $config{bugs}",
                                        });
 
-set_default(\%config,'tags',[qw(patch wontfix moreinfo unreproducible fixed stable)]);
+set_default(\%config,'tags',[qw(patch wontfix moreinfo unreproducible fixed),
+                            @{$config{distributions}}
+                           ]);
 
 set_default(\%config,'bounce_froms','^mailer|^da?emon|^post.*mast|^root|^wpuser|^mmdf|^smt.*|'.
            '^mrgate|^vmmail|^mail.*system|^uucp|-maiser-|^mal\@|'.
@@ -291,14 +469,87 @@ set_default(\%config,'spool_dir','/var/lib/debbugs/spool');
 set_default(\%config,'incoming_dir','incoming');
 set_default(\%config,'web_dir','/var/lib/debbugs/www');
 set_default(\%config,'doc_dir','/var/lib/debbugs/www/txt');
+set_default(\%config,'lib_path','/usr/lib/debbugs');
 
 set_default(\%config,'maintainer_file',$config{config_dir}.'/Maintainers');
 set_default(\%config,'maintainer_file_override',$config{config_dir}.'/Maintainers.override');
-set_default(\%config,'pseduo_desc_file',$config{config_dir}.'/pseudo-packages.description');
+set_default(\%config,'pseudo_desc_file',$config{config_dir}.'/pseudo-packages.description');
 set_default(\%config,'package_source',$config{config_dir}.'/indices/sources');
 
+
+=item version_packages_dir
+
+Location where the version package information is kept; defaults to
+spool_dir/../versions/pkg
+
+=cut
+
 set_default(\%config,'version_packages_dir',$config{spool_dir}.'/../versions/pkg');
-#set_default(\%config,'version_packages_dir',$config{spool_dir}'/../versions/pkg');
+
+=item version_time_index
+
+Location of the version/time index file. Defaults to
+spool_dir/../versions/idx/versions_time.idx if spool_dir/../versions
+exists; otherwise defaults to undef.
+
+=cut
+
+
+set_default(\%config,'version_time_index', -d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/versions_time.idx' : undef);
+
+=item version_index
+
+Location of the version index file. Defaults to
+spool_dir/../versions/indices/versions.idx if spool_dir/../versions
+exists; otherwise defaults to undef.
+
+=cut
+
+set_default(\%config,'version_index',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/versions.idx' : undef);
+
+=item binary_source_map
+
+Location of the binary -> source map. Defaults to
+spool_dir/../versions/indices/bin2src.idx if spool_dir/../versions
+exists; otherwise defaults to undef.
+
+=cut
+
+set_default(\%config,'binary_source_map',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/binsrc.idx' : undef);
+
+=item source_binary_map
+
+Location of the source -> binary map. Defaults to
+spool_dir/../versions/indices/src2bin.idx if spool_dir/../versions
+exists; otherwise defaults to undef.
+
+=cut
+
+set_default(\%config,'source_binary_map',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/srcbin.idx' : undef);
+
+
+
+set_default(\%config,'post_processall',[]);
+
+=item sendmail
+
+Sets the sendmail binary to execute; defaults to /usr/lib/sendmail
+
+=cut
+
+set_default(\%config,'sendmail','/usr/lib/sendmail');
+
+=item spam_scan
+
+Whether or not spamscan is being used; defaults to 0 (not being used
+
+=cut
+
+set_default(\%config,'spam_scan',0);
+
+
+=back
+
 
 =head2 Text Fields
 
@@ -322,6 +573,15 @@ This prefixes the text of all lines in a bad e-mail message ack.
 
 set_default(\%config,'bad_email_prefix','');
 
+
+=item text_instructions
+
+This gives more information about bad e-mails to receive.in
+
+=cut
+
+set_default(\%config,'text_instructions',$config{bad_email_prefix});
+
 =item html_tail
 
 This shows up at the end of (most) html pages
@@ -364,7 +624,7 @@ sub read_config{
          or die "Unable to open configuration file $conf_file for reading: $!";
      # A new version configuration file must have a comment as its first line
      my $first_line = <$fh>;
-     my ($version) = $first_line =~ /VERSION:\s*(\d+)/i;
+     my ($version) = defined $first_line?$first_line =~ /VERSION:\s*(\d+)/i:undef;
      if (defined $version) {
          if ($version == 1) {
               # Do something here;
@@ -381,7 +641,6 @@ sub read_config{
          my $cpt = new Safe or die "Unable to create safe compartment";
          # perldoc Opcode; for details
          $cpt->permit('require',':filesys_read','entereval','caller','pack','unpack','dofile');
-         $cpt->reval(q($gMaintainerFile = 'FOOOO'));
          $cpt->reval(qq(require '$conf_file';));
          die "Error in configuration file: $@" if $@;
          # Now what we do is check out the contents of %EXPORT_TAGS to see exactly which variables
@@ -390,14 +649,14 @@ sub read_config{
               my ($hash_name,$glob_name,$glob_type) = __convert_name($variable);
               my $var_glob = $cpt->varglob($glob_name);
               my $value; #= $cpt->reval("return $variable");
-              #print STDERR $value,qq(\n);
+              # print STDERR "$variable $value",qq(\n);
               if (defined $var_glob) {{
                    no strict 'refs';
                    if ($glob_type eq '%') {
-                        $value = {%{*{$var_glob}}};
+                        $value = {%{*{$var_glob}}} if defined *{$var_glob}{HASH};
                    }
                    elsif ($glob_type eq '@') {
-                        $value = [@{*{$var_glob}}];
+                        $value = [@{*{$var_glob}}] if defined *{$var_glob}{ARRAY};
                    }
                    else {
                         $value = ${*{$var_glob}};
@@ -440,19 +699,22 @@ sub set_default{
          $varname =~ s/(Html|Cgi)/uc($1)/ge;
      }
      # update the configuration value
-     if (not $USING_GLOBALS and not exists $config{$option}) {
-         $config{$option} = $value;
+     if (not $USING_GLOBALS and not exists $config->{$option}) {
+         $config->{$option} = $value;
      }
      elsif ($USING_GLOBALS) {{
          no strict 'refs';
          # Need to check if a value has already been set in a global
          if (defined *{"Debbugs::Config::${varname}"}) {
-              $config{$option} = *{"Debbugs::Config::${varname}"};
+              $config->{$option} = *{"Debbugs::Config::${varname}"};
+         }
+         else {
+              $config->{$option} = $value;
          }
      }}
      if ($USING_GLOBALS) {{
          no strict 'refs';
-         *{"Debbugs::Config::${varname}"} = $config{$option};
+         *{"Debbugs::Config::${varname}"} = $config->{$option};
      }}
 }