SSH port number option
authorJamie Cameron <jcameron@webmin.com>
Fri, 5 Jun 2009 16:40:11 +0000 (16:40 +0000)
committerJamie Cameron <jcameron@webmin.com>
Fri, 5 Jun 2009 16:40:11 +0000 (16:40 +0000)
status/CHANGELOG
status/lang/en
status/rssh-monitor.pl

index 870a1b4..bc3d88d 100644 (file)
@@ -63,3 +63,4 @@ Added a tooltip to status icons to show the hostname.
 ---- Changes since 1.470 ----
 Corrected the domain for AT&T SMS emails.
 Added a new monitor type for Dovecot.
+Added an option to the SSH monitor type for a port number.
index ec776bf..b06dfde 100644 (file)
@@ -429,6 +429,9 @@ rssh_eproc=The Running Processes module is not supported on your system
 rssh_wrongpass=Incorrect login
 rssh_failed=Connection failed
 rssh_error=SSH error
+rssh_haspass=Password
+rssh_port=SSH server port
+rssh_eport=Missing or invalid port number
 
 tmpls_title=Email Templates
 tmpls_ecannot=You are not allowed to edit email templates
index d443cbe..3f2b810 100644 (file)
@@ -7,8 +7,10 @@ sub get_rssh_status
 &foreign_require("proc", "proc-lib.pl");
 local $ruser = $_[0]->{'ruser'} || "root";
 local ($fh, $fpid) = &proc::pty_process_exec(
-       "ssh ".quotemeta($ruser)."\@".
-              quotemeta($_[0]->{'host'})." echo ok");
+       "ssh ".
+       ($_[0]->{'port'} ? "-p ".quotemeta($_[0]->{'port'})." " : "").
+       quotemeta($ruser)."\@".
+       quotemeta($_[0]->{'host'})." echo ok");
 local ($out, $wrong_password, $connect_failed, $got_password);
 while(1) {
        local $rv = &wait_for($fh, "password:", "yes\\/no", "(^|\\n)\\s*Permission denied.*\n", "ssh: connect.*\n", ".*\n");
@@ -64,6 +66,10 @@ sub show_rssh_dialog
 print &ui_table_row($text{'rssh_host'},
                    &ui_textbox("host", $_[0]->{'host'}, 50), 3);
 
+print &ui_table_row($text{'rssh_port'},
+                   &ui_opt_textbox("port", $_[0]->{'port'}, 6,
+                                   $text{'default'}), 3);
+
 print &ui_table_row($text{'rssh_ruser'},
                    &ui_textbox("ruser", $_[0]->{'ruser'}, 50), 3);
 
@@ -71,9 +77,10 @@ local $pmode = $_[0]->{'rpass'} eq '' ? 1 :
               $_[0]->{'rpass'} eq '*' ? 2 : 0;
 print &ui_table_row($text{'rssh_rpass'},
                    &ui_radio("rpass_def", $pmode,
-                     [ [ 1, $text{'rssh_nopass'} ],
-                       [ 2, $text{'rssh_nologin'} ],
-                       [ 0, &ui_textbox("rpass",
+                     [ [ 1, $text{'rssh_nopass'}."<br>" ],
+                       [ 2, $text{'rssh_nologin'}."<br>" ],
+                       [ 0, $text{'rssh_haspass'}." ".
+                            &ui_textbox("rpass",
                                $rpmode == 0 ? $_[0]->{'rpass'} : "", 30) ] ]));
 }
 
@@ -83,6 +90,13 @@ sub parse_rssh_dialog
 &foreign_installed("proc") || &error($text{'rssh_eproc'});
 $in{'host'} =~ /^[a-z0-9\.\-\_]+$/i || &error($text{'rssh_ehost'});
 $_[0]->{'host'} = $in{'host'};
+if ($in{'port_def'}) {
+       delete($_[0]->{'port'});
+       }
+else {
+       $in{'port'} =~ /^[1-9][0-9]*$/ || &error($text{'rssh_eport'});
+       $_[0]->{'port'} = $in{'port'};
+       }
 $in{'rpass_def'} == 2 || $in{'ruser'} =~ /\S/ || &error($text{'rssh_eruser'});
 $_[0]->{'ruser'} = $in{'ruser'};
 $_[0]->{'rpass'} = $in{'rpass_def'} == 1 ? undef :