[Xymon] function run_command in ../lib/run.c assumes sh but uses any $SHELL

J.C. Cleaver cleaver at terabithia.org
Fri Oct 17 18:24:59 CEST 2014


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
>





More information about the Xymon mailing list