3 # Create, update or delete a group
5 require './nis-lib.pl';
8 ($t, $lnums, $group) = &table_edit_setup($in{'table'}, $in{'line'}, '\s+');
10 # Just delete the group
11 &table_delete($t, $lnums);
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),
24 join(",", split(/\s+/, $in{'members'})) );
25 if ($in{'line'} eq '') {
26 &table_add($t, ":", \@group);
29 &table_update($t, $lnums, ":", \@group);
32 &apply_table_changes() if (!$config{'manual_build'});
33 &redirect("edit_tables.cgi?table=$in{'table'}");