forked from virtualmin/virtualmin-gpl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admins-lib.pl
executable file
·69 lines (63 loc) · 1.54 KB
/
admins-lib.pl
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Functions for managing extra admins
# list_extra_admins(&domain)
# Returns a list of extra admins for some domain
sub list_extra_admins
{
local ($d) = @_;
local @rv;
opendir(DIR, "$extra_admins_dir/$d->{'id'}");
foreach my $f (readdir(DIR)) {
if ($f =~ /^(.*)\.admin$/) {
local %admin;
&read_file("$extra_admins_dir/$d->{'id'}/$f", \%admin);
$admin{'file'} = "$extra_admins_dir/$d->{'id'}/$f";
push(@rv, \%admin);
}
}
closedir(DIR);
return @rv;
}
# create_extra_admin(&admin, &domain)
# Create an extra admin account for a domain
sub create_extra_admin
{
local ($admin, $d) = @_;
mkdir($extra_admins_dir, 0700);
mkdir("$extra_admins_dir/$d->{'id'}", 0700);
$admin->{'file'} = "$extra_admins_dir/$d->{'id'}/$admin->{'name'}.admin";
&write_file($admin->{'file'}, $admin);
&push_all_print();
&set_all_null_print();
&refresh_webmin_user($d);
&run_post_actions();
&pop_all_print();
}
# delete_extra_admin(&admin, &domain)
# Remove an extra admin account
sub delete_extra_admin
{
local ($admin, $d) = @_;
unlink($admin->{'file'});
&push_all_print();
&set_all_null_print();
&refresh_webmin_user($d);
&run_post_actions();
&pop_all_print();
}
# modify_extra_admin(&admin, &old, &domain)
# Update an extra admin
sub modify_extra_admin
{
local ($admin, $old, $d) = @_;
if ($old->{'name'} ne $admin->{'name'}) {
unlink($old->{'file'});
$admin->{'file'} = "$extra_admins_dir/$d->{'id'}/$admin->{'name'}.admin";
}
&write_file($admin->{'file'}, $admin);
&push_all_print();
&set_all_null_print();
&refresh_webmin_user($d);
&run_post_actions();
&pop_all_print();
}
1;