3

Do NOT Use This Perl Module: Passwd::Unix


Posted by Artem Russakovskii on April 22nd, 2008 in Linux, Programming
Share

Updated: April 29th, 2008

3 Responses to “Do NOT Use This Perl Module: Passwd::Unix”

    3 Comments:
  1. joe says:

    What have you used instead ?
    Did you write your own ?

  2. joe, yeah, I ended up writing my own version which has worked well so far. If I were writing new code though, I would give Passwd::Unix another try since the author rewrote it after my bug report.

    For reference, here's the code I've come up with:

    1
    
    system("echo '$username:$password' | chpasswd") && die "Oops, there was some error setting the password!";
  3. Jason says:

    I'm using v0.40 Passwd::Unix qw(uid encpass passwd) without any problems.

    I would recommend against using Artem's example of system("echo stuff | passwordprogram") since that will show up in the ps -eF output….

    There are other methods open a pipe to a program where your password won't be viewable non-root users. In Perl you can use

    open(HANDLE,">","|chpasswd") || die "$!\n";
    print HANDLE "$username:$password";

    In PHP you can use popoen() or proc_open()

Leave a Reply

Connect with Facebook