src/mercurialserver/refreshauth.py
branchdebian
changeset 229 3a28047ec6dc
parent 213 72e7ba8b41a6
child 242 03d8f07230b3
equal deleted inserted replaced
228:f98f716b2ae8 229:3a28047ec6dc
     8 import re
     8 import re
     9 import base64
     9 import base64
    10 import os
    10 import os
    11 import os.path
    11 import os.path
    12 import subprocess
    12 import subprocess
    13 from mercurialserver import paths
    13 from mercurialserver import config
    14 
    14 
    15 goodkey = re.compile("[/A-Za-z0-9._-]+$")
    15 goodkey = re.compile("[/A-Za-z0-9._-]+$")
    16 
    16 
    17 def refreshAuth():
    17 def refreshAuth():
    18     akeyfile = os.path.expanduser("~/.ssh/authorized_keys")
    18     akeyfile = config.getAuthorizedKeysPath()
    19     wrappercommand = paths.getExePath() + "/hg-ssh"
    19     wrappercommand = config.getExePath() + "/hg-ssh"
    20     prefix='no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,command='
    20     prefix='no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,command='
    21 
    21 
    22     if os.path.exists(akeyfile):
    22     if os.path.exists(akeyfile):
    23         f = open(akeyfile)
    23         f = open(akeyfile)
    24         try:
    24         try:
    27                     raise Exception("Safety check failed, delete %s to continue" % akeyfile)
    27                     raise Exception("Safety check failed, delete %s to continue" % akeyfile)
    28         finally:
    28         finally:
    29             f.close()
    29             f.close()
    30 
    30 
    31     akeys = open(akeyfile + "_new", "w")
    31     akeys = open(akeyfile + "_new", "w")
    32     for keyroot in paths.getKeysPaths():
    32     for keyroot in config.getKeysPaths():
    33         kr = keyroot + "/"
    33         kr = keyroot + "/"
    34         #print "Processing keyroot", keyroot
    34         #print "Processing keyroot", keyroot
    35         for root, dirs, files in os.walk(keyroot):
    35         for root, dirs, files in os.walk(keyroot):
    36             for fn in files:
    36             for fn in files:
    37                 ffn = os.path.join(root, fn)
    37                 ffn = os.path.join(root, fn)