[patch] radtest PPPhint option is not parsed properly
Attached is a patch that fixes a problem with radtest. This is the original bug report: https://bugzilla.redhat.com/show_bug.cgi?id=760193 John -- John Dennis <jdennis@redhat.com> Looking to carve out IT costs? www.redhat.com/carveoutcosts/
On Wed, Sep 26, 2012 at 03:55:14PM -0400, John Dennis wrote:
- if [ "$6" ] + if [ ! -z "$6" ] && [[ $6 =~ ^[0-9]+$ ]] && [ $6 -gt 0 ]
radtest starts with /bin/sh, not /bin/bash. Are you sure this regexp-matching stuff is in a vanilla POSIX shell? I don't think it is. $ /bin/dash -c '[[ "aaa" =~ "a" ]] && echo "yo"' /bin/dash: [[: not found Also you forgot to quote $6 (in case it contains spaces). Personally I would just go with: if [ ! -z "$6" -a "$6" -gt 0 ] This bombs out if you give a non-numeric value, but then that's your fault for passing bad data. A more backwards-compatible approach is simply: if [ "$6" != "" -a "$6" != "0" ] Regards, Brian.
Brian Candler wrote:
radtest starts with /bin/sh, not /bin/bash. Are you sure this regexp-matching stuff is in a vanilla POSIX shell? I don't think it is.
Me either. FreeRADIUS runs on Linux, *BSD, Solaris, and (at one time) AIX and HPUX. Portability is good.
This bombs out if you give a non-numeric value, but then that's your fault for passing bad data. A more backwards-compatible approach is simply:
if [ "$6" != "" -a "$6" != "0" ]
That should work, I think. Alan DeKok.
On 09/26/2012 05:20 PM, Alan DeKok wrote:
Brian Candler wrote:
radtest starts with /bin/sh, not /bin/bash. Are you sure this regexp-matching stuff is in a vanilla POSIX shell? I don't think it is.
Me either. FreeRADIUS runs on Linux, *BSD, Solaris, and (at one time) AIX and HPUX. Portability is good.
This bombs out if you give a non-numeric value, but then that's your fault for passing bad data. A more backwards-compatible approach is simply:
if [ "$6" != "" -a "$6" != "0" ]
That should work, I think.
Fine with me, I'm not wedded to any particular solution as long as it works. Although shouldn't the comparison to zero be performed with the integer operator -ne? In any event use whatever solution suits you. -- John Dennis <jdennis@redhat.com> Looking to carve out IT costs? www.redhat.com/carveoutcosts/
On Thu, Sep 27, 2012 at 08:57:38AM -0400, John Dennis wrote:
shouldn't the comparison to zero be performed with the integer operator -ne?
I don't think so, because it bombs if given a non-numeric value. $ [ "Y" -ne "0" ] -bash: [: Y: integer expression expected This would break anyone who is currently passing an arbitrary non-blank string as the ppphint argument. Of course, the documentation should probably be made consistent: .IP ppphint If you put an integer > 0 here, radtest (or actually radclient) will add the attribute \fIFramed-Protocol = PPP\fP to the request packet. --> If you put a value other than empty string or "0" here ... Regards, Brian.
participants (3)
-
Alan DeKok -
Brian Candler -
John Dennis