Skip to contentSkip to conversation

Replace hardcoded paths with configurable runstatedir

PATCH Applied Daniel Linjama 2 participants 5 messages Apr 6, 2022 – Apr 8, 2022 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Replace hardcoded paths with configurable runstatedir

Add support for configurable $(runstatedir) with RUNSTATEDIR and replace hardcoded /var/run paths

Daniel Linjama (2):
build: Support configurable run dir with RUNSTATEDIR
vpn: Replace hardcoded paths with RUNSTATEDIR

 Makefile.am        | 2 ++
 Makefile.plugins   | 1 +
 vpn/plugins/vpnc.c | 2 +-
 vpn/vpn-util.c     | 4 ++--
 4 files changed, 6 insertions(+), 3 deletions(-)
Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/2 build: Support configurable run dir with RUNSTATEDIR

Add configurable $(runstatedir) to CFLAGS as RUNSTATEDIR

---
 Makefile.am      | 2 ++
 Makefile.plugins | 1 +
 2 files changed, 3 insertions(+)
Makefile.am +2 -0
index 15178eca..3779eab9 100644
@@ -243,6 +243,7 @@ AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ \
 				-DSCRIPTDIR=\""$(build_scriptdir)"\" \
 				-DSTORAGEDIR=\""$(storagedir)\"" \
 				-DVPN_STORAGEDIR=\""$(vpn_storagedir)\"" \
+				-DRUNSTATEDIR=\""$(runstatedir)\"" \
 				-DCONFIGDIR=\""$(configdir)\""
 
 if VPN
@@ -275,6 +276,7 @@ vpn_connman_vpnd_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ \
 				-DSCRIPTDIR=\""$(build_scriptdir)"\" \
 				-DSTORAGEDIR=\""$(storagedir)\"" \
 				-DVPN_STORAGEDIR=\""$(vpn_storagedir)\"" \
+				-DRUNSTATEDIR=\""$(runstatedir)\"" \
 				-DCONFIGDIR=\""$(configdir)\"" \
 				-I$(builddir)/vpn
 
Makefile.plugins +1 -0
index 8e323617..bd5049ec 100644
@@ -138,6 +138,7 @@ vpn_plugin_objects += $(plugins_vpnc_la_OBJECTS)
 vpn_plugins_vpnc_la_SOURCES = vpn/plugins/vpnc.c
 vpn_plugins_vpnc_la_CFLAGS = $(plugin_cflags) -DVPNC=\"@VPNC@\" \
 					-DVPN_STATEDIR=\""$(vpn_statedir)"\" \
+					-DRUNSTATEDIR=\""$(runstatedir)"\" \
 					-DSCRIPTDIR=\""$(build_scriptdir)"\"
 vpn_plugins_vpnc_la_LDFLAGS = $(plugin_ldflags)
 endif
Signature · 1 line
2.35.1
#3 lore raw

PATCH 2/2 vpn: Replace hardcoded paths with RUNSTATEDIR

In reply to Daniel Linjama

Replace hardcoded /var/run paths with configurable RUNSTATEDIR

---
 vpn/plugins/vpnc.c | 2 +-
 vpn/vpn-util.c     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
vpn/plugins/vpnc.c +1 -1
index d11b9111..73012c5b 100644
@@ -54,7 +54,7 @@
 #include "../vpn.h"
 
 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
-#define PID_PATH_ROOT "/var/run/user"
+#define PID_PATH_ROOT RUNSTATEDIR "/user"
 
 enum {
 	OPT_STRING = 1,
vpn/vpn-util.c +2 -2
index 9ef14d38..bc3b01dd 100644
@@ -102,8 +102,8 @@ struct group *vpn_util_get_group(const char *groupname)
  * running a VPN plugin as a different user and thus, user specific run dir is
  * allowed and limitation to access any other system dir is restricted.
  */
-static const char *allowed_prefixes[] = { "/var/run/connman-vpn/",
-					"/var/run/user/", "/tmp/", NULL };
+static const char *allowed_prefixes[] = { RUNSTATEDIR "/connman-vpn/",
+					RUNSTATEDIR "/user/", "/tmp/", NULL };
 
 static int is_path_allowed(const char *path)
 {
Signature · 1 line
2.35.1
#2 lore raw

PATCH v2 1/2 build: Support configurable run dir with RUNSTATEDIR

In reply to Daniel Linjama

Add configurable $(runstatedir) to CFLAGS as RUNSTATEDIR
---
v1 -> v2:
- Changed quotes escaping from \""$(runstatedir)\"" -> \""$(runstatedir)"\"

 Makefile.am      | 2 ++
 Makefile.plugins | 1 +
 2 files changed, 3 insertions(+)
Makefile.am +2 -0
index 15178eca..c108b8f3 100644
@@ -243,6 +243,7 @@ AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ \
 				-DSCRIPTDIR=\""$(build_scriptdir)"\" \
 				-DSTORAGEDIR=\""$(storagedir)\"" \
 				-DVPN_STORAGEDIR=\""$(vpn_storagedir)\"" \
+				-DRUNSTATEDIR=\""$(runstatedir)"\" \
 				-DCONFIGDIR=\""$(configdir)\""
 
 if VPN
@@ -275,6 +276,7 @@ vpn_connman_vpnd_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ \
 				-DSCRIPTDIR=\""$(build_scriptdir)"\" \
 				-DSTORAGEDIR=\""$(storagedir)\"" \
 				-DVPN_STORAGEDIR=\""$(vpn_storagedir)\"" \
+				-DRUNSTATEDIR=\""$(runstatedir)"\" \
 				-DCONFIGDIR=\""$(configdir)\"" \
 				-I$(builddir)/vpn
 
Makefile.plugins +1 -0
index 8e323617..bd5049ec 100644
@@ -138,6 +138,7 @@ vpn_plugin_objects += $(plugins_vpnc_la_OBJECTS)
 vpn_plugins_vpnc_la_SOURCES = vpn/plugins/vpnc.c
 vpn_plugins_vpnc_la_CFLAGS = $(plugin_cflags) -DVPNC=\"@VPNC@\" \
 					-DVPN_STATEDIR=\""$(vpn_statedir)"\" \
+					-DRUNSTATEDIR=\""$(runstatedir)"\" \
 					-DSCRIPTDIR=\""$(build_scriptdir)"\"
 vpn_plugins_vpnc_la_LDFLAGS = $(plugin_ldflags)
 endif
Signature · 1 line
2.35.1
#4 lore raw
In reply to Daniel Linjama
Quoted 6 lines · Daniel Linjama

Add support for configurable $(runstatedir) with RUNSTATEDIR and replace hardcoded /var/run paths

Daniel Linjama (2):
build: Support configurable run dir with RUNSTATEDIR
vpn: Replace hardcoded paths with RUNSTATEDIR

Quoted 7 lines

Makefile.am | 2 ++

 Makefile.plugins   | 1 +
 vpn/plugins/vpnc.c | 2 +-
 vpn/vpn-util.c     | 4 ++--
 4 files changed, 6 insertions(+), 3 deletions(-)

[...]

Applied, thanks!

[1/2] build: Support configurable run dir with RUNSTATEDIR

      commit: a18acc883b7312d425eb0565e5f2c4d5235f2182
[2/2] vpn: Replace hardcoded paths with RUNSTATEDIR
      commit: 7c341aef347eb2a399a2717aa79ac6043f503430

Best regards,

Signature · 1 line
Daniel Wagner <[email protected]>