From 623c0e3abd0c22d54874685143d3ccb10af71eeb Mon Sep 17 00:00:00 2001 From: brent s Date: Fri, 18 Jan 2019 15:56:13 -0500 Subject: [PATCH] whoops.. --- sys/user_cull.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/user_cull.py b/sys/user_cull.py index 98ecd3a..a5481f9 100755 --- a/sys/user_cull.py +++ b/sys/user_cull.py @@ -93,6 +93,7 @@ for user in psutil.users(): if login_length.total_seconds() < timeout: continue # they haven't even been logged in for long enough yet. idle_time = get_idle(user) + parent_pid = psutil.Process(user.pid).ppid() try: diff = idle_time.total_seconds() >= timeout except AttributeError: @@ -106,17 +107,17 @@ for user in psutil.users(): 'timeout': timeout} fmtd_goodbye = goodbye_mesg.format(**fmt_vals) if only_ssh: - if psutil.Process(user.pid).ppid() in ssh_pids: + if parent_pid in ssh_pids: if goodbye: subprocess.run(['write', user.name, user.terminal], input = fmtd_goodbye.encode('utf-8')) - psutil.Process(user.pid).terminate() + psutil.Process(parent_pid).terminate() else: if goodbye: subprocess.run(['write', user.name, user.terminal], input = fmtd_goodbye.encode('utf-8')) - psutil.Process(user.pid).terminate() + psutil.Process(parent_pid).terminate()