Handle hostnames with upper-case letters
[webmin.git] / sshd / save_misc.cgi
1 #!/usr/local/bin/perl
2 # save_misc.cgi
3 # save miscellaneous options
4
5 require './sshd-lib.pl';
6 &ReadParse();
7 &error_setup($text{'misc_err'});
8 &lock_file($config{'sshd_config'});
9 $conf = &get_sshd_config();
10
11 &save_directive("X11Forwarding", $conf, $in{'x11'} ? 'yes' : 'no');
12
13 if ($version{'type'} ne 'ssh' || $version{'number'} < 2) {
14         if ($in{'xoff_def'}) {
15                 &save_directive("X11DisplayOffset", $conf);
16                 }
17         else {
18                 $in{'xoff'} =~ /^\d+$/ || &error($text{'misc_exoff'});
19                 &save_directive("X11DisplayOffset", $conf, $in{'xoff'});
20                 }
21
22         if ($version{'type'} eq 'ssh' || $version{'number'} >= 2) {
23                 if ($in{'xauth_def'}) {
24                         &save_directive("XAuthLocation", $conf);
25                         }
26                 else {
27                         -x $in{'xauth'} || &error($text{'misc_exauth'});
28                         &save_directive("XAuthLocation", $conf, $in{'xauth'});
29                         }
30                 }
31         }
32
33 if ($version{'type'} eq 'ssh' && $version{'number'} < 2) {
34         if ($in{'umask_def'}) {
35                 &save_directive("Umask", $conf);
36                 }
37         else {
38                 $in{'umask'} =~ /^0[0-7][0-7][0-7]$/ ||
39                         &error($text{'misc_eumask'});
40                 &save_directive("Umask", $conf, $in{'umask'});
41                 }
42         }
43
44 &save_directive("SyslogFacility", $conf,
45                 $in{'syslog_def'} ? undef : uc($in{'syslog'}));
46
47 if ($version{'type'} eq 'openssh') {
48         &save_directive("LogLevel", $conf,
49                         $in{'loglevel_def'} ? undef : $in{'loglevel'});
50         }
51
52 if ($version{'type'} ne 'ssh' || $version{'number'} < 2) {
53         if ($in{'bits_def'}) {
54                 &save_directive("ServerKeyBits", $conf);
55                 }
56         else {
57                 $in{'bits'} =~ /^\d+$/ || &error($text{'misc_ebits'});
58                 &save_directive("ServerKeyBits", $conf, $in{'bits'});
59                 }
60         }
61
62 if ($version{'type'} eq 'ssh') {
63         &save_directive("QuietMode", $conf, $in{'quite'} ? 'yes' : 'no');
64         }
65
66 if ($version{'type'} ne 'ssh' || $version{'number'} < 2) {
67         if ($in{'regen_def'}) {
68                 &save_directive("KeyRegenerationInterval", $conf);
69                 }
70         else {
71                 $in{'regen'} =~ /^\d+$/ || &error($text{'misc_eregen'});
72                 &save_directive("KeyRegenerationInterval", $conf, $in{'regen'});
73                 }
74         }
75
76 if ($version{'type'} eq 'ssh' && $version{'number'} < 2) {
77         &save_directive("FascistLogging", $conf, $in{'fascist'} ? 'yes' : 'no');
78         }
79
80 if ($version{'type'} eq 'openssh' && $version{'number'} >= 2) {
81         if ($in{'pid_def'}) {
82                 &save_directive("PidFile", $conf);
83                 }
84         else {
85                 $in{'pid'} =~ /^\S+$/ || &error($text{'misc_epid'});
86                 &save_directive("PidFile", $conf, $in{'pid'});
87                 }
88         }
89
90 if ($version{'type'} eq 'openssh' && $version{'number'} >= 3.2) {
91         &save_directive("UsePrivilegeSeparation", $conf,
92                         $in{'separ'} ? 'yes' : 'no');
93         }
94
95 &flush_file_lines();
96 &unlock_file($config{'sshd_config'});
97 &webmin_log("misc");
98 &redirect("");
99