From 272a6b10b55d61e65fa28bf1ee84d217913d317c Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Thu, 4 Jul 2013 15:23:16 -0400 Subject: [PATCH] try os.getlogin() first then fall back to os.geteuid() --- callback_plugins/logdetail.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/callback_plugins/logdetail.py b/callback_plugins/logdetail.py index 1433ef7f4a..3d19fcca88 100644 --- a/callback_plugins/logdetail.py +++ b/callback_plugins/logdetail.py @@ -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):