diff mbox series

[v2,29/37] multipath-tools Makefile: sanitize paths for configuration files

Message ID 20230911163846.27197-30-mwilck@suse.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series multipath-tools: user-friendly names rework | expand

Commit Message

Martin Wilck Sept. 11, 2023, 4:38 p.m. UTC
From: Martin Wilck <mwilck@suse.com>

Make the path to multipath.conf configurable, and use the same prefix
by default for multipath.conf and multipath/conf.d. For "usr-merged"
distributions with immutable /usr, we'll want to have the configuration
under a different prefix. This can be achieved by using e.g.

    make prefix=/usr etc_prefix=""

Note that with prefix=/usr, before this patch the code would use
/usr/etc/multipath/conf.d, but /etc/multipath.conf. If this (rather
inconsistent) behavior is desired, use the following command line:

    make prefix=/usr configfile=/etc/multipath.conf
---
 Makefile.inc            | 9 ++++++---
 libmultipath/defaults.h | 1 -
 2 files changed, 6 insertions(+), 4 deletions(-)

Comments

Benjamin Marzinski Sept. 13, 2023, 10:30 p.m. UTC | #1
On Mon, Sep 11, 2023 at 06:38:38PM +0200, mwilck@suse.com wrote:
> From: Martin Wilck <mwilck@suse.com>
> 
> Make the path to multipath.conf configurable, and use the same prefix
> by default for multipath.conf and multipath/conf.d. For "usr-merged"
> distributions with immutable /usr, we'll want to have the configuration
> under a different prefix. This can be achieved by using e.g.
> 
>     make prefix=/usr etc_prefix=""
> 
> Note that with prefix=/usr, before this patch the code would use
> /usr/etc/multipath/conf.d, but /etc/multipath.conf. If this (rather
> inconsistent) behavior is desired, use the following command line:
> 
>     make prefix=/usr configfile=/etc/multipath.conf

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---
>  Makefile.inc            | 9 ++++++---
>  libmultipath/defaults.h | 1 -
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/Makefile.inc b/Makefile.inc
> index 502cd0f..39972d9 100644
> --- a/Makefile.inc
> +++ b/Makefile.inc
> @@ -37,6 +37,8 @@ prefix		:=
>  exec_prefix	:= $(prefix)
>  # Prefix for non-essential libraries (libdmmp)
>  usr_prefix	:= $(prefix)
> +# Prefix for configfuration files (multipath.conf)
> +etc_prefix	:= $(prefix)
>  # Where to install systemd-related files. systemd is usually installed under /usr
>  # Note: some systemd installations use separate "prefix" and "rootprefix".
>  # In this case, override only unitdir to use systemd's "rootprefix" instead of $(systemd_prefix)
> @@ -54,7 +56,8 @@ usrlibdir	:= $(usr_prefix)/$(LIB)
>  includedir	:= $(usr_prefix)/include
>  pkgconfdir	:= $(usrlibdir)/pkgconfig
>  plugindir       := $(prefix)/$(LIB)/multipath
> -configdir       := $(prefix)/etc/multipath/conf.d
> +configdir       := $(etc_prefix)/etc/multipath/conf.d
> +configfile      := $(etc_prefix)/etc/multipath.conf
>  runtimedir      := $(if $(shell test -L /var/run -o ! -d /var/run && echo 1),/run,/var/run)
>  devmapper_incdir := $(or $(shell $(PKG_CONFIG) --variable=includedir devmapper),/usr/include)
>  libudev_incdir	:= $(or $(shell $(PKG_CONFIG) --variable=includedir libudev),/usr/include)
> @@ -84,8 +87,8 @@ WARNFLAGS	:= -Werror -Wall -Wextra -Wformat=2 $(WFORMATOVERFLOW) -Werror=implici
>  		  $(WNOCLOBBERED) -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) $(W_URCU_TYPE_LIMITS)
>  CPPFLAGS	:= $(FORTIFY_OPT) $(CPPFLAGS) \
>  		   -DBIN_DIR=\"$(bindir)\" -DMULTIPATH_DIR=\"$(plugindir)\" \
> -		   -DRUNTIME_DIR=\"$(runtimedir)\" \
> -		   -DCONFIG_DIR=\"$(configdir)\" -DEXTRAVERSION=\"$(EXTRAVERSION)\" -MMD -MP
> +		   -DRUNTIME_DIR=\"$(runtimedir)\" -DCONFIG_DIR=\"$(configdir)\" \
> +		   -DDEFAULT_CONFIGFILE=\"$(configfile)\" -DEXTRAVERSION=\"$(EXTRAVERSION)\" -MMD -MP
>  CFLAGS		:= --std=gnu99 $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe
>  BIN_CFLAGS	:= -fPIE -DPIE
>  LIB_CFLAGS	:= -fPIC
> diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h
> index b3f11d4..bc2d638 100644
> --- a/libmultipath/defaults.h
> +++ b/libmultipath/defaults.h
> @@ -66,7 +66,6 @@
>  #define MAX_DEV_LOSS_TMO	UINT_MAX
>  #define DEFAULT_PIDFILE		RUNTIME_DIR "/multipathd.pid"
>  #define DEFAULT_SOCKET		"/org/kernel/linux/storage/multipathd"
> -#define DEFAULT_CONFIGFILE	"/etc/multipath.conf"
>  #define DEFAULT_BINDINGS_FILE	"/etc/multipath/bindings"
>  #define DEFAULT_WWIDS_FILE	"/etc/multipath/wwids"
>  #define DEFAULT_PRKEYS_FILE    "/etc/multipath/prkeys"
> -- 
> 2.42.0
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
diff mbox series

Patch

diff --git a/Makefile.inc b/Makefile.inc
index 502cd0f..39972d9 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -37,6 +37,8 @@  prefix		:=
 exec_prefix	:= $(prefix)
 # Prefix for non-essential libraries (libdmmp)
 usr_prefix	:= $(prefix)
+# Prefix for configfuration files (multipath.conf)
+etc_prefix	:= $(prefix)
 # Where to install systemd-related files. systemd is usually installed under /usr
 # Note: some systemd installations use separate "prefix" and "rootprefix".
 # In this case, override only unitdir to use systemd's "rootprefix" instead of $(systemd_prefix)
@@ -54,7 +56,8 @@  usrlibdir	:= $(usr_prefix)/$(LIB)
 includedir	:= $(usr_prefix)/include
 pkgconfdir	:= $(usrlibdir)/pkgconfig
 plugindir       := $(prefix)/$(LIB)/multipath
-configdir       := $(prefix)/etc/multipath/conf.d
+configdir       := $(etc_prefix)/etc/multipath/conf.d
+configfile      := $(etc_prefix)/etc/multipath.conf
 runtimedir      := $(if $(shell test -L /var/run -o ! -d /var/run && echo 1),/run,/var/run)
 devmapper_incdir := $(or $(shell $(PKG_CONFIG) --variable=includedir devmapper),/usr/include)
 libudev_incdir	:= $(or $(shell $(PKG_CONFIG) --variable=includedir libudev),/usr/include)
@@ -84,8 +87,8 @@  WARNFLAGS	:= -Werror -Wall -Wextra -Wformat=2 $(WFORMATOVERFLOW) -Werror=implici
 		  $(WNOCLOBBERED) -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) $(W_URCU_TYPE_LIMITS)
 CPPFLAGS	:= $(FORTIFY_OPT) $(CPPFLAGS) \
 		   -DBIN_DIR=\"$(bindir)\" -DMULTIPATH_DIR=\"$(plugindir)\" \
-		   -DRUNTIME_DIR=\"$(runtimedir)\" \
-		   -DCONFIG_DIR=\"$(configdir)\" -DEXTRAVERSION=\"$(EXTRAVERSION)\" -MMD -MP
+		   -DRUNTIME_DIR=\"$(runtimedir)\" -DCONFIG_DIR=\"$(configdir)\" \
+		   -DDEFAULT_CONFIGFILE=\"$(configfile)\" -DEXTRAVERSION=\"$(EXTRAVERSION)\" -MMD -MP
 CFLAGS		:= --std=gnu99 $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe
 BIN_CFLAGS	:= -fPIE -DPIE
 LIB_CFLAGS	:= -fPIC
diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h
index b3f11d4..bc2d638 100644
--- a/libmultipath/defaults.h
+++ b/libmultipath/defaults.h
@@ -66,7 +66,6 @@ 
 #define MAX_DEV_LOSS_TMO	UINT_MAX
 #define DEFAULT_PIDFILE		RUNTIME_DIR "/multipathd.pid"
 #define DEFAULT_SOCKET		"/org/kernel/linux/storage/multipathd"
-#define DEFAULT_CONFIGFILE	"/etc/multipath.conf"
 #define DEFAULT_BINDINGS_FILE	"/etc/multipath/bindings"
 #define DEFAULT_WWIDS_FILE	"/etc/multipath/wwids"
 #define DEFAULT_PRKEYS_FILE    "/etc/multipath/prkeys"