3 # Create, update or delete a netgroup
5 require './nis-lib.pl';
8 ($t, $lnums, $netgroup) = &table_edit_setup($in{'table'}, $in{'line'}, '\s+');
10 # Just delete the netgroup
11 &table_delete($t, $lnums);
14 # Validate inputs and save the netgroup
15 &error_setup($text{'netgroup_err'});
16 $in{'name'} =~ /^[A-Za-z0-9\.\-]+$/ || &error($text{'netgroup_ename'});
17 @netgroup = ( $in{'name'} );
18 HOST: for($i=0; defined($in{"host_$i"}); $i++) {
20 foreach $v ('host', 'user', 'dom') {
21 if ($in{"${v}_def_$i"} == 1) { push(@h, ""); }
22 elsif ($in{"${v}_def_$i"} == 2) { next HOST; }
23 elsif ($in{"${v}_$i"} !~ /^\S+$/) {
24 &error(&text("netgroup_e$v", $i+1));
26 else { push(@h, $in{"${v}_$i"}); }
28 push(@netgroup, "($h[0],$h[1],$h[2])");
30 if ($in{'line'} eq '') {
31 &table_add($t, "\t", \@netgroup);
34 &table_update($t, $lnums, "\t", \@netgroup);
37 &apply_table_changes() if (!$config{'manual_build'});
38 &redirect("edit_tables.cgi?table=$in{'table'}");