Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: UNIX user authentication

by fokat (Deacon)
on Oct 31, 2001 at 21:09 UTC ( [id://122376]=note: print w/replies, xml ) Need Help??


in reply to UNIX user authentication

crypt() is smart enough to know about getting the salt out of the crypted password.

You can try something along these lines:

... my $pass = (getpwnam($login))[1]; if (crypt($password, $pass) eq $pass) { ## The user supplied the correct password } else { ## The user supplied a wrong password } ...
Which I think is considerably simpler and more portable. The code snippet you supplied will not work when the crypt() function in your system does not use a DES-based transformation.

If you need support for other crypt() methods (MD5 or Apache), I suggest you take a look at Crypt::Passwd*

Good luck.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://122376]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2024-04-23 14:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found