whoops..
This commit is contained in:
parent
31e8c4acee
commit
623c0e3abd
@ -93,6 +93,7 @@ for user in psutil.users():
|
|||||||
if login_length.total_seconds() < timeout:
|
if login_length.total_seconds() < timeout:
|
||||||
continue # they haven't even been logged in for long enough yet.
|
continue # they haven't even been logged in for long enough yet.
|
||||||
idle_time = get_idle(user)
|
idle_time = get_idle(user)
|
||||||
|
parent_pid = psutil.Process(user.pid).ppid()
|
||||||
try:
|
try:
|
||||||
diff = idle_time.total_seconds() >= timeout
|
diff = idle_time.total_seconds() >= timeout
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@ -106,17 +107,17 @@ for user in psutil.users():
|
|||||||
'timeout': timeout}
|
'timeout': timeout}
|
||||||
fmtd_goodbye = goodbye_mesg.format(**fmt_vals)
|
fmtd_goodbye = goodbye_mesg.format(**fmt_vals)
|
||||||
if only_ssh:
|
if only_ssh:
|
||||||
if psutil.Process(user.pid).ppid() in ssh_pids:
|
if parent_pid in ssh_pids:
|
||||||
if goodbye:
|
if goodbye:
|
||||||
subprocess.run(['write',
|
subprocess.run(['write',
|
||||||
user.name,
|
user.name,
|
||||||
user.terminal],
|
user.terminal],
|
||||||
input = fmtd_goodbye.encode('utf-8'))
|
input = fmtd_goodbye.encode('utf-8'))
|
||||||
psutil.Process(user.pid).terminate()
|
psutil.Process(parent_pid).terminate()
|
||||||
else:
|
else:
|
||||||
if goodbye:
|
if goodbye:
|
||||||
subprocess.run(['write',
|
subprocess.run(['write',
|
||||||
user.name,
|
user.name,
|
||||||
user.terminal],
|
user.terminal],
|
||||||
input = fmtd_goodbye.encode('utf-8'))
|
input = fmtd_goodbye.encode('utf-8'))
|
||||||
psutil.Process(user.pid).terminate()
|
psutil.Process(parent_pid).terminate()
|
||||||
|
Loading…
Reference in New Issue
Block a user