Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!rex!ames!vsi1!teda!mikel From: mikel@teda.UUCP (Mikel Lechner) Newsgroups: comp.unix.wizards Subject: Re: Password Pipe Message-ID: <23050@teda.UUCP> Date: 27 Mar 91 19:19:38 GMT References: <13766@helios.TAMU.EDU> <1991Mar26.203948.12567@ssd.kodak.com> Lines: 30 In article <13766@helios.TAMU.EDU>, packman@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.