refresh-auth
changeset 0 41ecb5a3172c
child 1 5bc7446cd2d1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/refresh-auth	Tue Apr 15 16:14:22 2008 +0100
@@ -0,0 +1,30 @@
+#!/usr/bin/python
+
+import os
+import os.path
+
+# THIS SCRIPT COMPLETELY DESTROYS YOUR .ssh/authorized_keys FILE EVERY TIME IT IS RUN
+
+#command='cd %s && ../path/bin/hg-ssh %s' % (repos, " ".join(projects))
+
+akeyfile = os.path.expanduser("~/.ssh/authorized_keys")
+
+akeys = open(akeyfile + "_new", "w")
+for root, dirs, files in os.walk("keys"):
+    for fn in files:
+        ffn = os.path.join(root, fn)
+        # FIXME: should ignore any path that contains dodgy characters
+        keyname = ffn[5:]
+        kf = open(ffn)
+        try:
+            for l in kf:
+                command='cd repos && hgadmin/hg-ssh %s' % keyname
+                prefix=('command="%s",no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding'
+                    % command)
+                #prefix='no-port-forwarding,no-X11-forwarding,no-agent-forwarding'
+                akeys.write("%s %s\n" % (prefix, l.strip()))
+        finally:
+            kf.close()
+
+os.rename(akeyfile + "_new", akeyfile)
+