--- a/src/mercurialserver/refreshauth.py Sat Mar 07 09:48:10 2009 +0000
+++ b/src/mercurialserver/refreshauth.py Sat Mar 07 09:55:01 2009 +0000
@@ -12,16 +12,10 @@
import subprocess
from mercurialserver import ruleset, paths
-def refreshAuth():
- pentry = pwd.getpwuid(os.geteuid())
- if pentry.pw_name != "hg":
- # FIXME: re-execute
- print >>sys.stderr, "Must be run as the 'hg' user"
- sys.exit(-1)
-
- akeyfile = pentry.pw_dir + "/.ssh/authorized_keys"
+def refreshAuth(pw_dir):
+ akeyfile = pw_dir + "/.ssh/authorized_keys"
wrappercommand = paths.getExePath() + "/hg-ssh"
- keydirs = [paths.getEtcPath() + "/keys", pentry.pw_dir + "/repos/hgadmin/keys"]
+ 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):
@@ -63,11 +57,10 @@
for l in klines:
if len(l):
akeys.write('%s"%s %s" %s\n' % (prefix, wrappercommand, keyname, l))
-
akeys.close()
-
os.rename(akeyfile + "_new", akeyfile)
def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
- refreshAuth()
+ pentry = pwd.getpwuid(os.geteuid())
+ refreshAuth(pentry.pw_dir)
--- a/src/refresh-auth Sat Mar 07 09:48:10 2009 +0000
+++ b/src/refresh-auth Sat Mar 07 09:55:01 2009 +0000
@@ -7,12 +7,20 @@
# WARNING
import sys
+import os
+import pwd
from mercurialserver import refreshauth, paths
if len(sys.argv) != 1:
sys.stderr.write("refresh-auth: must be called with no arguments (%s)\n" % sys.argv)
sys.exit(-1)
+pentry = pwd.getpwuid(os.geteuid())
+if pentry.pw_name != "hg":
+ # FIXME: re-execute
+ print >>sys.stderr, "Must be run as the 'hg' user"
+ sys.exit(-1)
+
paths.setExePath()
-refreshauth.refreshAuth()
+refreshauth.refreshAuth(pentry.pw_dir)