Shortly after this, users started reporting unexpected behaviour after logging in with telnet, and it turned out they all had environment variables set to values that only I would use.
It appears (at least, this is the only explanation I have been able to come up with) that inetd inherited my environment (carried over via su) when I executed the 'inetsvc start' script, and telnet, and thence the login shell, then also inherited that environment.
Has anyone else noticed this? Is this a bug? Or should I have restarted the service some other way?
Every process you create inherits a copy of your environment variables, and anything they create gets copies too.
I hadn't expected that would matter to a system service, though! I thought such things usually clear the environment then set a strict one of their own.
Exactly so. A system daemon (such as inetd) should surely be protected from inheriting it's parent process's environment in the normal way.
A warning to us all when writing service initialisation scripts, I think. Not inetd's fault, perhaps?
I was also surprised that this environment was inherited by telnet and by the login process. I somehow expected that a login shell would inherit only a predefined environment from the system configuration.
No. It is a Solaris 9 and older documented behavior.If you kill and restart inetd, be aware that any environment variables in your shell are inherited by a shell for an incoming telnet session. For example, if you have USER=root in your environment, a user who connects to your machine with telnet inherits USER=root.
If your goal was for inetd to reread its configuration, the documented way would have been to send SIGHUP to the inetd process, eg:
pkill -HUP inetd
Note that current Solaris releases (10, 11) no more use the same mechanism to restart this service so do not exhibit this issue.
Ah. Thank you. For 'bug' read 'feature'. Or 'documented behavior' - I must remember that one
The one place I didn't look - updated man pages. Having checked the installed man page and not found a mention there, I will be sure to check for updates in future.