line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SVN::ACL; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
101152
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
4
|
1
|
|
|
1
|
|
876
|
use YAML; |
|
1
|
|
|
|
|
18368
|
|
|
1
|
|
|
|
|
1826
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
1
|
|
|
1
|
0
|
698
|
my $class = shift; |
10
|
1
|
|
|
|
|
3
|
my $path = shift; |
11
|
1
|
|
|
|
|
1
|
my $perm; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
|
|
4
|
my $aclfile = "$path/YAML.conf"; |
14
|
1
|
50
|
|
|
|
30
|
(-w $path) or die "Can't access the config file: $aclfile"; |
15
|
1
|
50
|
|
|
|
16
|
if (-e $aclfile) { |
16
|
1
|
|
|
|
|
6
|
$perm = YAML::LoadFile($aclfile); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
else { |
19
|
0
|
|
|
|
|
0
|
$perm->{dir}->{'/'}->{'*'} = 'r'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
} |
22
|
1
|
|
|
|
|
49380
|
bless ( { path => $path, |
23
|
|
|
|
|
|
|
perm => $perm }, $class ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub newdir { |
27
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
28
|
0
|
|
|
|
|
0
|
my $dir = shift; |
29
|
0
|
|
|
|
|
0
|
$self->{perm}->{dir}->{$dir}->{'*'} = ''; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub newuser { |
33
|
1
|
|
|
1
|
0
|
11
|
my $self = shift; |
34
|
1
|
|
|
|
|
4
|
my ($name, $password) = @_; |
35
|
1
|
|
|
|
|
12
|
$self->{perm}->{user}->{$name} = $password; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub deluser { |
39
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
40
|
1
|
|
|
|
|
2
|
my $name = shift; |
41
|
1
|
|
|
|
|
7
|
delete $self->{perm}->{user}->{$name}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub newgroup { |
45
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
46
|
1
|
|
|
|
|
3
|
my $group = shift; |
47
|
1
|
|
|
|
|
10
|
$self->{perm}->{group}->{"@".$group} = []; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub delgroup { |
51
|
1
|
|
|
1
|
0
|
4
|
my $self = shift; |
52
|
1
|
|
|
|
|
2
|
my $group = shift; |
53
|
1
|
|
|
|
|
11
|
delete $self->{perm}->{group}->{"@".$group}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub grant { |
57
|
3
|
|
|
3
|
0
|
7
|
my $self = shift; |
58
|
3
|
|
|
|
|
7
|
my ($dir, $user, $permission) = @_; |
59
|
3
|
100
|
|
|
|
15
|
if ($user =~ /^@/) { |
60
|
1
|
50
|
|
|
|
7
|
exists ($self->{perm}->{group}->{$user}) |
61
|
|
|
|
|
|
|
or die "no such group, you have to new the user first"; |
62
|
1
|
50
|
|
|
|
10
|
$permission ? $self->{perm}->{dir}->{$dir}->{$user} = $permission |
63
|
|
|
|
|
|
|
: delete $self->{perm}->{dir}->{$dir}->{$user}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
else { |
66
|
|
|
|
|
|
|
# $self->newdir($dir) unless (exists $self->{perm}->{dir}->{$dir}); |
67
|
2
|
50
|
|
|
|
12
|
exists ($self->{perm}->{user}->{$user}) |
68
|
|
|
|
|
|
|
or die "no such user, you have to new the user first"; |
69
|
2
|
100
|
|
|
|
18
|
$permission ? $self->{perm}->{dir}->{$dir}->{$user} = $permission |
70
|
|
|
|
|
|
|
: delete $self->{perm}->{dir}->{$dir}->{$user}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub togroup { |
75
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
76
|
1
|
|
|
|
|
3
|
my ($user, $group) = @_; |
77
|
1
|
|
|
|
|
5
|
$group = "@".$group; |
78
|
1
|
50
|
|
|
|
11
|
$self->{perm}->{group}->{$group} = [] unless (exists $self->{perm}->{group}->{$group}); |
79
|
1
|
|
|
|
|
3
|
push @{$self->{perm}->{group}->{$group}}, $user; |
|
1
|
|
|
|
|
9
|
|
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub export { |
83
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
84
|
0
|
|
|
|
|
0
|
my $repospath = $self->{path}; |
85
|
|
|
|
|
|
|
# parse the svnserv.conf |
86
|
0
|
0
|
|
|
|
0
|
open SVNSERV, ">$repospath/conf/svnserve.conf" or die $!; |
87
|
0
|
|
|
|
|
0
|
print SVNSERV << "CONF"; |
88
|
|
|
|
|
|
|
[general] |
89
|
|
|
|
|
|
|
anon-access = read |
90
|
|
|
|
|
|
|
auth-access = write |
91
|
|
|
|
|
|
|
password-db = passwd |
92
|
|
|
|
|
|
|
authz-db = authz |
93
|
|
|
|
|
|
|
CONF |
94
|
0
|
|
|
|
|
0
|
close SVNSERV; |
95
|
|
|
|
|
|
|
# parse passwd file |
96
|
0
|
0
|
|
|
|
0
|
open PASSWD, ">$repospath/conf/passwd" or die $!; |
97
|
0
|
|
|
|
|
0
|
print PASSWD "[users]\n"; |
98
|
0
|
|
|
|
|
0
|
print PASSWD "$_ = ".$self->{perm}->{user}->{$_}."\n" for keys %{$self->{perm}->{user}}; |
|
0
|
|
|
|
|
0
|
|
99
|
0
|
|
|
|
|
0
|
close PASSWD; |
100
|
|
|
|
|
|
|
# parse authz |
101
|
0
|
0
|
|
|
|
0
|
open AUTHZ, ">$repospath/conf/authz" or die $!; |
102
|
0
|
|
|
|
|
0
|
print AUTHZ "[groups]\n"; |
103
|
0
|
|
|
|
|
0
|
for (keys %{$self->{perm}->{group}}) { |
|
0
|
|
|
|
|
0
|
|
104
|
0
|
|
|
|
|
0
|
my $users = join ",", @{$self->{perm}->{group}->{$_}}; |
|
0
|
|
|
|
|
0
|
|
105
|
0
|
|
|
|
|
0
|
print AUTHZ "$_ = $users\n" |
106
|
|
|
|
|
|
|
} |
107
|
0
|
|
|
|
|
0
|
print AUTHZ "\n\n"; |
108
|
0
|
|
|
|
|
0
|
for my $path (keys %{$self->{perm}->{dir}}) { |
|
0
|
|
|
|
|
0
|
|
109
|
0
|
|
|
|
|
0
|
print AUTHZ "[$path]\n"; |
110
|
0
|
|
|
|
|
0
|
for (keys %{$self->{perm}->{dir}->{$path}}) { |
|
0
|
|
|
|
|
0
|
|
111
|
0
|
|
|
|
|
0
|
print AUTHZ "$_ = ".$self->{perm}->{dir}->{$path}->{$_}."\n"; |
112
|
|
|
|
|
|
|
} |
113
|
0
|
|
|
|
|
0
|
print AUTHZ "\n"; |
114
|
|
|
|
|
|
|
} |
115
|
0
|
|
|
|
|
0
|
close AUTHZ; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub save { |
119
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
120
|
1
|
|
|
|
|
5
|
my $aclfile = $self->{path}."/YAML.conf"; |
121
|
1
|
|
|
|
|
9
|
YAML::DumpFile($aclfile, $self->{perm}); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
__END__ |