try os.getlogin() first then fall back to os.geteuid()
This commit is contained in:
parent
4ea5bc2a42
commit
272a6b10b5
1 changed files with 5 additions and 1 deletions
|
@ -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'
|
||||
|
||||
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):
|
||||
def __init__(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue