Ok, a little environment talk.  Note that I'm heavy Unix--been in it since
'80--have written a login replacment for it (decades ago), etc.  I haven't
gone to actually read the login source for Linux, but all the docs are the
same, and it's just such a basic mechanism that I'm certain it works the
same as in Unix.  Plus they're POSIX-compliant...or intend to be.

First:  Environment is in no way supported by the kernel.  It's pure
user-space stuff; totally in the shell.

Remember that the environment is nothing exotic.  It's an array in the
shell; when you export something, all that means is that when you spawn a
new shell, it copies those strings to the new shell's environment array.
Look at documentation for execl and its variants--you can see that you,
as the caller, give whatever *you* decide belongs in the child's environment
to it by pointing to your selected array of variables.

Getty--in whatever form it may take, e.g., mgetty, mingetty--gets first
crack at the environment.  Note that it actually is the program that
issues the first "login:" prompt you see; it then spawns 'login', which
asks for your password.  Getty usually doesn't do much with the environment,
although it _could_; read some source of your favorite getty or its replacement.

Login, then, really is the first to get at things--it constructs
an environment array per the man page.  Note that they say that
PATH is set to "/usr/local/bin:/bin:/usr/bin:." for normal users, and
"/sbin:/bin:/usr/sbin:/usr/bin" for root users.  It can state this because
these are actual compiled strings in the source--go on, do a strings
on /bin/login.  (Actually, it's interesting--it looks like at least in
RedHat 6.2 they took out the reference to "." for normal users...)

So, coming out of 'login' things are pretty simple--just what they said
in the login man page (plus whatever undocumented changes have crept in.)

Now, depending on your shell, things get more complicated.  Bash uses
/etc/bashrc, ksh uses /etc/profile, csh (feh!) uses /etc/csh.cshrc AND
/etc/csh.login.  At this point, go read the scripts.

Hope this has helped someone.  I'm going for coffee and the snowblower...

Cheers,
-- 
        Dave Ihnat
        [EMAIL PROTECTED]



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to