Handle hostnames with upper-case letters
[webmin.git] / ldap-client / save_switch.cgi
1 #!/usr/local/bin/perl
2 # Update one LDAP switch
3
4 if (-r 'ldap-client-lib.pl') {
5         require './ldap-client-lib.pl';
6         }
7 else {
8         require './nis-lib.pl';
9         }
10 require './switch-lib.pl';
11 &ReadParse();
12 &error_setup($text{'eswitch_err'});
13
14 # Get the current service
15 &lock_file($nsswitch_config_file);
16 $conf = &get_nsswitch_config();
17 ($switch) = grep { $_->{'name'} eq $in{'name'} } @$conf;
18 $switch || &error($text{'eswitch_egone'});
19
20 # Validate and store inputs
21 @srcs = ( );
22 for($i=0; defined($src = $in{"src_$i"}); $i++) {
23         next if (!$src);
24         $s = { 'src' => $src };
25         foreach $st (&list_switch_statuses()) {
26                 if ($in{"status_".$st."_".$i}) {
27                         $s->{$st} = $in{"status_".$st."_".$i};
28                         }
29                 }
30         push(@srcs, $s);
31         }
32 @srcs || &error($text{'eswitch_enone'});
33 $switch->{'srcs'} = \@srcs;
34
35 # Save it
36 &save_nsswitch_config($switch);
37 &unlock_file($nsswitch_config_file);
38 &webmin_log("modify", "switch", $switch->{'name'});
39
40 &redirect("list_switches.cgi");
41