Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CMS Script to allow "X" amount of sessions per login 1

Status
Not open for further replies.

aphophas

IS-IT--Management
Oct 21, 2004
3
0
0
US
I noticed in another thread "thread690-1251570" there was some info shared about this topic. I have been using something on my CMS for sometime, and works beautifully. Just replace the "/usr/bin/cms" with the new "/usr/bin/something" replacement

******** START OF SCRIPT **********
LOGINTAB="/etc/logins.table"

LOGINMAX=`grep '^[ ]*'$LOGNAME $LOGINTAB | tr -s "\011" " " | \

cut -f2 -d' '`

[ -z "${LOGINMAX}" ] && LOGINMAX=8

TTY=`ps -p $$ | grep -v PID | tr -s "\011" " " | cut -f3 -d' '`

echo "You are logging in at line $TTY ..."

LOGINDEV=`/usr/bin/w | grep \^$LOGNAME | grep -v $TTY | \

tr -s "\011" " " | \

cut -f2 -d' ' | tr -s "\012" " "`

if [ $LOGINMAX -ne 0 ]

then

LOGINCNT=`echo $LOGINDEV | wc -w 2> /dev/null`

LOGINCNT=`expr ${LOGINCNT:-0} + 0`

echo "Total number of sessions loggedin $LOGINCNT"

if [ $LOGINCNT -gt $LOGINMAX ]
then
echo $LOGINCNT
# /usr/ucb/logger -p daemon.notice -t PROFILE \

# "Denied login - user <$LOGNAME> - lines $TTY and $LOGINDEV"

echo "You are already logged in [$LOGINDEV] ..."

sleep 3

kill -KILL $$

fi

fi



/usr/bin/cms

********** END OF SCRIPT **********

The line "[ -z "${LOGINMAX}" ] && LOGINMAX=8" controls the amount of logins per user. This particular one is set for 8 sessions for the user that has this applied to their account. Just tweak the number to the amount you want, then save the file.

Just create the new file in "/usr/bin/something", then chmod to 755. Apply the new file either by editing the "/etc/passwd" file or through the GUI using "admintool". Of course depending on your preference, and version of Solaris. :)

Thanks,
Johnny
 
Very nice; why don't you add this as a FAQ?

Susan
"When the gods wish to punish us, they answer our prayers." - Oscar Wilde, An Ideal husband, 1893
 
I noticed in another thread "thread690-1251570: CMS logins/CentreVu 13.0" there was some info shared about this topic. I have been using something on my CMS for sometime, and works beautifully. Just replace the "/usr/bin/cms" with the new "/usr/bin/something" replacement

******** START OF SCRIPT **********
LOGINTAB="/etc/logins.table"

LOGINMAX=`grep '^[ ]*'$LOGNAME $LOGINTAB | tr -s "\011" " " | \

cut -f2 -d' '`

[ -z "${LOGINMAX}" ] && LOGINMAX=8

TTY=`ps -p $$ | grep -v PID | tr -s "\011" " " | cut -f3 -d' '`

echo "You are logging in at line $TTY ..."

LOGINDEV=`/usr/bin/w | grep \^$LOGNAME | grep -v $TTY | \

tr -s "\011" " " | \

cut -f2 -d' ' | tr -s "\012" " "`

if [ $LOGINMAX -ne 0 ]

then

LOGINCNT=`echo $LOGINDEV | wc -w 2> /dev/null`

LOGINCNT=`expr ${LOGINCNT:-0} + 0`

echo "Total number of sessions loggedin $LOGINCNT"

if [ $LOGINCNT -gt $LOGINMAX ]
then
echo $LOGINCNT
# /usr/ucb/logger -p daemon.notice -t PROFILE \

# "Denied login - user <$LOGNAME> - lines $TTY and $LOGINDEV"

echo "You are already logged in [$LOGINDEV] ..."

sleep 3

kill -KILL $$

fi

fi



/usr/bin/cms

********** END OF SCRIPT **********

The line "[ -z "${LOGINMAX}" ] && LOGINMAX=8" controls the amount of logins per user. This particular one is set for 8 sessions for the user that has this applied to their account. Just tweak the number to the amount you want, then save the file.

Just create the new file in "/usr/bin/something", then chmod to 755. Apply the new file either by editing the "/etc/passwd" file or through the GUI using "admintool". Of course depending on your preference, and version of Solaris.
 
I don't know what I'm doing wrong but it doesn't work for me.
I have created a file with the script named something (in usr/bin) and I let only 1 login per user in LOGINMAX=1.
Then I edit the file etc/password pointing some login to usr/bin/something instead usr/bin/cms.
When I loggin in a couple of PCs with the same login and works for the both.
Any help from whose it works please.
Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top