src/mercurialserver/refreshauth.py
changeset 260 57dcdb212d00
parent 242 03d8f07230b3
child 311 3cbde66305e4
equal deleted inserted replaced
253:f0630151e057 260:57dcdb212d00
     2 Rewrite ~/.ssh/authorized_keys by recursing through key directories
     2 Rewrite ~/.ssh/authorized_keys by recursing through key directories
     3 """
     3 """
     4 
     4 
     5 import re
     5 import re
     6 import base64
     6 import base64
     7 import os
     7 import os, stat
     8 import os.path
     8 import os.path
     9 import subprocess
     9 import subprocess
    10 from mercurialserver import config
    10 from mercurialserver import config
    11 
    11 
    12 goodkey = re.compile("[/A-Za-z0-9._-]+$")
    12 goodkey = re.compile("[/A-Za-z0-9._-]+$")
    53                         kf.close()
    53                         kf.close()
    54                 for l in klines:
    54                 for l in klines:
    55                     if len(l):
    55                     if len(l):
    56                         akeys.write('%s"%s %s" %s\n' % (prefix, wrappercommand, keyname, l))
    56                         akeys.write('%s"%s %s" %s\n' % (prefix, wrappercommand, keyname, l))
    57     akeys.close()
    57     akeys.close()
       
    58     os.chmod(akeyfile + "_new", stat.S_IRUSR)
    58     os.rename(akeyfile + "_new", akeyfile)
    59     os.rename(akeyfile + "_new", akeyfile)
    59     
    60     
    60 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
    61 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
    61     refreshAuth()
    62     refreshAuth()
    62 
    63