[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] chave USB para login
From: |
Keppler Alecrim |
Subject: |
Re: [shell-script] chave USB para login |
Date: |
Wed, 9 Aug 2006 13:12:02 -0400 |
Pow nao sabia que nao ia anexo.
lenin /usr/local/usbkeys # cat bin/usbkeys_check
#!/bin/bash
#Create by Michel Cunha and Karane Vieira
#Modified by Francisco Alecrim (address@hidden)
#WHOAMI=`/usr/bin/whoami`
WHOAMI=`echo $USER`
echo $USER
#Checking if user needs USB KEY
NUM_OCCURRENCE=`/bin/cat /etc/usbkeys | grep $WHOAMI | wc -l`
if [ $NUM_OCCURRENCE -lt 1 ];
then
echo 'Do not need USB KEY! Logando ';
#exec /bin/bash
exit 0
else
echo 'Needs USB KEY';
fi
#Getting USB KEYS registered
if [ -e /proc/bus/usb/devices ];
then
echo 'CAN find : /proc/bus/usb/devices';
DEVICES=`cat /proc/bus/usb/devices | grep "SerialNumber" |
cut -c 18-`
numLinhas=`cat /proc/bus/usb/devices | grep "SerialNumber" |
cut -c 18- | wc -l`
else
echo 'Cannot find : /proc/bus/usb/devices';
exit 0;
fi
echo -ne "Numeros de Serie no Sistema = $numLinhas\n"
for(( i=1 ; i<= numLinhas ; i++))
do
Linha=`cat /proc/bus/usb/devices | grep "SerialNumber" | cut -c 18-
| sort | head -$i | tail -1`
numLinhasArquivo=`/bin/cat /etc/usbkeys | wc -l`
for((j=1 ; j<= numLinhasArquivo ; j++))
do
LinhaArquivo=`/bin/cat /etc/usbkeys | grep $WHOAMI | cut -f2
-d'_'| sort | head -$j | tail -1`
echo -ne "Verificando ... $Linha = $LinhaArquivo\n"
if [ $Linha = $LinhaArquivo ];
then
echo -ne "Numero de Serie Encontrado. Logando no
Sistema ... \n"
#exec /bin/bash
exit
fi
done
echo -ne "Linha$i - $Linha\n"
done
echo -ne "\n Voce não foi autorizado a Entrar no Sistema. Saindo...\n"
logout
lenin /usr/local/usbkeys # cat README
Author
Created by Francisco Alecrim (address@hidden)
Objective
The objective of this work is to obtain a grade in activities
related with TSSO(Topicos Selecionados em Sistemas Operacioans) lectured by
Ilias Biris at UFAM(Universidade Federal do Amazonas).
License
GPL
Description
The program controls user's login.It just allows the login of some
users with a certain USB device plugged.Users that are with username on file
/etc/usbkeys needs to plug the USB device related with your login,if not the
login will be canceled.For those not listed on /etc/usbkeys,the login will
be normal.
Installing
Getting a USB serial number
# cat /proc/bus/usb/devices | grep "SerialNumber" | cut -c 18- >
/tmp/usb_before
Plug you USB device
# cat /proc/bus/usb/devices | grep "SerialNumber" | cut -c 18- >
/tmp/usb_after
# diff /tmp/usb_before /tmp/usb_after | grep '>' | cut -f2 -d' ' |
head -1
The number resulted of this operations is your USB serial key.
Creating a list of keys
Create a file
# touch /etc/usbkeys
The format of a entry is username_usbserialkey ,one entry per
line,for example :
teste_07912C401201B8A3
alecrim_06A06640F2E2A88F
Copy bin/usbkeys_check for /usr/local/bin.
# cp bin/usbkeys_check /usr/local/bin
Add to the end of /etc/bash.bashrc lines :
RES=`/usr/local/bin/usbkeys_check | grep "Logando" | wc -l`
if [ $RES -ne 1 ];
then
logout
fi
This file(/etc/bash.bashrc) is executed during login on shell.It's going
to check if login is available on SHELL.
Copy /etc/gdm/PostLogin/Default.sample /etc/gdm/PostLogin/Default
Add to the end of /etc/gdm/PostLogin/Default line :
/usr/local/bin/usbkeys_check > /tmp/log_usbkey
This file(/etc/gdm/PostLogin/Default) during desktop environment start
using GDM.It's going to check if login is available on desktop environment.
Comments
Francisco Alecrim ( address@hidden )
lenin /usr/local/usbkeys #
On 8/9/06, Fernando Zank <address@hidden> wrote:
>
> não vai anexo para a lista:
>
> Me mando o seu script para eu ver se possível, obrigado
>
> On 8/9/06, Keppler Alecrim < address@hidden> wrote:
>
> > Olá ,
> > Esta é a primeira vez que participo em uma lista de discursão.Espero não
> > apanhar muito.
> > Fiz um script simples que verfica se o usuário que está logando possui
> > uma
> > dispositivo USB plugado,senão ele não autoriza o login. Já vi um cara
> > fazendo algo com gdm e smartcard.
> >
> > O script vai em anexo com um README sobre a como deve ser o formato da
> > lista
> > de usuários.
> >
> > Aguardo comentários(bons ou ruins).
> >
> > PS: Estou desenvolvendo uma versão(não tem haver com esta lista,pois
> > estou
> > fazendo em C) para travar o boot do kernel.
> >
> > --
> > Francisco Keppler Silva Alecrim
> > Instituto Nokia de Tecnologia (INdT) - OSMRC
> >
> >
> > [As partes desta mensagem que não continham texto foram removidas]
> >
> >
> >
>
>
>
> --
> "Somos o que repetidamente fazemos, portanto a
> excelência não é um feito é um hábito" - Aristóteles
>
[As partes desta mensagem que não continham texto foram removidas]
- chave USB para login, Keppler Alecrim, 2006/08/09
- Message not available
- Re: [shell-script] chave USB para login,
Keppler Alecrim <=
- Re: [shell-script] chave USB para login, Julio C. Neves, 2006/08/09
- Re: [shell-script] chave USB para login, Keppler Alecrim, 2006/08/10
- Re: [shell-script] chave USB para login, Keppler Alecrim, 2006/08/10
- Re: chave USB para login, Mauricio, 2006/08/12
- Re: [shell-script] Re: chave USB para login, Keppler Alecrim, 2006/08/12