lib/Ius/Dav/Htpasswd.pm
branchfoerste
changeset 51 0551002b6228
parent 50 24c400b32505
child 53 dda58a85698b
equal deleted inserted replaced
50:24c400b32505 51:0551002b6228
   169     no warnings qw(syntax);
   169     no warnings qw(syntax);
   170     my $user_dir = "$conf->{dav_base_local}/$user";
   170     my $user_dir = "$conf->{dav_base_local}/$user";
   171     my $err;
   171     my $err;
   172     rmtree( $user_dir, error => $err )
   172     rmtree( $user_dir, error => $err )
   173       or $rc = -1
   173       or $rc = -1
   174       and defined $err
   174       and warn "Error(s) occurred during rmtree '$user_dir': ",
   175       and warn "Errors occurred during rmtree '$user_dir': ", @{$err};
   175         defined $err ? @{$err} : '';
   176 
   176 
   177     my $htpasswd_file = $conf->{htpasswd};
   177     my $htpasswd_file = $conf->{htpasswd};
   178     my $htpasswd      = new Apache::Htpasswd $htpasswd_file;
   178     my $htpasswd      = new Apache::Htpasswd $htpasswd_file;
   179     $htpasswd->htDelete($user)
   179     $htpasswd->htDelete($user)
   180       or $rc = -1 and warn "Can't htdelete '$user': ", $htpasswd->error;
   180       or $rc = -1 and warn "Can't htdelete '$user': ", $htpasswd->error;
   191 }
   191 }
   192 
   192 
   193 sub userexpiry {
   193 sub userexpiry {
   194 
   194 
   195     my ($conf) = @_;
   195     my ($conf) = @_;
       
   196 
       
   197     my $rc = 0;
   196 
   198 
   197     for (qw(htpasswd)) {
   199     for (qw(htpasswd)) {
   198         die "Can't determine '$_' - please check configuration"
   200         die "Can't determine '$_' - please check configuration"
   199           unless defined $conf->{$_};
   201           unless defined $conf->{$_};
   200     }
   202     }
   206     my $now = time;
   208     my $now = time;
   207 
   209 
   208     for my $u (@users) {
   210     for my $u (@users) {
   209         if ( my $e = $htpasswd->fetchInfo($u) ) {
   211         if ( my $e = $htpasswd->fetchInfo($u) ) {
   210             userdel( $conf, $u )
   212             userdel( $conf, $u )
   211               or warn "Can't 'userdel $conf, $u'\n"
   213                 and warn "Error(s) occured during 'userdel $conf, $u'\n"
   212               if $now >= $e;
   214               if $now >= $e;
   213         }
   215         }
   214         else {
   216         else {
   215             warn "Can't get expiry for '$u': ", $htpasswd->error, "\n";
   217             warn "Can't get expiry for '$u': ", $htpasswd->error, "\n";
   216         }
   218         }
   217     }
   219     }
   218 
   220 
       
   221     return $rc;
       
   222 
   219 }
   223 }
   220 
   224 
   221 1;
   225 1;
   222 
   226 
   223 __END__
   227 __END__