Default list of exported variables in sh(1) - $HOSTNAME

Mel fbsd.questions at
Mon Dec 29 21:05:44 UTC 2008

On Monday 29 December 2008 11:12:33 Brian A. Seklecki wrote:
> > > EDITOR
> >
> > I suspect linux to set them from .profile files (even /etc/profile) and
> > not hardcoded in a shell or login program. The default skeletons
> Mel:
>  You were right to some extent.  However, the problem is more
> complicated (or less complicated, depending).
> First, FreeBSD's default php.ini doesn't have:
> $variables_order = "EGPCS", so $ENV[] array wasn't getting popualted at
> all.

The port only installs php.ini-dist and php.ini-recommended, which are the 
ones from the PHP source tree. If neither of these is copied to php.ini then 
php.ini-dist is hardcoded inside php itself, also not something the FreeBSD 
port alters.

> Second, Apache FreeBSD RC scripts inherit the user environment from
> sudo(8) unless you pass -H or -i flag/args
> E.x.:,
>  % sudo -H -i -u root /usr/local/etc/rc.d/apache22 restart
> Compared to:
>  $ su -
>  Password:
>  $ /usr/local/etc/rc.d/apache22 restart
> Result in completely different results in PHP's $_ENV[]

As expected.
However, stuff in /etc/profile applies to all Bourne type shells.

> Additionally, the results of "$ su -" differ completely from the shell
> environment that executes when rc(8) is first run at boot time.

Correct. You can however clean the entire environment, by setting 
apache22limits_enable="YES" and apache22limits_args="-e -E -C daemon".
If you need specific variables to be available and the rest to be gone, the 
standard rc script doesn't support it. You'd have to roll your own.

> I may be better off using getenv() in PHP directly.

For portability yes, since it doesn't rely on EGPCS, but otherwise they give 
the same results.


Problem with today's modular software: they start with the modules
    and never get to the software part.

More information about the freebsd-questions mailing list