src/mercurialserver/refreshauth.py
changeset 165 3606d60b07e5
parent 107 84e9e33d866b
child 211 0cd59649772c
--- a/src/mercurialserver/refreshauth.py	Fri Oct 30 16:55:07 2009 +0000
+++ b/src/mercurialserver/refreshauth.py	Mon Nov 09 12:15:09 2009 +0000
@@ -9,16 +9,14 @@
 import base64
 import os
 import os.path
-import pwd
 import subprocess
 from mercurialserver import paths
 
 goodkey = re.compile("[/A-Za-z0-9._-]+$")
 
-def refreshAuth(pw_dir):
-    akeyfile = pw_dir + "/.ssh/authorized_keys"
+def refreshAuth():
+    akeyfile = os.path.expanduser("~/.ssh/authorized_keys")
     wrappercommand = paths.getExePath() + "/hg-ssh"
-    keydirs = [paths.getEtcPath() + "/keys", pw_dir + "/repos/hgadmin/keys"]
     prefix='no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,command='
 
     if os.path.exists(akeyfile):
@@ -31,7 +29,7 @@
             f.close()
 
     akeys = open(akeyfile + "_new", "w")
-    for keyroot in keydirs:
+    for keyroot in paths.getKeysPaths():
         kr = keyroot + "/"
         #print "Processing keyroot", keyroot
         for root, dirs, files in os.walk(keyroot):
@@ -63,6 +61,5 @@
     os.rename(akeyfile + "_new", akeyfile)
     
 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
-    pentry = pwd.getpwuid(os.geteuid())
-    refreshAuth(pentry.pw_dir)
+    refreshAuth()