Someone asked me recently where inetd gets its environment from. I said I didn't know for sure, but (since there's no place I know of to set them anywhere) I would expect it would inherit from whatever starts it. The person asking was running a SCO system, so that would be /etc/tcp. Most Linuxes now run xinetd, which lets you specify "env" in its xinetd.conf, but even those values are just added to (or replace) whatever it picks up from its startup heritage.
Well, he tested it by adding to /etc/tcp and found that yes, it picks that up. It would have surprised me if it didn't, because the underlying exec (fork and exec) of a shell script is going to pass the environment, and it would be a strange program indeed that didn't read what it had been passed.
If you only wanted this for a specific program that inetd or xinetd runs, it might make more sense to wrap that program in a script that set whatever you wanted, thus avoiding suddenly changing the environment of every other network program. Don't forget to export anything set that way.
Later on, he reported this:
Clarification on inetd and its environment.
The environment that inetd inherits from /etc/tcp is not passed
onward as I first thought. The actual environment seen by any
process started by inetd comes from /etc/default/login, which is
very limited in scope. About the only thing that would be of
interest there would be the PATH statement, usually
/bin:/usr/bin.
Got something to add? Send me email.
More Articles by Tony Lawrence © 2009-11-07 Tony Lawrence
A common and not necessarily apocryphal example portrays a solo practitioner starved for business in a small town. A second lawyer then arrives, and they both prosper. (Deborah L. Rhode)
Printer Friendly Version
Inetd environment variables Copyright © November 2004 Tony Lawrence
Have you tried Searching this site?
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.
Contact us
Printer Friendly Version