return $_[0]->request_cache->{params} ||= Bugzilla::Config::read_param_file();
}
+sub get_param_with_override {
+ my ($class, $name) = @_;
+ return $class->localconfig->{param_override}{$name} // $class->params->{$name};
+}
+
sub user {
return $_[0]->request_cache->{user} ||= new Bugzilla::User;
}
sub connect_shadow {
my $params = Bugzilla->params;
- die "Tried to connect to non-existent shadowdb"
- unless $params->{'shadowdb'};
+ die "Tried to connect to non-existent shadowdb"
+ unless Bugzilla->get_param_with_override('shadowdb');
# Instead of just passing in a new hashref, we locally modify the
# values of "localconfig", because some drivers access it while
# connecting.
- my %connect_params = %{ Bugzilla->localconfig };
- $connect_params{db_host} = $params->{'shadowdbhost'};
- $connect_params{db_name} = $params->{'shadowdb'};
- $connect_params{db_port} = $params->{'shadowdbport'};
- $connect_params{db_sock} = $params->{'shadowdbsock'};
+ my $connect_params = dclone(Bugzilla->localconfig);
+ $connect_params->{db_host} = Bugzilla->get_param_with_override('shadowdbhost');
+ $connect_params->{db_name} = Bugzilla->get_param_with_override('shadowdb');
+ $connect_params->{db_port} = Bugzilla->get_param_with_override('shadowport');
+ $connect_params->{db_sock} = Bugzilla->get_param_with_override('shadowsock');
- return _connect(\%connect_params);
+ return _connect($connect_params);
}
sub connect_main {
# is larger than anybody would ever be able to brute-force.
default => sub { generate_random_password(64) },
},
+ {
+ name => 'param_override',
+ default => {
+ inbound_proxies => undef,
+ memcached_servers => undef,
+ memcached_namespace => undef,
+ shadowdb => undef,
+ shadowdbhost => undef,
+ shadowdbport => undef,
+ shadowdbsock => undef,
+ },
+ },
);
sub read_localconfig {
# always return an object to simplify calling code when memcached is
# disabled.
- if (Bugzilla->feature('memcached')
- && Bugzilla->params->{memcached_servers})
- {
+ my $servers = Bugzilla->get_param_with_override('memcached_servers');
+ if (Bugzilla->feature('memcached') && $servers) {
require Cache::Memcached;
- $self->{namespace} = Bugzilla->params->{memcached_namespace} || '';
+ $self->{namespace} = Bugzilla->get_param_with_override('memcached_namespace');
$self->{memcached} =
Cache::Memcached->new({
- servers => [ split(/[, ]+/, Bugzilla->params->{memcached_servers}) ],
+ servers => [ split(/[, ]+/, $servers) ],
namespace => $self->{namespace},
});
}
# Returns the real remote address of the client,
sub remote_ip {
my $remote_ip = $ENV{'REMOTE_ADDR'} || '127.0.0.1';
- my @proxies = split(/[\s,]+/, Bugzilla->params->{inbound_proxies});
+ my @proxies = split(/[\s,]+/, Bugzilla->get_param_with_override('inbound_proxies'));
my @x_forwarded_for = split(/[\s,]+/, $ENV{HTTP_X_FORWARDED_FOR} // '');
return $remote_ip unless @x_forwarded_for;
my $current_module;
my @panels = ();
my $param_panels = Bugzilla::Config::param_panels();
+my $override = Bugzilla->localconfig->{param_override};
foreach my $panel (keys %$param_panels) {
my $module = $param_panels->{$panel};
eval("require $module") || die $@;
name => lc($panel),
current => ($current_panel eq lc($panel)) ? 1 : 0,
param_list => \@module_param_list,
+ param_override => { map { $_->{name} => $override->{$_->{name}} } @module_param_list },
sortkey => eval "\$${module}::sortkey;",
module => $module,
};
use Bugzilla::Util qw(remote_ip);
my $params = Bugzilla->params;
+local Bugzilla->localconfig->{param_override}{inbound_proxies} = undef;
{
local $params->{inbound_proxies} = '10.0.0.1,10.0.0.2';
<dl>
[% FOREACH param = panel.param_list %]
- <dt id="[% param.name FILTER html %]_desc">[% param.name FILTER html %]</dt>
+ <dt id="[% param.name FILTER html %]_desc">[% param.name FILTER html %]
+ [% IF panel.param_override.${param.name}.defined %]
+ (localconfig override)
+ [% END %]
+ </dt>
<dd>[% panel.param_descs.${param.name} FILTER none %]
<p>
+ [% IF panel.param_override.${param.name}.defined %]
+ <input type="hidden" name="[% param.name FILTER html %] value="[% Param(param.name) FILTER html %]">
+ <input type="text" size="80" readonly
+ id="[% param.name FILTER html %]" value="[% panel.param_override.${param.name} FILTER html %]">
+ [% NEXT %]
+ [% END %]
[% IF param.type == "t" %]
<input type="text" size="80" name="[% param.name FILTER html %]"
id="[% param.name FILTER html %]" value="[% Param(param.name) FILTER html %]">
security features in Bugzilla, to protect against certain types of attacks.
A random string is generated by default. It's very important that this key
is kept secret. It also must be very long.
+END
+ localconfig_param_override => <<'END',
+This hash is used by BMO to override select data/params values on a per-webhead
+basis. Keys set to undef will default to the value in data/params.
+Only the keys listed below can be overridden.
END
localconfig_use_suexec => <<'END',
Set this to 1 if Bugzilla runs in an Apache SuexecUserGroup environment.