Hi, again.
Attached, please find an updated new-and-improved version of the script.
This one wraps the whole functionality in an lts.conf variable called
"LDM_LIMIT_ONE_SESSION". So, this script will do nothing unless that
variable is set True.
Also, the script will run a server-side script
(name /usr/bin/LDM_keepalive) to retrieve additional process ID's *NOT*
to kill when it is killing processes. This script is optional, and it
allows the admin to fine-tune what types of apps should be kept alive.
For example, an admin may create a script in /usr/bin/LDM_keepalive that
does a "pgrep -u ${USER} screen", so no "screen" processes get killed.
That sort of thing.
Again, please give it a try, and let me know what you think.
-Gadi
On Mon, 2008-07-14 at 14:45 -0400, Gideon Romm wrote:
> Hi, all.
>
> Blinny and I have been picking at an rc.d script over the past few weeks
> to handle killing stale user processes that may have lingered from a
> previous login when users login again, as well as to prompt if the user
> is logged in elsewhere and offer to kill off her other session.
>
> Attached is the result of the effort. I'd like to put it out there for
> others who may be interested to test. Ultimately, if this works well,
> we may wrap the whole thing in lts.conf-param toggle, so admins can
> enable this feature or disable it as they see fit. As the script
> currently stands, it will never be enabled by default, as there exist
> environments where users may not want their processes from a previous
> session killed.
>
> If you try it, please give feedback.
>
> The script should be placed in:
>
> /opt/ltsp/i386/usr/lib/ldm/rc.d/S15userLoginCheck
>
> and then, reroll the image.
>
> NOTE: Older versions of ldm, may have the rc.d directory
> in: /opt/ltsp/i386/usr/share/ldm/rc.d/
>
> Enjoy,
>
> -Gadi
>
>
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
> _____________________________________________________________________
> Ltsp-discuss mailing list. To un-subscribe, or change prefs, goto:
> https://lists.sourceforge.net/lists/listinfo/ltsp-discuss For additional LTSP
> help, try #ltsp channel on irc.freenode.net
--
--------------------------------------------------------
Gideon Romm | Proud LTSP Developer
[EMAIL PROTECTED]
Support LTSP! Buy your hardware at:
www.DisklessWorkstations.com
www.DisklessThinClients.com
(use coupon code: LTSP5P for 5% off thin clients from DisklessThinClients.com)
#
# sourced with .
#
# Script to check if user is already logged in and offers to kill all of his
# procs (asside from sshd and SENTINEL related ones) before continuing
#
# get lts.conf vars
. /usr/lib/ltsp/ltsp_config
boolean_is_true(){
case "$(echo $1 | tr 'A-Z' 'a-z')" in
true|y|yes) return 0 ;;
*) return 1 ;;
esac
}
if boolean_is_true "$LDM_LIMIT_ONE_SESSION"; then
userProcs=$(ssh -X -S ${LDM_SOCKET} ${LDM_SERVER} '/usr/bin/pgrep -u
${USER}')
# Since we use a socket, by taking out the newest sshd proc from the kill
list,
# we should preserve our socket.
sshdProc=$(ssh -X -S ${LDM_SOCKET} ${LDM_SERVER} '/usr/bin/pgrep -n -u
$USER sshd')
sshdChildren=$(ssh -X -S ${LDM_SOCKET} ${LDM_SERVER} "/usr/bin/pgrep -P
$sshdProc")
sshdGrandKids=
for k in $sshdChildren; do
sshdGrandKid=$(ssh -X -S ${LDM_SOCKET} ${LDM_SERVER} "/usr/bin/pgrep -P
$k")
sshdGrandKids="$sshGrandKids $sshdGrandKid"
done
# Let's check if there is an old session or simply stale prcoesses
allsshdProcs=$(ssh -X -S ${LDM_SOCKET} ${LDM_SERVER} '/usr/bin/pgrep -u
$USER sshd')
oldSessions=0
for p in $allsshdProcs; do
if [ "$p" != "$sshdProc" ]; then
oldSessions=$(($oldSessions+1))
fi
done
# Let's ignore processes returned by the serverside script:
# /usr/bin/LDM_keepalive
blacklistProcs=$(ssh -X -S ${LDM_SOCKET} ${LDM_SERVER}
'/usr/bin/LDM_keepalive')
# Take out sshd and kids
procs=
for i in $userProcs; do
match=
for j in $sshdProc $sshdChildren $sshdGrandKids $blacklistProcs; do
[ "$i" = "$j" ] && match=1
done
[ -z "$match" ] && procs="$procs $i"
done
procsCheck=$(echo $procs|sed -e 's/ //g')
if [ -n "$procsCheck" ]; then
if [ $oldSessions -gt 0 ]; then
if [ -x "/usr/bin/zenity" ]; then
zenity --question --text="The system thinks you are logged in
elsewhere. Would you like to close the other session and continue to log in?"
ret=$?
else
xmessage -center -buttons "Continue":0,"Cancel":5 The system
thinks you are logged in elsewhere. Would you like to close the other session
and continue to log in?
ret=$?
fi
else
ret=0
fi
if [ "$ret" = 0 ]; then
ssh -X -S ${LDM_SOCKET} ${LDM_SERVER} "/bin/kill $procs"
sleep 1
ssh -X -S ${LDM_SOCKET} ${LDM_SERVER} "/bin/kill -9 $procs"
else
/bin/kill -9 ${PPID}
fi
fi
fi
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_____________________________________________________________________
Ltsp-discuss mailing list. To un-subscribe, or change prefs, goto:
https://lists.sourceforge.net/lists/listinfo/ltsp-discuss
For additional LTSP help, try #ltsp channel on irc.freenode.net