-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave_anon.cgi
executable file
·35 lines (30 loc) · 994 Bytes
/
save_anon.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/local/bin/perl
# Save the anonymous access settings for a repository
use strict;
use warnings;
our (%text, %in);
require './virtualmin-svn-lib.pl';
&ReadParse();
&error_setup($text{'anon_err'});
# Get the domain and repository
my $dom = &virtual_server::get_domain($in{'dom'});
&can_edit_domain($dom) || &error($text{'add_edom'});
my @reps = &list_reps($dom);
my ($rep) = grep { $_->{'rep'} eq $in{'rep'} } @reps;
$rep || &error($text{'delete_erep'});
# Get the anonymous user
my @users = &list_rep_users($dom, $in{'rep'});
my ($anon) = grep { $_->{'user'} eq '*' } @users;
# Create, update or delete
if ($anon && !$in{'anon'}) {
@users = grep { $_ ne $anon } @users;
}
elsif (!$anon && $in{'anon'}) {
push(@users, { 'user' => '*', 'perms' => $in{'perms'} });
}
elsif ($anon && $in{'anon'}) {
$anon->{'perms'} = $in{'perms'};
}
&save_rep_users($dom, $rep, \@users);
&webmin_log("anon", "repo", $in{'rep'}, { 'dom' => $dom->{'dom'} });
&redirect("index.cgi?show=$in{'show'}");