I'm using xymon 4.3.17, and server is what does the ntpdate test. Here's
the snippet of code in question:
if (strchr(cmd, ' ') == NULL) execlp(cmd, cmd, NULL);
else {
char *shell = getenv("SHELL");
if (!shell) shell = "/bin/sh";
execl(shell, "sh", "-c", cmd, NULL);
}
exit(127);
Note that 4.3.10 does what you say. I have that in the clients I have.
If I restart it as me, ntpdate is run, but not with an sh derivative. My
shell is tcsh, and what I start uses my environment variables. My init
script also has #!/bin/sh as the first line, but that doesn't necessarily
prevent environment variables from being inherited.
# echo $tcsh
6.18.01
# sh
# echo $SHELL
/bin/tcsh
I've added setting the shell to my startup script for now. And, to show you
what's happening, here's a snippet that echoes $SHELL:
xymon_precmd()
{
echo $SHELL
SHELL="/bin/sh"
export SHELL
touch ${xymon_pidfile} && chown ${xymon_user} ${xymon_pidfile}
}
And so, even though the startup script is run with /bin/sh, the $SHELL
variable is still set to /bin/tcsh:
# /etc/rc.d/xymon restart
Stopping xymon.
Waiting for PIDS: 29042.
/bin/tcsh
Starting xymon.
#
-Tracy
On Thu, Oct 16, 2014 at 11:43 PM, Jeremy Laidman <user-71895fb2e44c@xymon.invalid>
wrote:
On 17 October 2014 15:16, Tracy Di Marco White <user-4d3c8321d54f@xymon.invalid>
wrote:
If I restart xymon while using tcsh, for example, suddenly my ntp test
breaks,
Is this a client or server? How did you restart xymon? My init script
has "#! /bin/sh" in the first line, so I don't think it should matter what
shell I run it from.
For the moment, I've hard coded 'export SHELL=/bin/sh' in the startup
script for xymon, but the assumption shouldn't be made that $SHELL is a
/bin/sh derivative.
Curiously, the code that runs the "ntpdate" command is this:
execl("/bin/sh", "sh", "-c", cmd, NULL);
where "cmd" is the command (passed into the run_command() function. So,
I'm perplexed why it should matter what shell is running. As far as I can
tell, none of Xymon's binaries or scripts reference $SHELL.
Cheers
Jeremy