Handle hostnames with upper-case letters
[webmin.git] / squid / save_cachemgr.cgi
1 #!/usr/local/bin/perl
2 # Save the list of per-function cache manager passwords
3
4 require './squid-lib.pl';
5 &error_setup($text{'cachemgr_err'});
6 $access{'cachemgr'} || &error($text{'cachemgr_ecannot'});
7 &ReadParse();
8
9 # Validate and store inputs
10 &lock_file($config{'squid_conf'});
11 $conf = &get_config();
12
13 if ($in{'cachemgr_def'}) {
14         # Clear them all
15         &save_directive($conf, "cachemgr_passwd", [ ]);
16         }
17 else {
18         # Build up list and save
19         for($i=0; defined($pmode = $in{"pass_def_$i"}); $i++) {
20                 $pass = $pmode || $in{"pass_$i"};
21                 if ($in{"all_$i"}) {
22                         @actions = ( "all" );
23                         }
24                 else {
25                         @actions = ( split(/\0/, $in{"action_$i"}),
26                                      split(/\s+/, $in{"others_$i"}) );
27                         }
28                 if ($pass && @actions) {
29                         push(@rv, { 'name' => 'cachemgr_passwd',
30                                     'values' => [ $pass, @actions ] });
31                         }
32                 }
33
34         @rv || &error($text{'cachemgr_enone'});
35         &save_directive($conf, "cachemgr_passwd", \@rv);
36         }
37
38 # All done
39 &flush_file_lines();
40 &unlock_file($config{'squid_conf'});
41 &webmin_log("cachemgr");
42 &redirect("");
43
44