line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: DBM.pm,v 1.1.1.1 1997/12/23 11:14:48 lstein Exp $ |
2
|
|
|
|
|
|
|
package HTTPD::GroupAdmin::DBM; |
3
|
2
|
|
|
2
|
|
9
|
use vars qw(@ISA $DLM $VERSION); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
115
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
65
|
|
5
|
2
|
|
|
2
|
|
10
|
use Carp (); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
931
|
|
6
|
|
|
|
|
|
|
@ISA = qw(HTTPD::GroupAdmin); |
7
|
|
|
|
|
|
|
$VERSION = (qw$Revision: 1.1.1.1 $)[1]; |
8
|
|
|
|
|
|
|
$DLM = " "; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my %Default = (PATH => ".", |
11
|
|
|
|
|
|
|
DB => ".htgroup", |
12
|
|
|
|
|
|
|
DBMF => "NDBM", |
13
|
|
|
|
|
|
|
NAME => "", |
14
|
|
|
|
|
|
|
FLAGS => "rwc", |
15
|
|
|
|
|
|
|
MODE => 0644, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
0
|
|
|
0
|
1
|
0
|
my($class) = shift; |
20
|
0
|
|
|
|
|
0
|
my $self = bless {%Default, @_}, $class; |
21
|
0
|
|
|
|
|
0
|
$self->_dbm_init; |
22
|
0
|
|
|
|
|
0
|
$self->db($self->{DB}); |
23
|
0
|
|
|
|
|
0
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
DESTROY { |
27
|
0
|
|
|
0
|
|
0
|
local($^W)=0; |
28
|
0
|
|
|
|
|
0
|
$_[0]->_untie('_HASH'); |
29
|
0
|
|
|
|
|
0
|
$_[0]->unlock; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub add { |
33
|
6
|
|
|
6
|
1
|
11
|
my($self, $username, $group) = @_; |
34
|
6
|
50
|
|
|
|
10
|
$group = $self->{NAME} unless defined $group; |
35
|
6
|
50
|
|
|
|
10
|
return(0, "No group name!") unless defined $group; |
36
|
|
|
|
|
|
|
|
37
|
6
|
50
|
|
|
|
12
|
unless ($self->{'_HASH'}) { |
38
|
0
|
|
|
|
|
0
|
$self->_tie('_HASH', $self->{DB}); |
39
|
|
|
|
|
|
|
} |
40
|
6
|
100
|
|
|
|
21
|
if ($self->{'_HASH'}{$group}) { |
41
|
3
|
50
|
|
|
|
82
|
return (0, "'$username' already in '$group'") if |
42
|
|
|
|
|
|
|
$self->{'_HASH'}{$group} =~ /(^|[$DLM]+)$username([$DLM]+|$)/; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
#for that old .= bug, should be fixed now |
45
|
6
|
|
|
|
|
10
|
my $val = ""; |
46
|
6
|
100
|
|
|
|
20
|
if(defined $self->{'_HASH'}{$group}) { |
47
|
3
|
|
|
|
|
6
|
$val = $self->{'_HASH'}{$group} . $DLM; |
48
|
|
|
|
|
|
|
} |
49
|
6
|
|
|
|
|
8
|
$val .= $username; |
50
|
6
|
|
|
|
|
20
|
$self->{'_HASH'}{$group} = $val; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub remove { |
54
|
0
|
|
|
0
|
1
|
|
my($self,$group) = @_; |
55
|
0
|
0
|
|
|
|
|
$group = $self->{NAME} unless defined $group; |
56
|
0
|
|
|
|
|
|
delete $self->{'_HASH'}{$group}; |
57
|
0
|
0
|
|
|
|
|
if($self->{NAME} eq $group) { |
58
|
0
|
|
|
|
|
|
delete $self->{NAME}; |
59
|
|
|
|
|
|
|
} |
60
|
0
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub list { |
64
|
0
|
0
|
|
0
|
1
|
|
return split(/[$DLM]+/, $_[0]->{'_HASH'}{$_[1]}) if $_[1]; |
65
|
0
|
|
|
|
|
|
keys %{$_[0]->{'_HASH'}}; |
|
0
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
package HTTPD::GroupAdmin::DBM::_generic; |
69
|
2
|
|
|
2
|
|
11
|
use vars qw(@ISA); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
109
|
|
70
|
|
|
|
|
|
|
@ISA = qw(HTTPD::GroupAdmin::DBM); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |