[Openvpn-devel] Fix error message when using RHEL init script

Message ID c042fd01f62d707477c37e0298e303f1@vdberg.org
State Accepted
Headers show
Series
  • [Openvpn-devel] Fix error message when using RHEL init script
Related show

Commit Message

Rolf Fokkens via Openvpn-devel Dec. 21, 2018, 6:43 a.m.
In RHEL 7 /etc/sysconfig/network is no longer used (still there but 
empty). This results in the following error when openvpn starts:

Dec 20 09:01:25 localhost openvpn: /etc/rc.d/init.d/openvpn: line 94: [: 
=: unary operator expected

---
  distro/rpm/openvpn.init.d.rhel | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Gert Doering Dec. 21, 2018, 10:06 a.m. | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

Whatever the future might bring for this script (like "going away in 
favour of systemd units"), this is a reasonable fix for now - never 
rely on shell variables to be non-empty in script comparisons.

Your patch has been applied to the master and release/2.4 branch.

As a side note: please use "git send-email" to avoid your patch getting
broken by your mail client (it was whitespace-massacred so needed manual
adjustment) and use "git commit -s" so we have a proper signed-off-by:
line.  No hard requirements for a mini-fix, but for the next and bigger
one you'll hopefully send one day :-)


commit 7e711035f12a25199c3a04193ee4e22e43930f6a (master)
commit d18fa4aab1b73074d71a4d8cbf894c73c689d2ec (release/2.4)
Author: Richard van den Berg via Openvpn-devel
Date:   Fri Dec 21 07:43:28 2018 +0100

     Fix error message when using RHEL init script

     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <c042fd01f62d707477c37e0298e303f1@vdberg.org>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18057.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering
David Sommerseth Dec. 24, 2018, 11:59 p.m. | #2
On 21/12/2018 07:43, Richard van den Berg via Openvpn-devel wrote:
> In RHEL 7 /etc/sysconfig/network is no longer used (still there but empty).
> This results in the following error when openvpn starts:
> 
> Dec 20 09:01:25 localhost openvpn: /etc/rc.d/init.d/openvpn: line 94: [: =:
> unary operator expected

Not related to this fix, but we really need to get rid of the distro/rpm
folder.  These init script should NOT be used on any systemd based systems at all.

The complete distro/rpm folder is essentially unmaintained, as the .spec file
here most likely breaks any modern packaging guidelines.  If you want the
proper maintained .spec file, look at the ones in the Fedora EPEL repository [0].

As we don't here much from the upstream SUSE package maintainers, I don't have
a good pointer for that RPM flavour.  But I presume their spec file is also
far better maintained than the one we ship here.


[0] <https://src.fedoraproject.org/rpms/openvpn/tree/epel7>
Gert Doering Dec. 25, 2018, 8:03 a.m. | #3
Hi,

On Tue, Dec 25, 2018 at 12:59:34AM +0100, David Sommerseth wrote:
> On 21/12/2018 07:43, Richard van den Berg via Openvpn-devel wrote:
> > In RHEL 7 /etc/sysconfig/network is no longer used (still there but empty).
> > This results in the following error when openvpn starts:
> > 
> > Dec 20 09:01:25 localhost openvpn: /etc/rc.d/init.d/openvpn: line 94: [: =:
> > unary operator expected
> 
> Not related to this fix, but we really need to get rid of the distro/rpm
> folder.  These init script should NOT be used on any systemd based systems at all.

I've expected a comment along that lines :-)  - and I'm not objecting
to a massive cleanup here.  

But as long as we keep the script, it should better be well-behaved,
thus, my ACK :-)

gert

Patch

diff --git a/distro/rpm/openvpn.init.d.rhel 
b/distro/rpm/openvpn.init.d.rhel
index cdf3e9de..bfde2216 100755
--- a/distro/rpm/openvpn.init.d.rhel
+++ b/distro/rpm/openvpn.init.d.rhel
@@ -91,7 +91,7 @@  work=/etc/openvpn
  . /etc/sysconfig/network

  # Check that networking is up.
-if [ ${NETWORKING} = "no" ]
+if [ "${NETWORKING}" = "no" ]
  then
    echo "Networking is down"
    exit 0