calmthestorm has asked for the wisdom of the Perl Monks concerning the following question:
I am hoping someone has a solution to my problem because frankly I have burned hours an hours on trying to make this bug go away.
First a little background. I wrote a perl script to maintain passwords / UID's across a farm of servers that dont have other means of centralized password management setup. The script is/was working great for everyone until one day (yesterday) when the CTO asked me to reset his password on a subset of the servers because he was unable to login. I thought no problem, script I wrote has multiple arrays of servers configured for just such an occasion. Well, long story short, he types his password in and my script goes off and changes his password on the correct servers but he is still unable to login. Apparently his password has a dollar sign in it which is enough to bork my script. I spend the next few hours coming up with a solution to this problem but it is not working as expected. Here is a snippet of the code in question, hopefully someone gets an ah ha moment and can point to where I went wrong.
I guess I should add that my script is failing when comparing the two passwords taken from stdin only when special characters like $ are in the password which causes the usage sub to run/exitsub change_pass { my $user = shift; print "\n\tEnter a NEW password for $username: "; ReadMode('noecho'); $new_password = ReadLine(0); chomp $new_password; print "\n\tConfirm new password for $username: "; $confirm_password = ReadLine(0); chomp $confirm_password; ReadMode(0); print "\n"; unless ( $new_password =~ /\b\Q$confirm_password\E\b/) { &usage("\nPasswords entered do NOT match!\n"); } my $set_password = '/usr/bin/ssh ' . $master_host . " \"echo \Q$ne +w_password\E | /usr/bin/passwd --stdin \Q$username\E\""; system($set_password); print "\n"; }
|
|---|