[ClusterLabs] Small bug in RA heartbeat/syslog-ng

Lars Ellenberg lars.ellenberg at linbit.com
Tue Sep 22 12:30:54 UTC 2015


On Tue, Sep 22, 2015 at 07:47:22AM +0200, Dejan Muhamedagic wrote:
> Hi,
> 
> On Mon, Sep 21, 2015 at 09:01:07AM +0200, Ulrich Windl wrote:
> > Hi!
> > 
> > Just a small notice: While having a look at the syslog-ng RA, I found this bug (in SLES11 SP3, resource-agents-3.9.5-0.37.38.19):
> > SYSLOG_NG_EXE="${OCF_RESKEY_syslog_ng_binary-/sbin/syslog-ng}" ### line 237 of /usr/lib/ocf/resource.d/heartbeat/syslog-ng
> > 
> > I tried it in BASH, but if {OCF_RESKEY_syslog_ng_binary is unset, the default won't be substituted. It's because the correct syntax is:
> > SYSLOG_NG_EXE="${OCF_RESKEY_syslog_ng_binary:-/sbin/syslog-ng}"

That is incorrect.

if OCF_RESKEY_syslog_ng_binary is set to the empty string, the default
won't be substituted.

if it is *unset*, default will be substituded.

X="V"	  bash -c 'echo "colon-dash: X=\"${X:-default}\""; echo "dash-only: X=\"${X-default}\"";'
colon-dash: X="V"
dash-only: X="V"


X=""	  bash -c 'echo "colon-dash: X=\"${X:-default}\""; echo "dash-only: X=\"${X-default}\"";'
colon-dash: X="default"
dash-only: X=""

unset X;  bash -c 'echo "colon-dash: X=\"${X:-default}\""; echo "dash-only: X=\"${X-default}\"";'
colon-dash: X="default"
dash-only: X="default"


So, unless you happen to have an explicitly set to the empty string
OCF_RESKEY_syslog_ng_binary in your environment, things work just fine.
And if you do, then that's the bug.
Which could be worked around by:

> Yes. Interestingly, there's some code to handle that case (but
> commented out):
> 
> # why not default to /sbin/syslog-ng?
> #if [[ -z "$SYSLOG_NG_EXE" ]]; then
> #   ocf_log err "Undefined parameter:syslog_ng_binary"
> #   exit $OCF_ERR_CONFIGURED
> #fi

-- 
: Lars Ellenberg
: http://www.LINBIT.com | Your Way to High Availability
: DRBD, Linux-HA  and  Pacemaker support and consulting

DRBD® and LINBIT® are registered trademarks of LINBIT, Austria.




More information about the Users mailing list