home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.jcu.edu.au
/
2014.06.ftp.jcu.edu.au.tar
/
ftp.jcu.edu.au
/
v6.3.2b
/
SWBD63
/
fabos-6.3.2b-10.ppc.rpm
/
fabos-6.3.2b.10.cpio.gz
/
fabos-6.3.2b.10.cpio
/
fabos
/
libexec
/
usrlogout
< prev
next >
Wrap
Text File
|
2010-11-10
|
3KB
|
123 lines
#!/bin/sh
#
# Copyright (c) 2002-2007 Brocade Communications Systems, Inc.
# All rights reserved.
#
# File name: logout
# Module name: fabos/src/security/utils.c
#
# This script will logout all sessions of specified particular users.
# It's called by the in a number of situtaions in secure mode
# by the FABOS code such as when passwords change or FCS role
# change.
#
PATH=/fabos/sbin:/fabos/bin:/bin:/usr/bin:/sbin
if [ $# -ge 1 ]; then
# Logout Multiple Users
if [ $# -ge 2 ]; then
# Information for User
#echo Will logout user: $1
line="$*"
sw=`echo $line | cut -d' ' -f 1`
accts=`echo $line | cut -d' ' -f 2-`
msg="Security Policy, Password or Account Attribute Change: "
msg=$msg$accts" will be logged out"
chassis_info=`getchassisconfig`
num_switches=`echo $chassis_info | \
sed -n -e 's/Number of switches: //gp' | \
sed -n -e 's/ .*//gp'`
wall "$msg"
fi
if [ $# -eq 1 ]; then
# Logout Invalid Users
if [ $1 == "-invalid" ]; then
echo "Finding invalid users" >> /var/log/user.log
for logged_user in `who | cut -d' ' -f1`
do
echo "*logged_user - $logged_user* " >> /var/log/user.log
kill_user=1
# Check if the user is valid by searching the /etc/passwd file
for valid_user in `grep "$logged_user" < /etc/passwd | cut -d':' -f1`
do
if [ "$logged_user" == "$valid_user" ]
then
kill_user=0
break
fi
done
# If user is invalid, add it to the list of accounts
if [ $kill_user -eq 1 ]
then
accts="$logged_user $accts"
fi
done
if [ "$accts" != "" ]; then
wall "Active CP : Invalid users \"$accts\" will be logged out."
fi
accts=`echo $accts | cut -d' ' -f1-`
else
echo "Invalid Arguments/Options for usrlogout"
fi
fi
echo "logged_users : $accts" >> /var/log/user.log
echo "" >> /var/log/user.log
echo "looping through all accounts" >> /var/log/user.log
# Loop through all accounts
for name in $accts; do
echo "$name" >> /var/log/user.log
# Loop through all TTYs of user using 'who' command
for tty in `who | grep "$name " | sed -e 's/ / /g' | sed -e 's/ / /g' \
| sed -e 's/ / /g' | cut -d' ' -f2`
do
echo "*tty - $tty* " >> /var/log/user.log
pid=`fuser /dev/$tty | sed -e "s,^/dev/[[:alnum:]/]*:[[:space:]]*,,g"`
echo "*pid - $pid*" >> /var/log/user.log
if [ "$pid" != "" ]
then
kill -9 $pid 2> /dev/null
fi
done
done
# no argument, logout all
elif [ $# -eq 0 ]; then
msg="AAA Server Configuration Change: all accounts will be logged out"
mytty=`tty|sed -e 's/\/dev\///g'`
wall "$msg"
for tty in `who | sed -e 's/ / /g' | sed -e 's/ / /g' | sed -e 's/ / /g' \
| cut -d' ' -f2`
do
echo "*aaa tty - $tty*" >> /var/log/user.log
#kill all other shells first
if [ "$tty" != "$mytty" ]; then
pid=`fuser /dev/$tty | sed -e "s,^/dev/[[:alnum:]/]*:[[:space:]]*,,g"`
# echo Killing PID $pid
if [ "$pid" != "" ]; then
kill -9 $pid 2> /dev/null
fi
fi
done
#kill my own shell
pid=`fuser /dev/$mytty | sed -e "s,^/dev/[[:alnum:]/]*:[[:space:]]*,,g"`
# echo Killing PID $pid
if [ "$pid" != "" ]; then
kill -9 $pid 2> /dev/null
fi
fi