function run_command in ../lib/run.c assumes sh but uses any $SHELL
If I restart xymon while using tcsh, for example, suddenly my ntp test breaks, because:
red Thu Oct 16 22:39:47 2014 ntp NOT ok
Service ntp on <elided> is not OK : Service unavailable
Command: ntpdate -u -q -p 2 <elided> 2>&1
1: Permission denied.
/var/log/xymon/1, of course, is confused about the value of 2, because it can write there sometimes, which is also interesting. 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.
-Tracy
On 17 October 2014 15:16, Tracy Di Marco White <gendalia at iastate.edu> 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
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 <jlaidman at rebel-it.com.au> wrote:
On 17 October 2014 15:16, Tracy Di Marco White <gendalia at iastate.edu> 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
This is correct; there was change to do exactly this to allow alternative shells to be used directly (or not fork a shell at all if it wasn't needed).
There *should* be a SHELL= line in xymonserver.cfg and xymonclient.cfg which is where this would be set -- by default to /bin/sh -- which would take effect for xymonlaunch-executed commands and their children (including ntpdate).
Is there an .rpmnew or .pkg file that didn't get applied perhaps? How did the upgrade occur?
Regards,
-jc
On Fri, October 17, 2014 8:56 am, Tracy Di Marco White wrote:
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 <jlaidman at rebel-it.com.au> wrote:
On 17 October 2014 15:16, Tracy Di Marco White <gendalia at iastate.edu> 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
Xymon mailing list Xymon at xymon.com http://lists.xymon.com/mailman/listinfo/xymon
Since I've been running bb/hobbit/xymon a very long time, upgrades don't touch my config files, I tend to go through them by hand. That one is the one line I missed, it looks like.
-Tracy
On Fri, Oct 17, 2014 at 11:24 AM, J.C. Cleaver <cleaver at terabithia.org> wrote:
This is correct; there was change to do exactly this to allow alternative shells to be used directly (or not fork a shell at all if it wasn't needed).
There *should* be a SHELL= line in xymonserver.cfg and xymonclient.cfg which is where this would be set -- by default to /bin/sh -- which would take effect for xymonlaunch-executed commands and their children (including ntpdate).
Is there an .rpmnew or .pkg file that didn't get applied perhaps? How did the upgrade occur?
Regards,
-jc
On Fri, October 17, 2014 8:56 am, Tracy Di Marco White wrote:
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 <jlaidman at rebel-it.com.au> wrote:
On 17 October 2014 15:16, Tracy Di Marco White <gendalia at iastate.edu> 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
Xymon mailing list Xymon at xymon.com http://lists.xymon.com/mailman/listinfo/xymon
participants (3)
-
cleaver@terabithia.org
-
gendalia@iastate.edu
-
jlaidman@rebel-it.com.au