Rev 5462: (gz) Add support for GNU lsh as a secure shell client (Matthew Gordon) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Oct 5 22:15:16 BST 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5462 [merge]
revision-id: pqm at pqm.ubuntu.com-20101005211513-whouyj5t7oo92gmq
parent: pqm at pqm.ubuntu.com-20101005203907-tc90rcruoountj6x
parent: mgordon at ivs3d.com-20101002021030-5fyewq0hpg48fbcq
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2010-10-05 22:15:13 +0100
message:
  (gz) Add support for GNU lsh as a secure shell client (Matthew Gordon)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/help_topics/__init__.py help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
  bzrlib/tests/test_ssh_transport.py test_ssh_transport.p-20070105153201-f7iq2bosvgjbdgc3-1
  bzrlib/transport/ssh.py        ssh.py-20060824042150-0s9787kng6zv1nwq-1
=== modified file 'NEWS'
--- a/NEWS	2010-10-05 20:39:07 +0000
+++ b/NEWS	2010-10-05 21:15:13 +0000
@@ -27,6 +27,10 @@
   hook.
   (Parth Malwankar, #403687)
 
+* GNU lsh is now a supported lsh client; just set BZR_SSH to 'lsh'.
+  Also, bzr will recognize if the 'ssh' comand is a symlink to lsh.
+  (Matthew Gordon, #374700)
+
 Bug Fixes
 *********
 

=== modified file 'bzrlib/help_topics/__init__.py'
--- a/bzrlib/help_topics/__init__.py	2010-10-01 01:18:28 +0000
+++ b/bzrlib/help_topics/__init__.py	2010-10-02 01:58:11 +0000
@@ -606,7 +606,7 @@
                     HOME.
 BZR_REMOTE_PATH     Full name of remote 'bzr' command (for bzr+ssh:// URLs).
 BZR_SSH             Path to SSH client, or one of paramiko, openssh, sshcorp,
-                    plink.
+                    plink or lsh.
 BZR_LOG             Location of .bzr.log (use '/dev/null' to suppress log).
 BZR_LOG (Win32)     Location of .bzr.log (use 'NUL' to suppress log).
 BZR_COLUMNS         Override implicit terminal width.

=== modified file 'bzrlib/tests/test_ssh_transport.py'
--- a/bzrlib/tests/test_ssh_transport.py	2010-02-17 17:11:16 +0000
+++ b/bzrlib/tests/test_ssh_transport.py	2010-09-28 01:09:30 +0000
@@ -20,6 +20,7 @@
     OpenSSHSubprocessVendor,
     PLinkSubprocessVendor,
     SSHCorpSubprocessVendor,
+    LSHSubprocessVendor,
     SSHVendorManager,
     )
 
@@ -72,6 +73,12 @@
         manager.set_ssh_version_string("SSH Secure Shell")
         self.assertIsInstance(manager.get_vendor({}), SSHCorpSubprocessVendor)
 
+    def test_get_vendor_by_inspection_lsh(self):
+        manager = TestSSHVendorManager()
+        self.assertRaises(SSHVendorNotFound, manager.get_vendor, {})
+        manager.set_ssh_version_string("lsh")
+        self.assertIsInstance(manager.get_vendor({}), LSHSubprocessVendor)
+
     def test_get_vendor_by_inspection_plink(self):
         manager = TestSSHVendorManager()
         self.assertRaises(SSHVendorNotFound, manager.get_vendor, {})
@@ -202,6 +209,28 @@
                 "-s", "sftp", "host"]
             )
 
+    def test_lsh_command_arguments(self):
+        vendor = LSHSubprocessVendor()
+        self.assertEqual(
+            vendor._get_vendor_specific_argv(
+                "user", "host", 100, command=["bzr"]),
+            ["lsh",
+                "-p", "100",
+                "-l", "user",
+                "host", "bzr"]
+            )
+
+    def test_lsh_subsystem_arguments(self):
+        vendor = LSHSubprocessVendor()
+        self.assertEqual(
+            vendor._get_vendor_specific_argv(
+                "user", "host", 100, subsystem="sftp"),
+            ["lsh",
+                "-p", "100",
+                "-l", "user",
+                "--subsystem", "sftp", "host"]
+            )
+
     def test_plink_command_arguments(self):
         vendor = PLinkSubprocessVendor()
         self.assertEqual(

=== modified file 'bzrlib/transport/ssh.py'
--- a/bzrlib/transport/ssh.py	2010-09-28 18:51:47 +0000
+++ b/bzrlib/transport/ssh.py	2010-10-02 01:48:34 +0000
@@ -126,6 +126,9 @@
         elif 'SSH Secure Shell' in version:
             trace.mutter('ssh implementation is SSH Corp.')
             vendor = SSHCorpSubprocessVendor()
+        elif 'lsh' in version:
+            trace.mutter('ssh implementation is GNU lsh.')
+            vendor = LSHSubprocessVendor()
         # As plink user prompts are not handled currently, don't auto-detect
         # it by inspection below, but keep this vendor detection for if a path
         # is given in BZR_SSH. See https://bugs.launchpad.net/bugs/414743
@@ -439,6 +442,27 @@
 register_ssh_vendor('sshcorp', SSHCorpSubprocessVendor())
 
 
+class LSHSubprocessVendor(SubprocessVendor):
+    """SSH vendor that uses the 'lsh' executable from GNU"""
+
+    executable_path = 'lsh'
+
+    def _get_vendor_specific_argv(self, username, host, port, subsystem=None,
+                                  command=None):
+        args = [self.executable_path]
+        if port is not None:
+            args.extend(['-p', str(port)])
+        if username is not None:
+            args.extend(['-l', username])
+        if subsystem is not None:
+            args.extend(['--subsystem', subsystem, host])
+        else:
+            args.extend([host] + command)
+        return args
+
+register_ssh_vendor('lsh', LSHSubprocessVendor())
+
+
 class PLinkSubprocessVendor(SubprocessVendor):
     """SSH vendor that uses the 'plink' executable from Putty."""
 




More information about the bazaar-commits mailing list