Handle hostnames with upper-case letters
[webmin.git] / sshd / edit_keys.cgi
1 #!/usr/local/bin/perl
2 # Show a page for manually editing host keys
3 # Only displays keys for now
4
5 use File::Basename;
6 require './sshd-lib.pl';
7 &ReadParse();
8 &ui_print_header(undef, $text{'keys_title'}, "");
9
10 # Work out and show the files
11 @files = &get_mlvalues($config{'sshd_config'}, "HostKey");
12
13 # If there are no HostKey entries assume default keys in use
14
15 if (scalar(@files) == 0) {
16         if (-r (dirname($config{'sshd_config'}) . '/ssh_host_rsa_key')) {
17                 push(@files, (dirname($config{'sshd_config'}) . '/ssh_host_rsa_key'));
18                 }
19         if (-r (dirname($config{'sshd_config'}) . '/ssh_host_dsa_key')) {
20                 push(@files, (dirname($config{'sshd_config'}) . '/ssh_host_dsa_key'));
21                 }
22         if (-r (dirname($config{'sshd_config'}) . '/ssh_host_key')) {
23                 push(@files, (dirname($config{'sshd_config'}) . '/ssh_host_key'));
24                 }
25         }
26
27 foreach $key (@files) {
28          $key = $key . ".pub";
29          }
30         
31 $in{'file'} ||= $files[0];
32 &indexof($in{'file'}, @files) >= 0 || &error($text{'keys_none'});
33 print &ui_form_start("edit_keys.cgi");
34 print "<b>Key filename</b>\n";
35 print &ui_select("file", $in{'file'},
36                  [ map { [ $_ ] } @files ]),"\n";
37 print &ui_submit('View');
38 print &ui_form_end();
39
40 # Show the file contents
41 print &ui_form_start("save_manual.cgi", "form-data");
42 print &ui_hidden("file", $in{'file'}),"\n";
43 $data = &read_file_contents($in{'file'});
44 print &ui_textarea("data", $data, 20, 80),"\n";
45
46 &ui_print_footer("", $text{'index_sharelist'});
47