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