- Timestamp:
- 05/31/13 17:23:13 (12 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r516 r517 40 40 &getPermissions &changePermissions &comparePermissions 41 41 &changeGroup 42 & loadConfig &connectDB &finish42 &connectDB &finish 43 43 &addDomain &delZone &domainName &revName &domainID &revID &addRDNS 44 44 &getZoneCount &getZoneList &getZoneLocation … … 59 59 &export 60 60 &mailNotify 61 %typemap %reverse_typemap %config61 %typemap %reverse_typemap 62 62 @permtypes $permlist %permchains 63 63 ); … … 68 68 &getPermissions &changePermissions &comparePermissions 69 69 &changeGroup 70 & loadConfig &connectDB &finish70 &connectDB &finish 71 71 &addDomain &delZone &domainName &revName &domainID &revID &addRDNS 72 72 &getZoneCount &getZoneList &getZoneLocation … … 87 87 &export 88 88 &mailNotify 89 %typemap %reverse_typemap %config89 %typemap %reverse_typemap 90 90 @permtypes $permlist %permchains 91 91 )] … … 94 94 our $errstr = ''; 95 95 our $resultstr = ''; 96 97 # Halfway sane defaults for SOA, TTL, etc.98 # serial defaults to 0 for convenience.99 # value will be either YYYYMMDDNN for BIND/etc, or auto-internal for tinydns100 our %def = qw (101 contact hostmaster.DOMAIN102 prins ns1.myserver.com103 serial 0104 soattl 86400105 refresh 10800106 retry 3600107 expire 604800108 minttl 10800109 ttl 10800110 );111 96 112 97 # Arguably defined wholly in the db, but little reason to change without supporting code changes … … 135 120 our %typemap; 136 121 our %reverse_typemap; 137 138 # Prepopulate a basic config. Note some of these *will* cause errors if left unset.139 # note: add appropriate stanzas in loadConfig to parse these140 our %config = (141 # Database connection info142 dbname => 'dnsdb',143 dbuser => 'dnsdb',144 dbpass => 'secret',145 dbhost => '',146 147 # Email notice settings148 mailhost => 'smtp.example.com',149 mailnotify => 'dnsdb@example.com', # to150 mailsender => 'dnsdb@example.com', # from151 mailname => 'DNS Administration',152 orgname => 'Example Corp',153 domain => 'example.com',154 155 # Template directory156 templatedir => 'templates/',157 # fmeh. this is a real web path, not a logical internal one. hm..158 # cssdir => 'templates/',159 sessiondir => 'session/',160 exportcache => 'cache/',161 162 # Session params163 timeout => '3600', # 1 hour default164 165 # Other miscellanea166 log_failures => 1, # log all evarthing by default167 perpage => 15,168 maxfcgi => 100, # reasonable default?169 );170 122 171 123 ## (Semi)private variables … … 221 173 my $class = ref($this) || $this; 222 174 my %args = @_; 223 ##fixme? to ponder: do we do some magic if the caller sets eg dbname to prevent parsing of the config file? 224 if (!loadConfig(basename => $args{configfile})) { 225 warn "Using default configuration; unable to load custom settings: $errstr\n"; 226 } 227 my $self = \%config; 228 $self->{configfile} = $args{configfile}; 175 176 # Prepopulate a basic config. Note some of these *will* cause errors if left unset. 177 # note: add appropriate stanzas in __cfgload() to parse these 178 my %defconfig = ( 179 # The only configuration option not loadable from a config file. 180 configfile => '/etc/dnsdb/dnsdb.conf', 181 182 # Database connection info 183 dbname => 'dnsdb', 184 dbuser => 'dnsdb', 185 dbpass => 'secret', 186 dbhost => '', 187 188 # Email notice settings 189 mailhost => 'smtp.example.com', 190 mailnotify => 'dnsdb@example.com', # to 191 mailsender => 'dnsdb@example.com', # from 192 mailname => 'DNS Administration', 193 orgname => 'Example Corp', 194 domain => 'example.com', 195 196 # Template directory 197 templatedir => 'templates/', 198 # fmeh. this is a real web path, not a logical internal one. hm.. 199 # cssdir => 'templates/', 200 sessiondir => 'session/', 201 exportcache => 'cache/', 202 203 # Session params 204 timeout => '1h', # passed as-is to CGI::Session 205 206 # Other miscellanea 207 log_failures => 1, # log all evarthing by default 208 perpage => 15, 209 max_fcgi_requests => 100, # reasonable default? 210 ); 211 212 # Config file parse calls. 213 # If we are passed a blank argument for $args{configfile}, 214 # we should NOT parse the default config file - we will 215 # rely on hardcoded defaults OR caller-specified values. 216 # If we are passed a non-blank argument, parse that file. 217 # If no config file is specified, parse the default one. 218 my %siteconfig; 219 if (defined($args{configfile})) { 220 if ($args{configfile}) { 221 return if !__cfgload($args{configfile}, \%siteconfig); 222 } 223 } else { 224 return if !__cfgload($defconfig{configfile}, \%siteconfig); 225 } 226 227 # Assemble the object. Apply configuration hashes in order of precedence. 228 my $self = { 229 # Hardcoded defaults 230 %defconfig, 231 # Default config file OR caller-specified one, loaded above 232 %siteconfig, 233 # Caller-specified arguments 234 %args 235 }; 229 236 bless $self, $class; 237 238 # Try to connect to the DB, and initialize a number of handy globals. 230 239 $self->{dbh} = connectDB($self->{dbname}, $self->{dbuser}, $self->{dbpass}, $self->{dbhost}) or return; 231 240 $self->initGlobals(); … … 236 245 sub DESTROY { 237 246 my $self = shift; 238 $self->{dbh}->disconnect ;247 $self->{dbh}->disconnect if $self->{dbh}; 239 248 } 240 249 … … 372 381 373 382 ##fixme: farm out the actual logging to different subs for file, syslog, internal, etc based on config 374 # if ($ config{log_channel} eq 'sql') {383 # if ($self->{log_channel} eq 'sql') { 375 384 $dbh->do("INSERT INTO log (domain_id,rdns_id,group_id,entry,user_id,email,name) VALUES (?,?,?,?,?,?,?)", 376 385 undef, 377 386 ($args{domain_id}, $args{rdns_id}, $args{group_id}, $args{entry}, 378 387 $self->{loguserid}, $self->{logusername}, $self->{logfullname}) ); 379 # } elsif ($ config{log_channel} eq 'file') {380 # } elsif ($ config{log_channel} eq 'syslog') {388 # } elsif ($self->{log_channel} eq 'file') { 389 # } elsif ($self->{log_channel} eq 'syslog') { 381 390 # } 382 391 } # end _log … … 528 537 ${$args{val}} = "ZONE,${$args{val}}" unless ${$args{val}} =~ /^ZONE/; 529 538 } 530 ${$args{host}} =~ s/\.*$/\.$ config{domain}/ if ${$args{host}} !~ /(?:$config{domain}|ADMINDOMAIN)$/;539 ${$args{host}} =~ s/\.*$/\.$self->{domain}/ if ${$args{host}} !~ /(?:$self->{domain}|ADMINDOMAIN)$/; 531 540 } 532 541 … … 1239 1248 ## 1240 1249 1241 ## DNSDB::loadConfig()1242 # Load the minimum required initial state (DB connect info) from a config file1243 # Load misc other bits while we're at it.1244 # Takes an optional hash that may contain:1245 # - basename and config path to look for1246 # Populates the %config and %def hashes1247 sub loadConfig {1248 my %args = @_;1249 $args{configfile} = '' if !$args{configfile};1250 1251 ##fixme this is *intended* to load a system-default config template, and allow1252 # overriding on a per-tool or per-web-UI-instance basis with a secondary config1253 # file. The "default" config file can't be deleted in the current form.1254 1255 my $deferr = ''; # place to put error from default config file in case we can't find either one1256 1257 my $configroot = "/etc/dnsdb"; ##CFG_LEAF##1258 $configroot = '' if $args{configfile} =~ m|^/|; # allow passed siteconfig to specify an arbitrary absolute path1259 $args{configfile} .= ".conf" if $args{configfile} !~ /\.conf$/;1260 my $defconfig = "$configroot/dnsdb.conf";1261 my $siteconfig = "$configroot/$args{configfile}";1262 1263 # System defaults1264 __cfgload("$defconfig") or $deferr = $errstr;1265 1266 # Per-site-ish settings.1267 if ($args{configfile} ne '.conf') {1268 unless (__cfgload("$siteconfig")) {1269 $errstr = ($deferr ? "Error opening default config file $defconfig: $deferr\n" : '').1270 "Error opening site config file $siteconfig";1271 return;1272 }1273 }1274 1275 # Munge log_failures.1276 if ($config{log_failures} ne '1' && $config{log_failures} ne '0') {1277 # true/false, on/off, yes/no all valid.1278 if ($config{log_failures} =~ /^(?:true|false|on|off|yes|no)$/) {1279 if ($config{log_failures} =~ /(?:true|on|yes)/) {1280 $config{log_failures} = 1;1281 } else {1282 $config{log_failures} = 0;1283 }1284 } else {1285 $errstr = "Bad log_failures setting $config{log_failures}";1286 $config{log_failures} = 1;1287 # Bad setting shouldn't be fatal.1288 # return 2;1289 }1290 }1291 1292 # All good, clear the error and go home.1293 $errstr = '';1294 return 1;1295 } # end loadConfig()1296 1297 1298 1250 ## DNSDB::__cfgload() 1299 1251 # Private sub to parse a config file and load it into %config 1300 # Takes a filename 1252 # Takes a filename and a hashref to put the parsed entries in 1301 1253 sub __cfgload { 1302 1254 $errstr = ''; 1303 1255 my $cfgfile = shift; 1256 my $cfg = shift; 1304 1257 1305 1258 if (open CFG, "<$cfgfile") { … … 1312 1265 # $mode = $1 if /^\[(a-z)+]/; 1313 1266 # DB connect info 1314 $config{dbname} = $1 if /^dbname\s*=\s*([a-z0-9_.-]+)/i; 1315 $config{dbuser} = $1 if /^dbuser\s*=\s*([a-z0-9_.-]+)/i; 1316 $config{dbpass} = $1 if /^dbpass\s*=\s*([a-z0-9_.-]+)/i; 1317 $config{dbhost} = $1 if /^dbhost\s*=\s*([a-z0-9_.-]+)/i; 1318 # SOA defaults 1319 $def{contact} = $1 if /^contact\s*=\s*([a-z0-9_.-]+)/i; 1320 $def{prins} = $1 if /^prins\s*=\s*([a-z0-9_.-]+)/i; 1321 $def{soattl} = $1 if /^soattl\s*=\s*(\d+)/i; 1322 $def{refresh} = $1 if /^refresh\s*=\s*(\d+)/i; 1323 $def{retry} = $1 if /^retry\s*=\s*(\d+)/i; 1324 $def{expire} = $1 if /^expire\s*=\s*(\d+)/i; 1325 $def{minttl} = $1 if /^minttl\s*=\s*(\d+)/i; 1326 $def{ttl} = $1 if /^ttl\s*=\s*(\d+)/i; 1267 $cfg->{dbname} = $1 if /^dbname\s*=\s*([a-z0-9_.-]+)/i; 1268 $cfg->{dbuser} = $1 if /^dbuser\s*=\s*([a-z0-9_.-]+)/i; 1269 $cfg->{dbpass} = $1 if /^dbpass\s*=\s*([a-z0-9_.-]+)/i; 1270 $cfg->{dbhost} = $1 if /^dbhost\s*=\s*([a-z0-9_.-]+)/i; 1327 1271 # Mail settings 1328 $c onfig{mailhost} = $1 if /^mailhost\s*=\s*([a-z0-9_.-]+)/i;1329 $c onfig{mailnotify} = $1 if /^mailnotify\s*=\s*([a-z0-9_.\@-]+)/i;1330 $c onfig{mailsender} = $1 if /^mailsender\s*=\s*([a-z0-9_.\@-]+)/i;1331 $c onfig{mailname} = $1 if /^mailname\s*=\s*([a-z0-9\s_.-]+)/i;1332 $c onfig{orgname} = $1 if /^orgname\s*=\s*([a-z0-9\s_.,'-]+)/i;1333 $c onfig{domain} = $1 if /^domain\s*=\s*([a-z0-9_.-]+)/i;1272 $cfg->{mailhost} = $1 if /^mailhost\s*=\s*([a-z0-9_.-]+)/i; 1273 $cfg->{mailnotify} = $1 if /^mailnotify\s*=\s*([a-z0-9_.\@-]+)/i; 1274 $cfg->{mailsender} = $1 if /^mailsender\s*=\s*([a-z0-9_.\@-]+)/i; 1275 $cfg->{mailname} = $1 if /^mailname\s*=\s*([a-z0-9\s_.-]+)/i; 1276 $cfg->{orgname} = $1 if /^orgname\s*=\s*([a-z0-9\s_.,'-]+)/i; 1277 $cfg->{domain} = $1 if /^domain\s*=\s*([a-z0-9_.-]+)/i; 1334 1278 # session - note this is fed directly to CGI::Session 1335 $c onfig{timeout} = $1 if /^[tT][iI][mM][eE][oO][uU][tT]\s*=\s*(\d+[smhdwMy]?)/;1336 $c onfig{sessiondir} = $1 if m{^sessiondir\s*=\s*([a-z0-9/_.-]+)}i;1279 $cfg->{timeout} = $1 if /^[tT][iI][mM][eE][oO][uU][tT]\s*=\s*(\d+[smhdwMy]?)/; 1280 $cfg->{sessiondir} = $1 if m{^sessiondir\s*=\s*([a-z0-9/_.-]+)}i; 1337 1281 # misc 1338 $config{log_failures} = $1 if /^log_failures\s*=\s*([a-z01]+)/i; 1339 $config{perpage} = $1 if /^perpage\s*=\s*(\d+)/i; 1340 $config{exportcache} = $1 if m{^exportcache\s*=\s*([a-z0-9/_.-]+)}i; 1282 $cfg->{log_failures} = $1 if /^log_failures\s*=\s*([a-z01]+)/i; 1283 $cfg->{perpage} = $1 if /^perpage\s*=\s*(\d+)/i; 1284 $cfg->{exportcache} = $1 if m{^exportcache\s*=\s*([a-z0-9/_.-]+)}i; 1285 # not supported in dns.cgi yet 1286 # $cfg->{templatedir} = $1 if m{^templatedir\s*=\s*([a-z0-9/_.-]+)}i; 1287 # $cfg->{templateoverride} = $1 if m{^templateoverride\s*=\s*([a-z0-9/_.-]+)}i; 1341 1288 # RPC options 1342 $c onfig{rpcmode} = $1 if /^rpc_mode\s*=\s*(socket|HTTP|XMLRPC)\s*$/i;1343 $c onfig{maxfcgi} = $1 if /^max_fcgi_requests\s*=\s*(\d+)\s*$/i;1289 $cfg->{rpcmode} = $1 if /^rpc_mode\s*=\s*(socket|HTTP|XMLRPC)\s*$/i; 1290 $cfg->{maxfcgi} = $1 if /^max_fcgi_requests\s*=\s*(\d+)\s*$/i; 1344 1291 if (my ($tmp) = /^rpc_iplist\s*=\s*(.+)/i) { 1345 1292 my @ips = split /[,\s]+/, $tmp; 1346 1293 my $rpcsys = shift @ips; 1347 push @{$c onfig{rpcacl}{$rpcsys}}, @ips;1294 push @{$cfg->{rpcacl}{$rpcsys}}, @ips; 1348 1295 } 1349 1296 } 1350 1297 close CFG; 1351 1298 } else { 1352 $errstr = $!;1299 $errstr = "Couldn't load configuration file $cfgfile: $!"; 1353 1300 return; 1354 1301 } … … 1533 1480 # about having to open a file or a syslog channel 1534 1481 ##fixme Need to call _initActionLog_blah() for various logging channels, configured 1535 # via dnsdb.conf, in $ config{log_channel} or something1482 # via dnsdb.conf, in $self->{log_channel} or something 1536 1483 # See https://secure.deepnet.cx/trac/dnsadmin/ticket/21 1537 1484 sub initActionLog { … … 1554 1501 1555 1502 # convert to real check once we have other logging channels 1556 # if ($ config{log_channel} eq 'sql') {1503 # if ($self->{log_channel} eq 'sql') { 1557 1504 # Open Log, Sez Me! 1558 1505 # } … … 1781 1728 my $msg = $@; 1782 1729 eval { $dbh->rollback; }; 1783 if ($ config{log_failures}) {1730 if ($self->{log_failures}) { 1784 1731 $self->_log(group_id => $oldgid, entry => "Error moving $type $entname to $newgname: $msg"); 1785 1732 $dbh->commit; # since we enabled transactions earlier … … 1881 1828 eval { $dbh->rollback; }; 1882 1829 $self->_log(group_id => $group, entry => "Failed adding domain $domain ($msg)") 1883 if $ config{log_failures};1830 if $self->{log_failures}; 1884 1831 $dbh->commit; # since we enabled transactions earlier 1885 1832 return ('FAIL',$msg); … … 1912 1859 return ('FAIL', ($revrec eq 'n' ? 'Domain' : 'Reverse zone')." ID $zoneid doesn't exist") if !$zone; 1913 1860 1914 # Set this up here since we may use if if $ config{log_failures} is enabled1861 # Set this up here since we may use if if $self->{log_failures} is enabled 1915 1862 my %loghash; 1916 1863 $loghash{domain_id} = $zoneid if $revrec eq 'n'; … … 1960 1907 eval { $dbh->rollback; }; 1961 1908 $loghash{entry} = "Error deleting $zone: $msg ($failmsg)"; 1962 if ($ config{log_failures}) {1909 if ($self->{log_failures}) { 1963 1910 $self->_log(%loghash); 1964 1911 $dbh->commit; # since we enabled transactions earlier … … 2105 2052 } 2106 2053 2107 $host =~ s/ADMINDOMAIN/$ config{domain}/g;2054 $host =~ s/ADMINDOMAIN/$self->{domain}/g; 2108 2055 2109 2056 # Check to make sure the IP stubs will fit in the zone. Under most usage failures here should be rare. … … 2199 2146 eval { $dbh->rollback; }; 2200 2147 $self->_log(group_id => $group, entry => "Failed adding reverse zone $zone ($msg)") 2201 if $ config{log_failures};2148 if $self->{log_failures}; 2202 2149 $dbh->commit; # since we enabled transactions earlier 2203 2150 return ('FAIL',$msg); … … 2315 2262 # A common tail. 2316 2263 $sql .= " ORDER BY ".($args{sortby} eq 'group' ? 'groups.group_name' : $args{sortby})." $args{sortorder} ". 2317 ($args{offset} eq 'all' ? '' : " LIMIT $ config{perpage}".2318 " OFFSET ".$args{offset}*$ config{perpage});2264 ($args{offset} eq 'all' ? '' : " LIMIT $self->{perpage}". 2265 " OFFSET ".$args{offset}*$self->{perpage}); 2319 2266 my $sth = $dbh->prepare($sql); 2320 2267 $sth->execute(@filterargs); … … 2442 2389 my $msg = $@; 2443 2390 eval { $dbh->rollback; }; 2444 if ($ config{log_failures}) {2391 if ($self->{log_failures}) { 2445 2392 $self->_log(group_id => $pargroup, entry => "Failed to add group $groupname: $msg"); 2446 2393 $dbh->commit; … … 2508 2455 my $msg = $@; 2509 2456 eval { $dbh->rollback; }; 2510 if ($ config{log_failures}) {2457 if ($self->{log_failures}) { 2511 2458 $self->_log(group_id => $parid, entry => "$failmsg: $msg"); 2512 2459 $dbh->commit; # since we enabled transactions earlier … … 2655 2602 " GROUP BY g.group_id, g.group_name, g2.group_name ". 2656 2603 " ORDER BY $args{sortby} $args{sortorder} ". 2657 ($args{offset} eq 'all' ? '' : " LIMIT $ config{perpage} OFFSET ".$args{offset}*$config{perpage});2604 ($args{offset} eq 'all' ? '' : " LIMIT $self->{perpage} OFFSET ".$args{offset}*$self->{perpage}); 2658 2605 my $glist = $dbh->selectall_arrayref($sql, { Slice => {} }, (@filterargs) ); 2659 2606 $errstr = $dbh->errstr if !$glist; … … 2810 2757 my $msg = $@; 2811 2758 eval { $dbh->rollback; }; 2812 if ($ config{log_failures}) {2759 if ($self->{log_failures}) { 2813 2760 $self->_log(group_id => $group, entry => "Error adding user $username: $msg"); 2814 2761 $dbh->commit; # since we enabled transactions earlier … … 2905 2852 " AND NOT u.type = 'R' ". 2906 2853 " ORDER BY $args{sortby} $args{sortorder} ". 2907 ($args{offset} eq 'all' ? '' : " LIMIT $ config{perpage} OFFSET ".$args{offset}*$config{perpage});2854 ($args{offset} eq 'all' ? '' : " LIMIT $self->{perpage} OFFSET ".$args{offset}*$self->{perpage}); 2908 2855 my $ulist = $dbh->selectall_arrayref($sql, { Slice => {} }, (@filterargs) ); 2909 2856 $errstr = $dbh->errstr if !$ulist; … … 2988 2935 my $msg = $@; 2989 2936 eval { $dbh->rollback; }; 2990 if ($ config{log_failures}) {2937 if ($self->{log_failures}) { 2991 2938 $self->_log(group_id => $group, entry => "Error updating user $username: $msg"); 2992 2939 $dbh->commit; # since we enabled transactions earlier … … 3027 2974 my $msg = $@; 3028 2975 eval { $dbh->rollback; }; 3029 if ($ config{log_failures}) {2976 if ($self->{log_failures}) { 3030 2977 $self->_log(group_id => $userdata->{group_id}, entry => "Error deleting user ID ". 3031 2978 "$userid/".$userdata->{username}.": $msg"); … … 3200 3147 my $msg = $@; 3201 3148 eval { $dbh->rollback; }; 3202 if ($ config{log_failures}) {3149 if ($self->{log_failures}) { 3203 3150 $shdesc = $loc if !$shdesc; 3204 3151 $self->_log(entry => "Failed adding location ($shdesc, '$iplist'): $msg"); … … 3247 3194 my $msg = $@; 3248 3195 eval { $dbh->rollback; }; 3249 if ($ config{log_failures}) {3196 if ($self->{log_failures}) { 3250 3197 $shdesc = $loc if !$shdesc; 3251 3198 $self->_log(entry => "Failed updating location ($shdesc, '$iplist'): $msg"); … … 3286 3233 my $msg = $@; 3287 3234 eval { $dbh->rollback; }; 3288 if ($ config{log_failures}) {3235 if ($self->{log_failures}) { 3289 3236 $self->_log(entry => "Failed to delete location ($olddesc, '$oldloc->{iplist}'): $msg"); 3290 3237 $dbh->commit; … … 3390 3337 ($args{filter} ? " AND l.description ~* ?" : ''). 3391 3338 " ORDER BY $args{sortby} $args{sortorder} ". 3392 ($args{offset} eq 'all' ? '' : " LIMIT $ config{perpage} OFFSET ".$args{offset}*$config{perpage});3339 ($args{offset} eq 'all' ? '' : " LIMIT $self->{perpage} OFFSET ".$args{offset}*$self->{perpage}); 3393 3340 my $ulist = $dbh->selectall_arrayref($sql, { Slice => {} }, (@filterargs) ); 3394 3341 $errstr = $dbh->errstr if !$ulist; … … 3510 3457 $logdata{entry} = "Error updating ".($defrec eq 'y' ? ($revrec eq 'y' ? 'default reverse zone ' : 'default ') : ''). 3511 3458 "SOA record for $parname: $msg"; 3512 if ($ config{log_failures}) {3459 if ($self->{log_failures}) { 3513 3460 $self->_log(%logdata); 3514 3461 $dbh->commit; … … 3589 3536 $args{sortby} = $defsort if $args{sortby} !~ /^[\w_,.]+$/; 3590 3537 $args{offset} = 0 if !$args{offset} || $args{offset} !~ /^(?:all|\d+)$/; 3591 my $perpage = ($args{nrecs} ? $args{nrecs} : $ config{perpage});3538 my $perpage = ($args{nrecs} ? $args{nrecs} : $self->{perpage}); 3592 3539 3593 3540 # sort reverse zones on IP, correctly … … 3778 3725 my $msg = $@; 3779 3726 eval { $dbh->rollback; }; 3780 if ($ config{log_failures}) {3727 if ($self->{log_failures}) { 3781 3728 $logdata{entry} = "Failed adding ".($defrec eq 'y' ? 'default ' : ''). 3782 3729 "record '$$host $typemap{$$rectype} $$val', TTL $ttl ($msg)"; … … 3961 3908 my $msg = $@; 3962 3909 eval { $dbh->rollback; }; 3963 if ($ config{log_failures}) {3910 if ($self->{log_failures}) { 3964 3911 $logdata{entry} = "Failed updating ".($defrec eq 'y' ? 'default ' : ''). 3965 3912 "record '$oldrec->{host} $typemap{$oldrec->{type}} $oldrec->{val}', TTL $oldrec->{ttl} ($msg)"; … … 4072 4019 my $msg = $@; 4073 4020 eval { $dbh->rollback; }; 4074 if ($ config{log_failures}) {4021 if ($self->{log_failures}) { 4075 4022 $logdata{entry} = "Error deleting ".($defrec eq 'y' ? 'default record' : 'record'). 4076 4023 " '$oldrec->{host} $typemap{$oldrec->{type}} $oldrec->{val}', TTL $oldrec->{ttl} ($msg)"; … … 4155 4102 ($args{filter} ? " AND entry ~* ?" : ''). 4156 4103 " ORDER BY $args{sortby} $args{sortorder}, log_id $args{sortorder}". 4157 ($args{offset} eq 'all' ? '' : " LIMIT $ config{perpage} OFFSET ".$args{offset}*$config{perpage});4104 ($args{offset} eq 'all' ? '' : " LIMIT $self->{perpage} OFFSET ".$args{offset}*$self->{perpage}); 4158 4105 my $loglist = $dbh->selectall_arrayref($sql, { Slice => {} }, ($args{id}, @filterargs) ); 4159 4106 $errstr = $dbh->errstr if !$loglist; … … 4948 4895 # still be followed. 4949 4896 # but that doesn't help other platforms. :/ 4950 sysopen(ZONECACHE, "$ config{exportcache}/$dom", O_RDWR|O_CREAT);4897 sysopen(ZONECACHE, "$self->{exportcache}/$dom", O_RDWR|O_CREAT); 4951 4898 flock(ZONECACHE, LOCK_EX); 4952 if ($changed || -s "$ config{exportcache}/$dom" == 0) {4899 if ($changed || -s "$self->{exportcache}/$dom" == 0) { 4953 4900 $recsth->execute($domid); 4954 4901 while (my ($host,$type,$val,$dist,$weight,$port,$ttl,$recid,$loc) = $recsth->fetchrow_array) { … … 5026 4973 # but that doesn't help other platforms. :/ 5027 4974 my $tmpzone = NetAddr::IP->new($revzone); 5028 sysopen(ZONECACHE, "$ config{exportcache}/".$tmpzone->network->addr, O_RDWR|O_CREAT);4975 sysopen(ZONECACHE, "$self->{exportcache}/".$tmpzone->network->addr, O_RDWR|O_CREAT); 5029 4976 flock(ZONECACHE, LOCK_EX); 5030 if ($changed || -s "$ config{exportcache}/".$tmpzone->network->addr == 0) {4977 if ($changed || -s "$self->{exportcache}/".$tmpzone->network->addr == 0) { 5031 4978 # need to fetch this separately since the rest of the records all (should) have real IPs in val 5032 4979 $soasth->execute($revid); … … 5404 5351 my ($subj,$message) = @_; 5405 5352 5406 return if $ config{mailhost} eq 'smtp.example.com'; # do nothing if still using default SMTP host.5407 5408 my $mailer = Net::SMTP->new($ config{mailhost}, Hello => "dnsadmin.$config{domain}");5409 5410 my $mailsender = ($ config{mailsender} ? $config{mailsender} : $config{mailnotify});5353 return if $self->{mailhost} eq 'smtp.example.com'; # do nothing if still using default SMTP host. 5354 5355 my $mailer = Net::SMTP->new($self->{mailhost}, Hello => "dnsadmin.$self->{domain}"); 5356 5357 my $mailsender = ($self->{mailsender} ? $self->{mailsender} : $self->{mailnotify}); 5411 5358 5412 5359 $mailer->mail($mailsender); 5413 $mailer->to($ config{mailnotify});5414 $mailer->data("From: \"$ config{mailname}\" <$mailsender>\n",5415 "To: <$ config{mailnotify}>\n",5360 $mailer->to($self->{mailnotify}); 5361 $mailer->data("From: \"$self->{mailname}\" <$mailsender>\n", 5362 "To: <$self->{mailnotify}>\n", 5416 5363 "Date: ".strftime("%a, %d %b %Y %H:%M:%S %z",localtime)."\n", 5417 5364 "Subject: $subj\n", 5418 5365 "X-Mailer: DNSAdmin Notify v".sprintf("%.1d",$DNSDB::VERSION)."\n", 5419 "Organization: $ config{orgname}\n",5366 "Organization: $self->{orgname}\n", 5420 5367 "\n$message\n"); 5421 5368 $mailer->quit; -
trunk/dnsdb.conf
r216 r517 2 2 3 3 # Database connection info 4 #dbname =dsndb5 #dbuser =dnsdb6 #dbpass =dnsdbpwd7 #dbhost =dnsdbhost4 #dbname = dsndb 5 #dbuser = dnsdb 6 #dbpass = dnsdbpwd 7 #dbhost = dnsdbhost 8 8 9 # SOA defaults. contact and prins may only contain a-z, 0-9, . and -,10 # the rest are expected to be numeric.11 #contact=hostmaster.example.com12 #prins=ns1.example.com13 #soattl=720014 #refresh=8640015 #retry=1440016 #expire=2880017 #minttl=90018 #ttl=90019 20 9 # Mail settings 21 #mailhost =smtp.example.com22 #mailnotify =dns@example.com23 #mailsender =hostmaster@example.com24 #mailname =Example Corp DNS Administrator25 #orgname =Example Corp26 #domain =example.com10 #mailhost = smtp.example.com 11 #mailnotify = dns@example.com 12 #mailsender = hostmaster@example.com 13 #mailname = Example Corp DNS Administrator 14 #orgname = Example Corp 15 #domain = example.com 27 16 28 17 # session - note this is fed directly to CGI::Session 29 18 # timeout supports (s)econds, (m)inutes, (h)ours, (d)ays, (w)eeks, (M)months, or (y)ears 30 #timeout =3h31 #sessiondir =/var/lib/dnsdb19 #timeout = 3h 20 #sessiondir = /var/lib/dnsdb 32 21 33 # misc 22 ## misc 23 34 24 # flag to indicate if failed changes should be logged 35 #log_failures =025 #log_failures = 1 36 26 # number of entries to display in lists 37 #perpage=25 27 #perpage = 25 28 # maximum number of FCGI requests to serve before reloading/restarting FCGI 29 #max_fcgi_requests = 10 30 # path for per-zone cache files for export 31 #exportcache = /var/cache/dnsdb 32 33 # RPC ACL 34 # A comma-separated list starting with an abstract "system name" 35 # (passed by an RPC caller), followed by a list of IP addresses 36 # allowed to make RPC calls with that name. 37 # Finer-grained access control must be handled by the caller. 38 #rpc_iplist = billing, 192.168.0.11 39 #rpc_iplist = billing, 172.12.12.12 40 #rpc_iplist = custportal, 192.168.1.12, 192.168.1.13
Note:
See TracChangeset
for help on using the changeset viewer.