LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 04-14-2005, 09:21 AM   #1
CoolAJ86
Member
 
Registered: Jan 2004
Location: VT, USA
Distribution: Gentoo, Ubuntu - t3h 1337 & the easy, respectively
Posts: 125

Rep: Reputation: 15
Remotely Force Logout of other Users?


Is there any sort of standard utility for forcing a user to logoff as root?

Say Jane logs in remotely and her connection is dropped but she still has processes that are running. Sometimes when Jane logs back in she gets errors when trying to restart the processes which are already running but 'orphaned' so to speak.

Specifically, I'm using LTSP and everytime a PC is shut off before a user logs out it creates a mess of problems. I can create a bash script and run it in a cron job, but I was hoping some feature to handle this sort of thing had already been thought of and handled with some standard utility.
 
Old 04-14-2005, 09:53 AM   #2
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
hey i am working on a project like this

http://masand.sourceforge.net
 
Old 04-14-2005, 10:25 AM   #3
CoolAJ86
Member
 
Registered: Jan 2004
Location: VT, USA
Distribution: Gentoo, Ubuntu - t3h 1337 & the easy, respectively
Posts: 125

Original Poster
Rep: Reputation: 15
coolie, I'll check it out from time to time.

For my purposes I guess I'll just be using this script for now...

Code:
/usr/local/bin/loguseroff:

#!/bin/bash
if [ ! -n "${1}" ]; then
        echo "USAGE: ${0} username"
        exit 1
fi

USER_EXISTS=`cat /etc/passwd | grep ${1}`
if [ ! -n "${USER_EXISTS}" ]; then
        echo "That username is not in /etc/passwd"
        exit 1
fi

if [ "${1}" = "root" ]; then
        echo "Are you stupid or something? Been there, done that, BAD IDEA!"
        exit 1
fi

ps -U ${1} -u ${1} h --format pid | while read PID
do
        PID=`echo "${PROCESS}" | cut -f1`
done

sleep 10

ps -U ${1} -u ${1} h --format pid | while read PID
do
        kill -9 ${PID}
done

exit 0

Last edited by CoolAJ86; 04-14-2005 at 10:26 AM.
 
Old 04-14-2005, 10:27 AM   #4
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
Wouldn't it be easier just to kill the users shell with a signal 9?
 
Old 04-14-2005, 10:28 AM   #5
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
that script might not purge all process i think
because i used to get se remaining processes

regards
 
Old 04-16-2005, 06:51 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
If shell equals Bash, then you could globally set 'shopt -q -s huponexit'. A more constructive way for ppl to run cmdline jobs would be to use screen on login. When you've been thrown out of a session you can just login again and re-attach to a session.

//OT: for USER_EXISTS=`cat /etc/passwd | grep ${1}` you could turn to just using exit status, loose the cat usage doing 'grep -qie "$1" /etc/password' or even 'getent passwd "$1"' and the whole ps/kill thing may be shorter as pkill -U "$1"...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
who and finger reporting logout users untoldone Linux - Newbie 1 03-19-2004 11:53 PM
How can I force other users to log out? WarrenWright Linux - Newbie 2 02-06-2004 11:27 PM
Really Why do they force 56 modem users to use Kinternet instead of the well working maximalred Linux - General 0 08-23-2003 05:49 AM
Add users remotely, daemon? The Jesus Linux - Networking 1 08-14-2003 10:56 AM
Force logout bfloeagle Linux - General 4 01-07-2003 02:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 12:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration