From efa7d6d7bdbd184e61d1458fa32b5d3918c59675 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Wed, 18 Sep 2019 10:48:49 +0200 Subject: [PATCH] Don't dump keys if they consist only of whitespace --- gitdump.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gitdump.py b/gitdump.py index d0ddd81..8ded84c 100644 --- a/gitdump.py +++ b/gitdump.py @@ -36,7 +36,9 @@ class AuthorizedKeysDumper(object): f = open("%s/.ssh/authorized_keys.tmp" % self.conf.get("paths", "githome"), "w") for userid, sshkey in curs: for key in sshkey.split("\n"): - f.write("command=\"%s %s\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s\n" % (self.conf.get("paths", "pggit"), userid, key)) + key = key.strip() + if key: + f.write("command=\"%s %s\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s\n" % (self.conf.get("paths", "pggit"), userid, key)) f.close() os.chmod("%s/.ssh/authorized_keys.tmp" % self.conf.get("paths", "githome"), 0o600) os.rename("%s/.ssh/authorized_keys.tmp" % self.conf.get("paths", "githome"), "%s/.ssh/authorized_keys" % self.conf.get("paths", "githome")) -- 2.39.5