import repository from arizona
[raven.git] / apps / mprepo / repouid.py
1 """arizonaconfig
2    options=[["",   "--uid",    "uid",    "store",      "string", None,        "UID", "run as a particular user id"],
3              ]
4
5    includes=[]
6 """
7
8 import os
9 import pwd
10 import sys
11
12 import arizonaconfig
13
14 def switchuid():
15    uidStr = arizonaconfig.get_option("uid")
16    if uidStr:
17        try:
18            uid = int(uidStr)
19        except ValueError:
20            uid = pwd.getpwnam(uidStr).pw_uid
21
22    os.setuid(uid)
23