Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!cwjcc!hal!ncoast!allbery From: allbery@ncoast.ORG (Brandon S. Allbery) Newsgroups: comp.unix.wizards Subject: Re: (login) behaviour. Message-ID: <13683@ncoast.ORG> Date: 25 May 89 23:25:13 GMT References: <89@ <22200001@ux1.cso.uiuc.edu> Reply-To: allbery@ncoast.UUCP (Brandon S. Allbery) Followup-To: comp.unix.wizards Organization: Cleveland Public Access UN*X, Cleveland, Oh Lines: 53 As quoted from <22200001@ux1.cso.uiuc.edu> by phil@ux1.cso.uiuc.edu: +--------------- | (echo hey;login);echo test | | Saw "hey" displayed, and went through login. "ps ux" shows an extra csh. | I logged out, and then saw "test" displayed. So I guess I really got a | new login shell from the subshell. Apparently doing (login) all by itself | doesn't really fork a new process for shell commands such as login and cd, | but rather does them and then restores everything, such as connected | directory. +--------------- Nope. The shells recognize "login" (and often "newgrp") as special commands, and automagically maps them to "exec login" (and "exec newgrp"). When you said "(login)", you said "start a subshell, which should exec /bin/login". When you exited the resulting "login shell", you got the original shell back. This can be more than slightly disorienting, by the way: % who am i allbery tty15 May 25 18:25 % date Thu May 25 19:18:02 EDT 1989 % (login root) Password: ######## # ^D % who am i root tty15 May 25 19:18 % _ (The above is NOT a typescript; I didn't actually do it. But I have done so before, on other systems; I can't do it on ncoast.) <--"covering my *ss" ;-) AT&T System V prohibits this, by the way: since /etc/utmp contains the login shell's pid, login can determine that it wasn't execed from the login shell: % who am i bsa tty15 May 25 18:25 % date Thu May 25 19:18:02 EDT 1989 % (login root) Login must be execed from the top-level shell. % who am i bsa tty15 May 25 19:18 % _ ++Brandon -- Brandon S. Allbery, moderator of comp.sources.misc allbery@ncoast.org uunet!hal.cwru.edu!ncoast!allbery ncoast!allbery@hal.cwru.edu Send comp.sources.misc submissions to comp-sources-misc@ NCoast Public Access UN*X - (216) 781-6201, 300/1200/2400 baud, login: makeuser