- Timestamp:
- 10/03/12 18:02:56 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r399 r400 1198 1198 # Load the minimum required initial state (DB connect info) from a config file 1199 1199 # Load misc other bits while we're at it. 1200 # Takes an optional basename and config path to look for 1200 # Takes an optional hash that may contain: 1201 # - basename and config path to look for 1202 # - RPC flag (saves parsing the more complex RPC bits if not needed) 1201 1203 # Populates the %config and %def hashes 1202 1204 sub loadConfig { 1203 my $basename = shift || ''; # this will work OK 1204 ##fixme $basename isn't doing what I think I thought I was trying to do. 1205 my %args = @_; 1206 $args{basename} = '' if !$args{basename}; 1207 $args{rpcflag} = '' if !$args{rpcflag}; 1208 ##fixme $args{basename} isn't doing what I think I thought I was trying to do. 1205 1209 1206 1210 my $deferr = ''; # place to put error from default config file in case we can't find either one 1207 1211 1208 1212 my $configroot = "/etc/dnsdb"; ##CFG_LEAF## 1209 $configroot = '' if $ basename=~ m|^/|;1210 $ basename .= ".conf" if $basename!~ /\.conf$/;1213 $configroot = '' if $args{basename} =~ m|^/|; 1214 $args{basename} .= ".conf" if $args{basename} !~ /\.conf$/; 1211 1215 my $defconfig = "$configroot/dnsdb.conf"; 1212 my $siteconfig = "$configroot/$ basename";1216 my $siteconfig = "$configroot/$args{basename}"; 1213 1217 1214 1218 # System defaults 1215 __cfgload("$defconfig" ) or $deferr = $errstr;1219 __cfgload("$defconfig", $args{rpcflag}) or $deferr = $errstr; 1216 1220 1217 1221 # Per-site-ish settings. 1218 if ($ basenamene '.conf') {1219 unless (__cfgload("$siteconfig") ) {1222 if ($args{basename} ne '.conf') { 1223 unless (__cfgload("$siteconfig"), $args{rpcflag}) { 1220 1224 $errstr = ($deferr ? "Error opening default config file $defconfig: $deferr\n" : ''). 1221 1225 "Error opening site config file $siteconfig"; … … 1253 1257 $errstr = ''; 1254 1258 my $cfgfile = shift; 1259 my $rpcflag = shift; 1255 1260 1256 1261 if (open CFG, "<$cfgfile") { … … 1290 1295 $config{perpage} = $1 if /^perpage\s*=\s*(\d+)/i; 1291 1296 $config{exportcache} = $1 if m{^exportcache\s*=\s*([a-z0-9/_.-]+)}i; 1297 # RPC options 1298 if ($rpcflag && /^rpc/) { 1299 if (my ($tmp) = /^rpc_iplist\s*=\s*(.+)/i) { 1300 my @ips = split /[,\s]+/, $tmp; 1301 my $rpcsys = shift @ips; 1302 push @{$config{rpcacl}{$rpcsys}}, @ips; 1303 } 1304 } 1292 1305 } 1293 1306 close CFG;
Note:
See TracChangeset
for help on using the changeset viewer.