Skip to content

Commit

Permalink
Put the script login_control on this directory
Browse files Browse the repository at this point in the history
  • Loading branch information
ataliba committed Apr 16, 2012
1 parent 90ebb04 commit 6b3b6c1
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions login_control/login_control.sh
@@ -0,0 +1,53 @@
#!/bin/sh
#
# Version 0.1
# AUTHOR AND MAINTAINER: Ataliba Teixeira < http://github.com/ataliba >
#
# NAME
# login_control
#
# DESCRIPTION
# Limit the number of logins of a user on a Linux System
#
# HOW TO USE ?
#
# To install this script you need to create a file named login_control on you /etc directory
# After this, copy this script to the /usr/local/bin directory and set the exec permissions on this.
# # touch /etc/login_control
# # cp login_contro.sh /usr/local/bin/login_control
# # chmod 755 /usr/local/bin/login_control
#
# The default of this script is logout all the users try to connect more than one time on you Linux.
# But, if you need to permit more than one connect of a specific user, on the /etc/login_control file
# you need to put ( one per line ) the login and the number of connections of this user:
# Sintax: user:number of connections
# Example: ataliba:2
#
# If you have problems, open a bug request on GitHub
#
# CHANGELOG ( MM/DD/YYYY)
#
# ataliba 04/16/2012 - First public version
#

Me=`whoami`
Number=`who | grep $Me | wc -l`

# Processing user exceptions

LoginControl=`grep $Me /etc/login-control | awk -F":" '{print $2}'`

# Logout or login

if [ -z $LoginControl ]; then
if [ $Number -gt 1 ]; then
exit
fi
else
if [ $Number -gt $LoginControl ]; then
echo "You account has $Number connections at this time. Your limit is $LoginControl connections."
sleep 3
exit
fi
fi

0 comments on commit 6b3b6c1

Please sign in to comment.