Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.unix.wizards Subject: Re: Automatic login script execution Message-ID: <3174@auspex.auspex.com> Date: 14 Apr 90 20:08:12 GMT References: <780@barsoom.nhh.no> <40193@apple.Apple.COM> <1536@i2ack.sublink.org> Organization: Auspex Systems, Santa Clara Lines: 25 >What's wrong with putting a custom program in place of /bin/sh (or >whatever) inside /etc/passwd ? >All this program has to do is executing the shell as usual, at the >end of its job. Am i missing the point? Sorry if so. Be careful, because this can have unfortunate side effects. For instance, programs that either look at the SHELL environment variable, or at the "pw_shell" entry in your password file, to figure out what shell to use when they fire off a subshell will run your custom program. This means, for instance, that if you're running under a window system like SunView or X, every terminal emulator you fire up will use that custom program as your shell. If your custom program assumes that it's only run as a login shell, things may not work the way you expect them to.... In other words, your program should probably look at "argv[0]" to see if it begins with "-", just as the shells do, and use that to decide whether it's a login shell or not, if there's anything it'd do only as a login shell, not a subshell. Alternatively, it could modify the environment to set SHELL to your real shell before running your shell (although it should still check "argv[0]", so that it knows whether to run your real shell with a name beginning with "-" or not).