diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-03-15 10:46:12 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-03-15 10:46:12 -0700 |
commit | e4d6fe0018945aae9215c27a479108a1bd1c86ed (patch) | |
tree | 5d152f5de63b3721a3b98b2b536e2ca4d8af33da | |
parent | a824dee9afa1efd1ec34561388bce8f8ad25333e (diff) | |
download | vyatta-cfg-system-e4d6fe0018945aae9215c27a479108a1bd1c86ed.tar.gz vyatta-cfg-system-e4d6fe0018945aae9215c27a479108a1bd1c86ed.zip |
Force user to be logged out
Bug 5067
Need to force user off with SIGHUP/SIGKILL.
Shells started from telnet ignore SIGTERM.
-rwxr-xr-x | lib/Vyatta/Login/User.pm | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Vyatta/Login/User.pm b/lib/Vyatta/Login/User.pm index e4909b9a..afc3cf53 100755 --- a/lib/Vyatta/Login/User.pm +++ b/lib/Vyatta/Login/User.pm @@ -109,8 +109,11 @@ sub _delete_user { } elsif ( getlogin() eq $user ) { die "Attempting to delete current user: $user\n"; } else { - # This logs out user (so we can delete it) - system("pkill -u $user"); + if (`who | grep "^$user"` ne '') { + warn "$user is logged in, forcing logout\n"; + system("pkill -HUP -u $user"); + } + system("pkill -9 -u $user"); system("userdel $user") == 0 or die "userdel of $user failed: $?\n"; |