Date: Wed, 23 Oct 2002 19:05:26 -0400 (EDT) From: Jim Weeks <jim@jwweeks.com> To: Chris BeHanna <behanna@zbzoom.net> Cc: FreeBSD-Stable <stable@FreeBSD.ORG> Subject: Re: Password Authentication question Message-ID: <20021023185704.F1059-100000@veager.jwweeks.com> In-Reply-To: <20021023121442.X47335-100000@topperwein.pennasoft.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> On Wed, 23 Oct 2002, Mark Hennessy wrote:
> > I am trying to create an application that uses my existing passwd file to
> > authenticate users via a web form.
If you are writing your application in perl, this might be helpful. I
sometimes use poppassd to authenticate directly from /etc/master.passwd
with the follwing code. It probably could be cleaned up a bit, but you
get the idea.
use Socket;
sub chkpass {
$np = $form{'passwd'};
&open_TCP(PASSD, $host, $port) || &error ("Open Connection Fail");
# Get prompt
$_ = <PASSD>;
# Send username
print PASSD "user $SysUsr\n";
# Get password request
$_ = <PASSD>;
# Send password
print PASSD "pass $np\n";
# Get success(your new password please.) failure(Old password is
incorrect.)
$_ = <PASSD>;
if ($_ =~ /please/) { $success = "y"; }
elsif ($_ =~ /incorrect/) { $failure = "y"; }
# Quit cleanly
print PASSD "quit\n";
$_ = <PASSD>;
if ($failure) {
&error ("Incorrect password! Please hit your back button and try
again.");
}
elsif ($success) {
&setip;
&welcome;
}
else { &error ("Unknown Password Error!") }
}
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021023185704.F1059-100000>
