Re: [ILUG] Synchronising yp and samba passwords - solved, and another question

From: John Gaughan (jgaughan-ilug at domain irish-times.com)
Date: Thu 04 Oct 2001 - 15:46:57 IST


On Thu, 04 Oct 2001, Cormac McClean wrote:
> Hi,
>
> Solved my Perl-Expect problem.
> Problem: yppasswd uses different prompts to user, and also asks
> for the current password (smack!).
>
> The next question is: is there a way of getting this to work without
> echoing the passwords on the screen, e.g.
>
> Enter username: testuser
> Enter current password: see it here
> New password: on the screen
> Re-enter new password: on the screen
> Changing password ... succeeded.

Hi Cormac,

here's the solution given in the Perl FAQ:

  How do I ask the user for a password?

    (This question has nothing to do with the web. See a different
    FAQ for that.)

    There's an example of this in the "crypt" entry in the perlfunc
    manpage). First, you put the terminal into "no echo" mode, then
    just read the password normally. You may do this with an old-
    style ioctl() function, POSIX terminal control (see the POSIX
    manpage, and Chapter 7 of the Camel), or a call to the stty
    program, with varying degrees of portability.

    You can also do this for most systems using the Term::ReadKey
    module from CPAN, which is easier to use and in theory more
    portable.

        use Term::ReadKey;

        ReadMode('noecho');
        $password = ReadLine(0);

John.

-- 
John Gaughan, Systems Administrator
Irish Times New Media - http://www.ireland.com/


This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:12:31 GMT