Hi wize ones,

I am working on a cgi project involving security. The server is apache on solaris. I cannot change any of the apache configuration and cannot recompile it. Nor can I change perl. (I cannot add suidperl). I cannot install sudo or similar.

Now my question: I want the user to authenticate via the web browser via cookies (f.e. via this.)

The setup is that I need to authenticate via Unix user and passwords (/etc/passwd and /etc/shadow).

I have this code that works fine if ran as root
use strict; use Data::Dumper; use CfgTie::TieShadow; my $userid=shift || die "missing argument"; my $guess=shift || die "missing argument"; my %passwd; my %allgroup; tie %passwd, 'CfgTie::TieShadow'; die "cannot init passwd hash" if not keys %passwd; my $rc=1; if ( $passwd{$userid} ) { my $password=$passwd{$userid}->{password} ; if ( crypt($guess,$password) eq $password ) { $rc=0; my @mygroups; $mygroups[0]=getgrgid($passwd{$userid}->{groupid}); # Get the groups my $regex=qr/\b$userid\b/; while ( my ($group,$passwd,$gid,$members)= getgrent ) { if ( $members =~ $regex ) { push @mygroups, $group; } } print join(',',@mygroups); } else { warn "Authentication Failed"; } } else { warn "User $userid does not exist"; } exit $rc;
But not as the apache user (this is normal as /etc/shadow is not readable as a normal user, unix perms prevents this).

So I desided to put the suid flag on an authetication script, and call this with a system call. Since I have no suidperl I need to compile it. p2e does the trick, but this will NOT let suid scripts run.

To make a long store short. Is there a way to autheniticate unix users/groups via cgi-bin? Is there a way to compile perl code so that suid bits work?

I hope this question is clear enough.
---------------------------
Dr. Mark Ceulemans
Senior Consultant
IT Masters, Belgium


In reply to authenticate via cgi-bin by mce

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.