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

Ulrich Windl Ulrich.Windl at rz.uni-regensburg.de
Wed Sep 23 02:17:08 EDT 2015


>>> Lars Ellenberg <lars.ellenberg at linbit.com> schrieb am 22.09.2015 um 14:30
in
Nachricht <20150922123054.GA26107 at soda.linbit>:
> 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.

You are right: if X is unset ${X-Y} will do (in addition to ${X:-Y}, but if X
has no value only the latter will do:

v04:~> X=1
v04:~> echo ${X-Y}
1
v04:~> X=
pv04:~> echo ${X-Y}

v04:~> unset X
v04:~> echo ${X-Y}
Y
pv04:~> X=1
v04:~> echo ${X:-Y}
1
v04:~> X=
v04:~> echo ${X:-Y}
Y
v04:~> unset X
pv04:~> echo ${X:-Y}
Y
v04:~>

Still I think it's wrong, simply because it's not documented.

> 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.
> 
> _______________________________________________
> Users mailing list: Users at clusterlabs.org 
> http://clusterlabs.org/mailman/listinfo/users 
> 
> Project Home: http://www.clusterlabs.org 
> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf 
> Bugs: http://bugs.clusterlabs.org 







More information about the Users mailing list