Re: Process Understanding



On Mon, 2007-02-05 at 10:28 +0000, Dan Track wrote:
Hi

I'm trying to get my head round how processes start and how they get
their environment, especially env variables.

Let's say you have two scenarios, one where a user e.g www has the
following entry in /etc/passwd

www:x:500:500::/home/www:/bin/bash

and the other where the user has the following entry:

apache:x:48:48:Apache:/var/www:/sbin/nologin

The main difference between the two that I would like to focus on is
the that one user has a bash shell (www) while the other has no shell
(apache).

If both users are used to start an httpd process, then where and how
do the processess get their environment variables, i.e what files are
read in both cases e.g /etc/profile, /etc/bashrc etc.?

Thank in advance
Dan

Processes that are started explicitly receive the starting users
profile. The environment variables are read by software commands. The
processes started by cron will utilize a default profile, or a shell
script can be executed that will set the environment appropriately.
Other processes can use both the inherited profile, and then add their
own required variables by software. In short, like everything else
UNIX, Linux offers multiple ways and means to accomplish a given goal.
Environment variables are "shortcuts" or "global" items accessible by
the programs, scripts and shells to simplify the programming task and
make code custom on a per user or per invocation basis.

As an example:
Just create a text file "showpath" that contains only the following:
echo $PATH

Now depending on your security settings you may have to make this
executable, so do the following:
% chmod +x showpath
This adds the executable capability to the file.

Then from a command shell window (terminal):
% source ./showpath

And you will see the path that will be searched for any commands you
issue. Typically it will contain /bin and /usr/bin among others.

This can also be used to add a path to search. For instance if you
write a lot of script files, you might have a ~/scripts directory, and
you could add that path as the first place to look (so it could replace
system commands if you desire) doing the following in your bash shell in
the terminal (the default FC6 terminal shell).
PATH=~/scripts:$PATH

Now when you execute the source command again, the path will reflect
the new condition. Don't worry, this will disappear when you log out and
back in again.

Regards,
Les H

Regards,
Les H

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list



Relevant Pages

  • [UNIX] Vulnerabilities Found in Scponly
    ... SSHd environment files. ... the user can upload a file with a custom ... This provides the user with a means of running arbitrary commands ... the user could execute arbitrary commands by uploading ...
    (Securiteam)
  • Re: Redirection issue
    ... 1- execute input commands from standard input, ... the phrase "it does not work anymore" carries very little meaning. ... after compilation and execution of the shell with a simple command like ...
    (comp.lang.c)
  • Re: Redirection issue
    ... 1- execute input commands from standard input, ... code to implement the redirection it does not work anymore. ... And it's not good shell behavior to echo commands anyway. ...
    (comp.lang.c)
  • Re: Redirection issue
    ... 1- execute input commands from standard input, ... "does not work" could be anything from not compiling, not executing, ... after compilation and execution of the shell with a simple command like ...
    (comp.lang.c)
  • vulnerabilities in scponly
    ... without allowing shell access. ... scponly makes no effort to verify the path to the scp or sftp-server ... arbitrary commands by simply uploading a file. ... However, if this is *NOT* the case, the user could execute arbitrary ...
    (Bugtraq)