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

Re: [despammed] Re: [Sheflug] Redirecting to a index page depending on group membership on Apache 1.3



From: "Graham Cox" <grahamcox [at] despammed.com>
To: <shef-lug [at] list.sheflug.org.uk>
Sent: Tuesday, August 26, 2003 8:33 PM
Subject: Re: [despammed] Re: [Sheflug] Redirecting to a index page depending
on group membership on Apache 1.3


> On Tuesday, August 26, 2003 8:11 PM [GMT+0100=CET],
> Chris J <cej [at] nightwolf.org.uk> wrote:
>
> > I can't see anything obvious in the apache docs; what you'll probably
> > need is a short CGI script that does something like (this /will/ need
> > some work as it isn't perfect, and you'd probably be safer writing it
> > in perl/C++ or similar as shell really isn't ideal for CGI from a
> > security viewpoint):
> >
> <snip script>
>
> As Chris said, but here's a Perl script that should do the trick in place
of
> his shell script.
> Not tested, but something like this *should* work...
> Obviously you'll need to fill in the blanks - which are all in capitals to
> stand out...
>
> ----- CUT -----
> #!/usr/bin/perl -w
>
> setpwent();
> my $finished=1;
> while ($finished)
> {
>     @user = getpwent();
>     if ( [at] user == () )
>     {
>         USER_NOT_FOUND;
>         $finished = 0;
>     }
>     else
>     {
>         if ($user[0] eq USERNAME_TO_CHECK)
>         {
>             if ($user[3] == STAFF_GID)
>             {
>                 print "Location: STAFF_REDIRECT";
>                 $finished=0;
>             }
>             if ($user[3] == STUDENT_GID)
>             {
>                 print "Location: STUDENT_REDIRECT";
>                 $finished=0;
>             }
>             etc...
>         }
>     }
> }
> endpwent();
> ----- CUT -----
Thanks Graham,

If I read this correctly, it loops through each user on the system, finds
the user in question, and checks the default group.
The problem is a) there are 1500 users, and the "staff" & "student" groups
are not the default one.

does user[3] return all the groups the user is a member of?

Though I could use the same structure to loop through the members of the
staff group (about a 100) and compare that way.

Still thinking it through.

Rob Keeling

___________________________________________________________________

Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html

  GNU the choice of a complete generation.