diff --git a/openpyn/root.py b/openpyn/root.py index a6966eb..bce190e 100644 --- a/openpyn/root.py +++ b/openpyn/root.py @@ -52,17 +52,12 @@ def logged_in_user_is_root(username): def running_with_sudo(): if verify_running_as_root(): - logged_in_user = print(os.environ["USER"]) - if logged_in_user == "root": - return False - else: - return True - return False - - ''' - if logged_in_user_is_root(logged_in_user): - return False # when logged in as 'root' user notifications will work. - else: - return True # 'sudo' is used notification won't work. + try: + logged_in_user = os.getlogin() + if logged_in_user_is_root(logged_in_user): + return False # when logged in as 'root' user notifications will work. + else: + return True # 'sudo' is used notification won't work. + except FileNotFoundError: + print("os.getlogin, returned error, assuming 'openpyn' is running without 'SUDO'") return False # regular user without 'sudo' - '''