packman@tamuts.tamu.edu (Wally Strzelec) (03/27/91)
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: #include <stdio.h> main (argc, argv) int argc; char *argv[]; { char line[25], pass[9], user[9]; FILE *pi, *popen(); strcpy(user, argv[1]); strcpy(pass, argv[2]); printf("%s %s\n", user, pass); sprintf(line, "/bin/passwd %s ", user); pi = popen(line, "w"); if(!pi) { exit(1); } fprintf(pi, "%s\n", pass); fprintf(pi, "%s\n", pass); pclose(pi); exit(0); } Thanks.... Wally Strzelec Texas A&M University Unix System Administrator packman@tamuts.tamu.edu These are my own opinions and do not necessarily reflect those of Texas A&M University.
weimer@garden.kodak.COM (Gary Weimer (588-0953)) (03/27/91)
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: [code deleted] This may depend on your system. I've had problems trying to redirect the input of the passwd command in SunOS. If I remember correctly, it was trying to get its input directly from /dev/tty. weimer@ssd.kodak.com ( Gary Weimer )
jew@charon.sunquest.com (J. E. Ward) (03/27/91)
I did this once, not too long ago. The easiest way I found to do it was to do root remsh commands to edit the /etc/passwd file directly. Be sure to follow whatever proceedure is in place on your system for editing the /etc/passwd file. And if you're doing it on AIX, BE CAREFUL!
mikel@teda.UUCP (Mikel Lechner) (03/28/91)
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.
jik@athena.mit.edu (Jonathan I. Kamens) (03/28/91)
It is a sad comment on what comp.unix.wizards has become that when someone posts a message to the newsgroup asking a question that is specifically answered in the comp.unix.questions FAQ posting, three people post responses that are less correct than the FAQ's answer (not quite "wrong," but definitely sub-obtimal) and that don't even mention the fact that the FAQ answers the question. So, I'll mention it. Your question is answered in question number 27 in this periodic posting: Subject: Frequently Asked Questions about Unix - with Answers [Monthly posting] Newsgroups: comp.unix.questions If this article has expired at your site and you do not want to wait until it is posted again, you can get a copy of it using the instructions at the end of this posting. Please read the FAQ posting before posting further questions to this newsgroup. The fact that the question is answered in the FAQ implies that it should not have been posted in comp.unix.wizards. Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710 -- Subject: Frequently Asked Questions about Unix - with Answers [Monthly posting] Newsgroups: comp.unix.questions Available via anonymous ftp from pit-manager.mit.edu (18.72.1.58) in the file /pub/usenet/comp.unix.questions/Frequently_Asked_Questions_about_Unix_-_with_Answers_[Monthly_posting] Available from mail-server@pit-manager.mit.edu by sending a message containing send usenet/comp.unix.questions/Frequently_Asked_Questions_about_Unix_-_with_Answers_[Monthly_posting]
jfh@rpp386.cactus.org (John F Haugh II) (03/28/91)
In article <16528@sunquest.UUCP> jew@charon.sunquest.com (J. E. Ward) writes: >I did this once, not too long ago. The easiest way I found to do it was >to do root remsh commands to edit the /etc/passwd file directly. Be sure >to follow whatever proceedure is in place on your system for editing the >/etc/passwd file. And if you're doing it on AIX, BE CAREFUL! Not to rain on your AIX-bashing parade, but AIX versions differ greatly from one release to the next. Both versions 2 and 3 have "shadow" password files, which is also a feature of SVR3.2 and SVR4. This isn't just an IBM feature, although the implmentation is IBM-specific. -- John F. Haugh II | Distribution to | UUCP: ...!cs.utexas.edu!rpp386!jfh Ma Bell: (512) 832-8832 | GEnie PROHIBITED :-) | Domain: jfh@rpp386.cactus.org "I want to be Robin to Bush's Batman." -- Vice President Dan Quayle
jpm@logixwi.uucp (Jan-Piet Mens @ Logix GmbH, Wiesbaden) (03/28/91)
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 ^^^^^^^^^^^ Don't you mean "/bin/passwd" ? >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: The reason why this will never work, is because "/bin/passwd" (the program) opens /dev/tty to read the password directly from the terminal, and does not accept the password from stdin. Regards, JP -- Jan-Piet Mens, Logix GmbH jpm@logixwi.UUCP Moritzstr. 50, D-6200 Wiesbaden ...!uunet!mcsun!unido!logixwi!jpm
asg@sage.cc.purdue.edu (Bruce Varney) (03/29/91)
In article <JIK.91Mar27232213@pit-manager.mit.edu> jik@athena.mit.edu (Jonathan I. Kamens) writes: } } It is a sad comment on what comp.unix.wizards has become that when }someone posts a message to the newsgroup asking a question that is }specifically answered in the comp.unix.questions FAQ posting, three }people post responses that are less correct than the FAQ's answer (not }quite "wrong," but definitely sub-obtimal) and that don't even mention }the fact that the FAQ answers the question. What an insulting asshole. } }If this article has expired at your site and you do not want to wait }until it is posted again, you can get a copy of it using the }instructions at the end of this posting. } } Please read the FAQ posting before posting further questions to this }newsgroup. The fact that the question is answered in the FAQ implies }that it should not have been posted in comp.unix.wizards. And the fact that you are a dick implies that you should not post to comp.unix.wizards. } }Jonathan Kamens USnail: ^^^^^^ Get out your UShammers!!! Hey - you told me to point out the next time you were condescending. :-) Bruce --------- sar.casm \'sa:r-.kaz-*m\ \sa:r-'kas-tik\ \-ti-k(*-)le-\ n [F sarcasme, fr. LL sarcasmos, fr. Gk sarkasmos, fr. sarkazein to tear flesh, bite the lips in rage, sneer, fr. sark-, sarx flesh; akin to Av thwar*s to cut] 1: a cutting, hostile, or contemptuous remark : GIBE 2: the use of caustic or ironic language - sar.cas.tic aj ### ## Courtesy of Bruce Varney ### # aka -> The Grand Master # asg@sage.cc.purdue.edu ### ##### # PUCC ### # ;-) # # ;'> # ##
gwyn@smoke.brl.mil (Doug Gwyn) (03/29/91)
In article <13766@helios.TAMU.EDU> packman@tamuts.tamu.edu (Wally Strzelec) writes: >... 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. In assuming that the "passwd" utility reads the password from its standard input. (Hint: /dev/tty.)
brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (04/01/91)
In article <8952@mentor.cc.purdue.edu> asg@sage.cc.purdue.edu (Bruce Varney) writes: > In article <JIK.91Mar27232213@pit-manager.mit.edu> jik@athena.mit.edu (Jonathan I. Kamens) writes: > } It is a sad comment on what comp.unix.wizards has become that when > }someone posts a message to the newsgroup asking a question that is > }specifically answered in the comp.unix.questions FAQ posting, three > }people post responses that are less correct than the FAQ's answer (not > }quite "wrong," but definitely sub-obtimal) and that don't even mention > }the fact that the FAQ answers the question. > What an insulting asshole. It's an even sadder comment on what comp.unix.wizards has become that when someone posts a message to the newsgroup asking a question that is specifically answered in the comp.unix.questions FAQ posting, not only do five people post responses that are less correct than the FAQ's answer (not quite ``wrong,'' but definitely suboptimal) and that don't even mention the fact that the FAQ answers the question, but the one person to post a proper answer is flamed for his effort. ---Dan