Handle hostnames with upper-case letters
[webmin.git] / sshd / save_access.cgi
1 #!/usr/local/bin/perl
2 # save_users.cgi
3 # save user and group related sshd options
4
5 require './sshd-lib.pl';
6 &ReadParse();
7 &error_setup($text{'access_err'});
8 &lock_file($config{'sshd_config'});
9 $conf = &get_sshd_config();
10
11 if ($version{'type'} eq 'ssh') {
12         if ($in{'allowh_def'}) {
13                 &save_directive("AllowHosts", $conf);
14                 }
15         else {
16                 $in{'allowh'} =~ /\S/ || &error($text{'access_eallowh'});
17                 &save_directive("AllowHosts", $conf, $in{'allowh'});
18                 }
19
20         if ($in{'denyh_def'}) {
21                 &save_directive("DenyHosts", $conf);
22                 }
23         else {
24                 $in{'denyh'} =~ /\S/ || &error($text{'access_edenyh'});
25                 &save_directive("DenyHosts", $conf, $in{'denyh'});
26                 }
27         }
28
29 $commas = $version{'type'} eq 'ssh' && $version{'number'} >= 3.2;
30 if ($in{'allowu_def'}) {
31         &save_directive("AllowUsers", $conf);
32         }
33 else {
34         $in{'allowu'} =~ /\S/ || &error($text{'access_eallowu'});
35         &save_directive("AllowUsers", $conf,
36             $commas ? join(",", split(/\s+/, $in{'allowu'})) : $in{'allowu'});
37         }
38 if ($in{'denyu_def'}) {
39         &save_directive("DenyUsers", $conf);
40         }
41 else {
42         $in{'denyu'} =~ /\S/ || &error($text{'access_edenyu'});
43         &save_directive("DenyUsers", $conf,
44             $commas ? join(",", split(/\s+/, $in{'denyu'})) : $in{'denyu'});
45         }
46
47 if ($in{'allowg_def'}) {
48         &save_directive("AllowGroups", $conf);
49         }
50 else {
51         $in{'allowg'} =~ /\S/ || &error($text{'access_eallowg'});
52         &save_directive("AllowGroups", $conf,
53             $commas ? join(",", split(/\s+/, $in{'allowg'})) : $in{'allowg'});
54         }
55 if ($in{'denyg_def'}) {
56         &save_directive("DenyGroups", $conf);
57         }
58 else {
59         $in{'denyg'} =~ /\S/ || &error($text{'access_edenyg'});
60         &save_directive("DenyGroups", $conf,
61             $commas ? join(",", split(/\s+/, $in{'denyg'})) : $in{'denyg'});
62         }
63
64 if ($version{'type'} eq 'ssh' && $version{'number'} < 2) {
65         &save_directive("SilentDeny", $conf, $in{'silent'} ? 'yes' : 'no');
66         }
67
68 &flush_file_lines();
69 &unlock_file($config{'sshd_config'});
70 &webmin_log("access");
71 &redirect("");
72