/usr/share/mercurial-server/mercurialserver/config.py is in mercurial-server 1.2-2.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | """
Fix $HOME and read ~/.mercurial-server
"""
import sys
import os
import os.path
import pwd
import ConfigParser
globalconfig = None
def _getConf():
global globalconfig
if globalconfig is None:
globalconfig = ConfigParser.RawConfigParser()
globalconfig.read(os.path.expanduser("~/.mercurial-server"))
return globalconfig
def _getPath(name):
return os.path.expanduser(_getConf().get("paths", name))
def _getPaths(name):
return [os.path.expanduser(p)
for p in _getConf().get("paths", name).split(":")]
def getReposPath(): return _getPath("repos")
def getAuthorizedKeysPath(): return _getPath("authorized_keys")
def configExists():
try:
getAuthorizedKeysPath()
return True
except Exception, e:
print e
return False
def getKeysPaths(): return _getPaths("keys")
def getAccessPaths(): return _getPaths("access")
def getEnv(): return _getConf().items("env")
def _getdefault(section, option, default, f = lambda x: x):
conf = _getConf()
if conf.has_option(section, option):
return f(conf.get(section, option))
else:
return default
def getAllowedDots():
return _getdefault("exceptions", "allowdots", [],
lambda s: s.split(":"))
# Work out where we are, don't use config.
def initExe():
global _exePath
_exePath = os.path.dirname(os.path.abspath(sys.argv[0]))
# Fix $HOME in case of "sudo -u hg refresh-auth"
os.environ['HOME'] = pwd.getpwuid(os.geteuid()).pw_dir
def getExePath():
return _exePath
|