Date: Sat, 27 Dec 2008 10:28:11 -0900 From: Mel <fbsd.questions@rachie.is-a-geek.net> To: freebsd-questions@freebsd.org, bseklecki@collaborativefusion.com Cc: Bill Moran <wmoran@collaborativefusion.com> Subject: Re: Default list of exported variables in sh(1) - $HOSTNAME Message-ID: <200812271028.11339.fbsd.questions@rachie.is-a-geek.net> In-Reply-To: <1230146554.4673.265.camel@soundwave.ws.pitbpa0.priv.collaborativefusion.com> References: <1230146554.4673.265.camel@soundwave.ws.pitbpa0.priv.collaborativefusion.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday 24 December 2008 10:22:34 Brian A. Seklecki wrote: > All: > > I've got a fun problem ... > > I'm having trouble tracking down where the default list of exported > variables is set for sh(1). > > I've got a piece of PHP code that runs on GNU/Linux but not FreeBSD > because (I think) $HOSTNAME is exported by default. > > The PHP CLI calls $_ENV["HOSTNAME"], which under GNU/Linux returns: > > $ php -r 'print gethostbyaddr(gethostbyname($_ENV["HOSTNAME"]))' > soundwave.ws....collaborativefusion.com > > In HTTP/CGI mode, I can call $_SERVER[]. But $_ENV[] should work in both > CLI and HTTP mode. > > However, because Apache is spawned from sh(1) from rc(8) and in FreeBSD > 6.x, $HOSTNAME is not exported by default, which is what $_ENV[] uses > (getenv()): > > $ uname -a > FreeBSD bdb00 6.3-RELEASE-p2 > $ export > SSH_CLIENT > USER > MAIL > HOME > SSH_TTY > PAGER > ENV > LOGNAME > BLOCKSIZE > TERM > PATH > SHELL > SSH_CONNECTION > FTP_PASSIVE_MODE > 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 in /usr/share/skel on FreeBSD does not set them. Neither does /etc/login.conf. I would set it in /etc/profile. -- Mel Problem with today's modular software: they start with the modules and never get to the software part.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812271028.11339.fbsd.questions>