Re: [phplib] authentication via /etc/passwd From: Jonathan Gale (jgale <email protected>)
Date: 11/08/00

[sinp]

> If you could send the script that would be great jon thanks.

Here it is for anyone interested. Jens did bring up a good point about
security and using /etc/passwd to authenticate users. In our situation
we only allow SSL connections to the authenticated portion of the
website. I would reccommend doing the same.

-------- CUT ---------
#!/usr/bin/perl
#

open(PASSWD,"/etc/passwd");
open(SHADOW,"/etc/shadow");
open(FLATFILE,">/etc/passwd.httpd");
while(<SHADOW>){
        chop;
        ($uname,$temppass)=split(/:/);
        $pass{$uname}=$temppass;
}
while(<PASSWD>){
        chop;
        ($uname,$temppass,$uid,$gid,$fn,$homedir,$shell)=split(/:/);
        if ($temppass ne 'x'){ $pass{$uname}=$temppass; }
        if ($uid>=500) {
                print FLATFILE
"$uname:$pass{$uname}:$uid:$gid:$fn:$homedir:$shell\n";
        }
}

close(PASSWD);
close(SHADOW);
close(FLATFILE);
chmod(0400,"/etc/passwd.httpd");
chown(65534,65534,"/etc/passwd.httpd");

------- CUT -------

Remeber this must be run as root!

Jon

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>