Properly dump multiple ssh keys to the authorized_keys file.
authorMagnus Hagander <magnus@hagander.net>
Sat, 17 Oct 2009 18:34:40 +0000 (20:34 +0200)
committerMagnus Hagander <magnus@hagander.net>
Sat, 17 Oct 2009 18:34:40 +0000 (20:34 +0200)
gitdump.py

index 6f7a3ebaea1f21944d0c956080f51df77337fc7f..fac9f4b5e024b47dbe98f8d96ecd349b953c97b8 100644 (file)
@@ -34,7 +34,8 @@ class AuthorizedKeysDumper(object):
                curs.execute("SELECT userid,sshkey FROM git_users ORDER BY userid")
                f = open("%s/.ssh/authorized_keys.tmp" % self.conf.get("paths", "githome"), "w")
                for userid,sshkey in curs:
-                       f.write("command=\"%s %s\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s\n" % (self.conf.get("paths", "pggit"), userid, sshkey))
+                       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))
                f.close()
                os.chmod("%s/.ssh/authorized_keys.tmp" % self.conf.get("paths", "githome"), 0600)
                os.rename("%s/.ssh/authorized_keys.tmp" % self.conf.get("paths", "githome"), "%s/.ssh/authorized_keys" % self.conf.get("paths", "githome"))