try os.getlogin() first then fall back to os.geteuid()

This commit is contained in:
Seth Vidal 2013-07-04 15:23:16 -04:00
parent 4ea5bc2a42
commit 272a6b10b5

View file

@ -28,7 +28,11 @@ MSG_FORMAT="%(now)s\t%(count)s\t%(category)s\t%(name)s\t%(data)s\n"
LOG_PATH = '/var/log/ansible' LOG_PATH = '/var/log/ansible'
def getlogin(): def getlogin():
return pwd.getpwuid(os.geteuid())[0] try:
user = os.getlogin()
except OSError, e:
user = pwd.getpwuid(os.geteuid())[0]
return user
class LogMech(object): class LogMech(object):
def __init__(self): def __init__(self):