[Openvpn-devel] Fix TUNSETGROUP compatibility with very old Linux systems.

Message ID 20200909153725.1158-1-gert@greenie.muc.de
State Accepted
Headers show
Series
  • [Openvpn-devel] Fix TUNSETGROUP compatibility with very old Linux systems.
Related show

Commit Message

Gert Doering Sept. 9, 2020, 3:37 p.m.
Our code works on "very old Linux" (Fedora-1), but needs a #define
for TUNSETGROUP to compile.  Everything else is there.

While at it, fix TUNSETGROUP error message.

Reported-By: noloader on Trac
Trac: #1152

Signed-off-by: Gert Doering <gert@greenie.muc.de>
---
 src/openvpn/tun.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Arne Schwabe Sept. 10, 2020, 8:19 a.m. | #1
Am 09.09.20 um 17:37 schrieb Gert Doering:
> Our code works on "very old Linux" (Fedora-1), but needs a #define
> for TUNSETGROUP to compile.  Everything else is there.
> 
> While at it, fix TUNSETGROUP error message.
> 
> Reported-By: noloader on Trac
> Trac: #1152
> 
> Signed-off-by: Gert Doering <gert@greenie.muc.de>
> ---
>  src/openvpn/tun.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
> index 923131ad..651cb871 100644
> --- a/src/openvpn/tun.c
> +++ b/src/openvpn/tun.c
> @@ -1993,6 +1993,11 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
>  
>  #ifdef ENABLE_FEATURE_TUN_PERSIST
>  
> +/* TUNSETGROUP appeared in 2.6.23 */
> +#ifndef TUNSETGROUP
> +# define TUNSETGROUP   _IOW('T', 206, int)
> +#endif
> +
>  void
>  tuncfg(const char *dev, const char *dev_type, const char *dev_node,
>         int persist_mode, const char *username, const char *groupname,
> @@ -2032,7 +2037,7 @@ tuncfg(const char *dev, const char *dev_type, const char *dev_node,
>          }
>          else if (ioctl(tt->fd, TUNSETGROUP, platform_state_group.gr->gr_gid) < 0)
>          {
> -            msg(M_ERR, "Cannot ioctl TUNSETOWNER(%s) %s", groupname, dev);
> +            msg(M_ERR, "Cannot ioctl TUNSETGROUP(%s) %s", groupname, dev);
>          }
>      }
>      close_tun(tt, ctx);
> 

Hm, it does not hurt, so...

Acked-By: Arne Schwabe <arne@rfc2549.org>
Gert Doering Sept. 10, 2020, 9:10 a.m. | #2
Patch has been applied to the master, release/2.5 and release/2.4 branch.

commit a4e0ac0604460ea2431acb7481d6ffb7a3fc6298 (master)
commit 43e70c78c34b90b15b6bfdac9c1911853defca10 (release/2.5)
commit a1dc800348937d6993f5008140081f66a695026a (release/2.4)
Author: Gert Doering
Date:   Wed Sep 9 17:37:25 2020 +0200

     Fix TUNSETGROUP compatibility with very old Linux systems.

     Signed-off-by: Gert Doering <gert@greenie.muc.de>
     Acked-by: Arne Schwabe <arne@rfc2549.org>
     Message-Id: <20200909153725.1158-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20932.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index 923131ad..651cb871 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -1993,6 +1993,11 @@  open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
 
 #ifdef ENABLE_FEATURE_TUN_PERSIST
 
+/* TUNSETGROUP appeared in 2.6.23 */
+#ifndef TUNSETGROUP
+# define TUNSETGROUP   _IOW('T', 206, int)
+#endif
+
 void
 tuncfg(const char *dev, const char *dev_type, const char *dev_node,
        int persist_mode, const char *username, const char *groupname,
@@ -2032,7 +2037,7 @@  tuncfg(const char *dev, const char *dev_type, const char *dev_node,
         }
         else if (ioctl(tt->fd, TUNSETGROUP, platform_state_group.gr->gr_gid) < 0)
         {
-            msg(M_ERR, "Cannot ioctl TUNSETOWNER(%s) %s", groupname, dev);
+            msg(M_ERR, "Cannot ioctl TUNSETGROUP(%s) %s", groupname, dev);
         }
     }
     close_tun(tt, ctx);