Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Gentoo, Ubuntu - t3h 1337 & the easy, respectively
Posts: 125
Rep:
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.
Distribution: Gentoo, Ubuntu - t3h 1337 & the easy, respectively
Posts: 125
Original Poster
Rep:
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
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"...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.