Package: dput-ng
Version: 1.10
When using the sftp uploader, the user name from the SSH configuration
is always preferred, that is, the order is currently: login name, dput
profile, SSH configuration. This is backwards because one might want to
override the user name in the dput profile.
The attached patch fixes the problem by changing the order as follows:
login name, SSH configuration, dput profile
Best regards,
MichaelFrom 7607fabdbe5cf7fd7b7f5d9890e568a48d9791ed Mon Sep 17 00:00:00 2001
From: Michael Kuhn
Date: Fri, 19 Feb 2016 21:46:17 +0100
Subject: [PATCH] Fix user name ordering.
---
dput/uploaders/sftp.py | 16 +---
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/dput/uploaders/sftp.py b/dput/uploaders/sftp.py
index e00b892..f902e58 100644
--- a/dput/uploaders/sftp.py
+++ b/dput/uploaders/sftp.py
@@ -56,16 +56,20 @@ def check_paramiko_version(req):
return version_info >= req
-def find_username(conf):
+def find_username(conf, ssh_conf):
"""
-Given a profile (``conf``), return the preferred username to login
-with. It falls back to getting the logged in user's name.
+Given a profile (``conf``) and an SSH configuration (``ssh_conf``),
+return the preferred username to login with.
+The profile takes precedence over the SSH configuration.
+It falls back to getting the logged in user's name.
"""
user = None
user = pwd.getpwuid(os.getuid()).pw_name
+if 'user' in ssh_conf:
+user = ssh_conf['user']
if 'login' in conf:
new_user = conf['login']
-if new_user != "*":
+if new_user != '*':
user = new_user
if not user:
raise SftpUploadException(
@@ -151,9 +155,7 @@ class SFTPUploader(AbstractUploader):
config.parse(open(os.path.expanduser('~/.ssh/config')))
o = config.lookup(fqdn)
-user = find_username(self._config)
-if "user" in o:
-user = o['user']
+user = find_username(self._config, o)
ssh_kwargs['username'] = user
--
2.5.0