Handle hostnames with upper-case letters
[webmin.git] / nis / save_group_shadow.cgi
1 #!/usr/local/bin/perl
2 # save_group_shadow.cgi
3 # Create, update or delete a group
4
5 require './nis-lib.pl';
6 &ReadParse();
7
8 ($t, $lnums, $group, $shadow) =
9         &table_edit_setup($in{'table'}, $in{'line'}, '\s+');
10 if ($in{'delete'}) {
11         # Just delete the group
12         &table_delete($t, $lnums);
13         }
14 else {
15         # Validate inputs and save the group
16         &error_setup($text{'group_err'});
17         $in{'name'} =~ /^[^:\s]+$/ || &error($text{'group_ename'});
18         $in{'gid'} =~ /^\d+$/ || &error($text{'group_egid'});
19         $salt = chr(int(rand(26))+65) . chr(int(rand(26))+65);
20         @group = ( $in{'name'}, "x", $in{'gid'},
21                    join(",", split(/\s+/, $in{'members'})) );
22         @shadow = ( $in{'name'},
23                     $in{'passmode'} == 0 ? "" :
24                     $in{'passmode'} == 1 ? $in{'encpass'} :
25                                            &unix_crypt($in{'pass'}, $salt),
26                     "", join(",", split(/\s+/, $in{'members'})) );
27         if ($in{'line'} eq '') {
28                 &table_add($t, ":", \@group, \@shadow);
29                 }
30         else {
31                 &table_update($t, $lnums, ":", \@group, \@shadow);
32                 }
33         }
34 &apply_table_changes() if (!$config{'manual_build'});
35 &redirect("edit_tables.cgi?table=$in{'table'}");
36