forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave_group_shadow.cgi
executable file
·36 lines (33 loc) · 1.04 KB
/
save_group_shadow.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_group_shadow.cgi
# Create, update or delete a group
require './nis-lib.pl';
&ReadParse();
($t, $lnums, $group, $shadow) =
&table_edit_setup($in{'table'}, $in{'line'}, '\s+');
if ($in{'delete'}) {
# Just delete the group
&table_delete($t, $lnums);
}
else {
# Validate inputs and save the group
&error_setup($text{'group_err'});
$in{'name'} =~ /^[^:\s]+$/ || &error($text{'group_ename'});
$in{'gid'} =~ /^\d+$/ || &error($text{'group_egid'});
$salt = chr(int(rand(26))+65) . chr(int(rand(26))+65);
@group = ( $in{'name'}, "x", $in{'gid'},
join(",", split(/\s+/, $in{'members'})) );
@shadow = ( $in{'name'},
$in{'passmode'} == 0 ? "" :
$in{'passmode'} == 1 ? $in{'encpass'} :
&unix_crypt($in{'pass'}, $salt),
"", join(",", split(/\s+/, $in{'members'})) );
if ($in{'line'} eq '') {
&table_add($t, ":", \@group, \@shadow);
}
else {
&table_update($t, $lnums, ":", \@group, \@shadow);
}
}
&apply_table_changes() if (!$config{'manual_build'});
&redirect("edit_tables.cgi?table=$in{'table'}");