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.

sub 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"; }
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/exit

In reply to passwords with special characters are trying to kill me... no seriously! by calmthestorm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.