[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Internetnutzung zeitlich für User beschränken



Am 2009-03-19 13:07:22, schrieb Andre Bischof:
> und das wollte ich ja nicht - User, nicht IP-Adresse.

Wo ist das Problem?

Du bastelst Dir ein Startup-Script und legst es ins

    /etc/X11/Xsession.d/let_user_login

Im Script sendest Du dann per SSH einen Befehl wie

    RET=$(ssh -l root ${ROUTER} -c "IPT_gateway ${LOGIN}")

und in ${RET} kommt dann der Returnstatus zurück.

So, im script "IPT_gateway" kannste dann ${1} auswerten und entsprechend
IPT aktivieren wie:

    (cat /etc/IPT_gateway/${1}) |
    while read LINE
    do
      TIME_H=$(date +%H)
      TIME_M=$(date +%M)
      TIME=$(($TIME_H*6))
      TIME=$(($TIME+$M))
      S=$(echo "${LINE}" |cut -d ' ' -f1)
      E=$(echo "${LINE}" |cut -d ' ' -f2)
      if [ ${TIME} -ge ${S} ] && [ ${TIME} -lt ${E} ] ; then
        touch ${TMPDIR}/ALOWED_${1}
      fi
    done
    if [ -f ${TMPDIR}/ALOWED_${1} ] ; the
      iptables ....
      rm -f ${TMPDIR}/ALOWED_${1}
    fi

Dann brauchste nur noch ein durch  "cron"  ausgeführtes  Script  was  die
${USER} nach den Logauszeiten checked und die Gateway wieder schließt.


    for IPT_USERS in $(ls /etc/IPT_gateway/*) ; do
      IPT_USER=$(basename ${IPT_USERS})
      (cat /etc/IPT_gateway/${1}) |
      while read LINE
      do
        TIME_H=$(date +%H)
        TIME_M=$(date +%M)
        TIME=$(($TIME_H*6))
        TIME=$(($TIME+$M))
        S=$(echo "${LINE}" |cut -d ' ' -f1)
        E=$(echo "${LINE}" |cut -d ' ' -f2)
        if [ ${TIME} -ge ${S} ] && [ ${TIME} -lt ${E} ] ; then
          touch ${TMPDIR}/BLOCK_${1}
        fi
      done
      if [ -f ${TMPDIR}/BLOCK_${1} ] ; the
        iptables ....
        rm -f ${TMPDIR}/BLOCK_${1}
      fi
    done

somit kannste in die /etc/IPT_gateway/${1}  mehrere  Zeiten  definieren,
wobei das ${1} der loginname des Users ist und in der  Datei  pro  Zeile
zwei Zeiten in Minuten stehen müssen wie:

    540 960

wobei 540 eben 09:00 und 960 16:00 entspricht.


Thanks, Greetings and nice Day/Evening
    Michelle Konzack
    Systemadministrator
    24V Electronic Engineer
    Tamay Dogan Network
    Debian GNU/Linux Consultant

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
<http://www.tamay-dogan.net/>                 Michelle Konzack
<http://www.can4linux.org/>                   Apt. 917
<http://www.flexray4linux.org/>               50, rue de Soultz
Jabber linux4michelle@jabber.ccc.de           67100 Strasbourg/France
IRC #Debian (irc.icq.com)                     Tel. DE: +49 177 9351947
ICQ #328449886                                Tel. FR: +33  6  61925193

Attachment: signature.pgp
Description: Digital signature


Reply to: