diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-03-15 10:43:58 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-03-15 10:43:58 -0700 |
commit | fa0e2d31d5964c7d7bb0f8d34b568d065cf38890 (patch) | |
tree | b49eb257176b7dc9a0a9a282504518f34ec98662 /lib/Vyatta/Login | |
parent | 87c0562ee477ebc37248c00cdcfe93ecfcf31102 (diff) | |
download | vyatta-cfg-quagga-fa0e2d31d5964c7d7bb0f8d34b568d065cf38890.tar.gz vyatta-cfg-quagga-fa0e2d31d5964c7d7bb0f8d34b568d065cf38890.zip |
Better version of forcing user logout
Use warning and hup signal to force user to log out.
Diffstat (limited to 'lib/Vyatta/Login')
-rwxr-xr-x | lib/Vyatta/Login/User.pm | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Vyatta/Login/User.pm b/lib/Vyatta/Login/User.pm index edba13ac..afc3cf53 100755 --- a/lib/Vyatta/Login/User.pm +++ b/lib/Vyatta/Login/User.pm @@ -109,7 +109,13 @@ sub _delete_user { } elsif ( getlogin() eq $user ) { die "Attempting to delete current user: $user\n"; } else { - system("userdel -f $user") == 0 + 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"; } } |