- Timestamp:
- 03/22/12 15:31:21 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r279 r281 156 156 ## 157 157 ## utility functions 158 # _rectable() 158 ## 159 160 ## DNSDB::_rectable() 159 161 # Takes default+rdns flags, returns appropriate table name 160 162 sub _rectable { … … 167 169 } # end _rectable() 168 170 169 # 171 ## DNSDB::_recparent() 170 172 # Takes default+rdns flags, returns appropriate parent-id column name 171 173 sub _recparent { … … 178 180 } # end _recparent() 179 181 182 ## DNSDB::_ipparent() 180 183 # Check an IP to be added in a reverse zone to see if it's really in the requested parent. 181 184 # Takes a database handle, default and reverse flags, IP (fragment) to check, parent zone ID, … … 241 244 } # end _ipparent() 242 245 246 ## DNSDB::_hostparent() 243 247 # A little different than _ipparent above; this tries to *find* the parent zone of a hostname 248 # Takes a database handle and hostname. 249 # Returns the domain ID of the parent domain if one was found. 244 250 sub _hostparent { 245 251 my $dbh = shift; … … 258 264 } # end _hostparent() 259 265 266 ## DNSDB::_log() 267 # Log an action 268 # Takes a database handle and log entry hash containing at least: 269 # user_id, group_id, log entry 270 # and optionally one or more of: 271 # domain_id, rdns_id 272 sub _log { 273 my $dbh = shift; 274 275 my %args = @_; 276 277 $args{rdns_id} = 0 if !$args{rdns_id}; 278 $args{domain_id} = 0 if !$args{domain_id}; 279 280 ##fixme: farm out the actual logging to different subs for file, syslog, internal, etc based on config 281 # if ($config{log_channel} eq 'sql') { 282 $dbh->do("INSERT INTO log (domain_id,rdns_id,group_id,entry,user_id,email,name) VALUES (?,?,?,?,?,?,?)", 283 undef, 284 ($args{domain_id}, $args{rdns_id}, $args{group_id}, $args{entry}, 285 $userdata{userid}, $userdata{username}, $userdata{fullname}) ); 286 # } elsif ($config{log_channel} eq 'file') { 287 # } elsif ($config{log_channel} eq 'syslog') { 288 # } 289 } # end _log 290 291 260 292 ## 261 293 ## Record validation subs. 262 294 ## 295 296 ## All of these subs take substantially the same arguments: 297 # a database handle 298 # a hash containing at least the following keys: 299 # - defrec (default/live flag) 300 # - revrec (forward/reverse flag) 301 # - id (parent entity ID) 302 # - host (hostname) 303 # - rectype 304 # - val (IP, hostname [CNAME/MX/SRV] or text) 305 # - addr (NetAddr::IP object from val. May be undef.) 306 # MX and SRV record validation also expect distance, and SRV records expect weight and port as well. 307 # host, rectype, and addr should be references as these may be modified in validation 263 308 264 309 # A record … … 1192 1237 1193 1238 1194 ## DNSDB::_log()1195 # Log an action1196 # Internal sub1197 # Takes a database handle and log entry hash containing at least:1198 # user_id, group_id, log entry1199 # and optionally one or more of:1200 # username/email, user full name, domain_id, rdns_id1201 ##fixme: convert to trailing hash for user info1202 # User info must contain a (user ID OR username)+fullname1203 sub _log {1204 my $dbh = shift;1205 1206 my %args = @_;1207 1208 $args{rdns_id} = 0 if !$args{rdns_id};1209 $args{domain_id} = 0 if !$args{domain_id};1210 1211 ##fixme: need better way(s?) to snag userinfo for log entries. don't want to have1212 # to pass around yet *another* constant (already passing $dbh, shouldn't need to)1213 # my $fullname;1214 # if (!$args{user_id}) {1215 # ($args{user_id}, $fullname) = $dbh->selectrow_array("SELECT user_id, firstname || ' ' || lastname FROM users".1216 # " WHERE username=?", undef, ($args{username}));1217 # }1218 # if (!$args{username}) {1219 # ($args{username}, $fullname) = $dbh->selectrow_array("SELECT username, firstname || ' ' || lastname FROM users".1220 # " WHERE user_id=?", undef, ($args{user_id}));1221 # }1222 # if (!$args{fullname}) {1223 # ($fullname) = $dbh->selectrow_array("SELECT firstname || ' ' || lastname FROM users".1224 # " WHERE user_id=?", undef, ($args{user_id}));1225 # }1226 #1227 # $args{name} = $fullname if !$args{name};1228 1229 ##fixme: farm out the actual logging to different subs for file, syslog, internal, etc based on config1230 # if ($config{log_channel} eq 'sql') {1231 $dbh->do("INSERT INTO log (domain_id,rdns_id,group_id,entry,user_id,email,name) VALUES (?,?,?,?,?,?,?)",1232 undef,1233 ($args{domain_id}, $args{rdns_id}, $args{group_id}, $args{entry},1234 $userdata{userid}, $userdata{username}, $userdata{fullname}) );1235 # } elsif ($config{log_channel} eq 'file') {1236 # } elsif ($config{log_channel} eq 'syslog') {1237 # }1238 1239 } # end _log1240 1241 1242 1239 ## 1243 1240 ## Processing subs … … 2462 2459 # Collect these even if we're only doing a simple A record so we can call *any* validation sub 2463 2460 my $dist = shift; 2461 my $weight = shift; 2464 2462 my $port = shift; 2465 my $weight = shift;2466 2463 2467 2464 my $fields;
Note:
See TracChangeset
for help on using the changeset viewer.