Web header corruption with cgi calls using xymonmenu.cfg and xymonpage - a workaround
Maybe this has been fixed in Xymon releases 4.3.11+. This is dealing with custom cgi's being placed into cgi-bin/cgi-secure that are calling the xymonpage procedure. Problem is being experienced in 4.3.11.
When installing/modifying a custom module, running into corrupt web content with the upper menu installed through the xymonmenu.cfg/XYMONBODYHEADER mechanism via xymonpage. One variables is not being defined (XYMONSERVERSECURECGIURL) and de-referencing of another (XYMONSERVERWWWWURL) during execution. The latter condition is kinky; I tried tracing through xymonpage.c/headfoot.c but ended up getting lost. Until the XYMONSERVESECURECGIURL is ~~encountered in the xymonmenu.cfg, the XYMONSERVERWWWURL is being resolved.
Anyways, the problem can be demonstrated below by just setting the XYMONHOME variable and trying the three functions. Functions try1 and try2 are setting xymon environment using either sourcing of configuration file or through the xymoncmd. Results of both show the variables being undefined in the web page generation. If you look at the whole web page generation, there is also something weird with bad ~~duplication after the Help block from the xymonmenu.cfg (at least on my site). Oof...
One work around is to explicitly import the xymonserver.cfg content using the "--env" option with the xymonpage call. Function try3 (and try4) works - the variables all get defined. Note: still may need to set up xymon environment for the first portion feeding into the xymonpage pipeline either by sourcing or via the xymoncmd.
Looking through the mail archive, noticed others reporting something similar with the custom notes editor package. This work around may help them too.
#!/bin/sh export XYMONHOME=<your path>/xymon/server
function try1 {
1) bad iteration, source in everything at parent level - this results in erratic variable
expansion in results, cannot find value for XYMONSERVERSECURECGIURL and XYMONSERVERWWWURL
initially defined but lost on first incidence of XYMONSERVERSECURECGIURL (undefined)
. ${XYMONHOME}/etc/xymonserver.cfg
echo hello |
${XYMONHOME}/bin/xymonpage
}
function try2 {
2) bad iteration, source in using xymoncmd - same erratic results
exec ${XYMONHOME}/bin/xymoncmd --env=${XYMONHOME}/etc/xymonserver.cfg echo hello |
${XYMONHOME}/bin/xymonpage
}
function try3 {
3) works, source in everything at parent level - to set up environment for initial
execution (the "echo hello" portion) then also re-introduce environment in
xymonpage using "--env" setting, xymonpage is not reliably picking up runtime
inherittance otherwise
exec ${XYMONHOME}/bin/xymoncmd --env=${XYMONHOME}/etc/xymonserver.cfg echo hello |
${XYMONHOME}/bin/xymonpage --env=${XYMONHOME}/etc/xymonserver.cfg
}
function try4 {
4) works
. ${XYMONHOME}/etc/xymonserver.cfg
echo hello |
${XYMONHOME}/bin/xymonpage --env=${XYMONHOME}/etc/xymonserver.cfg
}
run test runs and filter out everything but blown variables -
XYMONSERVERSECURECGIURL and XYMONSERVERWWWURL
try1 2>&1 | grep -i xymonserver | head -10 #try2 2>&1 | grep -i xymonserver | head -10 #try3 2>&1 | grep -i xymonserver #try4 2>&1 | grep -i xymonserver
Den 10.01.2014 19:56, Deiss, Mark skrev:
Maybe this has been fixed in Xymon releases 4.3.11+. This is dealing with custom cgi's being placed into cgi-bin/cgi-secure that are calling the xymonpage procedure. Problem is being experienced in 4.3.11.
When installing/modifying a custom module, running into corrupt web content with the upper menu installed through the xymonmenu.cfg/XYMONBODYHEADER mechanism via xymonpage. One variables is not being defined (XYMONSERVERSECURECGIURL) and de-referencing of another (XYMONSERVERWWWWURL) during execution. The latter condition is kinky; I tried tracing through xymonpage.c/headfoot.c but ended up getting lost. Until the XYMONSERVESECURECGIURL is ~~encountered in the xymonmenu.cfg, the XYMONSERVERWWWURL is being resolved.
I think this is caused by missing out the fact that xymonserver.cfg is NOT intended to be used directly in shell scripts. As it says at the very top of xymonserver.cfg:
# NB : Even though it might look like a shell-script, it is NOT.
So when you do this:
#!/bin/sh export XYMONHOME=<your path>/xymon/server . ${XYMONHOME}/etc/xymonserver.cfg
then you are doing it wrong. E.g. it won't handle any "include" or "directory" settings.
function try1 {
1) bad iteration, source in everything at parent level - this
results in erratic variable
expansion in results, cannot find value for
XYMONSERVERSECURECGIURL and XYMONSERVERWWWURL
initially defined but lost on first incidence of
XYMONSERVERSECURECGIURL (undefined) . ${XYMONHOME}/etc/xymonserver.cfg echo hello |
${XYMONHOME}/bin/xymonpage
You cannot source xymonserver.cfg. The correct way of doing what you want is:
echo hello |
${XYMONHOME}/bin/xymoncmd
--env=${XYMONHOME}/etc/xymonserver.cfg xymonpage
In other words, you must let xymoncmd process the xymonserver.cfg file, and then have xymoncmd directly invoke the Xymon command that you want to use. You can omit the "--env" option if you compiled Xymon with the correct XYMONHOME setting.
function try2 {
2) bad iteration, source in using xymoncmd - same erratic results
exec ${XYMONHOME}/bin/xymoncmd --env=${XYMONHOME}/etc/xymonserver.cfg echo hello |
${XYMONHOME}/bin/xymonpage }
Here xymoncmd sets up the environment for the "echo hello" command, but your SHELL does NOT pass this to the xymonpage command.
function try3 {
3) works, source in everything at parent level - to set up
environment for initial
execution (the "echo hello" portion) then also re-introduce
environment in
xymonpage using "--env" setting, xymonpage is not reliably
picking up runtime
inherittance otherwise
exec ${XYMONHOME}/bin/xymoncmd --env=${XYMONHOME}/etc/xymonserver.cfg echo hello |
${XYMONHOME}/bin/xymonpage --env=${XYMONHOME}/etc/xymonserver.cfg }
Yep, this works because xymonpage now reads xymonserver.cfg by itself. So it doesn't rely on things coming in via the environment variables. You don't need the xymoncmd at all, the "echo hello" doesn't use it (same as in 2)).
function try4 {
4) works
. ${XYMONHOME}/etc/xymonserver.cfg echo hello |
${XYMONHOME}/bin/xymonpage --env=${XYMONHOME}/etc/xymonserver.cfg }
Same as 3), but the source'ing of xymonserver.cfg is both wrong and useless.
Hope this helps.
Regards, Henrik
participants (2)
-
henrik@hswn.dk
-
Mark.Deiss@xerox.com