Skip to contentSkip to conversation

Fix TUNSETGROUP compatibility with very old Linux systems.

PATCH In review Gert Doering 2 participants 3 messages Sep 9, 2020 – Sep 10, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix TUNSETGROUP compatibility with very old Linux systems.

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

---
 src/openvpn/tun.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
src/openvpn/tun.c +6 -1
index 923131ad..651cb871 100644
@@ -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);
Signature · 1 line
2.26.2
Acked-by on v1 1/1
#1 lore raw

Am 09.09.20 um 17:37 schrieb Gert Doering:

Quoted 31 lines

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

---
 src/openvpn/tun.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
src/openvpn/tun.c +5 -0
index 923131ad..651cb871 100644
@@ -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,

src/openvpn/tun.c tuncfg(const char *dev, const char *dev_type, const char *dev_node, · line 2043

Quoted 8 lines
src/openvpn/tun.c +1 -1
@@ -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...

#2 lore raw
In reply to Gert Doering

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 <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg20932.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering