Automatic login script execution

Guy Harris guy at auspex.auspex.com
Sun Apr 15 06:08:12 AEST 1990


>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).



More information about the Comp.unix.wizards mailing list