Edited by Corion: Moved to Seekers Of Perl Wisdom
Okay, this is a strange thing that probably has a lot to do with the way I implemented IO::Socket. I have the following main body of code:Basically, the client sends to this server a command such as VERIFY:username:password. I know the verification routine works if I run it on its own. However, when I try this encryption, I keep getting NOT VERIFIED's on an account I use to test. When I output the contents of $pass in verify_pass I notice that a ^M is tagged on the end of it. If I chop($pass), then this character goes and the verification works. Is there a reason why the ^M appears? When I checked $buf in the main loop, the ^M was not there. Any help would be appreciated.while ($new_sock = $sock->accept()) { ... while (defined ($buf = <$new_sock>)) { if ($buf =~ /^VERIFY:/) { if (verify_pass($buf)) { print $new_sock "VERIFIED\n"; } else { print $new_sock "NOT VERIFIED\n"; } ... ... } sub verify_pass { ($args) = @_; ($cmd, $user, $pass) = split(/:/, $args); chomp($pass); my $uid = getpwnam $user; my $pwd = (getpwuid $uid)[1]; my $salt = substr $pwd, 0; my $enc = crypt($pass, $salt); if ($enc eq $pwd) # Meaning success { return 1; } else { return 0; } }
In reply to ODD IO::SOCKET by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |