forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mass_delete_group.cgi
executable file
·87 lines (75 loc) · 2.05 KB
/
mass_delete_group.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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/local/bin/perl
# Delete multiple groups
require './ldap-useradmin-lib.pl';
&ReadParse();
%glist = map { $_->{'group'}, $_ } &list_groups();
&error_setup($text{'gmass_err'});
foreach $name (split(/\0/, $in{'gd'})) {
$group = $glist{$name};
if ($group) {
&can_edit_group(\%access, $group) ||
&error(&text('gmass_egroup', $name));
push(@dlist, $group);
}
}
@dlist || &error($text{'gmass_enone'});
&ui_print_header(undef, $text{'gmass_title'}, "");
if ($in{'confirmed'}) {
foreach $group (@dlist) {
# Show username
print "<b>",&text('gmass_doing', $group->{'group'}),
"</b><br>\n";
print "<ul>\n";
# Delete from other modules
if ($in{'others'}) {
print "$text{'gdel_other'}<br>\n";
local $error_must_die = 1;
eval { &other_modules("useradmin_delete_group",
$group); };
if ($@) {
print &text('udel_failed', $@),"<p>\n";
}
else {
print "$text{'gdel_done'}<p>\n";
}
}
# Delete from group file
&lock_user_files();
print "$text{'gdel_group'}<br>\n";
&set_group_envs($group, 'DELETE_GROUP');
$merr = &making_changes();
&error(&text('usave_emaking', "<tt>$merr</tt>"))
if (defined($merr));
&delete_group($group);
&unlock_user_files();
&made_changes();
print "$text{'gdel_done'}<p>\n";
print "</ul>\n";
}
&webmin_log("delete", "group", $group->{'group'}, $group);
&ui_print_footer("", $text{'index_return'});
}
else {
foreach $group (@dlist) {
# check if this is anyone's primary group
foreach $u (&list_users()) {
if ($u->{'gid'} == $group->{'gid'}) {
print "<b>",&text('gmass_eprimary',
$group->{'group'}, $u->{'user'}),
"</b> <p>\n";
&ui_print_footer("", $text{'index_return'});
exit;
}
}
}
# Ask if the user is sure
print &ui_confirmation_form(
"mass_delete_group.cgi",
&text('gmass_sure', scalar(@dlist)),
[ map { [ "gd", $_->{'group'} ] } @dlist ],
[ [ "confirmed", $text{'gdel_del'} ] ],
&ui_checkbox("others", 1, $text{'gdel_dothers'},
$mconfig{'default_other'}),
);
&ui_print_footer("", $text{'index_return'});
}