[comp.unix.wizards] Environment variables at login

wtoomey@gara.une.oz (Warren Toomey) (06/30/89)

Could anybody tell me where I can put a list of environment variables
(& their values) that everybody will get at login, regardless of which
shell they login to. Currently, our (old) tcsh is hacked to look in
/etc/cshinit, but of course users with /bin/sh don't get these variables.

I've tried putting them in /etc/rc, but for some reason they are not
passed onto the children process at bootup time.

BTW, we're running a Pyramid 90x with dual SysV & 4.3BSD universes!


				Thanks all,

					Warren Toomey
					(wtoomey@neumann.une.oz)

ckl@uwbln.UUCP (Christoph Kuenkel) (07/03/89)

In article <956@gara.une.oz>, wtoomey@gara.une.oz (Warren Toomey) writes:
> Could anybody tell me where I can put a list of environment variables
> [...] that everybody will get at login, regardless of which shell they login
We use the following scheme:

	- each interactive login shell (sh, csh, tcsh, ksh, whatever)
	  gets a link named ``-<usual name>'' (-sh, -csh, ...)
	- the systems bourne shell gets one extra link per login shell
	  named ``sh-<login shell>'' (sh-csh, sh-tcsh...)
	- any users gets one of the bourne shell links as login shell 
	    e.g. user:pw:uid:gid:gecos:home:/bin/sh-csh
	- any initialization (not only environment setting) is done
	  in /etc/profile
	- the last statement in /etc/profile overlays the bourne shell
	  with the real login shell, which is selected using $0

	    % grep -relevant /etc/profile
	    if [ $0 = -sh-csh ]; then
		SHELL=/bin/csh export SHELL
		exec -csh
	    fi
	    if [ $0 = sh-csh ]; then
		SHELL=/bin/csh export SHELL
		exec csh
	    fi
	    etc. pp.
	    # you could use a case statement instead...

the net effect is that any login shell will interpret /etc/profile using
/bin/sh and then start up the real shell which will still believe that its
the login shell (due to the -<name> linkname) [and thus will - for example -
execute ~/.login].

> I've tried putting them in /etc/rc, but for some reason they are not
> passed onto the children process at bootup time.
the shell which executes rc is a child of init just like all the gettys are.
so no environment is passed from rc to gettys :-(

And now my question for the wizards:  will the problem of setting up an
uniform process environment for any interactive and/or non-interactive
use be solved in a more elegant fashion in SysVR5 or in some BSD
version?
-- 
# include <std/disclaimer.h>
Christoph Kuenkel/UniWare GmbH       Kantstr. 152, 1000 Berlin 12, West Germany
ck@tub.BITNET                ckl@uwbln             {unido,tmpmbx,tub}!uwbln!ckl

guy@auspex.auspex.com (Guy Harris) (07/07/89)

>And now my question for the wizards:  will the problem of setting up an
>uniform process environment for any interactive and/or non-interactive
>use be solved in a more elegant fashion in SysVR5 or in some BSD
>version?

S5R3.1 already has a mechanism to do that - you put entries of the form

	VARIABLE=value

in "/etc/TIMEZONE" (a comment in the code says the name should be
changed in S5R4; presumably the name indicates that it was intended to
be used to set TZ, but it can set more than just TZ, so presumably the
intent was to change the name to reflect that) and "init" sets up the
environment of everything it spawns (except, apparently, for the
single-user shell) with those values (max of 6 values, at least in
S5R3.1).

That's what the code seems to do, anyway; try it and see.