Handle hostnames with upper-case letters
[webmin.git] / mon / save_global.cgi
1 #!/usr/local/bin/perl
2 # save_global.cgi
3 # Save global MON options
4
5 require './mon-lib.pl';
6 $conf = &get_mon_config();
7 &ReadParse();
8 &error_setup($text{'global_err'});
9
10 # Validate inputs
11 $in{'maxprocs'} =~ /^\d+$/ || &error($text{'global_emaxprocs'});
12 $in{'histlength'} =~ /^\d+$/ || &error($text{'global_ehistlength'});
13 -d $in{'alertdir'} ||  &error($text{'global_ealertdir'});
14 -d $in{'mondir'} ||  &error($text{'global_emondir'});
15 $in{'userfile_def'} || $in{'userfile'} =~ /^\S+$/ ||
16         &error($text{'global_euserfile'});
17
18 # Update config file
19 $maxprocs = &find("maxprocs", $conf);
20 &save_directive($conf, $maxprocs, { 'name' => 'maxprocs',
21                                     'global' => 1,
22                                     'values' => [ $in{'maxprocs'} ] } );
23 $histlength = &find("histlength", $conf);
24 &save_directive($conf, $histlength, { 'name' => 'histlength',
25                                       'global' => 1,
26                                       'values' => [ $in{'histlength'} ] } );
27 $alertdir = &find("alertdir", $conf);
28 &save_directive($conf, $alertdir, { 'name' => 'alertdir',
29                                     'global' => 1,
30                                     'values' => [ $in{'alertdir'} ] } );
31 $mondir = &find("mondir", $conf);
32 &save_directive($conf, $mondir, { 'name' => 'mondir',
33                                   'global' => 1,
34                                   'values' => [ $in{'mondir'} ] } );
35 $authtype = &find("authtype", $conf);
36 if ($in{'authtype'}) {
37         &save_directive($conf, $authtype, { 'name' => 'authtype',
38                                             'global' => 1,
39                                             'values' => [ $in{'authtype'} ] } );
40         }
41 else {
42         &save_directive($conf, $authtype) if ($authtype);
43         }
44 $userfile = &find("userfile", $conf);
45 if ($in{'userfile_def'}) {
46         &save_directive($conf, $userfile) if ($userfile);
47         }
48 else {
49         &save_directive($conf, $userfile, { 'name' => 'userfile',
50                                             'global' => 1,
51                                             'values' => [ $in{'userfile'} ] } );
52         }
53
54 &flush_file_lines();
55 &redirect("");
56