[2] | 1 | #!/usr/bin/perl -w -T
|
---|
[262] | 2 | # Main web UI script for DeepNet DNS Administrator
|
---|
| 3 | ##
|
---|
| 4 | # $Id: dns.cgi 320 2012-04-29 17:11:43Z kdeugau $
|
---|
[320] | 5 | # Copyright 2008-2012 Kris Deugau <kdeugau@deepnet.cx>
|
---|
[262] | 6 | #
|
---|
| 7 | # This program is free software: you can redistribute it and/or modify
|
---|
| 8 | # it under the terms of the GNU General Public License as published by
|
---|
| 9 | # the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | # (at your option) any later version.
|
---|
| 11 | #
|
---|
| 12 | # This program is distributed in the hope that it will be useful,
|
---|
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | # GNU General Public License for more details.
|
---|
| 16 | #
|
---|
| 17 | # You should have received a copy of the GNU General Public License
|
---|
| 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | ##
|
---|
[2] | 20 |
|
---|
| 21 | use strict;
|
---|
| 22 | use warnings;
|
---|
| 23 |
|
---|
| 24 | use CGI::Carp qw (fatalsToBrowser);
|
---|
| 25 | use CGI::Simple;
|
---|
| 26 | use HTML::Template;
|
---|
| 27 | use CGI::Session;
|
---|
[29] | 28 | use Crypt::PasswdMD5;
|
---|
[92] | 29 | use Digest::MD5 qw(md5_hex);
|
---|
[30] | 30 | use Net::DNS;
|
---|
[2] | 31 | use DBI;
|
---|
[83] | 32 | use Data::Dumper;
|
---|
[2] | 33 |
|
---|
[95] | 34 | #sub is_tainted {
|
---|
| 35 | # # from perldoc perlsec
|
---|
| 36 | # return ! eval { eval("#" . substr(join("", @_), 0, 0)); 1 };
|
---|
| 37 | #}
|
---|
| 38 | #use Cwd 'abs_path';
|
---|
| 39 | #use File::Basename;
|
---|
| 40 | #use lib dirname( abs_path $0 );
|
---|
| 41 | #die "argh! tainted!" if is_tainted($0);
|
---|
| 42 | #die "argh! \@INC got tainted!" if is_tainted(@INC);
|
---|
| 43 |
|
---|
[216] | 44 | # don't remove! required for GNU/FHS-ish install from tarball
|
---|
| 45 | use lib '.'; ##uselib##
|
---|
| 46 |
|
---|
[2] | 47 | use DNSDB qw(:ALL);
|
---|
| 48 |
|
---|
[13] | 49 | my @debugbits; # temp, to be spit out near the end of processing
|
---|
[160] | 50 | my $debugenv = 0;
|
---|
[13] | 51 |
|
---|
[2] | 52 | # Let's do these templates right...
|
---|
| 53 | my $templatedir = "templates";
|
---|
| 54 |
|
---|
| 55 | # Set up the CGI object...
|
---|
| 56 | my $q = new CGI::Simple;
|
---|
| 57 | # ... and get query-string params as well as POST params if necessary
|
---|
| 58 | $q->parse_query_string;
|
---|
| 59 |
|
---|
| 60 | # This is probably excessive fiddling, but it puts the parameters somewhere my fingers know about...
|
---|
[7] | 61 | my %webvar = $q->Vars;
|
---|
[2] | 62 |
|
---|
[168] | 63 | # shut up some warnings, in case we arrive somewhere we forgot to set this
|
---|
[224] | 64 | $webvar{defrec} = 'n' if !$webvar{defrec}; # non-default records
|
---|
| 65 | $webvar{revrec} = 'n' if !$webvar{revrec}; # non-reverse (domain) records
|
---|
[168] | 66 |
|
---|
[163] | 67 | # load some local system defaults (mainly DB connect info)
|
---|
| 68 | # note this is not *absolutely* fatal, since there's a default dbname/user/pass in DNSDB.pm
|
---|
| 69 | # we'll catch a bad DB connect string once we get to trying that
|
---|
| 70 | ##fixme: pass params to loadConfig, and use them there, to allow one codebase to support multiple sites
|
---|
| 71 | if (!loadConfig()) {
|
---|
| 72 | warn "Using default configuration; unable to load custom settings: $DNSDB::errstr";
|
---|
| 73 | }
|
---|
| 74 |
|
---|
[13] | 75 | # persistent stuff needed on most/all pages
|
---|
[2] | 76 | my $sid = ($webvar{sid} ? $webvar{sid} : undef);
|
---|
[216] | 77 | my $session = new CGI::Session("driver:File", $sid, {Directory => $config{sessiondir}})
|
---|
[68] | 78 | or die CGI::Session->errstr();
|
---|
[2] | 79 | #$sid = $session->id() if !$sid;
|
---|
| 80 | if (!$sid) {
|
---|
| 81 | # init stuff. can probably axe this down to just above if'n'when user manipulation happens
|
---|
| 82 | $sid = $session->id();
|
---|
[163] | 83 | $session->expire($config{timeout});
|
---|
[2] | 84 | # need to know the "upper" group the user can deal with; may as well
|
---|
| 85 | # stick this in the session rather than calling out to the DB every time.
|
---|
[18] | 86 | $session->param('logingroup',1);
|
---|
| 87 | $session->param('curgroup',1); # yes, we *do* need to track this too. er, probably.
|
---|
[51] | 88 | $session->param('domlistsortby','domain');
|
---|
| 89 | $session->param('domlistorder','ASC');
|
---|
[238] | 90 | $session->param('revzonessortby','revnet');
|
---|
| 91 | $session->param('revzonesorder','ASC');
|
---|
[54] | 92 | $session->param('useradminsortby','user');
|
---|
[51] | 93 | $session->param('useradminorder','ASC');
|
---|
| 94 | $session->param('grpmansortby','group');
|
---|
| 95 | $session->param('grpmanorder','ASC');
|
---|
[76] | 96 | $session->param('reclistsortby','host');
|
---|
[51] | 97 | $session->param('reclistorder','ASC');
|
---|
[2] | 98 | }
|
---|
| 99 |
|
---|
[125] | 100 | # Just In Case. Stale sessions should not be resurrectable.
|
---|
| 101 | if ($sid ne $session->id()) {
|
---|
[163] | 102 | $sid = '';
|
---|
[125] | 103 | changepage(page=> "login", sessexpired => 1);
|
---|
| 104 | }
|
---|
| 105 |
|
---|
[163] | 106 | # normal expiry, more or less
|
---|
| 107 | if ($session->is_expired) {
|
---|
| 108 | $sid = '';
|
---|
| 109 | changepage(page=> "login", sessexpired => 1);
|
---|
| 110 | }
|
---|
| 111 |
|
---|
[19] | 112 | my $logingroup = ($session->param('logingroup') ? $session->param('logingroup') : 1);
|
---|
| 113 | my $curgroup = ($session->param('curgroup') ? $session->param('curgroup') : $logingroup);
|
---|
[18] | 114 |
|
---|
[176] | 115 | # decide which page to spit out...
|
---|
| 116 | # also set $webvar{page} before we try to use it.
|
---|
| 117 | $webvar{page} = 'login' if !$webvar{page};
|
---|
| 118 |
|
---|
[54] | 119 | # per-page startwith, filter, searchsubs
|
---|
[160] | 120 |
|
---|
| 121 | ##fixme: complain-munge-and-continue with non-"[a-z0-9-.]" filter and startwith
|
---|
| 122 | $webvar{startwith} =~ s/^(0-9|[a-z]).*/$1/ if $webvar{startwith};
|
---|
| 123 | # not much call for chars not allowed in domain names
|
---|
| 124 | $webvar{filter} =~ s/[^a-zA-Z0-9_.:@-]//g if $webvar{filter};
|
---|
[176] | 125 | ## only set 'y' if box is checked, no other values legal
|
---|
| 126 | ## however, see https://secure.deepnet.cx/trac/dnsadmin/ticket/31
|
---|
| 127 | # first, drop obvious fakes
|
---|
| 128 | delete $webvar{searchsubs} if $webvar{searchsubs} && $webvar{searchsubs} !~ /^[ny]/;
|
---|
| 129 | # strip the known "turn me off!" bit.
|
---|
| 130 | $webvar{searchsubs} =~ s/^n\s?// if $webvar{searchsubs};
|
---|
| 131 | # strip non-y/n - note this legitimately allows {searchsubs} to go empty
|
---|
| 132 | $webvar{searchsubs} =~ s/[^yn]//g if $webvar{searchsubs};
|
---|
[160] | 133 |
|
---|
[64] | 134 | $session->param($webvar{page}.'startwith', $webvar{startwith}) if defined($webvar{startwith});
|
---|
[62] | 135 | $session->param($webvar{page}.'filter', $webvar{filter}) if defined($webvar{filter});
|
---|
[57] | 136 | $session->param($webvar{page}.'searchsubs', $webvar{searchsubs}) if defined($webvar{searchsubs});
|
---|
[54] | 137 |
|
---|
| 138 | my $startwith = $session->param($webvar{page}.'startwith');
|
---|
| 139 | my $filter = $session->param($webvar{page}.'filter');
|
---|
| 140 | my $searchsubs = $session->param($webvar{page}.'searchsubs');
|
---|
| 141 |
|
---|
[160] | 142 | # ... and assemble the args
|
---|
| 143 | my @filterargs;
|
---|
| 144 | push @filterargs, "^[$startwith]" if $startwith;
|
---|
| 145 | push @filterargs, $filter if $filter;
|
---|
| 146 |
|
---|
[26] | 147 | # nrgh, can't handle login here because we don't have a database handle to check the user/pass with yet
|
---|
[2] | 148 |
|
---|
| 149 | my $header = HTML::Template->new(filename => "$templatedir/header.tmpl");
|
---|
| 150 | my $footer = HTML::Template->new(filename => "$templatedir/footer.tmpl");
|
---|
[210] | 151 | $header->param(orgname => $config{orgname}) if $config{orgname} ne 'Example Corp';
|
---|
| 152 | $footer->param(version => $DNSDB::VERSION);
|
---|
[2] | 153 |
|
---|
[117] | 154 | ## set up "URL to self"
|
---|
| 155 | # @#$%@%@#% XHTML - & in a URL must be escaped. >:(
|
---|
| 156 | my $uri_self = $ENV{REQUEST_URI};
|
---|
| 157 | $uri_self =~ s/\&([a-z])/\&\;$1/g;
|
---|
| 158 |
|
---|
| 159 | # le sigh. and we need to strip any previous action
|
---|
| 160 | $uri_self =~ s/\&action=[^&]+//g;
|
---|
| 161 |
|
---|
| 162 | # and search filter options. these get stored in the session, but discarded
|
---|
| 163 | # as soon as you switch to a different page.
|
---|
| 164 | ##fixme: think about retaining these on a per-page basis, as well as offset; same as the sort-order bits
|
---|
| 165 | no warnings qw(uninitialized);
|
---|
| 166 | $uri_self =~ s/\&startwith=[a-z09-]*(\&)?/$1/g;
|
---|
| 167 | $uri_self =~ s/\&searchsubs=[a-z09-]*(\&)?/$1/g;
|
---|
| 168 | $uri_self =~ s/\&filter=[a-z09-]*(\&)?/$1/g;
|
---|
| 169 | use warnings qw(uninitialized);
|
---|
| 170 |
|
---|
[213] | 171 | # Fix up $uri_self so we don't lose the session/page
|
---|
| 172 | $uri_self .= "?sid=$sid&page=$webvar{page}" if $uri_self =~ m{/dns.cgi$};
|
---|
| 173 | $uri_self = "$ENV{SCRIPT_NAME}?sid=$sid&page=$webvar{page}$1" if $uri_self =~ m{/dns.cgi\&(.+)$};
|
---|
| 174 |
|
---|
[160] | 175 | # pagination
|
---|
| 176 | my $perpage = 15;
|
---|
[201] | 177 | $perpage = $config{perpage} if $config{perpage};
|
---|
[2] | 178 | my $offset = ($webvar{offset} ? $webvar{offset} : 0);
|
---|
| 179 |
|
---|
| 180 | # NB: these must match the field name and SQL ascend/descend syntax respectively
|
---|
[41] | 181 | my $sortby = "domain";
|
---|
| 182 | my $sortorder = "ASC";
|
---|
[2] | 183 |
|
---|
[128] | 184 | ##fixme: quit throwing the database handle around, and put all the SQL and direct DB fiddling into DNSDB.pm
|
---|
[112] | 185 | # dbname, user, pass, host (optional)
|
---|
[128] | 186 | my ($dbh,$msg) = connectDB($config{dbname}, $config{dbuser}, $config{dbpass}, $config{dbhost});
|
---|
[2] | 187 |
|
---|
[128] | 188 | if (!$dbh) {
|
---|
| 189 | print "Content-type: text/html\n\n";
|
---|
| 190 | print $header->output;
|
---|
| 191 | my $errpage = HTML::Template->new(filename => "$templatedir/dberr.tmpl");
|
---|
| 192 | $errpage->param(errmsg => $msg);
|
---|
| 193 | print $errpage->output;
|
---|
| 194 | print $footer->output;
|
---|
| 195 | exit;
|
---|
| 196 | }
|
---|
[2] | 197 |
|
---|
[128] | 198 | # Load config pieces from the database. Ideally all but the DB user/pass/etc should be loaded here.
|
---|
[2] | 199 | initGlobals($dbh);
|
---|
| 200 |
|
---|
[153] | 201 | # security check - does the user have permission to view this entity?
|
---|
| 202 | # this is a prep step used "many" places
|
---|
| 203 | my @viewablegroups;
|
---|
| 204 | getChildren($dbh, $logingroup, \@viewablegroups, 'all');
|
---|
| 205 | push @viewablegroups, $logingroup;
|
---|
| 206 |
|
---|
[173] | 207 | my $page;
|
---|
| 208 | eval {
|
---|
[238] | 209 | # sigh. can't set loop_context_vars or global_vars once instantiated.
|
---|
| 210 | $page = HTML::Template->new(filename => "$templatedir/$webvar{page}.tmpl",
|
---|
| 211 | loop_context_vars => 1, global_vars => 1);
|
---|
[173] | 212 | };
|
---|
| 213 | if ($@) {
|
---|
[238] | 214 | my $msg = $@;
|
---|
[173] | 215 | $page = HTML::Template->new(filename => "$templatedir/badpage.tmpl");
|
---|
[238] | 216 | if (-e "$templatedir/$webvar{page}.tmpl") {
|
---|
| 217 | $page->param(badtemplate => $q->escapeHTML($msg));
|
---|
| 218 | } else {
|
---|
| 219 | warn "Bad page $webvar{page} requested";
|
---|
| 220 | $page->param(badpage => $q->escapeHTML($webvar{page}));
|
---|
| 221 | }
|
---|
[173] | 222 | $webvar{page} = 'badpage';
|
---|
| 223 | }
|
---|
[154] | 224 |
|
---|
[26] | 225 | # handle login redirect
|
---|
[30] | 226 | if ($webvar{action}) {
|
---|
| 227 | if ($webvar{action} eq 'login') {
|
---|
[65] | 228 | # Snag ACL/permissions here too
|
---|
[26] | 229 |
|
---|
[279] | 230 | my $userdata = login($dbh, $webvar{username}, $webvar{password});
|
---|
[183] | 231 |
|
---|
[279] | 232 | if ($userdata) {
|
---|
| 233 |
|
---|
[183] | 234 | # set session bits
|
---|
[279] | 235 | $session->param('logingroup',$userdata->{group_id});
|
---|
| 236 | $session->param('curgroup',$userdata->{group_id});
|
---|
| 237 | $session->param('uid',$userdata->{user_id});
|
---|
[280] | 238 | $session->param('username',$webvar{username});
|
---|
[183] | 239 |
|
---|
[279] | 240 | changepage(page => "domlist");
|
---|
[183] | 241 |
|
---|
[30] | 242 | } else {
|
---|
[183] | 243 | $webvar{loginfailed} = 1;
|
---|
| 244 | } # user data fetch check
|
---|
[29] | 245 |
|
---|
[30] | 246 | } elsif ($webvar{action} eq 'logout') {
|
---|
| 247 | # delete the session
|
---|
| 248 | $session->delete();
|
---|
| 249 | $session->flush();
|
---|
| 250 |
|
---|
| 251 | my $newurl = "http://$ENV{HTTP_HOST}$ENV{SCRIPT_NAME}";
|
---|
| 252 | $newurl =~ s|/[^/]+$|/|;
|
---|
| 253 | print "Status: 302\nLocation: $newurl\n\n";
|
---|
| 254 | exit;
|
---|
| 255 |
|
---|
[57] | 256 | } elsif ($webvar{action} eq 'chgroup') {
|
---|
| 257 | # fiddle session-stored group data
|
---|
| 258 | # magic incantation to... uhhh...
|
---|
[117] | 259 |
|
---|
| 260 | # ... and the "change group" bits...
|
---|
| 261 | $uri_self =~ s/\&group=[^&]*//g;
|
---|
| 262 |
|
---|
[154] | 263 | # security check - does the user have permission to view this entity?
|
---|
[155] | 264 | my $errmsg;
|
---|
[154] | 265 | if (!(grep /^$webvar{group}$/, @viewablegroups)) {
|
---|
| 266 | # hmm. Reset the current group to the login group? Yes. Prevents confusing behaviour elsewhere.
|
---|
| 267 | $session->param('curgroup',$logingroup);
|
---|
| 268 | $webvar{group} = $logingroup;
|
---|
| 269 | $curgroup = $logingroup;
|
---|
[155] | 270 | $errmsg = "You are not permitted to view or make changes in the requested group";
|
---|
| 271 | $page->param(errmsg => $errmsg);
|
---|
[154] | 272 | }
|
---|
[153] | 273 |
|
---|
[57] | 274 | $session->param('curgroup', $webvar{group});
|
---|
| 275 | $curgroup = ($webvar{group} ? $webvar{group} : $session->param('curgroup'));
|
---|
[155] | 276 |
|
---|
| 277 | # I hate special cases.
|
---|
[224] | 278 | ##fixme: probably need to handle webvar{revrec}=='y' too
|
---|
[155] | 279 | if ($webvar{page} eq 'reclist' && $webvar{defrec} eq 'y') {
|
---|
[245] | 280 | my %args = (page => $webvar{page}, id => $curgroup, defrec => $webvar{defrec}, revrec => $webvar{revrec});
|
---|
[155] | 281 | $args{errmsg} = $errmsg if $errmsg;
|
---|
| 282 | changepage(%args);
|
---|
| 283 | }
|
---|
| 284 |
|
---|
[30] | 285 | }
|
---|
[57] | 286 | } # handle global webvar{action}s
|
---|
[26] | 287 |
|
---|
[319] | 288 | # finally check if the user was disabled. we could just leave this for logout/session expiry,
|
---|
| 289 | # but if they keep the session active they'll continue to have access long after being disabled. :/
|
---|
| 290 | # Treat it as a session expiry.
|
---|
| 291 | if ($session->param('uid') && !userStatus($dbh, $session->param('uid')) ) {
|
---|
| 292 | $sid = '';
|
---|
| 293 | $session->delete; # force expiry of the session Right Away
|
---|
| 294 | $session->flush; # make sure it hits storage
|
---|
| 295 | changepage(page=> "login", sessexpired => 1);
|
---|
| 296 | }
|
---|
| 297 |
|
---|
[279] | 298 | # Misc Things To Do on most pages
|
---|
| 299 | initPermissions($dbh, $session->param('uid'));
|
---|
| 300 | initActionLog($dbh, $session->param('uid'));
|
---|
[57] | 301 |
|
---|
[163] | 302 | $page->param(sid => $sid) unless $webvar{page} eq 'login'; # no session ID on the login page
|
---|
[2] | 303 |
|
---|
[26] | 304 | if ($webvar{page} eq 'login') {
|
---|
[3] | 305 |
|
---|
[26] | 306 | $page->param(loginfailed => 1) if $webvar{loginfailed};
|
---|
[163] | 307 | $page->param(sessexpired => 1) if $webvar{sessexpired};
|
---|
[210] | 308 | $page->param(version => $DNSDB::VERSION);
|
---|
[26] | 309 |
|
---|
| 310 | } elsif ($webvar{page} eq 'domlist' or $webvar{page} eq 'index') {
|
---|
| 311 |
|
---|
[239] | 312 | $page->param(domlist => 1);
|
---|
| 313 |
|
---|
[3] | 314 | # hmm. seeing problems in some possibly-not-so-corner cases.
|
---|
[10] | 315 | # this currently only handles "domain on", "domain off"
|
---|
[275] | 316 | if (defined($webvar{zonestatus})) {
|
---|
[154] | 317 | # security check - does the user have permission to access this entity?
|
---|
| 318 | my $flag = 0;
|
---|
| 319 | foreach (@viewablegroups) {
|
---|
| 320 | $flag = 1 if isParent($dbh, $_, 'group', $webvar{id}, 'domain');
|
---|
| 321 | }
|
---|
[188] | 322 | if ($flag && ($permissions{admin} || $permissions{domain_edit})) {
|
---|
[275] | 323 | my $stat = zoneStatus($dbh,$webvar{id},'n',$webvar{zonestatus});
|
---|
[283] | 324 | $page->param(resultmsg => $DNSDB::resultstr);
|
---|
[154] | 325 | } else {
|
---|
| 326 | $page->param(errmsg => "You are not permitted to view or change the requested domain");
|
---|
| 327 | }
|
---|
[275] | 328 | $uri_self =~ s/\&zonestatus=[^&]*//g; # clean up URL for stuffing into templates
|
---|
[3] | 329 | }
|
---|
| 330 |
|
---|
[177] | 331 | if ($session->param('resultmsg')) {
|
---|
| 332 | $page->param(resultmsg => $session->param('resultmsg'));
|
---|
| 333 | $session->clear('resultmsg');
|
---|
| 334 | }
|
---|
[174] | 335 | if ($session->param('errmsg')) {
|
---|
| 336 | $page->param(errmsg => $session->param('errmsg'));
|
---|
| 337 | $session->clear('errmsg');
|
---|
| 338 | }
|
---|
[147] | 339 |
|
---|
[18] | 340 | $page->param(curpage => $webvar{page});
|
---|
| 341 |
|
---|
[11] | 342 | listdomains();
|
---|
[2] | 343 |
|
---|
[4] | 344 | } elsif ($webvar{page} eq 'newdomain') {
|
---|
[2] | 345 |
|
---|
[95] | 346 | changepage(page => "domlist", errmsg => "You are not permitted to add domains")
|
---|
| 347 | unless ($permissions{admin} || $permissions{domain_create});
|
---|
| 348 |
|
---|
[310] | 349 | $webvar{group} = $curgroup if !$webvar{group};
|
---|
| 350 | fill_grouplist("grouplist", $webvar{group});
|
---|
[126] | 351 |
|
---|
[174] | 352 | if ($session->param('add_failed')) {
|
---|
| 353 | $session->clear('add_failed');
|
---|
[62] | 354 | $page->param(add_failed => 1);
|
---|
[174] | 355 | $page->param(errmsg => $session->param('errmsg'));
|
---|
| 356 | $session->clear('errmsg');
|
---|
[62] | 357 | $page->param(domain => $webvar{domain});
|
---|
[310] | 358 | $page->param(addinactive => $webvar{makeactive} eq 'n');
|
---|
[62] | 359 | }
|
---|
[2] | 360 |
|
---|
[57] | 361 | } elsif ($webvar{page} eq 'adddomain') {
|
---|
| 362 |
|
---|
[95] | 363 | changepage(page => "domlist", errmsg => "You are not permitted to add domains")
|
---|
| 364 | unless ($permissions{admin} || $permissions{domain_create});
|
---|
| 365 |
|
---|
[162] | 366 | # security check - does the user have permission to access this entity?
|
---|
[169] | 367 | if (!check_scope(id => $webvar{group}, type => 'group')) {
|
---|
[174] | 368 | $session->param('add_failed', 1);
|
---|
| 369 | ##fixme: domain a security risk for XSS?
|
---|
| 370 | changepage(page => "newdomain", domain => $webvar{domain},
|
---|
[162] | 371 | errmsg => "You do not have permission to add a domain to the requested group");
|
---|
| 372 | }
|
---|
| 373 |
|
---|
[205] | 374 | $webvar{makeactive} = 0 if !defined($webvar{makeactive});
|
---|
| 375 |
|
---|
[190] | 376 | my ($code,$msg) = addDomain($dbh,$webvar{domain},$webvar{group},($webvar{makeactive} eq 'on' ? 1 : 0),
|
---|
[259] | 377 | (username => $session->param("username"), id => $session->param("uid")));
|
---|
[57] | 378 |
|
---|
| 379 | if ($code eq 'OK') {
|
---|
[198] | 380 | mailNotify($dbh, "New ".($webvar{makeactive} eq 'on' ? 'Active' : 'Inactive')." Domain Created",
|
---|
| 381 | ($webvar{makeactive} eq 'on' ? 'Active' : 'Inactive').qq( domain "$webvar{domain}" added by ).
|
---|
| 382 | $session->param("username"));
|
---|
[57] | 383 | changepage(page => "reclist", id => $msg);
|
---|
| 384 | } else {
|
---|
[174] | 385 | $session->param('add_failed', 1);
|
---|
| 386 | ##fixme: domain a security risk for XSS?
|
---|
[310] | 387 | changepage(page => "newdomain", domain => $webvar{domain}, errmsg => $msg,
|
---|
| 388 | makeactive => ($webvar{makeactive} ? 'y' : 'n'), group => $webvar{group});
|
---|
[57] | 389 | }
|
---|
| 390 |
|
---|
[11] | 391 | } elsif ($webvar{page} eq 'deldom') {
|
---|
| 392 |
|
---|
[95] | 393 | changepage(page => "domlist", errmsg => "You are not permitted to delete domains")
|
---|
| 394 | unless ($permissions{admin} || $permissions{domain_delete});
|
---|
| 395 |
|
---|
[162] | 396 | # security check - does the user have permission to access this entity?
|
---|
[169] | 397 | if (!check_scope(id => $webvar{id}, type => 'domain')) {
|
---|
[162] | 398 | changepage(page => "domlist", errmsg => "You do not have permission to delete the requested domain");
|
---|
| 399 | }
|
---|
| 400 |
|
---|
[11] | 401 | $page->param(id => $webvar{id});
|
---|
[88] | 402 |
|
---|
[11] | 403 | # first pass = confirm y/n (sorta)
|
---|
| 404 | if (!defined($webvar{del})) {
|
---|
[88] | 405 |
|
---|
[11] | 406 | $page->param(del_getconf => 1);
|
---|
| 407 | $page->param(domain => domainName($dbh,$webvar{id}));
|
---|
| 408 |
|
---|
[88] | 409 | } elsif ($webvar{del} eq 'ok') {
|
---|
[254] | 410 | my $pargroup = parentID($dbh, (id => $webvar{id}, type => 'domain', revrec => $webvar{revrec}));
|
---|
[274] | 411 | my ($code,$msg) = delZone($dbh, $webvar{id}, $webvar{revrec});
|
---|
[187] | 412 | if ($code eq 'OK') {
|
---|
[285] | 413 | changepage(page => "domlist", resultmsg => $msg);
|
---|
[187] | 414 | } else {
|
---|
[285] | 415 | changepage(page => "domlist", errmsg => $msg);
|
---|
[11] | 416 | }
|
---|
[88] | 417 |
|
---|
[11] | 418 | } else {
|
---|
| 419 | # cancelled. whee!
|
---|
| 420 | changepage(page => "domlist");
|
---|
| 421 | }
|
---|
| 422 |
|
---|
[237] | 423 | } elsif ($webvar{page} eq 'revzones') {
|
---|
| 424 |
|
---|
| 425 | $webvar{revrec} = 'y';
|
---|
[274] | 426 |
|
---|
[275] | 427 | if (defined($webvar{zonestatus})) {
|
---|
| 428 | # security check - does the user have permission to access this entity?
|
---|
| 429 | my $flag = 0;
|
---|
| 430 | foreach (@viewablegroups) {
|
---|
| 431 | $flag = 1 if isParent($dbh, $_, 'group', $webvar{id}, 'revzone');
|
---|
| 432 | }
|
---|
| 433 | if ($flag && ($permissions{admin} || $permissions{domain_edit})) {
|
---|
| 434 | my $stat = zoneStatus($dbh,$webvar{id},'y',$webvar{zonestatus});
|
---|
[283] | 435 | $page->param(resultmsg => $DNSDB::resultstr);
|
---|
[275] | 436 | } else {
|
---|
| 437 | $page->param(errmsg => "You are not permitted to view or change the requested reverse zone");
|
---|
| 438 | }
|
---|
| 439 | $uri_self =~ s/\&zonestatus=[^&]*//g; # clean up URL for stuffing into templates
|
---|
| 440 | }
|
---|
| 441 |
|
---|
[274] | 442 | if ($session->param('resultmsg')) {
|
---|
| 443 | $page->param(resultmsg => $session->param('resultmsg'));
|
---|
| 444 | $session->clear('resultmsg');
|
---|
| 445 | }
|
---|
| 446 | if ($session->param('errmsg')) {
|
---|
| 447 | $page->param(errmsg => $session->param('errmsg'));
|
---|
| 448 | $session->clear('errmsg');
|
---|
| 449 | }
|
---|
| 450 |
|
---|
[237] | 451 | $page->param(curpage => $webvar{page});
|
---|
| 452 | listzones();
|
---|
| 453 |
|
---|
[260] | 454 | } elsif ($webvar{page} eq 'newrevzone') {
|
---|
| 455 |
|
---|
| 456 | ## scope/access check - use domain settings? invent new (bleh)
|
---|
| 457 | changepage(page => "revzones", errmsg => "You are not permitted to add reverse zones")
|
---|
| 458 | unless ($permissions{admin} || $permissions{domain_create});
|
---|
| 459 |
|
---|
| 460 | fill_grouplist("grouplist");
|
---|
| 461 |
|
---|
[269] | 462 | # prepopulate revpatt with the matching default record
|
---|
| 463 | # getRecByName($dbh, (revrec => $webvar{revrec}, defrec => $webvar{defrec}, host => 'string'));
|
---|
| 464 |
|
---|
[270] | 465 | if ($session->param('add_failed')) {
|
---|
| 466 | $session->clear('add_failed');
|
---|
| 467 | $page->param(errmsg => $session->param('errmsg'));
|
---|
| 468 | $session->clear('errmsg');
|
---|
[260] | 469 | $page->param(revzone => $webvar{revzone});
|
---|
| 470 | $page->param(revpatt => $webvar{revpatt});
|
---|
| 471 | }
|
---|
| 472 |
|
---|
| 473 | } elsif ($webvar{page} eq 'addrevzone') {
|
---|
| 474 |
|
---|
| 475 | changepage(page => "revzones", errmsg => "You are not permitted to add reverse zones")
|
---|
| 476 | unless ($permissions{admin} || $permissions{domain_create});
|
---|
| 477 |
|
---|
| 478 | # security check - does the user have permission to access this entity?
|
---|
| 479 | if (!check_scope(id => $webvar{group}, type => 'group')) {
|
---|
| 480 | changepage(page => "newrevzone", add_failed => 1, revzone => $webvar{revzone}, revpatt => $webvar{revpatt},
|
---|
| 481 | errmsg => "You do not have permission to add a reverse zone to the requested group");
|
---|
| 482 | }
|
---|
| 483 |
|
---|
| 484 | my ($code,$msg) = addRDNS($dbh, $webvar{revzone}, $webvar{revpatt}, $webvar{group},
|
---|
[286] | 485 | ($webvar{makeactive} eq 'on' ? 1 : 0));
|
---|
[260] | 486 |
|
---|
| 487 | if ($code eq 'OK') {
|
---|
| 488 | changepage(page => "reclist", id => $msg, revrec => 'y');
|
---|
[286] | 489 | } elsif ($code eq 'WARN') {
|
---|
| 490 | changepage(page => "reclist", id => $msg, revrec => 'y', warnmsg => $DNSDB::resultstr);
|
---|
[260] | 491 | } else {
|
---|
[270] | 492 | $session->param('add_failed', 1);
|
---|
| 493 | changepage(page => "newrevzone", revzone => $webvar{revzone}, revpatt => $webvar{revpatt}, errmsg => $msg);
|
---|
[260] | 494 | }
|
---|
| 495 |
|
---|
[274] | 496 | } elsif ($webvar{page} eq 'delrevzone') {
|
---|
[260] | 497 |
|
---|
[274] | 498 | changepage(page => "revzones", errmsg => "You are not permitted to delete reverse zones")
|
---|
| 499 | unless ($permissions{admin} || $permissions{domain_delete});
|
---|
| 500 |
|
---|
| 501 | # security check - does the user have permission to access this entity?
|
---|
| 502 | if (!check_scope(id => $webvar{id}, type => 'revzone')) {
|
---|
| 503 | changepage(page => "revzones", errmsg => "You do not have permission to delete the requested reverse zone");
|
---|
| 504 | }
|
---|
| 505 |
|
---|
| 506 | $page->param(id => $webvar{id});
|
---|
| 507 |
|
---|
| 508 | # first pass = confirm y/n (sorta)
|
---|
| 509 | if (!defined($webvar{del})) {
|
---|
| 510 |
|
---|
| 511 | $page->param(del_getconf => 1);
|
---|
| 512 | $page->param(revzone => revName($dbh,$webvar{id}));
|
---|
| 513 |
|
---|
| 514 | } elsif ($webvar{del} eq 'ok') {
|
---|
| 515 | my $pargroup = parentID($dbh, (id => $webvar{id}, type => 'revzone', revrec => $webvar{revrec}));
|
---|
| 516 | my $zone = revName($dbh, $webvar{id});
|
---|
| 517 | my ($code,$msg) = delZone($dbh, $webvar{id}, 'y');
|
---|
| 518 | if ($code eq 'OK') {
|
---|
[285] | 519 | changepage(page => "revzones", resultmsg => $msg);
|
---|
[274] | 520 | } else {
|
---|
[285] | 521 | changepage(page => "revzones", errmsg => $msg);
|
---|
[274] | 522 | }
|
---|
| 523 |
|
---|
| 524 | } else {
|
---|
| 525 | # cancelled. whee!
|
---|
| 526 | changepage(page => "revzones");
|
---|
| 527 | }
|
---|
| 528 |
|
---|
[47] | 529 | } elsif ($webvar{page} eq 'reclist') {
|
---|
| 530 |
|
---|
[162] | 531 | # security check - does the user have permission to view this entity?
|
---|
[244] | 532 | if (!check_scope(id => $webvar{id}, type =>
|
---|
| 533 | ($webvar{defrec} eq 'y' ? 'group' : ($webvar{revrec} eq 'y' ? 'revzone' : 'domain')))) {
|
---|
[154] | 534 | $page->param(errmsg => "You are not permitted to view or change the requested ".
|
---|
[244] | 535 | ($webvar{defrec} eq 'y' ? "group's default records" :
|
---|
| 536 | ($webvar{revrec} eq 'y' ? "reverse zone's records" : "domain's records")));
|
---|
[160] | 537 | $page->param(perm_err => 1); # this causes the template to skip the record listing output.
|
---|
[162] | 538 | goto DONERECLIST; # and now we skip filling in the content which is not printed due to perm_err above
|
---|
[154] | 539 | }
|
---|
[162] | 540 |
|
---|
[140] | 541 | # hmm. where do we send them?
|
---|
| 542 | if ($webvar{defrec} eq 'y' && !$permissions{admin}) {
|
---|
| 543 | $page->param(errmsg => "You are not permitted to edit default records");
|
---|
| 544 | $page->param(perm_err => 1);
|
---|
[162] | 545 | } else {
|
---|
[140] | 546 |
|
---|
| 547 | $page->param(mayeditsoa => $permissions{admin} || $permissions{domain_edit});
|
---|
[95] | 548 | ##fixme: ACL needs pondering. Does "edit domain" interact with record add/remove/etc?
|
---|
| 549 | # Note this seems to be answered "no" in Vega.
|
---|
| 550 | # ACLs
|
---|
[140] | 551 | $page->param(record_create => ($permissions{admin} || $permissions{record_create}) );
|
---|
[160] | 552 | # we don't have any general edit links on the page; they're all embedded in the TMPL_LOOP
|
---|
| 553 | # $page->param(record_edit => ($permissions{admin} || $permissions{record_edit}) );
|
---|
[140] | 554 | $page->param(record_delete => ($permissions{admin} || $permissions{record_delete}) );
|
---|
[95] | 555 |
|
---|
[47] | 556 | # Handle record list for both default records (per-group) and live domain records
|
---|
| 557 |
|
---|
[140] | 558 | $page->param(defrec => $webvar{defrec});
|
---|
[227] | 559 | $page->param(revrec => $webvar{revrec});
|
---|
[140] | 560 | $page->param(id => $webvar{id});
|
---|
| 561 | $page->param(curpage => $webvar{page});
|
---|
[47] | 562 |
|
---|
[224] | 563 | my $count = getRecCount($dbh, $webvar{defrec}, $webvar{revrec}, $webvar{id}, $filter);
|
---|
[47] | 564 |
|
---|
[140] | 565 | $sortby = 'host';
|
---|
[76] | 566 | # sort/order
|
---|
[140] | 567 | $session->param($webvar{page}.'sortby', $webvar{sortby}) if $webvar{sortby};
|
---|
| 568 | $session->param($webvar{page}.'order', $webvar{order}) if $webvar{order};
|
---|
[76] | 569 |
|
---|
[140] | 570 | $sortby = $session->param($webvar{page}.'sortby') if $session->param($webvar{page}.'sortby');
|
---|
| 571 | $sortorder = $session->param($webvar{page}.'order') if $session->param($webvar{page}.'order');
|
---|
[76] | 572 |
|
---|
[72] | 573 | # set up the headers
|
---|
[224] | 574 | my @cols;
|
---|
| 575 | my %colheads;
|
---|
| 576 | if ($webvar{revrec} eq 'n') {
|
---|
| 577 | @cols = ('host', 'type', 'val', 'distance', 'weight', 'port', 'ttl');
|
---|
| 578 | %colheads = (host => 'Name', type => 'Type', val => 'Address',
|
---|
[72] | 579 | distance => 'Distance', weight => 'Weight', port => 'Port', ttl => 'TTL');
|
---|
[224] | 580 | } else {
|
---|
[267] | 581 | @cols = ('val', 'type', 'host', 'ttl');
|
---|
[268] | 582 | %colheads = (val => 'IP Address', type => 'Type', host => 'Hostname', ttl => 'TTL');
|
---|
[224] | 583 | }
|
---|
| 584 | my %custom = (id => $webvar{id}, defrec => $webvar{defrec}, revrec => $webvar{revrec});
|
---|
[140] | 585 | fill_colheads($sortby, $sortorder, \@cols, \%colheads, \%custom);
|
---|
[72] | 586 |
|
---|
[47] | 587 | # fill the page-count and first-previous-next-last-all details
|
---|
[140] | 588 | fill_pgcount($count,"records",
|
---|
[224] | 589 | ($webvar{defrec} eq 'y' ? "group ".groupName($dbh,$webvar{id}) :
|
---|
| 590 | ($webvar{revrec} eq 'y' ? revName($dbh,$webvar{id}) : domainName($dbh,$webvar{id}))
|
---|
| 591 | ));
|
---|
[140] | 592 | fill_fpnla($count); # should put some params on this sub...
|
---|
[47] | 593 |
|
---|
[140] | 594 | $page->param(defrec => $webvar{defrec});
|
---|
[224] | 595 | showzone($webvar{defrec}, $webvar{revrec}, $webvar{id});
|
---|
[248] | 596 | if ($webvar{defrec} eq 'n') {
|
---|
| 597 | if ($webvar{revrec} eq 'n') {
|
---|
| 598 | $page->param(logdom => 1);
|
---|
| 599 | } else {
|
---|
| 600 | $page->param(logrdns => 1);
|
---|
| 601 | }
|
---|
[140] | 602 | }
|
---|
[47] | 603 |
|
---|
[177] | 604 | if ($session->param('resultmsg')) {
|
---|
| 605 | $page->param(resultmsg => $session->param('resultmsg'));
|
---|
| 606 | $session->clear('resultmsg');
|
---|
| 607 | }
|
---|
[234] | 608 | if ($session->param('warnmsg')) {
|
---|
| 609 | $page->param(warnmsg => $session->param('warnmsg'));
|
---|
| 610 | $session->clear('warnmsg');
|
---|
| 611 | }
|
---|
[174] | 612 | if ($session->param('errmsg')) {
|
---|
| 613 | $page->param(errmsg => $session->param('errmsg'));
|
---|
| 614 | $session->clear('errmsg');
|
---|
| 615 | }
|
---|
[63] | 616 |
|
---|
[140] | 617 | } # close "you can't edit default records" check
|
---|
| 618 |
|
---|
[162] | 619 | # Yes, this is a GOTO target. PTBHTTT.
|
---|
| 620 | DONERECLIST: ;
|
---|
| 621 |
|
---|
[13] | 622 | } elsif ($webvar{page} eq 'record') {
|
---|
[16] | 623 |
|
---|
[155] | 624 | # security check - does the user have permission to access this entity?
|
---|
[244] | 625 | if (!check_scope(id => $webvar{id}, type =>
|
---|
[248] | 626 | ($webvar{defrec} eq 'y' ? ($webvar{revrec} eq 'y' ? 'defrevrec' : 'defrec') : 'record'))) {
|
---|
[158] | 627 | $page->param(perm_err => "You are not permitted to edit the requested record");
|
---|
[155] | 628 | goto DONEREC;
|
---|
| 629 | }
|
---|
| 630 | # round 2, check the parent.
|
---|
[244] | 631 | if (!check_scope(id => $webvar{parentid}, type =>
|
---|
| 632 | ($webvar{defrec} eq 'y' ? 'group' : ($webvar{revrec} eq 'y' ? 'revzone' : 'domain')))) {
|
---|
[155] | 633 | my $msg = ($webvar{defrec} eq 'y' ?
|
---|
| 634 | "You are not permitted to add or edit default records in the requested group" :
|
---|
[244] | 635 | "You are not permitted to add or edit records in the requested domain/zone");
|
---|
[155] | 636 | $page->param(perm_err => $msg);
|
---|
| 637 | goto DONEREC;
|
---|
| 638 | }
|
---|
| 639 |
|
---|
[253] | 640 | $page->param(defrec => $webvar{defrec});
|
---|
| 641 | $page->param(revrec => $webvar{revrec});
|
---|
| 642 | $page->param(fwdzone => $webvar{revrec} eq 'n');
|
---|
| 643 |
|
---|
[13] | 644 | if ($webvar{recact} eq 'new') {
|
---|
[16] | 645 |
|
---|
[95] | 646 | changepage(page => "reclist", errmsg => "You are not permitted to add records", id => $webvar{parentid})
|
---|
| 647 | unless ($permissions{admin} || $permissions{record_create});
|
---|
| 648 |
|
---|
[87] | 649 | $page->param(todo => "Add record");
|
---|
[15] | 650 | $page->param(recact => "add");
|
---|
[59] | 651 | $page->param(parentid => $webvar{parentid});
|
---|
[16] | 652 |
|
---|
[59] | 653 | fill_recdata();
|
---|
| 654 |
|
---|
[15] | 655 | } elsif ($webvar{recact} eq 'add') {
|
---|
| 656 |
|
---|
[95] | 657 | changepage(page => "reclist", errmsg => "You are not permitted to add records", id => $webvar{parentid})
|
---|
| 658 | unless ($permissions{admin} || $permissions{record_create});
|
---|
| 659 |
|
---|
[226] | 660 | my @recargs = ($dbh,$webvar{defrec},$webvar{revrec},$webvar{parentid},
|
---|
[249] | 661 | \$webvar{name},\$webvar{type},\$webvar{address},$webvar{ttl});
|
---|
[15] | 662 | if ($webvar{type} == $reverse_typemap{MX} or $webvar{type} == $reverse_typemap{SRV}) {
|
---|
| 663 | push @recargs, $webvar{distance};
|
---|
| 664 | if ($webvar{type} == $reverse_typemap{SRV}) {
|
---|
| 665 | push @recargs, $webvar{weight};
|
---|
| 666 | push @recargs, $webvar{port};
|
---|
| 667 | }
|
---|
| 668 | }
|
---|
[59] | 669 |
|
---|
[15] | 670 | my ($code,$msg) = addRec(@recargs);
|
---|
| 671 |
|
---|
[234] | 672 | if ($code eq 'OK' || $code eq 'WARN') {
|
---|
| 673 | my %pageparams = (page => "reclist", id => $webvar{parentid},
|
---|
| 674 | defrec => $webvar{defrec}, revrec => $webvar{revrec});
|
---|
[287] | 675 | $pageparams{warnmsg} = $msg."<br><br>\n".$DNSDB::resultstr if $code eq 'WARN';
|
---|
| 676 | $pageparams{resultmsg} = $DNSDB::resultstr if $code eq 'OK';
|
---|
[234] | 677 | changepage(%pageparams);
|
---|
[15] | 678 | } else {
|
---|
[24] | 679 | $page->param(failed => 1);
|
---|
| 680 | $page->param(errmsg => $msg);
|
---|
| 681 | $page->param(wastrying => "adding");
|
---|
[87] | 682 | $page->param(todo => "Add record");
|
---|
[24] | 683 | $page->param(recact => "add");
|
---|
| 684 | $page->param(parentid => $webvar{parentid});
|
---|
| 685 | $page->param(id => $webvar{id});
|
---|
[16] | 686 | fill_recdata(); # populate the form... er, mostly.
|
---|
[15] | 687 | }
|
---|
| 688 |
|
---|
[13] | 689 | } elsif ($webvar{recact} eq 'edit') {
|
---|
[15] | 690 |
|
---|
[95] | 691 | changepage(page => "reclist", errmsg => "You are not permitted to edit records", id => $webvar{parentid})
|
---|
| 692 | unless ($permissions{admin} || $permissions{record_edit});
|
---|
| 693 |
|
---|
[16] | 694 | $page->param(todo => "Update record");
|
---|
| 695 | $page->param(recact => "update");
|
---|
| 696 | $page->param(parentid => $webvar{parentid});
|
---|
[17] | 697 | $page->param(id => $webvar{id});
|
---|
[243] | 698 | my $recdata = getRecLine($dbh, $webvar{defrec}, $webvar{revrec}, $webvar{id});
|
---|
[90] | 699 | $page->param(name => $recdata->{host});
|
---|
| 700 | $page->param(address => $recdata->{val});
|
---|
| 701 | $page->param(distance => $recdata->{distance});
|
---|
| 702 | $page->param(weight => $recdata->{weight});
|
---|
| 703 | $page->param(port => $recdata->{port});
|
---|
| 704 | $page->param(ttl => $recdata->{ttl});
|
---|
[272] | 705 | $page->param(typelist => getTypelist($dbh, $webvar{revrec}, $recdata->{type}));
|
---|
[16] | 706 |
|
---|
| 707 | } elsif ($webvar{recact} eq 'update') {
|
---|
| 708 |
|
---|
[95] | 709 | changepage(page => "reclist", errmsg => "You are not permitted to edit records", id => $webvar{parentid})
|
---|
| 710 | unless ($permissions{admin} || $permissions{record_edit});
|
---|
| 711 |
|
---|
[272] | 712 | my ($code,$msg) = updateRec($dbh,$webvar{defrec},$webvar{revrec},$webvar{id},$webvar{parentid},
|
---|
| 713 | \$webvar{name},\$webvar{type},\$webvar{address},$webvar{ttl},
|
---|
[16] | 714 | $webvar{distance},$webvar{weight},$webvar{port});
|
---|
| 715 |
|
---|
[272] | 716 | if ($code eq 'OK' || $code eq 'WARN') {
|
---|
[288] | 717 | my %pageparams = (page => "reclist", id => $webvar{parentid},
|
---|
| 718 | defrec => $webvar{defrec}, revrec => $webvar{revrec});
|
---|
| 719 | $pageparams{warnmsg} = $msg."<br><br>\n".$DNSDB::resultstr if $code eq 'WARN';
|
---|
| 720 | $pageparams{resultmsg} = $DNSDB::resultstr if $code eq 'OK';
|
---|
| 721 | changepage(%pageparams);
|
---|
[16] | 722 | } else {
|
---|
| 723 | $page->param(failed => 1);
|
---|
| 724 | $page->param(errmsg => $msg);
|
---|
| 725 | $page->param(wastrying => "updating");
|
---|
| 726 | $page->param(todo => "Update record");
|
---|
| 727 | $page->param(recact => "update");
|
---|
| 728 | $page->param(parentid => $webvar{parentid});
|
---|
[17] | 729 | $page->param(id => $webvar{id});
|
---|
[16] | 730 | fill_recdata();
|
---|
| 731 | }
|
---|
[13] | 732 | }
|
---|
[16] | 733 |
|
---|
[13] | 734 | if ($webvar{defrec} eq 'y') {
|
---|
[20] | 735 | $page->param(dohere => "default records in group ".groupName($dbh,$webvar{parentid}));
|
---|
[13] | 736 | } else {
|
---|
[242] | 737 | $page->param(dohere => domainName($dbh,$webvar{parentid})) if $webvar{revrec} eq 'n';
|
---|
| 738 | $page->param(dohere => revName($dbh,$webvar{parentid})) if $webvar{revrec} eq 'y';
|
---|
[13] | 739 | }
|
---|
| 740 |
|
---|
[155] | 741 | # Yes, this is a GOTO target. PTBHTTT.
|
---|
| 742 | DONEREC: ;
|
---|
| 743 |
|
---|
[2] | 744 | } elsif ($webvar{page} eq 'delrec') {
|
---|
| 745 |
|
---|
[111] | 746 | # This is a complete separate segment since it uses a different template from add/edit records above
|
---|
| 747 |
|
---|
[243] | 748 | changepage(page => "reclist", errmsg => "You are not permitted to delete records", id => $webvar{parentid},
|
---|
[244] | 749 | defrec => $webvar{defrec}, revrec => $webvar{revrec})
|
---|
[95] | 750 | unless ($permissions{admin} || $permissions{record_delete});
|
---|
| 751 |
|
---|
[244] | 752 | if (!check_scope(id => $webvar{id}, type =>
|
---|
| 753 | ($webvar{defrec} eq 'y' ? ($webvar{revrec} eq 'y' ? 'defrevrec' : 'defrec') : 'record'))) {
|
---|
| 754 | # redirect to domlist because we don't have permission for the entity requested
|
---|
[250] | 755 | changepage(page => 'domlist', revrec => $webvar{revrec},
|
---|
| 756 | errmsg => "You do not have permission to delete records in the requested ".
|
---|
[182] | 757 | ($webvar{defrec} eq 'y' ? 'group' : 'domain'));
|
---|
| 758 | }
|
---|
| 759 |
|
---|
[2] | 760 | $page->param(id => $webvar{id});
|
---|
| 761 | $page->param(defrec => $webvar{defrec});
|
---|
[243] | 762 | $page->param(revrec => $webvar{revrec});
|
---|
[39] | 763 | $page->param(parentid => $webvar{parentid});
|
---|
[2] | 764 | # first pass = confirm y/n (sorta)
|
---|
| 765 | if (!defined($webvar{del})) {
|
---|
| 766 | $page->param(del_getconf => 1);
|
---|
[243] | 767 | my $rec = getRecLine($dbh, $webvar{defrec}, $webvar{revrec}, $webvar{id});
|
---|
[107] | 768 | $page->param(host => $rec->{host});
|
---|
| 769 | $page->param(ftype => $typemap{$rec->{type}});
|
---|
| 770 | $page->param(recval => $rec->{val});
|
---|
[39] | 771 | } elsif ($webvar{del} eq 'ok') {
|
---|
[243] | 772 | my ($code,$msg) = delRec($dbh, $webvar{defrec}, $webvar{revrec}, $webvar{id});
|
---|
[187] | 773 | if ($code eq 'OK') {
|
---|
[290] | 774 | changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec},
|
---|
| 775 | revrec => $webvar{revrec}, resultmsg => $msg);
|
---|
[187] | 776 | } else {
|
---|
[3] | 777 | ## need to find failure mode
|
---|
[88] | 778 | changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec},
|
---|
[290] | 779 | revrec => $webvar{revrec}, errmsg => $msg);
|
---|
[3] | 780 | }
|
---|
[39] | 781 | } else {
|
---|
[250] | 782 | changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}, revrec => $webvar{revrec});
|
---|
[2] | 783 | }
|
---|
| 784 |
|
---|
| 785 | } elsif ($webvar{page} eq 'editsoa') {
|
---|
| 786 |
|
---|
[162] | 787 | # security check - does the user have permission to view this entity?
|
---|
[244] | 788 | # id is domain/revzone/group id
|
---|
| 789 | if (!check_scope(id => $webvar{id}, type =>
|
---|
[248] | 790 | ($webvar{defrec} eq 'y' ? 'group' : ($webvar{revrec} eq 'y' ? 'revzone' : 'domain')))) {
|
---|
[162] | 791 | changepage(page => 'domlist', errmsg => "You do not have permission to edit the ".
|
---|
| 792 | ($webvar{defrec} eq 'y' ? 'default ' : '')."SOA record for the requested ".
|
---|
| 793 | ($webvar{defrec} eq 'y' ? 'group' : 'domain'));
|
---|
| 794 | }
|
---|
| 795 |
|
---|
| 796 | if ($webvar{defrec} eq 'y') {
|
---|
| 797 | changepage(page => "domlist", errmsg => "You are not permitted to edit default records")
|
---|
| 798 | unless $permissions{admin};
|
---|
| 799 | } else {
|
---|
| 800 | changepage(page => "reclist", errmsg => "You are not permitted to edit domain SOA records", id => $webvar{id})
|
---|
[111] | 801 | unless ($permissions{admin} || $permissions{domain_edit});
|
---|
[162] | 802 | }
|
---|
[111] | 803 |
|
---|
[277] | 804 | fillsoa($webvar{defrec},$webvar{revrec},$webvar{id});
|
---|
[2] | 805 |
|
---|
| 806 | } elsif ($webvar{page} eq 'updatesoa') {
|
---|
| 807 |
|
---|
[162] | 808 | # security check - does the user have permission to view this entity?
|
---|
| 809 | # pass 1, record ID
|
---|
[244] | 810 | if (!check_scope(id => $webvar{recid}, type =>
|
---|
| 811 | ($webvar{defrec} eq 'y' ? ($webvar{revrec} eq 'y' ? 'defrevrec' : 'defrec') : 'record'))) {
|
---|
[311] | 812 | ##fixme: should we redirect to the requested record list page instead of the domain list?
|
---|
[162] | 813 | changepage(page => 'domlist', errmsg => "You do not have permission to edit the requested SOA record");
|
---|
| 814 | }
|
---|
| 815 | # pass 2, parent (group or domain) ID
|
---|
[244] | 816 | if (!check_scope(id => $webvar{id}, type =>
|
---|
| 817 | ($webvar{defrec} eq 'y' ? 'group' : ($webvar{revrec} eq 'y' ? 'revzone' : 'domain')))) {
|
---|
[311] | 818 | changepage(page => ($webvar{revrec} eq 'y' ? 'revzones' : 'domlist'),
|
---|
| 819 | errmsg => "You do not have permission to edit the ".
|
---|
[162] | 820 | ($webvar{defrec} eq 'y' ? 'default ' : '')."SOA record for the requested ".
|
---|
[311] | 821 | ($webvar{defrec} eq 'y' ? 'group' : ($webvar{revrec} eq 'y' ? 'reverse zone' : 'domain')) );
|
---|
[162] | 822 | }
|
---|
| 823 |
|
---|
[111] | 824 | changepage(page => "reclist", errmsg => "You are not permitted to edit domain SOA records", id => $webvar{id})
|
---|
| 825 | unless ($permissions{admin} || $permissions{domain_edit});
|
---|
| 826 |
|
---|
[277] | 827 | my ($code, $msg) = updateSOA($dbh, $webvar{defrec}, $webvar{revrec},
|
---|
| 828 | (contact => $webvar{contact}, prins => $webvar{prins}, refresh => $webvar{refresh},
|
---|
[311] | 829 | retry => $webvar{retry}, expire => $webvar{expire}, minttl => $webvar{minttl},
|
---|
| 830 | ttl => $webvar{ttl}, id => $webvar{id}) );
|
---|
[277] | 831 | if ($code eq 'OK') {
|
---|
| 832 | changepage(page => "reclist", id => $webvar{id}, defrec => $webvar{defrec}, revrec => $webvar{revrec},
|
---|
| 833 | resultmsg => "SOA record updated");
|
---|
| 834 | } else {
|
---|
[2] | 835 | $page->param(update_failed => 1);
|
---|
[311] | 836 | $page->param(msg => $msg);
|
---|
| 837 | fillsoa($webvar{defrec}, $webvar{revrec}, $webvar{id}, 'w');
|
---|
[277] | 838 | }
|
---|
| 839 |
|
---|
[17] | 840 | } elsif ($webvar{page} eq 'grpman') {
|
---|
[2] | 841 |
|
---|
[22] | 842 | listgroups();
|
---|
[140] | 843 |
|
---|
| 844 | # Permissions!
|
---|
| 845 | $page->param(addgrp => $permissions{admin} || $permissions{group_create});
|
---|
| 846 | $page->param(edgrp => $permissions{admin} || $permissions{group_edit});
|
---|
| 847 | $page->param(delgrp => $permissions{admin} || $permissions{group_delete});
|
---|
| 848 |
|
---|
[177] | 849 | if ($session->param('resultmsg')) {
|
---|
| 850 | $page->param(resultmsg => $session->param('resultmsg'));
|
---|
| 851 | $session->clear('resultmsg');
|
---|
| 852 | }
|
---|
[178] | 853 | if ($session->param('warnmsg')) {
|
---|
| 854 | $page->param(warnmsg => $session->param('warnmsg'));
|
---|
| 855 | $session->clear('warnmsg');
|
---|
| 856 | }
|
---|
[174] | 857 | if ($session->param('errmsg')) {
|
---|
| 858 | $page->param(errmsg => $session->param('errmsg'));
|
---|
| 859 | $session->clear('errmsg');
|
---|
| 860 | }
|
---|
[18] | 861 | $page->param(curpage => $webvar{page});
|
---|
| 862 |
|
---|
[17] | 863 | } elsif ($webvar{page} eq 'newgrp') {
|
---|
[20] | 864 |
|
---|
[179] | 865 | changepage(page => "grpman", errmsg => "You are not permitted to add groups")
|
---|
| 866 | unless ($permissions{admin} || $permissions{group_create});
|
---|
[111] | 867 |
|
---|
[207] | 868 | # do.. uhh.. stuff.. if we have no webvar{grpaction}
|
---|
| 869 | if ($webvar{grpaction} && $webvar{grpaction} eq 'add') {
|
---|
[179] | 870 |
|
---|
| 871 | # security check - does the user have permission to access this entity?
|
---|
| 872 | if (!check_scope(id => $webvar{pargroup}, type => 'group')) {
|
---|
| 873 | changepage(page => "grpman", errmsg => "You are not permitted to add a group to the requested parent group");
|
---|
| 874 | }
|
---|
| 875 |
|
---|
[66] | 876 | my %newperms;
|
---|
[179] | 877 | my $alterperms = 0;
|
---|
[66] | 878 | foreach (@permtypes) {
|
---|
| 879 | $newperms{$_} = 0;
|
---|
[179] | 880 | if ($permissions{admin} || $permissions{$_}) {
|
---|
| 881 | $newperms{$_} = (defined($webvar{$_}) && $webvar{$_} eq 'on' ? 1 : 0);
|
---|
| 882 | } else {
|
---|
| 883 | $alterperms = 1;
|
---|
| 884 | }
|
---|
[66] | 885 | }
|
---|
[88] | 886 | # not gonna provide the 4th param: template-or-clone flag, just yet
|
---|
[66] | 887 | my ($code,$msg) = addGroup($dbh, $webvar{newgroup}, $webvar{pargroup}, \%newperms);
|
---|
[57] | 888 | if ($code eq 'OK') {
|
---|
[179] | 889 | if ($alterperms) {
|
---|
| 890 | changepage(page => "grpman", warnmsg =>
|
---|
| 891 | "You can only grant permissions you hold. New group $webvar{newgroup} added with reduced access.");
|
---|
| 892 | } else {
|
---|
| 893 | changepage(page => "grpman", resultmsg => "Added group $webvar{newgroup}");
|
---|
| 894 | }
|
---|
[187] | 895 | } # fallthrough else
|
---|
[66] | 896 | # no point in doing extra work
|
---|
| 897 | fill_permissions($page, \%newperms);
|
---|
[18] | 898 | $page->param(add_failed => 1);
|
---|
| 899 | $page->param(errmsg => $msg);
|
---|
| 900 | $page->param(newgroup => $webvar{newgroup});
|
---|
[66] | 901 | fill_grouplist('pargroup',$webvar{pargroup});
|
---|
[19] | 902 | } else {
|
---|
[66] | 903 | fill_grouplist('pargroup',$curgroup);
|
---|
[88] | 904 | # fill default permissions with immediate parent's current ones
|
---|
[66] | 905 | my %parperms;
|
---|
| 906 | getPermissions($dbh, 'group', $curgroup, \%parperms);
|
---|
| 907 | fill_permissions($page, \%parperms);
|
---|
[18] | 908 | }
|
---|
[20] | 909 |
|
---|
[22] | 910 | } elsif ($webvar{page} eq 'delgrp') {
|
---|
[20] | 911 |
|
---|
[111] | 912 | changepage(page => "grpman", errmsg => "You are not permitted to delete groups", id => $webvar{parentid})
|
---|
| 913 | unless ($permissions{admin} || $permissions{group_delete});
|
---|
| 914 |
|
---|
[179] | 915 | # security check - does the user have permission to access this entity?
|
---|
| 916 | if (!check_scope(id => $webvar{id}, type => 'group')) {
|
---|
| 917 | changepage(page => "grpman", errmsg => "You are not permitted to delete the requested group");
|
---|
| 918 | }
|
---|
| 919 |
|
---|
[20] | 920 | $page->param(id => $webvar{id});
|
---|
| 921 | # first pass = confirm y/n (sorta)
|
---|
| 922 | if (!defined($webvar{del})) {
|
---|
| 923 | $page->param(del_getconf => 1);
|
---|
[140] | 924 |
|
---|
| 925 | ##fixme
|
---|
| 926 | # do a check for "group has stuff in it", and splatter a big warning
|
---|
| 927 | # up along with an unchecked-by-default check box to YES DAMMIT DELETE THE WHOLE THING
|
---|
| 928 |
|
---|
[20] | 929 | } elsif ($webvar{del} eq 'ok') {
|
---|
| 930 | my ($code,$msg) = delGroup($dbh, $webvar{id});
|
---|
[187] | 931 | if ($code eq 'OK') {
|
---|
[57] | 932 | ##fixme: need to clean up log when deleting a major container
|
---|
[293] | 933 | changepage(page => "grpman", resultmsg => $msg);
|
---|
[187] | 934 | } else {
|
---|
| 935 | # need to find failure mode
|
---|
[293] | 936 | changepage(page => "grpman", errmsg => $msg);
|
---|
[20] | 937 | }
|
---|
| 938 | } else {
|
---|
| 939 | # cancelled. whee!
|
---|
| 940 | changepage(page => "grpman");
|
---|
| 941 | }
|
---|
[23] | 942 | $page->param(delgroupname => groupName($dbh, $webvar{id}));
|
---|
[24] | 943 |
|
---|
[65] | 944 | } elsif ($webvar{page} eq 'edgroup') {
|
---|
| 945 |
|
---|
[140] | 946 | changepage(page => "grpman", errmsg => "You are not permitted to edit groups")
|
---|
[111] | 947 | unless ($permissions{admin} || $permissions{group_edit});
|
---|
| 948 |
|
---|
[179] | 949 | # security check - does the user have permission to access this entity?
|
---|
| 950 | if (!check_scope(id => $webvar{gid}, type => 'group')) {
|
---|
| 951 | changepage(page => "grpman", errmsg => "You are not permitted to edit the requested group");
|
---|
| 952 | }
|
---|
| 953 |
|
---|
[291] | 954 | if ($webvar{grpaction} && $webvar{grpaction} eq 'updperms') {
|
---|
[65] | 955 | # extra safety check; make sure user can't construct a URL to bypass ACLs
|
---|
| 956 | my %curperms;
|
---|
| 957 | getPermissions($dbh, 'group', $webvar{gid}, \%curperms);
|
---|
[66] | 958 | my %chperms;
|
---|
[178] | 959 | my $alterperms = 0;
|
---|
[66] | 960 | foreach (@permtypes) {
|
---|
[65] | 961 | $webvar{$_} = 0 if !defined($webvar{$_});
|
---|
| 962 | $webvar{$_} = 1 if $webvar{$_} eq 'on';
|
---|
[178] | 963 | if ($permissions{admin} || $permissions{$_}) {
|
---|
| 964 | $chperms{$_} = $webvar{$_} if $curperms{$_} ne $webvar{$_};
|
---|
| 965 | } else {
|
---|
| 966 | $alterperms = 1;
|
---|
| 967 | $chperms{$_} = 0;
|
---|
| 968 | }
|
---|
[65] | 969 | }
|
---|
[66] | 970 | my ($code,$msg) = changePermissions($dbh, 'group', $webvar{gid}, \%chperms);
|
---|
| 971 | if ($code eq 'OK') {
|
---|
[178] | 972 | if ($alterperms) {
|
---|
| 973 | changepage(page => "grpman", warnmsg =>
|
---|
| 974 | "You can only grant permissions you hold. Default permissions in group ".
|
---|
| 975 | groupName($dbh, $webvar{gid})." updated with reduced access");
|
---|
| 976 | } else {
|
---|
[294] | 977 | changepage(page => "grpman", resultmsg => $msg);
|
---|
[178] | 978 | }
|
---|
[187] | 979 | } # fallthrough else
|
---|
[66] | 980 | # no point in doing extra work
|
---|
| 981 | fill_permissions($page, \%chperms);
|
---|
| 982 | $page->param(errmsg => $msg);
|
---|
[65] | 983 | }
|
---|
| 984 | $page->param(gid => $webvar{gid});
|
---|
| 985 | $page->param(grpmeddle => groupName($dbh, $webvar{gid}));
|
---|
| 986 | my %grpperms;
|
---|
| 987 | getPermissions($dbh, 'group', $webvar{gid}, \%grpperms);
|
---|
[66] | 988 | fill_permissions($page, \%grpperms);
|
---|
[65] | 989 |
|
---|
[110] | 990 | } elsif ($webvar{page} eq 'bulkdomain') {
|
---|
| 991 | # Bulk operations on domains. Note all but group move are available on the domain list.
|
---|
[313] | 992 | ##fixme: do we care about bulk operations on revzones? Move-to-group, activate, deactivate,
|
---|
| 993 | # and delete should all be much rarer for revzones than for domains.
|
---|
[110] | 994 |
|
---|
| 995 | changepage(page => "domlist", errmsg => "You are not permitted to make bulk domain changes")
|
---|
[111] | 996 | unless ($permissions{admin} || $permissions{domain_edit} || $permissions{domain_create} || $permissions{domain_delete});
|
---|
[110] | 997 |
|
---|
[126] | 998 | fill_grouplist("grouplist");
|
---|
| 999 |
|
---|
[313] | 1000 | my $count = getZoneCount($dbh, (revrec => 'n', curgroup => $curgroup) );
|
---|
[110] | 1001 |
|
---|
| 1002 | $page->param(curpage => $webvar{page});
|
---|
| 1003 | fill_pgcount($count,'domains',groupName($dbh,$curgroup));
|
---|
| 1004 | fill_fpnla($count);
|
---|
[112] | 1005 | $page->param(perpage => $perpage);
|
---|
[110] | 1006 |
|
---|
[313] | 1007 | my $domlist = getZoneList($dbh, (revrec => 'n', curgroup => $curgroup) );
|
---|
[110] | 1008 | my $rownum = 0;
|
---|
[313] | 1009 | foreach my $dom (@{$domlist}) {
|
---|
| 1010 | delete $dom->{status};
|
---|
| 1011 | delete $dom->{group};
|
---|
| 1012 | $dom->{newrow} = (++$rownum) % 5 == 0;
|
---|
[110] | 1013 | }
|
---|
[313] | 1014 |
|
---|
| 1015 | $page->param(domtable => $domlist);
|
---|
[112] | 1016 | # ACLs
|
---|
[110] | 1017 | $page->param(maymove => ($permissions{admin} || ($permissions{domain_edit} && $permissions{domain_create} && $permissions{domain_delete})));
|
---|
| 1018 | $page->param(maystatus => $permissions{admin} || $permissions{domain_edit});
|
---|
| 1019 | $page->param(maydelete => $permissions{admin} || $permissions{domain_delete});
|
---|
| 1020 |
|
---|
[112] | 1021 | } elsif ($webvar{page} eq 'bulkchange') {
|
---|
[110] | 1022 |
|
---|
[155] | 1023 | # security check - does the user have permission to access this entity?
|
---|
[169] | 1024 | if (!check_scope(id => $webvar{destgroup}, type => 'group')) {
|
---|
[155] | 1025 | $page->param(errmsg => "You are not permitted to make bulk changes in the requested group");
|
---|
| 1026 | goto DONEBULK;
|
---|
| 1027 | }
|
---|
| 1028 |
|
---|
[295] | 1029 | # per-action scope checks
|
---|
[207] | 1030 | if ($webvar{bulkaction} eq 'move') {
|
---|
[112] | 1031 | changepage(page => "domlist", errmsg => "You are not permitted to bulk-move domains")
|
---|
| 1032 | unless ($permissions{admin} || ($permissions{domain_edit} && $permissions{domain_create} && $permissions{domain_delete}));
|
---|
[114] | 1033 | my $newgname = groupName($dbh,$webvar{destgroup});
|
---|
| 1034 | $page->param(action => "Move to group $newgname");
|
---|
[207] | 1035 | } elsif ($webvar{bulkaction} eq 'deactivate' || $webvar{bulkaction} eq 'activate') {
|
---|
| 1036 | changepage(page => "domlist", errmsg => "You are not permitted to bulk-$webvar{bulkaction} domains")
|
---|
[112] | 1037 | unless ($permissions{admin} || $permissions{domain_edit});
|
---|
[207] | 1038 | $page->param(action => "$webvar{bulkaction} domains");
|
---|
| 1039 | } elsif ($webvar{bulkaction} eq 'delete') {
|
---|
[112] | 1040 | changepage(page => "domlist", errmsg => "You are not permitted to bulk-delete domains")
|
---|
| 1041 | unless ($permissions{admin} || $permissions{domain_delete});
|
---|
[207] | 1042 | $page->param(action => "$webvar{bulkaction} domains");
|
---|
[295] | 1043 | } else {
|
---|
| 1044 | # unknown action, bypass actually doing anything. it should not be possible in
|
---|
| 1045 | # normal operations, and anyone who meddles with the URL gets what they deserve.
|
---|
| 1046 | goto DONEBULK;
|
---|
| 1047 | } # move/(de)activate/delete if()
|
---|
| 1048 |
|
---|
| 1049 | my @bulkresults;
|
---|
| 1050 | # nngh. due to alpha-sorting on the previous page, we can't use domid-numeric
|
---|
| 1051 | # order here, and since we don't have the domain names until we go around this
|
---|
| 1052 | # loop, we can't alpha-sort them here. :(
|
---|
| 1053 | foreach (keys %webvar) {
|
---|
| 1054 | my %row;
|
---|
| 1055 | next unless $_ =~ /^dom_\d+$/;
|
---|
| 1056 | # second security check - does the user have permission to meddle with this domain?
|
---|
| 1057 | if (!check_scope(id => $webvar{$_}, type => 'domain')) {
|
---|
| 1058 | $row{domerr} = "You are not permitted to make changes to the requested domain";
|
---|
| 1059 | $row{domain} = $webvar{$_};
|
---|
[114] | 1060 | push @bulkresults, \%row;
|
---|
[295] | 1061 | next;
|
---|
[114] | 1062 | }
|
---|
[295] | 1063 | $row{domain} = domainName($dbh,$webvar{$_});
|
---|
[114] | 1064 |
|
---|
[295] | 1065 | # Do the $webvar{bulkaction}
|
---|
| 1066 | my ($code, $msg);
|
---|
| 1067 | ($code, $msg) = changeGroup($dbh, 'domain', $webvar{$_}, $webvar{destgroup})
|
---|
| 1068 | if $webvar{bulkaction} eq 'move';
|
---|
| 1069 | if ($webvar{bulkaction} eq 'deactivate' || $webvar{bulkaction} eq 'activate') {
|
---|
| 1070 | my $stat = zoneStatus($dbh,$webvar{$_},'n',($webvar{bulkaction} eq 'activate' ? 'domon' : 'domoff'));
|
---|
| 1071 | $code = (defined($stat) ? 'OK' : 'FAIL');
|
---|
| 1072 | $msg = (defined($stat) ? $DNSDB::resultstr : $DNSDB::errstr);
|
---|
| 1073 | }
|
---|
| 1074 | ($code, $msg) = delZone($dbh, $webvar{$_}, 'n')
|
---|
| 1075 | if $webvar{bulkaction} eq 'delete';
|
---|
[114] | 1076 |
|
---|
[295] | 1077 | # Set the result output from the action
|
---|
| 1078 | if ($code eq 'OK') {
|
---|
| 1079 | $row{domok} = $msg;
|
---|
| 1080 | } elsif ($code eq 'WARN') {
|
---|
| 1081 | $row{domwarn} = $msg;
|
---|
| 1082 | } else {
|
---|
| 1083 | $row{domerr} = $msg;
|
---|
| 1084 | }
|
---|
| 1085 | push @bulkresults, \%row;
|
---|
[112] | 1086 |
|
---|
[295] | 1087 | } # foreach (keys %webvar)
|
---|
| 1088 | $page->param(bulkresults => \@bulkresults);
|
---|
| 1089 |
|
---|
[155] | 1090 | # Yes, this is a GOTO target. PTHBTTT.
|
---|
| 1091 | DONEBULK: ;
|
---|
| 1092 |
|
---|
[24] | 1093 | } elsif ($webvar{page} eq 'useradmin') {
|
---|
| 1094 |
|
---|
[139] | 1095 | if (defined($webvar{userstatus})) {
|
---|
[153] | 1096 | # security check - does the user have permission to access this entity?
|
---|
| 1097 | my $flag = 0;
|
---|
| 1098 | foreach (@viewablegroups) {
|
---|
| 1099 | $flag = 1 if isParent($dbh, $_, 'group', $webvar{id}, 'user');
|
---|
| 1100 | }
|
---|
[319] | 1101 | if ($flag && ($permissions{admin} || $permissions{user_edit} ||
|
---|
| 1102 | ($permissions{self_edit} && $webvar{id} == $session->param('uid')) )) {
|
---|
[188] | 1103 | my $stat = userStatus($dbh,$webvar{id},$webvar{userstatus});
|
---|
[296] | 1104 | $page->param(resultmsg => $DNSDB::resultstr);
|
---|
[153] | 1105 | } else {
|
---|
| 1106 | $page->param(errmsg => "You are not permitted to view or change the requested user");
|
---|
| 1107 | }
|
---|
[188] | 1108 | $uri_self =~ s/\&userstatus=[^&]*//g; # clean up URL for stuffing into templates
|
---|
[51] | 1109 | }
|
---|
| 1110 |
|
---|
[142] | 1111 | list_users();
|
---|
| 1112 |
|
---|
| 1113 | # Permissions!
|
---|
| 1114 | $page->param(adduser => $permissions{admin} || $permissions{user_create});
|
---|
| 1115 | # should we block viewing other users? Vega blocks "editing"...
|
---|
| 1116 | # NB: no "edit self" link as with groups here. maybe there should be?
|
---|
| 1117 | # $page->param(eduser => $permissions{admin} || $permissions{user_edit});
|
---|
| 1118 | $page->param(deluser => $permissions{admin} || $permissions{user_delete});
|
---|
| 1119 |
|
---|
[177] | 1120 | if ($session->param('resultmsg')) {
|
---|
| 1121 | $page->param(resultmsg => $session->param('resultmsg'));
|
---|
| 1122 | $session->clear('resultmsg');
|
---|
| 1123 | }
|
---|
| 1124 | if ($session->param('warnmsg')) {
|
---|
| 1125 | $page->param(warnmsg => $session->param('warnmsg'));
|
---|
| 1126 | $session->clear('warnmsg');
|
---|
| 1127 | }
|
---|
[174] | 1128 | if ($session->param('errmsg')) {
|
---|
| 1129 | $page->param(errmsg => $session->param('errmsg'));
|
---|
| 1130 | $session->clear('errmsg');
|
---|
| 1131 | }
|
---|
[24] | 1132 | $page->param(curpage => $webvar{page});
|
---|
| 1133 |
|
---|
[67] | 1134 | } elsif ($webvar{page} eq 'user') {
|
---|
| 1135 |
|
---|
[111] | 1136 | # All user add/edit actions fall through the same page, since there aren't
|
---|
| 1137 | # really any hard differences between the templates
|
---|
| 1138 |
|
---|
[83] | 1139 | #fill_actypelist($webvar{accttype});
|
---|
[67] | 1140 | fill_clonemelist();
|
---|
| 1141 | my %grpperms;
|
---|
| 1142 | getPermissions($dbh, 'group', $curgroup, \%grpperms);
|
---|
[83] | 1143 |
|
---|
[67] | 1144 | my $grppermlist = new HTML::Template(filename => "$templatedir/permlist.tmpl");
|
---|
| 1145 | my %noaccess;
|
---|
| 1146 | fill_permissions($grppermlist, \%grpperms, \%noaccess);
|
---|
| 1147 | $grppermlist->param(info => 1);
|
---|
| 1148 | $page->param(grpperms => $grppermlist->output);
|
---|
[83] | 1149 |
|
---|
[67] | 1150 | $page->param(is_admin => $permissions{admin});
|
---|
| 1151 |
|
---|
[207] | 1152 | $webvar{useraction} = '' if !$webvar{useraction};
|
---|
[88] | 1153 |
|
---|
[207] | 1154 | if ($webvar{useraction} eq 'add' or $webvar{useraction} eq 'update') {
|
---|
[67] | 1155 |
|
---|
[207] | 1156 | $page->param(add => 1) if $webvar{useraction} eq 'add';
|
---|
[83] | 1157 |
|
---|
[294] | 1158 | # can't re-use $code and $msg for update if we want to be able to identify separate failure states
|
---|
| 1159 | my ($code,$code2,$msg,$msg2) = ('OK','OK','OK','OK');
|
---|
[67] | 1160 |
|
---|
| 1161 | my $alterperms = 0; # flag iff we need to force custom permissions due to user's current access limits
|
---|
| 1162 |
|
---|
[87] | 1163 | my %newperms; # we're going to prefill the existing permissions, so we can change them.
|
---|
| 1164 | getPermissions($dbh, 'user', $webvar{uid}, \%newperms);
|
---|
| 1165 |
|
---|
[67] | 1166 | if ($webvar{pass1} ne $webvar{pass2}) {
|
---|
| 1167 | $code = 'FAIL';
|
---|
| 1168 | $msg = "Passwords don't match";
|
---|
| 1169 | } else {
|
---|
| 1170 |
|
---|
[83] | 1171 | # assemble a permission string - far simpler than trying to pass an
|
---|
| 1172 | # indeterminate set of permission flags individually
|
---|
[67] | 1173 |
|
---|
[83] | 1174 | # But first, we have to see if the user can add any particular
|
---|
| 1175 | # permissions; otherwise we have a priviledge escalation. Whee.
|
---|
| 1176 |
|
---|
| 1177 | if (!$permissions{admin}) {
|
---|
| 1178 | my %grpperms;
|
---|
| 1179 | getPermissions($dbh, 'group', $curgroup, \%grpperms);
|
---|
| 1180 | my $ret = comparePermissions(\%permissions, \%grpperms);
|
---|
[144] | 1181 | if ($ret eq '<' || $ret eq '!') {
|
---|
[83] | 1182 | # User's permissions are not a superset or equivalent to group. Can't inherit
|
---|
| 1183 | # (and include access user doesn't currently have), so we force custom.
|
---|
| 1184 | $webvar{perms_type} = 'custom';
|
---|
| 1185 | $alterperms = 1;
|
---|
| 1186 | }
|
---|
| 1187 | }
|
---|
| 1188 |
|
---|
[67] | 1189 | my $permstring;
|
---|
| 1190 | if ($webvar{perms_type} eq 'custom') {
|
---|
| 1191 | $permstring = 'C:';
|
---|
| 1192 | foreach (@permtypes) {
|
---|
[87] | 1193 | if ($permissions{admin} || $permissions{$_}) {
|
---|
[67] | 1194 | $permstring .= ",$_" if defined($webvar{$_}) && $webvar{$_} eq 'on';
|
---|
[87] | 1195 | $newperms{$_} = (defined($webvar{$_}) && $webvar{$_} eq 'on' ? 1 : 0);
|
---|
[67] | 1196 | }
|
---|
| 1197 | }
|
---|
| 1198 | $page->param(perm_custom => 1);
|
---|
| 1199 | } elsif ($permissions{admin} && $webvar{perms_type} eq 'clone') {
|
---|
| 1200 | $permstring = "c:$webvar{clonesrc}";
|
---|
[87] | 1201 | getPermissions($dbh, 'user', $webvar{clonesrc}, \%newperms);
|
---|
[67] | 1202 | $page->param(perm_clone => 1);
|
---|
| 1203 | } else {
|
---|
| 1204 | $permstring = 'i';
|
---|
| 1205 | }
|
---|
[207] | 1206 | if ($webvar{useraction} eq 'add') {
|
---|
[144] | 1207 | changepage(page => "useradmin", errmsg => "You do not have permission to add new users")
|
---|
| 1208 | unless $permissions{admin} || $permissions{user_create};
|
---|
[181] | 1209 | # no scope check; user is created in the current group
|
---|
[83] | 1210 | ($code,$msg) = addUser($dbh, $webvar{uname}, $curgroup, $webvar{pass1},
|
---|
| 1211 | ($webvar{makeactive} eq 'on' ? 1 : 0), $webvar{accttype}, $permstring,
|
---|
| 1212 | $webvar{fname}, $webvar{lname}, $webvar{phone});
|
---|
| 1213 | } else {
|
---|
[144] | 1214 | changepage(page => "useradmin", errmsg => "You do not have permission to edit users")
|
---|
[319] | 1215 | unless $permissions{admin} || $permissions{user_edit} ||
|
---|
| 1216 | ($permissions{self_edit} && $session->param('uid') == $webvar{uid});
|
---|
[181] | 1217 | # security check - does the user have permission to access this entity?
|
---|
| 1218 | if (!check_scope(id => $webvar{user}, type => 'user')) {
|
---|
| 1219 | changepage(page => "useradmin", errmsg => "You do not have permission to edit the requested user");
|
---|
| 1220 | }
|
---|
[294] | 1221 | # User update is icky. I'd really like to do this in one atomic operation,
|
---|
| 1222 | # but that gets hairy by either duplicating a **lot** of code in DNSDB.pm
|
---|
| 1223 | # or self-torture trying to not commit the transaction until we're really done.
|
---|
[83] | 1224 | # Allowing for changing group, but not coding web support just yet.
|
---|
| 1225 | ($code,$msg) = updateUser($dbh, $webvar{uid}, $webvar{uname}, $webvar{gid}, $webvar{pass1},
|
---|
| 1226 | ($webvar{makeactive} eq 'on' ? 1 : 0), $webvar{accttype},
|
---|
| 1227 | $webvar{fname}, $webvar{lname}, $webvar{phone});
|
---|
| 1228 | if ($code eq 'OK') {
|
---|
[90] | 1229 | $newperms{admin} = 1 if $webvar{accttype} eq 'S';
|
---|
[294] | 1230 | ($code2,$msg2) = changePermissions($dbh, 'user', $webvar{uid}, \%newperms, ($permstring eq 'i'));
|
---|
[83] | 1231 | }
|
---|
| 1232 | }
|
---|
[67] | 1233 | }
|
---|
| 1234 |
|
---|
[294] | 1235 | if ($code eq 'OK' && $code2 eq 'OK') {
|
---|
| 1236 | my %pageparams = (page => "useradmin");
|
---|
[67] | 1237 | if ($alterperms) {
|
---|
[294] | 1238 | $pageparams{warnmsg} = "You can only grant permissions you hold.\nUser ".
|
---|
| 1239 | ($webvar{useraction} eq 'add' ? "$webvar{uname} added" : "info updated for $webvar{uname}").
|
---|
| 1240 | ".\nPermissions ".($webvar{useraction} eq 'add' ? 'added' : 'updated')." with reduced access.";
|
---|
[67] | 1241 | } else {
|
---|
[294] | 1242 | $pageparams{resultmsg} = "$msg".($webvar{useraction} eq 'add' ? '' : "\n$msg2");
|
---|
[67] | 1243 | }
|
---|
[294] | 1244 | changepage(%pageparams);
|
---|
[83] | 1245 |
|
---|
| 1246 | # add/update failed:
|
---|
[67] | 1247 | } else {
|
---|
| 1248 | $page->param(add_failed => 1);
|
---|
[207] | 1249 | $page->param(action => $webvar{useraction});
|
---|
[83] | 1250 | $page->param(set_permgroup => 1);
|
---|
[87] | 1251 | if ($webvar{perms_type} eq 'inherit') { # set permission class radio
|
---|
| 1252 | $page->param(perm_inherit => 1);
|
---|
| 1253 | } elsif ($webvar{perms_type} eq 'clone') {
|
---|
| 1254 | $page->param(perm_clone => 1);
|
---|
| 1255 | } else {
|
---|
| 1256 | $page->param(perm_custom => 1);
|
---|
| 1257 | }
|
---|
[67] | 1258 | $page->param(uname => $webvar{uname});
|
---|
| 1259 | $page->param(fname => $webvar{fname});
|
---|
| 1260 | $page->param(lname => $webvar{lname});
|
---|
| 1261 | $page->param(pass1 => $webvar{pass1});
|
---|
| 1262 | $page->param(pass2 => $webvar{pass2});
|
---|
[294] | 1263 | $page->param(errmsg => "User info updated but permissions update failed: $msg2") if $code eq 'OK';
|
---|
| 1264 | $page->param(errmsg => $msg) if $code ne 'OK';
|
---|
[83] | 1265 | fill_permissions($page, \%newperms);
|
---|
| 1266 | fill_actypelist($webvar{accttype});
|
---|
[67] | 1267 | fill_clonemelist();
|
---|
| 1268 | }
|
---|
| 1269 |
|
---|
[207] | 1270 | } elsif ($webvar{useraction} eq 'edit') {
|
---|
[83] | 1271 |
|
---|
[144] | 1272 | changepage(page => "useradmin", errmsg => "You do not have permission to edit users")
|
---|
[319] | 1273 | unless $permissions{admin} || $permissions{user_edit} ||
|
---|
| 1274 | ($permissions{self_edit} && $session->param('uid') == $webvar{user});
|
---|
[144] | 1275 |
|
---|
[181] | 1276 | # security check - does the user have permission to access this entity?
|
---|
| 1277 | if (!check_scope(id => $webvar{user}, type => 'user')) {
|
---|
| 1278 | changepage(page => "useradmin", errmsg => "You do not have permission to edit the requested user");
|
---|
| 1279 | }
|
---|
| 1280 |
|
---|
[83] | 1281 | $page->param(set_permgroup => 1);
|
---|
| 1282 | $page->param(action => 'update');
|
---|
| 1283 | $page->param(uid => $webvar{user});
|
---|
| 1284 | fill_clonemelist();
|
---|
| 1285 |
|
---|
| 1286 | my $userinfo = getUserData($dbh,$webvar{user});
|
---|
| 1287 | fill_actypelist($userinfo->{type});
|
---|
| 1288 | # not using this yet, but adding it now means we can *much* more easily do so later.
|
---|
[294] | 1289 | $page->param(gid => $userinfo->{group_id});
|
---|
[83] | 1290 |
|
---|
| 1291 | my %curperms;
|
---|
| 1292 | getPermissions($dbh, 'user', $webvar{user}, \%curperms);
|
---|
| 1293 | fill_permissions($page, \%curperms);
|
---|
| 1294 |
|
---|
| 1295 | $page->param(uname => $userinfo->{username});
|
---|
| 1296 | $page->param(fname => $userinfo->{firstname});
|
---|
| 1297 | $page->param(lname => $userinfo->{lastname});
|
---|
[87] | 1298 | $page->param(set_permgroup => 1);
|
---|
[83] | 1299 | if ($userinfo->{inherit_perm}) {
|
---|
| 1300 | $page->param(perm_inherit => 1);
|
---|
| 1301 | } else {
|
---|
| 1302 | $page->param(perm_custom => 1);
|
---|
| 1303 | }
|
---|
[67] | 1304 | } else {
|
---|
[144] | 1305 | changepage(page => "useradmin", errmsg => "You are not allowed to add new users")
|
---|
| 1306 | unless $permissions{admin} || $permissions{user_create};
|
---|
[67] | 1307 | # default is "new"
|
---|
[83] | 1308 | $page->param(add => 1);
|
---|
| 1309 | $page->param(action => 'add');
|
---|
| 1310 | fill_permissions($page, \%grpperms);
|
---|
| 1311 | fill_actypelist();
|
---|
[67] | 1312 | }
|
---|
| 1313 |
|
---|
[90] | 1314 | } elsif ($webvar{page} eq 'deluser') {
|
---|
| 1315 |
|
---|
[145] | 1316 | changepage(page=> "useradmin", errmsg => "You are not allowed to delete users")
|
---|
| 1317 | unless $permissions{admin} || $permissions{user_delete};
|
---|
| 1318 |
|
---|
[181] | 1319 | # security check - does the user have permission to access this entity?
|
---|
| 1320 | if (!check_scope(id => $webvar{id}, type => 'user')) {
|
---|
| 1321 | changepage(page => "useradmin", errmsg => "You are not permitted to delete the requested user");
|
---|
| 1322 | }
|
---|
| 1323 |
|
---|
[90] | 1324 | $page->param(id => $webvar{id});
|
---|
| 1325 | # first pass = confirm y/n (sorta)
|
---|
| 1326 | if (!defined($webvar{del})) {
|
---|
| 1327 | $page->param(del_getconf => 1);
|
---|
| 1328 | $page->param(user => userFullName($dbh,$webvar{id}));
|
---|
| 1329 | } elsif ($webvar{del} eq 'ok') {
|
---|
| 1330 | my ($code,$msg) = delUser($dbh, $webvar{id});
|
---|
[187] | 1331 | if ($code eq 'OK') {
|
---|
[90] | 1332 | # success. go back to the user list, do not pass "GO"
|
---|
[297] | 1333 | changepage(page => "useradmin", resultmsg => $msg);
|
---|
[187] | 1334 | } else {
|
---|
[297] | 1335 | changepage(page => "useradmin", errmsg => $msg);
|
---|
[90] | 1336 | }
|
---|
| 1337 | } else {
|
---|
| 1338 | # cancelled. whee!
|
---|
| 1339 | changepage(page => "useradmin");
|
---|
| 1340 | }
|
---|
| 1341 |
|
---|
[30] | 1342 | } elsif ($webvar{page} eq 'dnsq') {
|
---|
| 1343 |
|
---|
| 1344 | $page->param(qfor => $webvar{qfor}) if $webvar{qfor};
|
---|
[225] | 1345 | $page->param(typelist => getTypelist($dbh, 'l', ($webvar{type} ? $webvar{type} : undef)));
|
---|
[31] | 1346 | $page->param(nrecurse => $webvar{nrecurse}) if $webvar{nrecurse};
|
---|
[30] | 1347 | $page->param(resolver => $webvar{resolver}) if $webvar{resolver};
|
---|
| 1348 |
|
---|
| 1349 | if ($webvar{qfor}) {
|
---|
| 1350 | my $resolv = Net::DNS::Resolver->new;
|
---|
[31] | 1351 | $resolv->tcp_timeout(5); # make me adjustable!
|
---|
| 1352 | $resolv->udp_timeout(5); # make me adjustable!
|
---|
| 1353 | $resolv->recurse(0) if $webvar{nrecurse};
|
---|
| 1354 | $resolv->nameservers($webvar{resolver}) if $webvar{resolver};
|
---|
[30] | 1355 | my $query = $resolv->query($webvar{qfor}, $typemap{$webvar{type}});
|
---|
| 1356 | if ($query) {
|
---|
| 1357 |
|
---|
| 1358 | $page->param(showresults => 1);
|
---|
| 1359 |
|
---|
| 1360 | my @answer;
|
---|
| 1361 | foreach my $rr ($query->answer) {
|
---|
| 1362 | # next unless $rr->type eq "A" or $rr->type eq 'NS';
|
---|
| 1363 | my %row;
|
---|
| 1364 | my ($host,$ttl,$class,$type,$data) =
|
---|
[31] | 1365 | ($rr->string =~ /^([0-9a-zA-Z_.-]+)\s+(\d+)\s+([A-Za-z]+)\s+([A-Za-z]+)\s+(.+)$/s);
|
---|
[30] | 1366 | $row{host} = $host;
|
---|
| 1367 | $row{ftype} = $type;
|
---|
[31] | 1368 | $row{rdata} = ($type eq 'SOA' ? "<pre>$data</pre>" : $data);
|
---|
[30] | 1369 | push @answer, \%row;
|
---|
| 1370 | }
|
---|
| 1371 | $page->param(answer => \@answer);
|
---|
| 1372 |
|
---|
| 1373 | my @additional;
|
---|
| 1374 | foreach my $rr ($query->additional) {
|
---|
| 1375 | # next unless $rr->type eq "A" or $rr->type eq 'NS';
|
---|
| 1376 | my %row;
|
---|
| 1377 | my ($host,$ttl,$class,$type,$data) =
|
---|
| 1378 | ($rr->string =~ /^([0-9a-zA-Z_.-]+)\s+(\d+)\s+([A-Za-z]+)\s+([A-Za-z]+)\s+(.+)$/);
|
---|
| 1379 | $row{host} = $host;
|
---|
| 1380 | $row{ftype} = $type;
|
---|
| 1381 | $row{rdata} = $data;
|
---|
| 1382 | push @additional, \%row;
|
---|
| 1383 | }
|
---|
| 1384 | $page->param(additional => \@additional);
|
---|
| 1385 |
|
---|
| 1386 | my @authority;
|
---|
| 1387 | foreach my $rr ($query->authority) {
|
---|
| 1388 | # next unless $rr->type eq "A" or $rr->type eq 'NS';
|
---|
| 1389 | my %row;
|
---|
| 1390 | my ($host,$ttl,$class,$type,$data) =
|
---|
| 1391 | ($rr->string =~ /^([0-9a-zA-Z_.-]+)\s+(\d+)\s+([A-Za-z]+)\s+([A-Za-z]+)\s+(.+)$/);
|
---|
| 1392 | $row{host} = $host;
|
---|
| 1393 | $row{ftype} = $type;
|
---|
| 1394 | $row{rdata} = $data;
|
---|
| 1395 | push @authority, \%row;
|
---|
| 1396 | }
|
---|
| 1397 | $page->param(authority => \@authority);
|
---|
| 1398 |
|
---|
| 1399 | $page->param(usedresolver => $resolv->answerfrom);
|
---|
| 1400 | $page->param(frtype => $typemap{$webvar{type}});
|
---|
| 1401 |
|
---|
| 1402 | } else {
|
---|
| 1403 | $page->param(errmsg => $resolv->errorstring);
|
---|
| 1404 | }
|
---|
| 1405 | }
|
---|
| 1406 | ## done DNS query
|
---|
| 1407 |
|
---|
[31] | 1408 | } elsif ($webvar{page} eq 'axfr') {
|
---|
| 1409 |
|
---|
[111] | 1410 | changepage(page => "domlist", errmsg => "You are not permitted to import domains")
|
---|
| 1411 | unless ($permissions{admin} || $permissions{domain_create});
|
---|
| 1412 |
|
---|
[31] | 1413 | # don't need this while we've got the dropdown in the menu. hmm.
|
---|
[126] | 1414 | fill_grouplist("grouplist");
|
---|
[31] | 1415 |
|
---|
| 1416 | $page->param(ifrom => $webvar{ifrom}) if $webvar{ifrom};
|
---|
| 1417 | $page->param(rwsoa => $webvar{rwsoa}) if $webvar{rwsoa};
|
---|
| 1418 | $page->param(rwns => $webvar{rwns}) if $webvar{rwns};
|
---|
[308] | 1419 | # This next one is arguably better on by default, but Breaking Things Is Bad, Mmmkay?
|
---|
| 1420 | $page->param(mergematching => $webvar{mergematching}) if $webvar{mergematching};
|
---|
[37] | 1421 | $page->param(dominactive => 1) if (!$webvar{domactive} && $webvar{doit}); # eww.
|
---|
[31] | 1422 | $page->param(importdoms => $webvar{importdoms}) if $webvar{importdoms};
|
---|
[33] | 1423 |
|
---|
[91] | 1424 | # shut up warning about uninitialized variable
|
---|
| 1425 | $webvar{doit} = '' if !defined($webvar{doit});
|
---|
| 1426 |
|
---|
[33] | 1427 | if ($webvar{doit} eq 'y' && !$webvar{ifrom}) {
|
---|
| 1428 | $page->param(errmsg => "Need to set host to import from");
|
---|
| 1429 | } elsif ($webvar{doit} eq 'y' && !$webvar{importdoms}) {
|
---|
| 1430 | $page->param(errmsg => "Need domains to import");
|
---|
[91] | 1431 | } elsif ($webvar{doit} eq 'y') {
|
---|
[162] | 1432 |
|
---|
| 1433 | # security check - does the user have permission to access this entity?
|
---|
[169] | 1434 | if (!check_scope(id => $webvar{group}, type => 'group')) {
|
---|
[162] | 1435 | $page->param(errmsg => "You are not permitted to import domains into the requested group");
|
---|
| 1436 | goto DONEAXFR;
|
---|
| 1437 | }
|
---|
| 1438 |
|
---|
[308] | 1439 | # Bizarre Things Happen when you AXFR a null-named zone.
|
---|
| 1440 | $webvar{importdoms} =~ s/^\s+//;
|
---|
[33] | 1441 | my @domlist = split /\s+/, $webvar{importdoms};
|
---|
| 1442 | my @results;
|
---|
| 1443 | foreach my $domain (@domlist) {
|
---|
[34] | 1444 | my %row;
|
---|
| 1445 | my ($code,$msg) = importAXFR($dbh, $webvar{ifrom}, $domain, $webvar{group},
|
---|
[308] | 1446 | $webvar{zonestatus}, $webvar{rwsoa}, $webvar{rwns}, $webvar{mergematching});
|
---|
[35] | 1447 | $row{domok} = $msg if $code eq 'OK';
|
---|
| 1448 | if ($code eq 'WARN') {
|
---|
| 1449 | $msg =~ s|\n|<br />|g;
|
---|
| 1450 | $row{domwarn} = $msg;
|
---|
| 1451 | }
|
---|
[37] | 1452 | if ($code eq 'FAIL') {
|
---|
[91] | 1453 | $msg =~ s|\n|<br />\n|g;
|
---|
[37] | 1454 | $row{domerr} = $msg;
|
---|
| 1455 | }
|
---|
[91] | 1456 | $msg = "<br />\n".$msg if $msg =~ m|<br />|;
|
---|
[33] | 1457 | $row{domain} = $domain;
|
---|
| 1458 | push @results, \%row;
|
---|
| 1459 | }
|
---|
| 1460 | $page->param(axfrresults => \@results);
|
---|
| 1461 | }
|
---|
| 1462 |
|
---|
[155] | 1463 | # Yes, this is a GOTO target. PTBHTTT.
|
---|
| 1464 | DONEAXFR: ;
|
---|
| 1465 |
|
---|
[48] | 1466 | } elsif ($webvar{page} eq 'whoisq') {
|
---|
[47] | 1467 |
|
---|
[48] | 1468 | if ($webvar{qfor}) {
|
---|
| 1469 | use Net::Whois::Raw;
|
---|
| 1470 | use Text::Wrap;
|
---|
| 1471 |
|
---|
| 1472 | # caching useful?
|
---|
| 1473 | #$Net::Whois::Raw::CACHE_DIR = "/var/spool/pwhois/";
|
---|
| 1474 | #$Net::Whois::Raw::CACHE_TIME = 60;
|
---|
| 1475 |
|
---|
| 1476 | my ($dominfo, $whois_server) = whois($webvar{qfor});
|
---|
| 1477 | ##fixme: if we're given an IP, try rwhois as well as whois so we get the real final data
|
---|
| 1478 |
|
---|
| 1479 | # le sigh. idjits spit out data without linefeeds...
|
---|
| 1480 | $Text::Wrap::columns = 88;
|
---|
| 1481 |
|
---|
[93] | 1482 | # &%$@%@# high-bit crap. We should probably find a way to properly recode these
|
---|
| 1483 | # instead of one-by-one. Note CGI::Simple's escapeHTML() doesn't do more than
|
---|
| 1484 | # the bare minimum. :/
|
---|
[48] | 1485 | # Mainly an XHTML validation thing.
|
---|
[93] | 1486 | $dominfo = $q->escapeHTML($dominfo);
|
---|
[48] | 1487 | $dominfo =~ s/\xa9/\©/g;
|
---|
| 1488 | $dominfo =~ s/\xae/\®/g;
|
---|
| 1489 |
|
---|
| 1490 | $page->param(qfor => $webvar{qfor});
|
---|
| 1491 | $page->param(dominfo => wrap('','',$dominfo));
|
---|
| 1492 | $page->param(whois_server => $whois_server);
|
---|
| 1493 | } else {
|
---|
| 1494 | $page->param(errmsg => "Missing host or domain to query in WHOIS") if $webvar{askaway};
|
---|
| 1495 | }
|
---|
| 1496 |
|
---|
[47] | 1497 | } elsif ($webvar{page} eq 'log') {
|
---|
| 1498 |
|
---|
| 1499 | ##fixme put in some real log-munching stuff
|
---|
[59] | 1500 | my $sql = "SELECT user_id, email, name, entry, date_trunc('second',stamp) FROM log WHERE ";
|
---|
[60] | 1501 | my $id = $curgroup; # we do this because the group log may be called from (almost) any page,
|
---|
| 1502 | # but the others are much more limited. this is probably non-optimal.
|
---|
[180] | 1503 |
|
---|
[61] | 1504 | if ($webvar{ltype} && $webvar{ltype} eq 'user') {
|
---|
[60] | 1505 | $sql .= "user_id=?";
|
---|
| 1506 | $id = $webvar{id};
|
---|
[180] | 1507 | if (!check_scope(id => $id, type => 'user')) {
|
---|
| 1508 | $page->param(errmsg => "You are not permitted to view log entries for the requested user");
|
---|
| 1509 | goto DONELOG;
|
---|
| 1510 | }
|
---|
[60] | 1511 | $page->param(logfor => 'user '.userFullName($dbh,$id));
|
---|
| 1512 | } elsif ($webvar{ltype} && $webvar{ltype} eq 'dom') {
|
---|
[59] | 1513 | $sql .= "domain_id=?";
|
---|
| 1514 | $id = $webvar{id};
|
---|
[180] | 1515 | if (!check_scope(id => $id, type => 'domain')) {
|
---|
| 1516 | $page->param(errmsg => "You are not permitted to view log entries for the requested domain");
|
---|
| 1517 | goto DONELOG;
|
---|
| 1518 | }
|
---|
[60] | 1519 | $page->param(logfor => 'domain '.domainName($dbh,$id));
|
---|
[248] | 1520 | } elsif ($webvar{ltype} && $webvar{ltype} eq 'rdns') {
|
---|
| 1521 | $sql .= "rdns_id=?";
|
---|
| 1522 | $id = $webvar{id};
|
---|
| 1523 | if (!check_scope(id => $id, type => 'revzone')) {
|
---|
| 1524 | $page->param(errmsg => "You are not permitted to view log entries for the requested reverse zone");
|
---|
| 1525 | goto DONELOG;
|
---|
| 1526 | }
|
---|
| 1527 | $page->param(logfor => 'reverse zone '.revName($dbh,$id));
|
---|
[59] | 1528 | } else {
|
---|
| 1529 | # Default to listing curgroup log
|
---|
| 1530 | $sql .= "group_id=?";
|
---|
[60] | 1531 | $page->param(logfor => 'group '.groupName($dbh,$id));
|
---|
[180] | 1532 | # note that scope limitations are applied via the change-group check;
|
---|
| 1533 | # group log is always for the "current" group
|
---|
[59] | 1534 | }
|
---|
[248] | 1535 | ##fixme:
|
---|
| 1536 | # - filtering
|
---|
| 1537 | # - show reverse zone column?
|
---|
| 1538 | # - pagination/limiting number of records - put newest-first so user
|
---|
| 1539 | # doesn't always need to go to the last page for recent activity?
|
---|
[59] | 1540 | my $sth = $dbh->prepare($sql);
|
---|
| 1541 | $sth->execute($id);
|
---|
[47] | 1542 | my @logbits;
|
---|
[59] | 1543 | while (my ($uid, $email, $name, $entry, $stamp) = $sth->fetchrow_array) {
|
---|
[47] | 1544 | my %row;
|
---|
[59] | 1545 | $row{userfname} = $name;
|
---|
| 1546 | $row{userid} = $uid;
|
---|
| 1547 | $row{useremail} = $email;
|
---|
[266] | 1548 | ($row{logentry} = $entry) =~ s/\n/<br>\n/g;
|
---|
[59] | 1549 | ($row{logtime}) = ($stamp =~ /^(.+)-\d\d$/);
|
---|
[47] | 1550 | push @logbits, \%row;
|
---|
| 1551 | }
|
---|
| 1552 | $page->param(logentries => \@logbits);
|
---|
| 1553 |
|
---|
[180] | 1554 | # scope check fail target
|
---|
| 1555 | DONELOG: ;
|
---|
| 1556 |
|
---|
[60] | 1557 | } # end $webvar{page} dance
|
---|
[2] | 1558 |
|
---|
| 1559 |
|
---|
[17] | 1560 | # start output here so we can redirect pages.
|
---|
[7] | 1561 | print "Content-type: text/html\n\n", $header->output;
|
---|
| 1562 |
|
---|
[20] | 1563 | ##common bits
|
---|
[173] | 1564 | if ($webvar{page} ne 'login' && $webvar{page} ne 'badpage') {
|
---|
[30] | 1565 | $page->param(username => $session->param("username"));
|
---|
| 1566 |
|
---|
[20] | 1567 | $page->param(group => $curgroup);
|
---|
| 1568 | $page->param(groupname => groupName($dbh,$curgroup));
|
---|
[43] | 1569 | $page->param(logingrp => groupName($dbh,$logingroup));
|
---|
[117] | 1570 | $page->param(logingrp_num => $logingroup);
|
---|
[20] | 1571 |
|
---|
[224] | 1572 | ##fixme
|
---|
| 1573 | $page->param(mayrdns => 1);
|
---|
| 1574 |
|
---|
[140] | 1575 | $page->param(maydefrec => $permissions{admin});
|
---|
[111] | 1576 | $page->param(mayimport => $permissions{admin} || $permissions{domain_create});
|
---|
| 1577 | $page->param(maybulk => $permissions{admin} || $permissions{domain_edit} || $permissions{domain_create} || $permissions{domain_delete});
|
---|
| 1578 |
|
---|
[140] | 1579 | $page->param(chggrps => ($permissions{admin} || $permissions{group_create} || $permissions{group_edit} || $permissions{group_delete}));
|
---|
| 1580 |
|
---|
[24] | 1581 | # group tree. should go elsewhere, probably
|
---|
| 1582 | my $tmpgrplist = fill_grptree($logingroup,$curgroup);
|
---|
| 1583 | $page->param(grptree => $tmpgrplist);
|
---|
[65] | 1584 | $page->param(subs => ($tmpgrplist ? 1 : 0)); # probably not useful to pass gobs of data in for a boolean
|
---|
[42] | 1585 | $page->param(inlogingrp => $curgroup == $logingroup);
|
---|
| 1586 |
|
---|
[53] | 1587 | # fill in the URL-to-self
|
---|
[117] | 1588 | $page->param(whereami => $uri_self);
|
---|
[17] | 1589 | }
|
---|
[13] | 1590 |
|
---|
[166] | 1591 | if (@debugbits) {
|
---|
| 1592 | print "<pre>\n";
|
---|
| 1593 | foreach (@debugbits) { print; }
|
---|
| 1594 | print "</pre>\n";
|
---|
| 1595 | }
|
---|
[24] | 1596 |
|
---|
[2] | 1597 | # spit it out
|
---|
| 1598 | print $page->output;
|
---|
| 1599 |
|
---|
[38] | 1600 | if ($debugenv) {
|
---|
| 1601 | print "<div id=\"debug\">webvar keys: <pre>\n";
|
---|
| 1602 | foreach my $key (keys %webvar) {
|
---|
| 1603 | print "key: $key\tval: $webvar{$key}\n";
|
---|
| 1604 | }
|
---|
| 1605 | print "</pre>\nsession:\n<pre>\n";
|
---|
| 1606 | my $sesdata = $session->dataref();
|
---|
| 1607 | foreach my $key (keys %$sesdata) {
|
---|
| 1608 | print "key: $key\tval: ".$sesdata->{$key}."\n";
|
---|
| 1609 | }
|
---|
| 1610 | print "</pre>\nENV:\n<pre>\n";
|
---|
| 1611 | foreach my $key (keys %ENV) {
|
---|
| 1612 | print "key: $key\tval: $ENV{$key}\n";
|
---|
| 1613 | }
|
---|
| 1614 | print "</pre></div>\n";
|
---|
[2] | 1615 | }
|
---|
| 1616 |
|
---|
| 1617 | print $footer->output;
|
---|
| 1618 |
|
---|
[18] | 1619 | # as per the docs, Just In Case
|
---|
| 1620 | $session->flush();
|
---|
[2] | 1621 |
|
---|
| 1622 | exit 0;
|
---|
| 1623 |
|
---|
| 1624 |
|
---|
[24] | 1625 | sub fill_grptree {
|
---|
| 1626 | my $root = shift;
|
---|
| 1627 | my $cur = shift;
|
---|
[69] | 1628 | my $indent = shift || ' ';
|
---|
[24] | 1629 |
|
---|
| 1630 | my @childlist;
|
---|
| 1631 |
|
---|
| 1632 | my $grptree = HTML::Template->new(filename => 'templates/grptree.tmpl');
|
---|
| 1633 | getChildren($dbh,$root,\@childlist,'immediate');
|
---|
| 1634 | return if $#childlist == -1;
|
---|
| 1635 | my @grouplist;
|
---|
| 1636 | foreach (@childlist) {
|
---|
| 1637 | my %row;
|
---|
| 1638 | $row{grpname} = groupName($dbh,$_);
|
---|
[117] | 1639 | $row{grpnum} = $_;
|
---|
| 1640 | $row{whereami} = $uri_self;
|
---|
[185] | 1641 | $row{curgrp} = ($_ == $cur);
|
---|
| 1642 | $row{expanded} = isParent($dbh, $_, 'group', $cur, 'group');
|
---|
| 1643 | $row{expanded} = 1 if $_ == $cur;
|
---|
[69] | 1644 | $row{subs} = fill_grptree($_,$cur,$indent.' ');
|
---|
| 1645 | $row{indent} = $indent;
|
---|
[24] | 1646 | push @grouplist, \%row;
|
---|
| 1647 | }
|
---|
[69] | 1648 | $grptree->param(indent => $indent);
|
---|
[24] | 1649 | $grptree->param(treelvl => \@grouplist);
|
---|
| 1650 | return $grptree->output;
|
---|
| 1651 | }
|
---|
| 1652 |
|
---|
[11] | 1653 | sub changepage {
|
---|
| 1654 | my %params = @_; # think this works the way I want...
|
---|
| 1655 |
|
---|
[174] | 1656 | # cross-site scripting fixup. instead of passing error messages by URL/form
|
---|
| 1657 | # variable, put them in the session where the nasty user can't meddle.
|
---|
[177] | 1658 | # these are done here since it's far simpler to pass them in from wherever
|
---|
| 1659 | # than set them locally everywhere.
|
---|
| 1660 | foreach my $sessme ('resultmsg','warnmsg','errmsg') {
|
---|
[272] | 1661 | if (my $tmp = $params{$sessme}) {
|
---|
[286] | 1662 | $tmp =~ s/^\n//;
|
---|
[272] | 1663 | $tmp =~ s|\n|<br />\n|g;
|
---|
[286] | 1664 | $session->param($sessme, $tmp);
|
---|
[177] | 1665 | delete $params{$sessme};
|
---|
| 1666 | }
|
---|
[174] | 1667 | }
|
---|
| 1668 |
|
---|
[11] | 1669 | # handle user check
|
---|
| 1670 | my $newurl = "http://$ENV{HTTP_HOST}$ENV{SCRIPT_NAME}?sid=$sid";
|
---|
[245] | 1671 | foreach (sort keys %params) {
|
---|
[92] | 1672 | $newurl .= "&$_=".$q->url_encode($params{$_});
|
---|
[11] | 1673 | }
|
---|
| 1674 |
|
---|
[30] | 1675 | # Just In Case
|
---|
| 1676 | $session->flush();
|
---|
| 1677 |
|
---|
[11] | 1678 | print "Status: 302\nLocation: $newurl\n\n";
|
---|
| 1679 | exit;
|
---|
| 1680 | } # end changepage
|
---|
| 1681 |
|
---|
[2] | 1682 | sub fillsoa {
|
---|
[277] | 1683 | my $defrec = shift;
|
---|
| 1684 | my $revrec = shift;
|
---|
[2] | 1685 | my $id = shift;
|
---|
[311] | 1686 | my $preserve = shift || 'd'; # Flag to use webvar fields or retrieve from database
|
---|
| 1687 |
|
---|
[277] | 1688 | my $domname = ($defrec eq 'y' ? '' : "DOMAIN");
|
---|
[2] | 1689 |
|
---|
[277] | 1690 | $page->param(defrec => $defrec);
|
---|
| 1691 | $page->param(revrec => $revrec);
|
---|
[2] | 1692 |
|
---|
[39] | 1693 | # i had a good reason to do this when I wrote it...
|
---|
| 1694 | # $page->param(domain => $domname);
|
---|
| 1695 | # $page->param(group => $DNSDB::group);
|
---|
[277] | 1696 | $page->param(isgrp => 1) if $defrec eq 'y';
|
---|
| 1697 | $page->param(parent => ($defrec eq 'y' ? groupName($dbh, $id) :
|
---|
| 1698 | ($revrec eq 'n' ? domainName($dbh, $id) : revName($dbh, $id)) ) );
|
---|
[2] | 1699 |
|
---|
| 1700 | # defaults
|
---|
[17] | 1701 | $page->param(defcontact => $DNSDB::def{contact});
|
---|
| 1702 | $page->param(defns => $DNSDB::def{prins});
|
---|
| 1703 | $page->param(defsoattl => $DNSDB::def{soattl});
|
---|
| 1704 | $page->param(defrefresh => $DNSDB::def{refresh});
|
---|
| 1705 | $page->param(defretry => $DNSDB::def{retry});
|
---|
| 1706 | $page->param(defexpire => $DNSDB::def{expire});
|
---|
| 1707 | $page->param(defminttl => $DNSDB::def{minttl});
|
---|
[2] | 1708 |
|
---|
[311] | 1709 | $page->param(id => $id);
|
---|
[2] | 1710 |
|
---|
[311] | 1711 | if ($preserve eq 'd') {
|
---|
| 1712 | # there are probably better ways to do this. TMTOWTDI.
|
---|
| 1713 | my $soa = getSOA($dbh,$defrec,$revrec,$id);
|
---|
| 1714 |
|
---|
| 1715 | $page->param(prins => ($soa->{prins} ? $soa->{prins} : $DNSDB::def{prins}));
|
---|
| 1716 | $page->param(contact => ($soa->{contact} ? $soa->{contact} : $DNSDB::def{contact}));
|
---|
| 1717 | $page->param(refresh => ($soa->{refresh} ? $soa->{refresh} : $DNSDB::def{refresh}));
|
---|
| 1718 | $page->param(retry => ($soa->{retry} ? $soa->{retry} : $DNSDB::def{retry}));
|
---|
| 1719 | $page->param(expire => ($soa->{expire} ? $soa->{expire} : $DNSDB::def{expire}));
|
---|
| 1720 | $page->param(minttl => ($soa->{minttl} ? $soa->{minttl} : $DNSDB::def{minttl}));
|
---|
| 1721 | $page->param(ttl => ($soa->{ttl} ? $soa->{ttl} : $DNSDB::def{soattl}));
|
---|
| 1722 | } else {
|
---|
| 1723 | $page->param(prins => ($webvar{prins} ? $webvar{prins} : $DNSDB::def{prins}));
|
---|
| 1724 | $page->param(contact => ($webvar{contact} ? $webvar{contact} : $DNSDB::def{contact}));
|
---|
| 1725 | $page->param(refresh => ($webvar{refresh} ? $webvar{refresh} : $DNSDB::def{refresh}));
|
---|
| 1726 | $page->param(retry => ($webvar{retry} ? $webvar{retry} : $DNSDB::def{retry}));
|
---|
| 1727 | $page->param(expire => ($webvar{expire} ? $webvar{expire} : $DNSDB::def{expire}));
|
---|
| 1728 | $page->param(minttl => ($webvar{minttl} ? $webvar{minttl} : $DNSDB::def{minttl}));
|
---|
| 1729 | $page->param(ttl => ($webvar{ttl} ? $webvar{ttl} : $DNSDB::def{soattl}));
|
---|
| 1730 | }
|
---|
[2] | 1731 | }
|
---|
| 1732 |
|
---|
[224] | 1733 | sub showzone {
|
---|
[2] | 1734 | my $def = shift;
|
---|
[224] | 1735 | my $rev = shift;
|
---|
[2] | 1736 | my $id = shift;
|
---|
| 1737 |
|
---|
| 1738 | # get the SOA first
|
---|
[311] | 1739 | my $soa = getSOA($dbh,$def,$rev,$id);
|
---|
[2] | 1740 |
|
---|
[311] | 1741 | $page->param(contact => $soa->{contact});
|
---|
| 1742 | $page->param(prins => $soa->{prins});
|
---|
| 1743 | $page->param(refresh => $soa->{refresh});
|
---|
| 1744 | $page->param(retry => $soa->{retry});
|
---|
| 1745 | $page->param(expire => $soa->{expire});
|
---|
| 1746 | $page->param(minttl => $soa->{minttl});
|
---|
| 1747 | $page->param(ttl => $soa->{ttl});
|
---|
[2] | 1748 |
|
---|
[224] | 1749 | my $foo2 = getDomRecs($dbh,$def,$rev,$id,$perpage,$webvar{offset},$sortby,$sortorder,$filter);
|
---|
[2] | 1750 |
|
---|
| 1751 | my $row = 0;
|
---|
| 1752 | foreach my $rec (@$foo2) {
|
---|
| 1753 | $rec->{type} = $typemap{$rec->{type}};
|
---|
| 1754 | $rec->{row} = $row % 2;
|
---|
[62] | 1755 | $rec->{defrec} = $def;
|
---|
[224] | 1756 | $rec->{revrec} = $rev;
|
---|
[2] | 1757 | $rec->{sid} = $webvar{sid};
|
---|
[13] | 1758 | $rec->{id} = $id;
|
---|
[224] | 1759 | $rec->{fwdzone} = $rev eq 'n';
|
---|
[23] | 1760 | $rec->{distance} = 'n/a' unless ($rec->{type} eq 'MX' || $rec->{type} eq 'SRV');
|
---|
| 1761 | $rec->{weight} = 'n/a' unless ($rec->{type} eq 'SRV');
|
---|
| 1762 | $rec->{port} = 'n/a' unless ($rec->{type} eq 'SRV');
|
---|
[2] | 1763 | $row++;
|
---|
[95] | 1764 | # ACLs
|
---|
| 1765 | $rec->{record_edit} = ($permissions{admin} || $permissions{record_edit});
|
---|
| 1766 | $rec->{record_delete} = ($permissions{admin} || $permissions{record_delete});
|
---|
[2] | 1767 | }
|
---|
| 1768 | $page->param(reclist => $foo2);
|
---|
| 1769 | }
|
---|
| 1770 |
|
---|
[16] | 1771 | sub fill_recdata {
|
---|
[225] | 1772 | $page->param(typelist => getTypelist($dbh, $webvar{revrec}, $webvar{type}));
|
---|
[16] | 1773 |
|
---|
[91] | 1774 | # le sigh. we may get called with many empty %webvar keys
|
---|
| 1775 | no warnings qw( uninitialized );
|
---|
| 1776 |
|
---|
[101] | 1777 | ##todo: allow BIND-style bare names, ASS-U-ME that the name is within the domain?
|
---|
| 1778 | # prefill <domain> or DOMAIN in "Host" space for new records
|
---|
[242] | 1779 | if ($webvar{revrec} eq 'n') {
|
---|
| 1780 | my $domroot = ($webvar{defrec} eq 'y' ? 'DOMAIN' : domainName($dbh,$webvar{parentid}));
|
---|
| 1781 | $page->param(name => $domroot);
|
---|
| 1782 | $page->param(address => $webvar{address});
|
---|
| 1783 | $page->param(distance => $webvar{distance})
|
---|
[16] | 1784 | if ($webvar{type} == $reverse_typemap{MX} or $webvar{type} == $reverse_typemap{SRV});
|
---|
[242] | 1785 | $page->param(weight => $webvar{weight}) if $webvar{type} == $reverse_typemap{SRV};
|
---|
| 1786 | $page->param(port => $webvar{port}) if $webvar{type} == $reverse_typemap{SRV};
|
---|
| 1787 | } else {
|
---|
| 1788 | my $domroot = ($webvar{defrec} eq 'y' ? 'ADMINDOMAIN' : ".$config{domain}");
|
---|
| 1789 | $page->param(name => ($webvar{name} ? $webvar{name} : $domroot));
|
---|
| 1790 | my $zname = ($webvar{defrec} eq 'y' ? 'ZONE' : revName($dbh,$webvar{parentid}));
|
---|
| 1791 | $zname =~ s|\d*/\d+$||;
|
---|
| 1792 | $page->param(address => ($webvar{address} ? $webvar{address} : $zname));
|
---|
| 1793 | }
|
---|
[101] | 1794 | # retrieve the right ttl instead of falling (way) back to the hardcoded system default
|
---|
[311] | 1795 | my $soa = getSOA($dbh,$webvar{defrec},$webvar{revrec},$webvar{parentid});
|
---|
| 1796 | $page->param(ttl => ($webvar{ttl} ? $webvar{ttl} : $soa->{minttl}));
|
---|
[2] | 1797 | }
|
---|
[7] | 1798 |
|
---|
[24] | 1799 | sub fill_actypelist {
|
---|
[83] | 1800 | my $curtype = shift || 'u';
|
---|
| 1801 |
|
---|
[24] | 1802 | my @actypes;
|
---|
| 1803 |
|
---|
| 1804 | my %row1 = (actypeval => 'u', actypename => 'user');
|
---|
[83] | 1805 | $row1{typesel} = 1 if $curtype eq 'u';
|
---|
[24] | 1806 | push @actypes, \%row1;
|
---|
| 1807 |
|
---|
| 1808 | my %row2 = (actypeval => 'S', actypename => 'superuser');
|
---|
[83] | 1809 | $row2{typesel} = 1 if $curtype eq 'S';
|
---|
[24] | 1810 | push @actypes, \%row2;
|
---|
| 1811 |
|
---|
[83] | 1812 | $page->param(actypelist => \@actypes);
|
---|
[24] | 1813 | }
|
---|
| 1814 |
|
---|
[65] | 1815 | sub fill_clonemelist {
|
---|
| 1816 | my $sth = $dbh->prepare("SELECT username,user_id FROM users WHERE group_id=$curgroup");
|
---|
| 1817 | $sth->execute;
|
---|
| 1818 |
|
---|
[87] | 1819 | # shut up some warnings, but don't stomp on caller's state
|
---|
| 1820 | local $webvar{clonesrc} = 0 if !defined($webvar{clonesrc});
|
---|
| 1821 |
|
---|
[65] | 1822 | my @clonesrc;
|
---|
| 1823 | while (my ($username,$uid) = $sth->fetchrow_array) {
|
---|
| 1824 | my %row = (
|
---|
| 1825 | username => $username,
|
---|
| 1826 | uid => $uid,
|
---|
| 1827 | selected => ($webvar{clonesrc} == $uid ? 1 : 0)
|
---|
| 1828 | );
|
---|
| 1829 | push @clonesrc, \%row;
|
---|
| 1830 | }
|
---|
| 1831 | $page->param(clonesrc => \@clonesrc);
|
---|
| 1832 | }
|
---|
| 1833 |
|
---|
[7] | 1834 | sub fill_fpnla {
|
---|
| 1835 | my $count = shift;
|
---|
| 1836 | if ($offset eq 'all') {
|
---|
[70] | 1837 | $page->param(perpage => $perpage);
|
---|
[41] | 1838 | # uhm....
|
---|
[7] | 1839 | } else {
|
---|
| 1840 | # all these bits only have sensible behaviour if offset is numeric. err, probably.
|
---|
| 1841 | if ($count > $perpage) {
|
---|
| 1842 | # if there are more results than the default, always show the "all" link
|
---|
| 1843 | $page->param(navall => 1);
|
---|
| 1844 |
|
---|
| 1845 | if ($offset > 0) {
|
---|
| 1846 | $page->param(navfirst => 1);
|
---|
| 1847 | $page->param(navprev => 1);
|
---|
| 1848 | $page->param(prevoffs => $offset-1);
|
---|
| 1849 | }
|
---|
| 1850 |
|
---|
| 1851 | # show "next" and "last" links if we're not on the last page of results
|
---|
| 1852 | if ( (($offset+1) * $perpage - $count) < 0 ) {
|
---|
| 1853 | $page->param(navnext => 1);
|
---|
| 1854 | $page->param(nextoffs => $offset+1);
|
---|
| 1855 | $page->param(navlast => 1);
|
---|
[8] | 1856 | $page->param(lastoffs => int (($count-1)/$perpage));
|
---|
[7] | 1857 | }
|
---|
[87] | 1858 | } else {
|
---|
| 1859 | $page->param(onepage => 1);
|
---|
[7] | 1860 | }
|
---|
| 1861 | }
|
---|
[10] | 1862 | } # end fill_fpnla()
|
---|
| 1863 |
|
---|
[12] | 1864 | sub fill_pgcount {
|
---|
| 1865 | my $pgcount = shift;
|
---|
| 1866 | my $pgtype = shift;
|
---|
| 1867 | my $parent = shift;
|
---|
| 1868 |
|
---|
[98] | 1869 | # Fix display/UI bug where if you are not on the first page of the list, and
|
---|
| 1870 | # you add a search term or click one of the "starts with" links, you end up
|
---|
| 1871 | # on a page showing nothing.
|
---|
| 1872 | # For bonus points, this reverts to the original offset on clicking the "All" link (mostly)
|
---|
[237] | 1873 | if ($offset ne 'all') {
|
---|
[138] | 1874 | $offset-- while ($offset * $perpage) >= $pgcount;
|
---|
| 1875 | }
|
---|
[98] | 1876 |
|
---|
[12] | 1877 | $page->param(ntot => $pgcount);
|
---|
| 1878 | $page->param(nfirst => (($offset eq 'all' ? 0 : $offset)*$perpage+1));
|
---|
| 1879 | $page->param(npglast => ($offset eq 'all' ? $pgcount :
|
---|
| 1880 | ( (($offset+1)*$perpage) > $pgcount ? $pgcount : (($offset+1)*$perpage) )
|
---|
| 1881 | ));
|
---|
| 1882 | $page->param(pgtype => $pgtype);
|
---|
| 1883 | $page->param(parent => $parent);
|
---|
[137] | 1884 | $page->param(filter => $filter);
|
---|
[12] | 1885 | } # end fill_pgcount()
|
---|
| 1886 |
|
---|
[41] | 1887 |
|
---|
[237] | 1888 | sub listdomains { listzones(); } # temp
|
---|
| 1889 |
|
---|
| 1890 | sub listzones {
|
---|
[95] | 1891 | # ACLs
|
---|
| 1892 | $page->param(domain_create => ($permissions{admin} || $permissions{domain_create}) );
|
---|
| 1893 | $page->param(domain_edit => ($permissions{admin} || $permissions{domain_edit}) );
|
---|
| 1894 | $page->param(domain_delete => ($permissions{admin} || $permissions{domain_delete}) );
|
---|
| 1895 |
|
---|
[52] | 1896 | my @childgroups;
|
---|
[61] | 1897 | getChildren($dbh, $curgroup, \@childgroups, 'all') if $searchsubs;
|
---|
[52] | 1898 | my $childlist = join(',',@childgroups);
|
---|
| 1899 |
|
---|
[237] | 1900 | my $count = getZoneCount($dbh, (childlist => $childlist, curgroup => $curgroup, revrec => $webvar{revrec},
|
---|
| 1901 | filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef) ) );
|
---|
[17] | 1902 |
|
---|
[12] | 1903 | # fill page count and first-previous-next-last-all bits
|
---|
[237] | 1904 | fill_pgcount($count,($webvar{revrec} eq 'n' ? 'domains' : 'revzones'),groupName($dbh,$curgroup));
|
---|
[10] | 1905 | fill_fpnla($count);
|
---|
| 1906 |
|
---|
[41] | 1907 | # sort/order
|
---|
[51] | 1908 | $session->param($webvar{page}.'sortby', $webvar{sortby}) if $webvar{sortby};
|
---|
| 1909 | $session->param($webvar{page}.'order', $webvar{order}) if $webvar{order};
|
---|
[41] | 1910 |
|
---|
[120] | 1911 | $sortby = $session->param($webvar{page}.'sortby') if $session->param($webvar{page}.'sortby');
|
---|
| 1912 | $sortorder = $session->param($webvar{page}.'order') if $session->param($webvar{page}.'order');
|
---|
[51] | 1913 |
|
---|
[44] | 1914 | # set up the headers
|
---|
[237] | 1915 | my @cols = (($webvar{revrec} eq 'n' ? 'domain' : 'revnet'), 'status', 'group');
|
---|
| 1916 | my %colheads = (domain => 'Domain', revnet => 'Reverse Zone', status => 'Status', group => 'Group');
|
---|
[54] | 1917 | fill_colheads($sortby, $sortorder, \@cols, \%colheads);
|
---|
[41] | 1918 |
|
---|
| 1919 | # hack! hack! pthbttt. have to rethink the status column storage,
|
---|
| 1920 | # or inactive comes "before" active. *sigh*
|
---|
| 1921 | $sortorder = ($sortorder eq 'ASC' ? 'DESC' : 'ASC') if $sortby eq 'status';
|
---|
| 1922 |
|
---|
[51] | 1923 | # waffle, waffle - keep state on these as well as sortby, sortorder?
|
---|
[237] | 1924 | ##fixme: put this higher so the count doesn't get munched?
|
---|
[53] | 1925 | $page->param("start$startwith" => 1) if $startwith && $startwith =~ /^(?:[a-z]|0-9)$/;
|
---|
[41] | 1926 |
|
---|
[53] | 1927 | $page->param(filter => $filter) if $filter;
|
---|
| 1928 | $page->param(searchsubs => $searchsubs) if $searchsubs;
|
---|
[41] | 1929 |
|
---|
[237] | 1930 | $page->param(group => $curgroup);
|
---|
[41] | 1931 |
|
---|
[237] | 1932 | my $zonelist = getZoneList($dbh, (childlist => $childlist, curgroup => $curgroup,
|
---|
| 1933 | revrec => $webvar{revrec},
|
---|
| 1934 | filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef),
|
---|
| 1935 | offset => $webvar{offset}, sortby => $sortby, sortorder => $sortorder
|
---|
| 1936 | ) );
|
---|
[239] | 1937 | # probably don't need this, keeping for reference for now
|
---|
| 1938 | # foreach (@$zonelist) {
|
---|
| 1939 | # }
|
---|
[237] | 1940 | $page->param(domtable => $zonelist);
|
---|
[11] | 1941 | } # end listdomains()
|
---|
[18] | 1942 |
|
---|
[87] | 1943 |
|
---|
[22] | 1944 | sub listgroups {
|
---|
[53] | 1945 |
|
---|
[153] | 1946 | # security check - does the user have permission to view this entity?
|
---|
| 1947 | if (!(grep /^$curgroup$/, @viewablegroups)) {
|
---|
| 1948 | # hmm. Reset the current group to the login group? Yes. Prevents confusing behaviour elsewhere.
|
---|
| 1949 | $session->param('curgroup',$logingroup);
|
---|
| 1950 | $page->param(errmsg => "You are not permitted to view the requested group");
|
---|
| 1951 | $curgroup = $logingroup;
|
---|
| 1952 | }
|
---|
| 1953 |
|
---|
[26] | 1954 | my @childgroups;
|
---|
[140] | 1955 | getChildren($dbh, $curgroup, \@childgroups, 'all') if $searchsubs;
|
---|
[26] | 1956 | my $childlist = join(',',@childgroups);
|
---|
| 1957 |
|
---|
[314] | 1958 | my ($count) = getGroupCount($dbh, (childlist => $childlist, curgroup => $curgroup,
|
---|
| 1959 | filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef) ) );
|
---|
[26] | 1960 |
|
---|
[22] | 1961 | # fill page count and first-previous-next-last-all bits
|
---|
| 1962 | fill_pgcount($count,"groups",'');
|
---|
| 1963 | fill_fpnla($count);
|
---|
| 1964 |
|
---|
[80] | 1965 | $page->param(gid => $curgroup);
|
---|
| 1966 |
|
---|
[124] | 1967 | $sortby = 'group';
|
---|
[42] | 1968 | # sort/order
|
---|
[51] | 1969 | $session->param($webvar{page}.'sortby', $webvar{sortby}) if $webvar{sortby};
|
---|
| 1970 | $session->param($webvar{page}.'order', $webvar{order}) if $webvar{order};
|
---|
[42] | 1971 |
|
---|
[120] | 1972 | $sortby = $session->param($webvar{page}.'sortby') if $session->param($webvar{page}.'sortby');
|
---|
| 1973 | $sortorder = $session->param($webvar{page}.'order') if $session->param($webvar{page}.'order');
|
---|
[51] | 1974 |
|
---|
[44] | 1975 | # set up the headers
|
---|
[314] | 1976 | my @cols = ('group','parent','nusers','ndomains','nrevzones');
|
---|
| 1977 | my %colnames = (group => 'Group', parent => 'Parent Group', nusers => 'Users', ndomains => 'Domains', nrevzones => 'Reverse Zones');
|
---|
[54] | 1978 | fill_colheads($sortby, $sortorder, \@cols, \%colnames);
|
---|
[42] | 1979 |
|
---|
[51] | 1980 | # waffle, waffle - keep state on these as well as sortby, sortorder?
|
---|
[64] | 1981 | $page->param("start$startwith" => 1) if $startwith && $startwith =~ /^(?:[a-z]|0-9)$/;
|
---|
[51] | 1982 |
|
---|
[53] | 1983 | $page->param(filter => $filter) if $filter;
|
---|
| 1984 | $page->param(searchsubs => $searchsubs) if $searchsubs;
|
---|
[51] | 1985 |
|
---|
| 1986 | # munge sortby for columns in database
|
---|
| 1987 | $sortby = 'g.group_name' if $sortby eq 'group';
|
---|
| 1988 | $sortby = 'g2.group_name' if $sortby eq 'parent';
|
---|
| 1989 |
|
---|
[314] | 1990 | my $glist = getGroupList($dbh, (childlist => $childlist, curgroup => $curgroup,
|
---|
| 1991 | filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef),
|
---|
| 1992 | sortby => $sortby, sortorder => $sortorder) );
|
---|
[22] | 1993 |
|
---|
[314] | 1994 | $page->param(grouptable => $glist);
|
---|
[22] | 1995 | } # end listgroups()
|
---|
| 1996 |
|
---|
[92] | 1997 |
|
---|
[20] | 1998 | sub fill_grouplist {
|
---|
[19] | 1999 | my $template_var = shift;
|
---|
| 2000 | my $cur = shift || $curgroup;
|
---|
[26] | 2001 |
|
---|
| 2002 | my @childgroups;
|
---|
| 2003 | getChildren($dbh, $logingroup, \@childgroups, 'all');
|
---|
| 2004 | my $childlist = join(',',@childgroups);
|
---|
| 2005 |
|
---|
[117] | 2006 | ##fixme: need to reorder list so that we can display a pseudotree in group dropdowns
|
---|
| 2007 |
|
---|
[18] | 2008 | # weesa gonna discard parent_group_id for now
|
---|
[26] | 2009 | my $sth = $dbh->prepare("SELECT group_id,parent_group_id,group_name FROM groups ".
|
---|
| 2010 | "WHERE group_id IN ($logingroup".($childlist ? ",$childlist" : '').")".
|
---|
| 2011 | "ORDER BY group_id");
|
---|
[18] | 2012 | $sth->execute;
|
---|
[20] | 2013 | my @grouplist;
|
---|
| 2014 | while (my ($groupid,$pargroup,$groupname) = $sth->fetchrow_array()) {
|
---|
[18] | 2015 | my %row;
|
---|
[20] | 2016 | $row{groupname} = $groupname;
|
---|
| 2017 | $row{groupval} = $groupid;
|
---|
[18] | 2018 | ##fixme: need magic
|
---|
[93] | 2019 | ## ... WTF?
|
---|
[20] | 2020 | # $row{defgroup} = '';
|
---|
| 2021 | $row{groupactive} = 1 if $groupid == $cur;
|
---|
| 2022 | push @grouplist, \%row;
|
---|
[18] | 2023 | }
|
---|
| 2024 |
|
---|
[20] | 2025 | $page->param("$template_var" => \@grouplist);
|
---|
[18] | 2026 |
|
---|
[24] | 2027 | } # end fill_grouplist()
|
---|
| 2028 |
|
---|
[92] | 2029 |
|
---|
[24] | 2030 | sub list_users {
|
---|
[52] | 2031 |
|
---|
| 2032 | my @childgroups;
|
---|
[53] | 2033 | getChildren($dbh, $curgroup, \@childgroups, 'all') if $searchsubs;
|
---|
[52] | 2034 | my $childlist = join(',',@childgroups);
|
---|
| 2035 |
|
---|
| 2036 | my $sql = "SELECT count(*) FROM users WHERE group_id IN ($curgroup".($childlist ? ",$childlist" : '').")".
|
---|
[160] | 2037 | ($startwith ? " AND username ~* ?" : '').
|
---|
| 2038 | ($filter ? " AND username ~* ?" : '');
|
---|
[52] | 2039 | my $sth = $dbh->prepare($sql);
|
---|
[160] | 2040 | $sth->execute(@filterargs);
|
---|
[24] | 2041 | my ($count) = ($sth->fetchrow_array);
|
---|
| 2042 |
|
---|
| 2043 | # fill page count and first-previous-next-last-all bits
|
---|
| 2044 | fill_pgcount($count,"users",'');
|
---|
| 2045 | fill_fpnla($count);
|
---|
| 2046 |
|
---|
[124] | 2047 | $sortby = 'user';
|
---|
[44] | 2048 | # sort/order
|
---|
[51] | 2049 | $session->param($webvar{page}.'sortby', $webvar{sortby}) if $webvar{sortby};
|
---|
| 2050 | $session->param($webvar{page}.'order', $webvar{order}) if $webvar{order};
|
---|
[44] | 2051 |
|
---|
[120] | 2052 | $sortby = $session->param($webvar{page}.'sortby') if $session->param($webvar{page}.'sortby');
|
---|
| 2053 | $sortorder = $session->param($webvar{page}.'order') if $session->param($webvar{page}.'order');
|
---|
[51] | 2054 |
|
---|
[44] | 2055 | # set up the headers
|
---|
| 2056 | my @cols = ('user','fname','type','group','status');
|
---|
| 2057 | my %colnames = (user => 'Username', fname => 'Full Name', type => 'Type', group => 'Group', status => 'Status');
|
---|
[54] | 2058 | fill_colheads($sortby, $sortorder, \@cols, \%colnames);
|
---|
[44] | 2059 |
|
---|
[51] | 2060 | # waffle, waffle - keep state on these as well as sortby, sortorder?
|
---|
[64] | 2061 | $page->param("start$startwith" => 1) if $startwith && $startwith =~ /^(?:[a-z]|0-9)$/;
|
---|
[51] | 2062 |
|
---|
[53] | 2063 | $page->param(filter => $filter) if $filter;
|
---|
| 2064 | $page->param(searchsubs => $searchsubs) if $searchsubs;
|
---|
[51] | 2065 |
|
---|
| 2066 | # munge sortby for columns in database
|
---|
| 2067 | $sortby = 'u.username' if $sortby eq 'user';
|
---|
| 2068 | $sortby = 'u.type' if $sortby eq 'type';
|
---|
| 2069 | $sortby = 'g.group_name' if $sortby eq 'group';
|
---|
| 2070 | $sortby = 'u.status' if $sortby eq 'status';
|
---|
| 2071 |
|
---|
[24] | 2072 | my @userlist;
|
---|
[52] | 2073 | $sql = "SELECT u.user_id, u.username, u.firstname || ' ' || u.lastname AS fname, u.type, g.group_name, u.status ".
|
---|
[24] | 2074 | "FROM users u ".
|
---|
| 2075 | "INNER JOIN groups g ON u.group_id=g.group_id ".
|
---|
[52] | 2076 | "WHERE u.group_id IN ($curgroup".($childlist ? ",$childlist" : '').")".
|
---|
[160] | 2077 | ($startwith ? " AND u.username ~* ?" : '').
|
---|
| 2078 | ($filter ? " AND u.username ~* ?" : '').
|
---|
[51] | 2079 | " ORDER BY $sortby $sortorder ".
|
---|
[52] | 2080 | ($offset eq 'all' ? '' : " LIMIT $perpage OFFSET ".$offset*$perpage);
|
---|
[51] | 2081 |
|
---|
[52] | 2082 | $sth = $dbh->prepare($sql);
|
---|
[160] | 2083 | $sth->execute(@filterargs);
|
---|
[24] | 2084 |
|
---|
| 2085 | my $rownum = 0;
|
---|
| 2086 | while (my @data = $sth->fetchrow_array) {
|
---|
[41] | 2087 | no warnings "uninitialized"; # Just In Case something stupid happens and a user gets no first or last name
|
---|
[24] | 2088 | my %row;
|
---|
| 2089 | $row{userid} = $data[0];
|
---|
| 2090 | $row{username} = $data[1];
|
---|
[51] | 2091 | $row{userfull} = $data[2];
|
---|
| 2092 | $row{usertype} = ($data[3] eq 'S' ? 'superuser' : "user");
|
---|
| 2093 | $row{usergroup} = $data[4];
|
---|
| 2094 | $row{active} = $data[5];
|
---|
[24] | 2095 | $row{bg} = ($rownum++)%2;
|
---|
| 2096 | $row{sid} = $sid;
|
---|
[319] | 2097 | $row{eduser} = ($permissions{admin} ||
|
---|
| 2098 | ($permissions{user_edit} && $data[3] ne 'S') ||
|
---|
| 2099 | ($permissions{self_edit} && $data[0] == $session->param('uid')) );
|
---|
| 2100 | $row{deluser} = ($permissions{admin} || ($permissions{user_delete} && $data[3] ne 'S'));
|
---|
[24] | 2101 | push @userlist, \%row;
|
---|
| 2102 | }
|
---|
| 2103 | $page->param(usertable => \@userlist);
|
---|
[55] | 2104 | } # end list_users()
|
---|
[43] | 2105 |
|
---|
[92] | 2106 |
|
---|
[43] | 2107 | # Generate all of the glop necessary to add or not the appropriate marker/flag for
|
---|
| 2108 | # the sort order and column in domain, user, group, and record lists
|
---|
| 2109 | # Takes an array ref and hash ref
|
---|
| 2110 | sub fill_colheads {
|
---|
[54] | 2111 | my $sortby = shift;
|
---|
| 2112 | my $sortorder = shift;
|
---|
[43] | 2113 | my $cols = shift;
|
---|
| 2114 | my $colnames = shift;
|
---|
[72] | 2115 | my $custom = shift;
|
---|
[43] | 2116 |
|
---|
| 2117 | my @headings;
|
---|
| 2118 |
|
---|
| 2119 | foreach my $col (@$cols) {
|
---|
| 2120 | my %coldata;
|
---|
| 2121 | $coldata{firstcol} = 1 if $col eq $cols->[0];
|
---|
| 2122 | $coldata{sid} = $sid;
|
---|
| 2123 | $coldata{page} = $webvar{page};
|
---|
| 2124 | $coldata{offset} = $webvar{offset} if $webvar{offset};
|
---|
| 2125 | $coldata{sortby} = $col;
|
---|
| 2126 | $coldata{colname} = $colnames->{$col};
|
---|
| 2127 | if ($col eq $sortby) {
|
---|
| 2128 | $coldata{order} = ($sortorder eq 'ASC' ? 'DESC' : 'ASC');
|
---|
| 2129 | $coldata{sortorder} = $sortorder;
|
---|
| 2130 | } else {
|
---|
| 2131 | $coldata{order} = 'ASC';
|
---|
| 2132 | }
|
---|
[72] | 2133 | if ($custom) {
|
---|
| 2134 | foreach my $ckey (keys %$custom) {
|
---|
| 2135 | $coldata{$ckey} = $custom->{$ckey};
|
---|
| 2136 | }
|
---|
| 2137 | }
|
---|
[43] | 2138 | push @headings, \%coldata;
|
---|
| 2139 | }
|
---|
| 2140 |
|
---|
| 2141 | $page->param(colheads => \@headings);
|
---|
| 2142 |
|
---|
[54] | 2143 | } # end fill_colheads()
|
---|
[55] | 2144 |
|
---|
[92] | 2145 |
|
---|
[66] | 2146 | # we have to do this in a variety of places; let's make it consistent
|
---|
| 2147 | sub fill_permissions {
|
---|
| 2148 | my $template = shift; # may need to do several sets on a single page
|
---|
| 2149 | my $permset = shift; # hashref to permissions on object
|
---|
[67] | 2150 | my $usercan = shift || \%permissions; # allow alternate user-is-allowed permission block
|
---|
[66] | 2151 |
|
---|
| 2152 | foreach (@permtypes) {
|
---|
[67] | 2153 | $template->param("may_$_" => ($usercan->{admin} || $usercan->{$_}));
|
---|
[66] | 2154 | $template->param($_ => $permset->{$_});
|
---|
| 2155 | }
|
---|
| 2156 | }
|
---|
[155] | 2157 |
|
---|
| 2158 | # so simple when defined as a sub instead of inline. O_o
|
---|
| 2159 | sub check_scope {
|
---|
[169] | 2160 | my %args = @_;
|
---|
| 2161 | my $entity = $args{id} || 0; # prevent the shooting of feet with SQL "... intcolumn = '' ..."
|
---|
| 2162 | my $entype = $args{type} || '';
|
---|
[155] | 2163 |
|
---|
| 2164 | if ($entype eq 'group') {
|
---|
| 2165 | return 1 if grep /^$entity$/, @viewablegroups;
|
---|
| 2166 | } else {
|
---|
| 2167 | foreach (@viewablegroups) {
|
---|
| 2168 | return 1 if isParent($dbh, $_, 'group', $entity, $entype);
|
---|
| 2169 | }
|
---|
| 2170 | }
|
---|
| 2171 | }
|
---|