Password Pipe

Mikel Lechner mikel at teda.UUCP
Thu Mar 28 05:19:38 AEST 1991


In article <13766 at helios.TAMU.EDU>, packman at tamuts.tamu.edu (Wally 
Strzelec) writes:
> Howdy.... I am writing a short program that will allow me to change the
> password on a remote machine.  To do this I am trying to use popen and
> feed it the "/etc/passwd" command on the remote machine. The problem
> is that it seems that the passwd command doesn't accept anything that
> I send down the pipe.  Can someone please tell me where I am messing
> up.  The following is my test:

That's because "passwd" calls the library routine "getpass" to read the
password from the user.  From reading the SunOS manual page it says
that "getpass" does an open of "/dev/tty" to read the password, instead
of reading from its standard input.  I believe that this is intentional
for security reasons.

The SunOS manual page also says it will read from standard input if it
cannot open "/dev/tty", but not for programs linked with the Sys V libraries.

So, if you're running SunOS 4.1.1 and want this to work you can try
fork'ing, removing your control terminal (for the child process),
setting up I/O redirection, and then exec the "passwd" program.
Of course, this is almost certainly not portable to other systems
(specificly Sys V).

-- 
Mikel Lechner			UUCP:  teda!mikel
Teradyne EDA, Inc.
5155 Old Ironsides Drive	| If you explain so clearly that nobody
Santa Clara, Ca 95054		| can misunderstand, somebody will.



More information about the Comp.unix.wizards mailing list