loginlimit
loginlimit is a program that is put into a users .profile. It will prevent a user from logging in if:
- The user would exceed the default session limit
- The user would exceed their personal session limit
- Logins are disabled for everyone
- Logins are disabled for that particular user (handy if they are
behind on their monthly payments to IT for the privilege of logging in
;)
The deflected user gets a message, displayed in plain text if using a
regular terminal, or in a pop-up box if using User Interface™
The line in .profile that accomplishes this is:
/usr/local/bin/loginlimit $( who am i | cut -f1 ) || exit
This assumes that the loginlimit script is put into /usr/local/bin
Setup
First, download the tarball from here
Use the command 'tar -xvf loginlimits.tar' to untar it, you will create a directory called loginlimits.
cd to loginlimits:
- Edit loginOverLimit.msg - this is what will be displayed if a
user is trying to log in over their session limit. The word
"loginLimit" will be replaced by their personal limit in the message
that gets displayed.
- Edit loginDisabled.msg - this is what will be displayed if logins are currently disabled for a user or all users.
- Copy these two files to /usr/local/etc, and
'chmod 444 /usr/local/etc/loginOverLimit.msg /usr/local/etc/loginDisabled.msg'
so that both files are readable by all users.
Note: You may have to create /usr/local/etc first...
- Copy loginlimit to /usr/local/bin, and
'chmod 755 /usr/local/bin/loginlimit'
Usage
To make a user "limitable" - insert the
following line in their .profile (ksh, sh, or pk-ksh, pk-sh) near the
end (exactly where depends on your .profile...)
/usr/local/bin/loginlimit $( who am i | cut -f1 ) || exit
To disable logins for all loginlimit users, touch /usr/local/etc/loginlimit.4all. To re-enable, rm /usr/local/etc/loginlimit.4all.
To disable logins for an individual user or a group of users, put their
names in /usr/local/etc/loginlimit.list with vi or another editor, one
on a line.
To enforce session limits, put a users name followed by a colon and the
session limit in the file /usr/local/etc/loginlimit.userLimits - e.g.:
joeuser:3
will limit joeuser to 3 sessions.
/usr/local/etc/loginlimit.userLimits may also contain a line such as
defaultLimit=3
which will set the default session limit to 3 for all users.
There are example files in the loginlimits directory that you untar'd.
You can look at screenshots here.
Requires
bash shell - here's links to get it for:
solaris
HP/UX
AIX