Handle hostnames with upper-case letters
[webmin.git] / sshd / index.cgi
1 #!/usr/local/bin/perl
2 # index.cgi
3 # Display sshd option categories
4
5 require './sshd-lib.pl';
6
7 # Check if config file exists
8 if (!-r $config{'sshd_config'}) {
9         &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1);
10         print &text('index_econfig', "<tt>$config{'sshd_config'}</tt>",
11                     "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
12         &ui_print_footer("/", $text{"index"});
13         exit;
14         }
15
16 # Check if sshd exists
17 if (!&has_command($config{'sshd_path'})) {
18         &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1);
19         print &text('index_esshd', "<tt>$config{'sshd_path'}</tt>",
20                     "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
21         &ui_print_footer("/", $text{"index"});
22         exit;
23         }
24
25 # Check if sshd is the right version
26 %version = &get_sshd_version();
27 if (!%version) {
28         # Unknown version
29         &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1);
30         print &text('index_eversion', "<tt>$config{'sshd_path'}</tt>",
31                     "$gconfig{'webprefix'}/config.cgi?$module_name",
32                     "<tt>$config{'sshd_path'} -h</tt>",
33                     "<pre>$out</pre>"),"<p>\n";
34         &ui_print_footer("/", $text{"index"});
35         exit;
36         }
37 &write_file("$module_config_directory/version", \%version);
38
39 &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
40         &help_search_link("ssh", "man", "doc", "google"), undef, undef,
41         &text('index_version', $version{'full'}));
42
43 # Display icons for options
44 foreach $i ('users', 'net', 'access', 'misc') {
45         push(@links, "edit_$i.cgi");
46         push(@titles, $text{$i.'_title'});
47         push(@icons, "images/$i.gif");
48         }
49 if (-r $config{'client_config'}) {
50         push(@links, "list_hosts.cgi");
51         push(@titles, $text{'hosts_title'});
52         push(@icons, "images/hosts.gif");
53         }
54 push(@links, "edit_sync.cgi");
55 push(@titles, $text{'sync_title'});
56 push(@icons, "images/sync.gif");
57
58 push(@links, "edit_keys.cgi");
59 push(@titles, $text{'keys_title'});
60 push(@icons, "images/keys.gif");
61
62 push(@links, "edit_manual.cgi");
63 push(@titles, $text{'manual_title'});
64 push(@icons, "images/manual.gif");
65 &icons_table(\@links, \@titles, \@icons, 4);
66
67 # Check if sshd is running
68 $pid = &get_sshd_pid();
69 print &ui_hr();
70 print &ui_buttons_start();
71 if ($pid) {
72         # Running .. offer to apply changes and stop
73         print &ui_buttons_row("apply.cgi",
74               $text{'index_apply'},
75               $config{'restart_cmd'} ?
76                 &text('index_applymsg2', "<tt>$config{'restart_cmd'}</tt>") :
77                 $text{'index_applymsg'});
78
79         print &ui_buttons_row("stop.cgi",
80                               $text{'index_stop'}, $text{'index_stopmsg'});
81         }
82 else {
83         # Not running .. offer to start
84         print &ui_buttons_row("start.cgi", $text{'index_start'},
85                               $text{'index_startmsg'});
86         }
87 print &ui_buttons_end();
88
89 &ui_print_footer("/", $text{"index"});
90