From fa0e2d31d5964c7d7bb0f8d34b568d065cf38890 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 15 Mar 2010 10:43:58 -0700 Subject: Better version of forcing user logout Use warning and hup signal to force user to log out. --- lib/Vyatta/Login/User.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/Vyatta') 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"; } } -- cgit v1.2.3