equal
deleted
inserted
replaced
7 # WARNING |
7 # WARNING |
8 |
8 |
9 import sys |
9 import sys |
10 import os |
10 import os |
11 import os.path |
11 import os.path |
|
12 import pwd |
12 import subprocess |
13 import subprocess |
13 from mercurialserver import ruleset |
14 from mercurialserver import ruleset, paths |
14 |
15 |
15 if len(sys.argv) <= 3: |
16 if len(sys.argv) != 1: |
16 sys.stderr.write("refresh-auth: wrong number of arguments (%s)\n" % sys.argv) |
17 sys.stderr.write("refresh-auth: must be called with no arguments (%s)\n" % sys.argv) |
17 sys.exit(-1) |
18 sys.exit(-1) |
18 |
19 |
19 akeyfile = sys.argv[1] |
20 pentry = pwd.getpwuid(os.geteuid()) |
20 wrappercommand = sys.argv[2] |
21 if pentry.pw_name != "hg": |
|
22 # FIXME: re-execute |
|
23 print >>sys.stderr, "Must be run as the 'hg' user" |
|
24 |
|
25 akeyfile = pentry.pw_dir + "/.ssh/authorized_keys" |
|
26 wrappercommand = paths.getEtcPath() + "/hg-ssh-wrapper" |
|
27 keydirs = [paths.getEtcPath() + "/keys", pentry.pw_dir + "/repos/hgadmin/keys"] |
21 prefix='no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,command=' |
28 prefix='no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,command=' |
22 |
29 |
23 if os.path.exists(akeyfile): |
30 if os.path.exists(akeyfile): |
24 f = open(akeyfile) |
31 f = open(akeyfile) |
25 try: |
32 try: |
28 raise Exception("Safety check failed, delete %s to continue" % akeyfile) |
35 raise Exception("Safety check failed, delete %s to continue" % akeyfile) |
29 finally: |
36 finally: |
30 f.close() |
37 f.close() |
31 |
38 |
32 akeys = open(akeyfile + "_new", "w") |
39 akeys = open(akeyfile + "_new", "w") |
33 for keyroot in sys.argv[3:]: |
40 for keyroot in keydirs: |
34 kr = keyroot + "/" |
41 kr = keyroot + "/" |
35 #print "Processing keyroot", keyroot |
42 #print "Processing keyroot", keyroot |
36 for root, dirs, files in os.walk(keyroot): |
43 for root, dirs, files in os.walk(keyroot): |
37 for fn in files: |
44 for fn in files: |
38 ffn = os.path.join(root, fn) |
45 ffn = os.path.join(root, fn) |