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