- Timestamp:
- 04/15/11 17:53:45 (14 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dns.cgi
r93 r95 22 22 use Data::Dumper; 23 23 24 #sub is_tainted { 25 # # from perldoc perlsec 26 # return ! eval { eval("#" . substr(join("", @_), 0, 0)); 1 }; 27 #} 28 #use Cwd 'abs_path'; 29 #use File::Basename; 30 #use lib dirname( abs_path $0 ); 31 #die "argh! tainted!" if is_tainted($0); 32 #die "argh! \@INC got tainted!" if is_tainted(@INC); 33 34 # custom modules 24 35 use lib '.'; 25 # custom modules26 36 use DNSDB qw(:ALL); 27 37 … … 185 195 186 196 $page->param(curpage => $webvar{page}); 187 if ($webvar{del_failed}) { 188 $page->param(del_failed => 1); 189 $page->param(errmsg => $webvar{errmsg}); 190 } 197 $page->param(errmsg => $webvar{errmsg}) if $webvar{errmsg}; 198 # if ($webvar{del_failed}) { 199 # $page->param(del_failed => 1); 200 # $page->param(errmsg => $webvar{errmsg}); 201 # } 191 202 192 203 listdomains(); 193 204 194 205 } elsif ($webvar{page} eq 'newdomain') { 206 207 changepage(page => "domlist", errmsg => "You are not permitted to add domains") 208 unless ($permissions{admin} || $permissions{domain_create}); 195 209 196 210 # hmm. nothing to do here? … … 204 218 } elsif ($webvar{page} eq 'adddomain') { 205 219 220 changepage(page => "domlist", errmsg => "You are not permitted to add domains") 221 unless ($permissions{admin} || $permissions{domain_create}); 222 206 223 my ($code,$msg) = addDomain($dbh,$webvar{domain},$webvar{group},($webvar{makeactive} eq 'on' ? 1 : 0)); 207 224 … … 216 233 } elsif ($webvar{page} eq 'deldom') { 217 234 235 changepage(page => "domlist", errmsg => "You are not permitted to delete domains") 236 unless ($permissions{admin} || $permissions{domain_delete}); 237 218 238 $page->param(id => $webvar{id}); 219 239 … … 232 252 # need to find failure mode 233 253 logaction($webvar{id}, $session->param("username"), $pargroup, "Failed to delete domain $dom ($msg)"); 234 changepage(page => "domlist", del_failed => 1, errmsg => $msg);254 changepage(page => "domlist", errmsg => "Error deleting domain $dom: $msg"); 235 255 } else { 236 256 logaction($webvar{id}, $session->param("username"), $pargroup, "Deleted domain $dom"); … … 244 264 245 265 } elsif ($webvar{page} eq 'reclist') { 266 267 ##fixme: ACL needs pondering. Does "edit domain" interact with record add/remove/etc? 268 # Note this seems to be answered "no" in Vega. 269 # ACLs 270 $page->param(record_create => ($permissions{admin} || $permissions{record_create}) ); 271 # $page->param(record_edit => ($permissions{admin} || $permissions{record_edit}) ); 272 $page->param(record_delete => ($permissions{admin} || $permissions{record_delete}) ); 246 273 247 274 # Handle record list for both default records (per-group) and live domain records … … 280 307 } 281 308 282 if ($webvar{del_failed}) { 283 $page->param(del_failed => 1); 284 $page->param(errmsg => $webvar{errmsg}); 285 } 309 $page->param(errmsg => $webvar{errmsg}) if $webvar{errmsg}; 286 310 287 311 } elsif ($webvar{page} eq 'record') { 288 312 289 313 if ($webvar{recact} eq 'new') { 314 315 changepage(page => "reclist", errmsg => "You are not permitted to add records", id => $webvar{parentid}) 316 unless ($permissions{admin} || $permissions{record_create}); 290 317 291 318 $page->param(todo => "Add record"); … … 297 324 298 325 } elsif ($webvar{recact} eq 'add') { 326 327 changepage(page => "reclist", errmsg => "You are not permitted to add records", id => $webvar{parentid}) 328 unless ($permissions{admin} || $permissions{record_create}); 299 329 300 330 my @recargs = ($dbh,$webvar{defrec},$webvar{parentid},$webvar{name},$webvar{type},$webvar{address},$webvar{ttl}); … … 339 369 } elsif ($webvar{recact} eq 'edit') { 340 370 371 changepage(page => "reclist", errmsg => "You are not permitted to edit records", id => $webvar{parentid}) 372 unless ($permissions{admin} || $permissions{record_edit}); 373 341 374 $page->param(todo => "Update record"); 342 375 $page->param(recact => "update"); … … 354 387 355 388 } elsif ($webvar{recact} eq 'update') { 389 390 changepage(page => "reclist", errmsg => "You are not permitted to edit records", id => $webvar{parentid}) 391 unless ($permissions{admin} || $permissions{record_edit}); 356 392 357 393 my ($code,$msg) = updateRec($dbh,$webvar{defrec},$webvar{id}, … … 402 438 403 439 } elsif ($webvar{page} eq 'delrec') { 440 441 changepage(page => "reclist", errmsg => "You are not permitted to delete records", id => $webvar{parentid}) 442 unless ($permissions{admin} || $permissions{record_delete}); 404 443 405 444 $page->param(id => $webvar{id}); … … 427 466 } 428 467 changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}, 429 del_failed => 1, errmsg => $msg);430 $page->param(del_failed => 1);431 $page->param(errmsg => $msg);432 showdomain($webvar{defrec}, $webvar{parentid});468 errmsg => "Error deleting record: $msg"); 469 # $page->param(del_failed => 1); 470 # $page->param(errmsg => $msg); 471 # showdomain($webvar{defrec}, $webvar{parentid}); 433 472 } else { 434 473 if ($webvar{defrec} eq 'y') { … … 1195 1234 $rec->{port} = 'n/a' unless ($rec->{type} eq 'SRV'); 1196 1235 $row++; 1236 # ACLs 1237 $rec->{record_edit} = ($permissions{admin} || $permissions{record_edit}); 1238 $rec->{record_delete} = ($permissions{admin} || $permissions{record_delete}); 1197 1239 } 1198 1240 $page->param(reclist => $foo2); … … 1319 1361 $filter = $session->param($webvar{page}.'filter'); 1320 1362 $searchsubs = $session->param($webvar{page}.'searchsubs'); 1363 1364 # ACLs 1365 $page->param(domain_create => ($permissions{admin} || $permissions{domain_create}) ); 1366 $page->param(domain_edit => ($permissions{admin} || $permissions{domain_edit}) ); 1367 $page->param(domain_delete => ($permissions{admin} || $permissions{domain_delete}) ); 1321 1368 1322 1369 ##fixme: $logingroup or $curgroup? … … 1387 1434 $row{sid} = $sid; 1388 1435 $row{offset} = $offset; 1436 # ACLs 1437 $row{domain_edit} = ($permissions{admin} || $permissions{domain_edit}); 1438 $row{domain_delete} = ($permissions{admin} || $permissions{domain_delete}); 1389 1439 ##fixme: need to clean up status indicator/usage/inversion 1390 1440 push @domlist, \%row; -
trunk/templates/domlist.tmpl
r44 r95 5 5 <td align="center"> 6 6 7 <TMPL_IF del_failed>8 <div class='errmsg'> Error deleting domain <TMPL_VAR NAME=domain>:<TMPL_VAR NAME=errmsg></div>7 <TMPL_IF errmsg> 8 <div class='errmsg'><TMPL_VAR NAME=errmsg></div> 9 9 </TMPL_IF> 10 10 … … 19 19 </tr> 20 20 <tr><td colspan="3" align="center"><TMPL_INCLUDE NAME="lettsearch.tmpl"></td></tr> 21 <tr><td colspan="3" align="right">< a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=newdomain">New Domain</a></td></tr>21 <tr><td colspan="3" align="right"><TMPL_IF domain_create><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=newdomain">New Domain</a></TMPL_IF></td></tr> 22 22 </table> 23 23 … … 31 31 src="images/<TMPL_VAR NAME=sortorder>.png" /></TMPL_IF></td> 32 32 </TMPL_LOOP> 33 <td class="datahead_s">Change Status</td>34 <td class="datahead_s">Delete</td>33 <TMPL_IF domain_edit> <td class="datahead_s">Change Status</td></TMPL_IF> 34 <TMPL_IF domain_delete> <td class="datahead_s">Delete</td></TMPL_IF> 35 35 </tr> 36 36 <TMPL_IF name=domtable> … … 40 40 <td><TMPL_VAR name=status></td> 41 41 <td><TMPL_VAR name=group></td> 42 <td align="center"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=domlist<TMPL_IF NAME=offset>&offset=<TMPL_VAR NAME=offset></TMPL_IF>&id=<TMPL_VAR NAME=domainid>&action=<TMPL_IF NAME=mkactive>domon<TMPL_ELSE>domoff</TMPL_IF>"><TMPL_IF NAME=mkactive>activate<TMPL_ELSE>deactivate</TMPL_IF></a></td>43 <td align="center"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deldom&id=<TMPL_VAR NAME=domainid>"><img src="images/trash2.png" alt="[ Delete ]" /></a></td>42 <TMPL_IF domain_edit> <td align="center"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=domlist<TMPL_IF NAME=offset>&offset=<TMPL_VAR NAME=offset></TMPL_IF>&id=<TMPL_VAR NAME=domainid>&action=<TMPL_IF NAME=mkactive>domon<TMPL_ELSE>domoff</TMPL_IF>"><TMPL_IF NAME=mkactive>activate<TMPL_ELSE>deactivate</TMPL_IF></a></td></TMPL_IF> 43 <TMPL_IF domain_delete> <td align="center"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deldom&id=<TMPL_VAR NAME=domainid>"><img src="images/trash2.png" alt="[ Delete ]" /></a></td></TMPL_IF> 44 44 </tr> 45 45 </TMPL_LOOP> -
trunk/templates/reclist.tmpl
r76 r95 5 5 <td align="center" valign="top"> 6 6 7 <TMPL_IF del_failed>8 <div class='errmsg'> Error deleting record:<TMPL_VAR NAME=errmsg></div>7 <TMPL_IF errmsg> 8 <div class='errmsg'><TMPL_VAR NAME=errmsg></div> 9 9 </TMPL_IF> 10 10 … … 41 41 <tr class="darkrowheader"> 42 42 <td colspan="4">Records</td> 43 <td align="right"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=record&parentid=<TMPL_VAR NAME=id>&defrec=<TMPL_VAR NAME=defrec>&recact=new">Add record</a></td>43 <TMPL_IF record_create> <td align="right"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=record&parentid=<TMPL_VAR NAME=id>&defrec=<TMPL_VAR NAME=defrec>&recact=new">Add record</a></td></TMPL_IF> 44 44 <td align="right"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=log&id=<TMPL_VAR NAME=id><TMPL_IF logdom>&ltype=dom</TMPL_IF>">View log</a></td> 45 45 </tr> … … 56 56 NAME=defrec>"><TMPL_VAR NAME=colname></a><TMPL_IF NAME=sortorder> <img alt="<TMPL_VAR 57 57 NAME=sortorder>" src="images/<TMPL_VAR NAME=sortorder>.png" /></TMPL_IF></td></TMPL_LOOP> 58 <td>Delete</td>58 <TMPL_IF record_delete> <td>Delete</td></TMPL_IF> 59 59 </tr> 60 60 <TMPL_LOOP NAME=reclist> 61 61 <tr class="row<TMPL_VAR NAME=row>"> 62 <td>< a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=record&parentid=<TMPL_VAR NAME=id>&defrec=<TMPL_VAR NAME=defrec>&recact=edit&id=<TMPL_VAR NAME=record_id>"><TMPL_VAR NAME=host></a></td>62 <td><TMPL_IF record_edit><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=record&parentid=<TMPL_VAR NAME=id>&defrec=<TMPL_VAR NAME=defrec>&recact=edit&id=<TMPL_VAR NAME=record_id>"><TMPL_VAR NAME=host></a><TMPL_ELSE><TMPL_VAR NAME=host></TMPL_IF></td> 63 63 <td><TMPL_VAR NAME=type></td> 64 64 <td><TMPL_VAR NAME=val></td> … … 67 67 <td><TMPL_VAR NAME=port></td> 68 68 <td><TMPL_VAR NAME=ttl></td> 69 <td align="center"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=delrec&id=<TMPL_VAR NAME=record_id>&defrec=<TMPL_VAR NAME=defrec>&parentid=<TMPL_VAR NAME=id>"><img src="images/trash2.png" alt="[ Delete ]" /></a></td>69 <TMPL_IF record_delete> <td align="center"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=delrec&id=<TMPL_VAR NAME=record_id>&defrec=<TMPL_VAR NAME=defrec>&parentid=<TMPL_VAR NAME=id>"><img src="images/trash2.png" alt="[ Delete ]" /></a></td></TMPL_IF> 70 70 </tr> 71 71 </TMPL_LOOP>
Note:
See TracChangeset
for help on using the changeset viewer.