Re: [squid-users] Account expiry

From: Henrik Nordstrom <henrik_at_henriknordstrom.net>
Date: Thu, 03 Jul 2008 11:52:57 +0200

Please do not reply to an existing question when asking a new question.
Changing the subject is not sufficient, your message is still a response
to the original, and gets threaded as such in thread aware mail clients
and mail archives.

On tor, 2008-07-03 at 11:32 +0800, Patrick G. Victoriano wrote:

> I want to give access a certain user to the internet at a certain date. What config should I enter to my conf to implement this
> setup

Here is two options. Either place the restriction in whatever user
database you are using, only keeping the account enabled at those dates,
or build the restriction using acl's in squid.conf.

Now, Squid acls as such is a little limited in this regards as it
doesn't support dates, only days of the week and time. But It's
reletively trivial to extend with an external acl evaluating the time..

Example external acl helper for date checks. Used like

external_acl_type datecheck /path/to/datecheck.sh

acl user_a_dates external datecheck startdate enddate

where startdate and enddate is given like YYYYMMDD where YYYY is year,
MM is month and DD is day.

### cut here ###
#!/bin/sh
while read start end; do
        today=`date +%Y%m%d`
        if [ $start -le $today && $end -ge $today ]; then
                echo OK
        else
                echo ERR
        fi
done
### END CUT ###

Depending on how the timezone is configured on your server you MAY need
to add a TZ variable in the beginning of the script defining your
timezone. But normally not needed.

TZ=yourtimezone
export TZ

Regards
Henrik

Received on Thu Jul 03 2008 - 09:53:04 MDT

This archive was generated by hypermail 2.2.0 : Thu Jul 03 2008 - 12:00:02 MDT