That's a damm good effort for a Perl newbie (I suspect you must have other programming experience).
There's no glaring holes. Just a couple of comments:
1. You should add a check to see if $user and/or $pass are not specified, otherwise there's no point in proceeding. So before the open, do a:
die "No username supplied\n" unless $user;
die "No password supplied\n" unless $pass;
2. Also your for loop could probably be written to be a little more readable (although there's nothing really wrong with it). As I can figure, the password file has entries along the lines of:
username:xxxxxxxxxxxxzzzzz
Where x is the salt and z is the encrypted password?
for (@pwfile) {
if (/^$user:/) {
my ($salt,$encpass) = /:(.{12})(.{22})/;
if ($salt$encpass eq unix_md5_crypt($pass,$salt
print "Authorized\n";
exit;
}
}
}
print "Incorrect username or password\n";
Main Topics
Browse All Topics





by: BrianPap22Posted on 2004-04-06 at 16:14:55ID: 10770586
Should I take the lack of responses as a sign that I did something right for once? I find that hard to believe for this, my second Perl script ever.
Would a working prototype help someone? If so, just let me know and I can throw one up on some webspace.
OK, new policy... I won't split the points. 500 points per valid suggestion (I'll just create a new award question). If this is not acceptable under the ToS of EE, then a moderator may kindly let me know, and I will not do that. Otherwise, I have unlimited question points and I'm itchin' to use them :)