Global Environment Variables

Global Environment Variables

Post by fd.mo.. » Wed, 13 Jun 2001 05:10:06



Very interesting scenario.  When I login to our 2.7 machine (bourne shell),

But I'm logging in as a regular user.  The /etc/profile and my personal
profile (as well as all other Bourne shell users)have no reference to PS1
anywhere, so when I login, I should see the default "$".

When I "su" to a particular userid with a Bourne shell, I get the "$" prompt.
If I put a "echo $PS1" at the BEGIINING of the /etc/profile, it comes back

variable.  

BUT I CANNOT FIND OUT WHERE IT'S BEING SET!  It's driving me crazy!  Any
ideas????

TIA,
FD

 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts

 
 
 

Global Environment Variables

Post by Casper H.S. Dik - Network Security Engine » Wed, 13 Jun 2001 05:44:17


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


>Very interesting scenario.  When I login to our 2.7 machine (bourne shell),

>But I'm logging in as a regular user.  The /etc/profile and my personal
>profile (as well as all other Bourne shell users)have no reference to PS1
>anywhere, so when I login, I should see the default "$".

Somebody probably killed inetd and restarted it with his own environment.

Kill it and restart it with a clean environemtn (probably set only $TZ)

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

Global Environment Variables

Post by Kjetil Torgrim Homm » Wed, 13 Jun 2001 18:29:06


[Casper H.S. Dik - Network Security Engineer]

Quote:>   Somebody probably killed inetd and restarted it with his own
>   environment.

>   Kill it and restart it with a clean environemtn (probably set only
>   $TZ)

Another good reason for leaving root's shell and well environment
alone. :-)

We type "exec bash" (or similar, depending on tastes) if we want a
fancy shell with PATH including local stuff etc. etc.  The /sbin/sh
environment is clean.  When I wish to restart a daemon, I routinely do
"rsh localhost" to get a clean environment for that.  ("su -" would do
as well.)

Kjetil T.

 
 
 

Global Environment Variables

Post by Mathew Kirsc » Wed, 13 Jun 2001 21:16:41



> Very interesting scenario.  When I login to our 2.7 machine (bourne shell),

> But I'm logging in as a regular user.  The /etc/profile and my personal
> profile (as well as all other Bourne shell users)have no reference to PS1
> anywhere, so when I login, I should see the default "$".

> When I "su" to a particular userid with a Bourne shell, I get the "$" prompt.
> If I put a "echo $PS1" at the BEGIINING of the /etc/profile, it comes back

> variable.

> BUT I CANNOT FIND OUT WHERE IT'S BEING SET!  It's driving me crazy!  Any
> ideas????

While Casper probably has the right answer, as he always does, I do have an
alternate theory:

Is the user's home directory being mounted/accessed properly? When a user's
home directory can't be accessed at login time, the system sets the user's
$HOME to /, which is root's home directory. Of course, normal shell login
procedure dictates that $HOME/.profile is executed. If root's .profile is

hard-coded in /.profile (as opposed to using the bash-specific prompt

Yes, I'm reaching a bit, but sillier things have happened...

 
 
 

Global Environment Variables

Post by FD Moo » Thu, 14 Jun 2001 02:59:07


Actually good answers from both, Mathew...

I'm still having the problem, but it just gets curiouser and
curiouser...

Following Casper's recommendation, here's what I found -

I changed the PS1 in /.profile to "hey beavis #" or something like
that.  Logged on as normal user, no effect.  Restart inetd as
root(actually inetd -s), and log back on as joe user1, and now my PS1
is "hey beavis #".  Remove the PS1 from /.profile, restart inetd and
now everyone's bourne shell prompt is..., yep you guessed it, "#"
(whatever root's .profile is, which in this case is missing, so it
defaults to "#").  So the /.profile is being cached (?) for everyone
to use.  But as Mathew said, /.profile (cached?) must be run by
everyone, but my $HOME is accesible just fine.  Log in and I'm in
/home/beavis, /etc/profile and my .profile runs, everything is honkey
dorey (or so it seems).  So the problem takes another turn, but it's
still THE problem.

Thanks for the help, and any more ways to "hone" in on it will be
greatly appreciated.

FD



> > Very interesting scenario.  When I login to our 2.7 machine (bourne shell),

> > But I'm logging in as a regular user.  The /etc/profile and my personal
> > profile (as well as all other Bourne shell users)have no reference to PS1
> > anywhere, so when I login, I should see the default "$".

> > When I "su" to a particular userid with a Bourne shell, I get the "$" prompt.
> > If I put a "echo $PS1" at the BEGIINING of the /etc/profile, it comes back

> > variable.

> > BUT I CANNOT FIND OUT WHERE IT'S BEING SET!  It's driving me crazy!  Any
> > ideas????

> While Casper probably has the right answer, as he always does, I do have an
> alternate theory:

> Is the user's home directory being mounted/accessed properly? When a user's
> home directory can't be accessed at login time, the system sets the user's
> $HOME to /, which is root's home directory. Of course, normal shell login
> procedure dictates that $HOME/.profile is executed. If root's .profile is

> hard-coded in /.profile (as opposed to using the bash-specific prompt

> Yes, I'm reaching a bit, but sillier things have happened...

 
 
 

Global Environment Variables

Post by FD Moo » Thu, 14 Jun 2001 02:59:08


Actually good answers from both, Mathew...

I'm still having the problem, but it just gets curiouser and
curiouser...

Following Casper's recommendation, here's what I found -

I changed the PS1 in /.profile to "hey beavis #" or something like
that.  Logged on as normal user, no effect.  Restart inetd as
root(actually inetd -s), and log back on as joe user1, and now my PS1
is "hey beavis #".  Remove the PS1 from /.profile, restart inetd and
now everyone's bourne shell prompt is..., yep you guessed it, "#"
(whatever root's .profile is, which in this case is missing, so it
defaults to "#").  So the /.profile is being cached (?) for everyone
to use.  But as Mathew said, /.profile (cached?) must be run by
everyone, but my $HOME is accesible just fine.  Log in and I'm in
/home/beavis, /etc/profile and my .profile runs, everything is honkey
dorey (or so it seems).  So the problem takes another turn, but it's
still THE problem.

Thanks for the help, and any more ways to "hone" in on it will be
greatly appreciated.

FD



> > Very interesting scenario.  When I login to our 2.7 machine (bourne shell),

> > But I'm logging in as a regular user.  The /etc/profile and my personal
> > profile (as well as all other Bourne shell users)have no reference to PS1
> > anywhere, so when I login, I should see the default "$".

> > When I "su" to a particular userid with a Bourne shell, I get the "$" prompt.
> > If I put a "echo $PS1" at the BEGIINING of the /etc/profile, it comes back

> > variable.

> > BUT I CANNOT FIND OUT WHERE IT'S BEING SET!  It's driving me crazy!  Any
> > ideas????

> While Casper probably has the right answer, as he always does, I do have an
> alternate theory:

> Is the user's home directory being mounted/accessed properly? When a user's
> home directory can't be accessed at login time, the system sets the user's
> $HOME to /, which is root's home directory. Of course, normal shell login
> procedure dictates that $HOME/.profile is executed. If root's .profile is

> hard-coded in /.profile (as opposed to using the bash-specific prompt

> Yes, I'm reaching a bit, but sillier things have happened...

 
 
 

Global Environment Variables

Post by Casper H.S. Dik - Network Security Engine » Thu, 14 Jun 2001 04:15:21


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


>that.  Logged on as normal user, no effect.  Restart inetd as
>root(actually inetd -s), and log back on as joe user1, and now my PS1
>is "hey beavis #".  Remove the PS1 from /.profile, restart inetd and
>now everyone's bourne shell prompt is..., yep you guessed it, "#"
>(whatever root's .profile is, which in this case is missing, so it
>defaults to "#").  So the /.profile is being cached (?) for everyone
>to use.  But as Mathew said, /.profile (cached?) must be run by
>everyone, but my $HOME is accesible just fine.  Log in and I'm in
>/home/beavis, /etc/profile and my .profile runs, everything is honkey
>dorey (or so it seems).  So the problem takes another turn, but it's
>still THE problem.

It's not cached; inetd inherits the environment from whoever starts
it (it should not be restarted; use kill -HUP inetd instead).

Then telnetd/rlogind etc inherit from inetd.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

Global Environment Variables

Post by Mathew Kirsc » Thu, 14 Jun 2001 21:55:17



> I'm still having the problem, but it just gets curiouser and
> curiouser...

No it doesn't. Casper hit the nail right on the head as usual!

Quote:> Following Casper's recommendation, here's what I found -

> I changed the PS1 in /.profile to "hey beavis #" or something like
> that.  Logged on as normal user, no effect.  Restart inetd as
> root(actually inetd -s), and log back on as joe user1, and now my PS1
> is "hey beavis #".  Remove the PS1 from /.profile, restart inetd and
> now everyone's bourne shell prompt is..., yep you guessed it, "#"
> (whatever root's .profile is, which in this case is missing, so it
> defaults to "#").  So the /.profile is being cached (?) for everyone
> to use.

What is happening is that PS1 is being set by inetd, just like Casper said.

When you log in as root, /.profile is run and a bunch of environment
variables, like PS1, are set. This is your "environment" when you're logged in
as root.

The variables are exported, meaning that anything root starts will also have
those environment variables set in the exact same way. This is what he meant
by "inheriting the environment."

You log in as root, your PS1 is set to "hey beavis #", then you stop and start
inetd. inetd stores the variable PS1 as "hey beavis #" and sets PS1 for any
processes it starts, like in.telnetd. in.telnetd starts login, which starts
your shell, and PS1 is copied from one to the next like a bad Dilbert cartoon.

Restarting inetd from an interactive login is where your problem is. Either:
1. Don't do that. Use kill -HUP to restart inetd.
2. Don't customize root. Leave everything to the defaults, and things will be
okay.

 
 
 

1. global environment variables before 1st login

Hi,
A newbie tries to set global environment variables at boot (before the
first user logs).
In what script file can it be done.
Please don't answer $HOME/.profile, it's not the solution I need cause I
need to launch WebObjects processes during init, those processes need
NEXT_ROOT environment variable.


Gilles Lenfant

2. Audit analycing on solaris 2.5

3. defining global environment variable

4. Patch for SPARCompiler C 4.0

5. Quest: how to set global environment variables?

6. DSL Cisco 675 modem/router to linux

7. NCSA httpd: forcing global environment variables

8. Slack '96: 3c59x 10b2: configuring module

9. Quest: how to set global environment variables?

10. Setting global environment variables

11. Quest: how to set global environment variables?

12. .profile, PS1 and global environment variables