mirror of
https://github.com/openSUSE/osc.git
synced 2025-08-25 15:48:54 +02:00
Move prepending '~/.ssh' to the ssh key path from SignatureAuthHandler.ssh_sign() to __init__()
This commit is contained in:
@@ -568,6 +568,12 @@ class SignatureAuthHandler(AuthHandlerBase):
|
|||||||
self.user = user
|
self.user = user
|
||||||
self.sshkey = sshkey
|
self.sshkey = sshkey
|
||||||
|
|
||||||
|
if self.sshkey:
|
||||||
|
# if only a file name is provided, prepend ~/.ssh
|
||||||
|
if "/" not in self.sshkey:
|
||||||
|
self.sshkey = os.path.join("~", ".ssh", self.sshkey)
|
||||||
|
self.sshkey = os.path.expanduser(self.sshkey)
|
||||||
|
|
||||||
self.ssh_keygen_path = shutil.which("ssh-keygen")
|
self.ssh_keygen_path = shutil.which("ssh-keygen")
|
||||||
self.ssh_add_path = shutil.which("ssh-add")
|
self.ssh_add_path = shutil.which("ssh-add")
|
||||||
|
|
||||||
@@ -612,11 +618,6 @@ class SignatureAuthHandler(AuthHandlerBase):
|
|||||||
def ssh_sign(self, data, namespace, keyfile=None):
|
def ssh_sign(self, data, namespace, keyfile=None):
|
||||||
if not keyfile:
|
if not keyfile:
|
||||||
keyfile = self.guess_keyfile()
|
keyfile = self.guess_keyfile()
|
||||||
else:
|
|
||||||
if '/' not in keyfile:
|
|
||||||
keyfile = f"~/.ssh/{keyfile}"
|
|
||||||
keyfile = os.path.expanduser(keyfile)
|
|
||||||
|
|
||||||
cmd = [self.ssh_keygen_path, '-Y', 'sign', '-f', keyfile, '-n', namespace, '-q']
|
cmd = [self.ssh_keygen_path, '-Y', 'sign', '-f', keyfile, '-n', namespace, '-q']
|
||||||
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, encoding="utf-8")
|
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, encoding="utf-8")
|
||||||
signature, _ = proc.communicate(data)
|
signature, _ = proc.communicate(data)
|
||||||
|
Reference in New Issue
Block a user