muriloventuroso / easyssh

The SSH connection manager to make your life easier.
GNU General Public License v3.0
523 stars 39 forks source link

Connection Error if password is blank #118

Closed bjwest closed 3 years ago

bjwest commented 3 years ago

If the password field is left blank, easyssh still submits it when prompted by the server. This results in a connection error, and when the dialog is closed and the password entered manually, the error dialog pops back up after logging in.

It seems the method that sends the password isn't checking for an empty string, but simply appending a newline. This results in sending an empty string as the password.

I created a simple patch that wraps the contents of the term_send_password() method in TerminalBox.vala in an if statement that checks for a zero length password before continuing, that seems to fix the issue. The editor won't let me upload a file, so I'm including the text below.

--- /home/bjwest/tmp/easyssh-master/src/Widgets/TerminalBox.vala        2021-08-13 05:35:00.000000000 -0500
+++ /home/bjwest/tmp/easyssh/src/Widgets/TerminalBox.vala       2021-08-13 11:50:41.142240750 -0500
@@ -204,16 +204,18 @@
         }

         private void term_send_password() {
-            var cmd = dataHost.password + "\n";
-            #if UBUNTU_BIONIC_PATCHED_VTE
-                term.feed_child(cmd, cmd.length);
-            #else 
-                #if PATCHED_VTE
-                    term.feed_child((uint8[]) cmd.to_utf8 ());
-                #else
-                    term.feed_child(cmd.to_utf8 ());
+            if(dataHost.password.length > 0) {
+                var cmd = dataHost.password + "\n";
+                #if UBUNTU_BIONIC_PATCHED_VTE
+                    term.feed_child(cmd, cmd.length);
+                #else 
+                    #if PATCHED_VTE
+                        term.feed_child((uint8[]) cmd.to_utf8 ());
+                    #else
+                        term.feed_child(cmd.to_utf8 ());
+                    #endif
                 #endif
-            #endif
+            }
         }

         private void term_send(string cmd) {
@@ -304,4 +306,4 @@

     }
-}
\ No newline at end of file
+}