All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Suchanek <msuchanek@suse.de>
To: linux-modules@vger.kernel.org
Cc: "Michal Suchanek" <msuchanek@suse.de>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Lucas De Marchi" <lucas.de.marchi@gmail.com>,
	"Michal Koutný" <mkoutny@suse.com>,
	"Jiri Slaby" <jslaby@suse.com>,
	"Jan Engelhardt" <jengelh@inai.de>,
	"Masahiro Yamada" <masahiroy@kernel.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	"Nicolas Schier" <nicolas@fjasle.eu>,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH kmod v5 3/5] libkmod, depmod: Load modprobe.d, depmod.d from ${prefix}/lib.
Date: Tue, 18 Jul 2023 14:01:54 +0200	[thread overview]
Message-ID: <a290343ce32e2a3c25b134e4f27c13b26e06c9e0.1689681454.git.msuchanek@suse.de> (raw)
In-Reply-To: <cover.1689681454.git.msuchanek@suse.de>

There is an ongoing effort to limit use of files outside of /usr (or
${prefix} on general). Currently all modprobe.d paths are hardcoded to
outside of $prefix. Teach kmod to load modprobe.d from ${prefix}/lib.

On some distributions /usr/lib and /lib are the same directory because
of a compatibility symlink, and it is possible to craft configuration
files with sideeffects that would behave differently when loaded twice.
However, the override semantic ensures that one 'overrides' the other,
and only one configuration file of the same name is loaded from any of
the search directories.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
v2: Fix commit message typo
v3: Fix modprobe.d path list in code comment
v5: Add distconfdir
---
 Makefile.am        | 1 +
 configure.ac       | 5 +++++
 libkmod/libkmod.c  | 7 ++++---
 man/Makefile.am    | 9 +++++++--
 man/depmod.d.xml   | 1 +
 man/modprobe.d.xml | 1 +
 tools/depmod.c     | 1 +
 7 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 8ba85c91a0f3..14eb07e63cea 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,6 +19,7 @@ AM_CPPFLAGS = \
 	-include $(top_builddir)/config.h \
 	-I$(top_srcdir) \
 	-DSYSCONFDIR=\""$(sysconfdir)"\" \
+	-DDISTCONFDIR=\""$(distconfdir)"\" \
 	${zlib_CFLAGS}
 
 AM_CFLAGS = $(OUR_CFLAGS)
diff --git a/configure.ac b/configure.ac
index 331cc8a1ffd5..728f88a56704 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,6 +79,10 @@ AC_COMPILE_IFELSE(
 # --with-
 #####################################################################
 
+AC_ARG_WITH([distconfdir], AS_HELP_STRING([--with-distconfdir=DIR], [directory to search for distribution configuration files]),
+        [], [with_distconfdir='${prefix}/lib'])
+AC_SUBST([distconfdir], [$with_distconfdir])
+
 AC_ARG_WITH([rootlibdir],
         AS_HELP_STRING([--with-rootlibdir=DIR], [rootfs directory to install shared libraries]),
         [], [with_rootlibdir=$libdir])
@@ -313,6 +317,7 @@ AC_MSG_RESULT([
 
 	prefix:			${prefix}
 	sysconfdir:		${sysconfdir}
+	distconfdir:		${distconfdir}
 	libdir:			${libdir}
 	rootlibdir:		${rootlibdir}
 	includedir:		${includedir}
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 2670f9a4611a..09e6041461b0 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -65,6 +65,7 @@ static const char *const default_config_paths[] = {
 	SYSCONFDIR "/modprobe.d",
 	"/run/modprobe.d",
 	"/usr/local/lib/modprobe.d",
+	DISTCONFDIR "/modprobe.d",
 	"/lib/modprobe.d",
 	NULL
 };
@@ -237,9 +238,9 @@ static char *get_kernel_release(const char *dirname)
  *                to load from user-defined configuration parameters such as
  *                alias, blacklists, commands (install, remove). If NULL
  *                defaults to /etc/modprobe.d, /run/modprobe.d,
- *                /usr/local/lib/modprobe.d and /lib/modprobe.d. Give an empty
- *                vector if configuration should not be read. This array must
- *                be null terminated.
+ *                /usr/local/lib/modprobe.d, DISTCONFDIR/modprobe.d, and
+ *                /lib/modprobe.d. Give an empty vector if configuration should
+ *                not be read. This array must be null terminated.
  *
  * Create kmod library context. This reads the kmod configuration
  * and fills in the default values.
diff --git a/man/Makefile.am b/man/Makefile.am
index 11514d52a190..2fea8e46bf2f 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -17,9 +17,14 @@ EXTRA_DIST = $(MAN5:%.5=%.xml) $(MAN8:%.8=%.xml)
 CLEANFILES = $(dist_man_MANS)
 
 %.5 %.8: %.xml
-	$(AM_V_XSLT)$(XSLT) \
+	$(AM_V_XSLT)if [ '$(distconfdir)' != '/lib' ] ; then \
+		sed -e 's|@DISTCONFDIR@|$(distconfdir)|g' $< ; \
+	else \
+		sed -e '/@DISTCONFDIR@/d' $< ; \
+	fi | \
+	$(XSLT) \
 		-o $@ \
 		--nonet \
 		--stringparam man.output.quietly 1 \
 		--param funcsynopsis.style "'ansi'" \
-		http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
+		http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl -
diff --git a/man/depmod.d.xml b/man/depmod.d.xml
index 8d3d821cddc8..f282a39cc840 100644
--- a/man/depmod.d.xml
+++ b/man/depmod.d.xml
@@ -40,6 +40,7 @@
 
   <refsynopsisdiv>
     <para><filename>/lib/depmod.d/*.conf</filename></para>
+    <para><filename>@DISTCONFDIR@/depmod.d/*.conf</filename></para>
     <para><filename>/usr/local/lib/depmod.d/*.conf</filename></para>
     <para><filename>/run/depmod.d/*.conf</filename></para>
     <para><filename>/etc/depmod.d/*.conf</filename></para>
diff --git a/man/modprobe.d.xml b/man/modprobe.d.xml
index 0ab3e9110a7e..2bf6537f07e6 100644
--- a/man/modprobe.d.xml
+++ b/man/modprobe.d.xml
@@ -41,6 +41,7 @@
 
   <refsynopsisdiv>
     <para><filename>/lib/modprobe.d/*.conf</filename></para>
+    <para><filename>@DISTCONFDIR@/modprobe.d/*.conf</filename></para>
     <para><filename>/usr/local/lib/modprobe.d/*.conf</filename></para>
     <para><filename>/run/modprobe.d/*.conf</filename></para>
     <para><filename>/etc/modprobe.d/*.conf</filename></para>
diff --git a/tools/depmod.c b/tools/depmod.c
index 1d1d41db860f..630fef9c8fb0 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -54,6 +54,7 @@ static const char *const default_cfg_paths[] = {
 	SYSCONFDIR "/depmod.d",
 	"/run/depmod.d",
 	"/usr/local/lib/depmod.d",
+	DISTCONFDIR "/depmod.d",
 	"/lib/depmod.d",
 	NULL
 };
-- 
2.41.0


  parent reply	other threads:[~2023-07-18 12:03 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-11 15:31 [PATCH 0/4] kmod /usr support Michal Suchanek
2023-07-11 15:31 ` [PATCH 1/4] man/depmod.d: Fix incorrect /usr/lib search path Michal Suchanek
2023-07-11 15:31 ` [PATCH 2/4] libkmod, depmod: Load modprobe.d, depmod.d from $prefix/lib Michal Suchanek
2023-07-12  6:47   ` Jiri Slaby
2023-07-12  7:35     ` Michal Suchánek
2023-07-11 15:31 ` [PATCH 3/4] kmod: Add config command to show compile time configuration as JSON Michal Suchanek
2023-07-11 15:31 ` [PATCH 4/4] libkmod, depmod, modprobe: Search for kernel modules under ${module_prefix} Michal Suchanek
2023-07-11 15:34 ` [PATCH] depmod: Handle installing modules under a prefix Michal Suchanek
2023-07-12  5:47   ` Jiri Slaby
2023-07-12  7:38     ` Michal Suchánek
2023-07-12 13:45     ` [PATCH v2--to=linux-modules@vger.kernel.org] " Michal Suchanek
2023-07-12 14:14       ` Masahiro Yamada
2023-07-12 16:15         ` Michal Suchánek
2023-07-14  6:25       ` [PATCH v2] " Jiri Slaby
2023-07-14 12:21         ` [PATCH v3] " Michal Suchanek
2023-07-14 13:38           ` Jan Engelhardt
2023-07-14 13:57             ` Michal Suchánek
2023-07-14 13:59             ` Michal Koutný
2023-07-14 14:05               ` Michal Suchánek
2023-07-14 14:05           ` Nicolas Schier
2023-07-14 14:30             ` Michal Suchánek
2023-07-14 14:42               ` Jan Engelhardt
2023-07-14 14:54               ` Nicolas Schier
2023-07-14 15:10                 ` Michal Suchánek
2023-07-14 19:37                   ` Nicolas Schier
2023-07-17  9:55                     ` Michal Suchánek
2023-07-17 19:14                   ` Masahiro Yamada
2023-07-18  8:52                     ` Michal Suchánek
2023-09-11 19:56                     ` [PATCH] kbuild: rpm-pkg: Fix build with non-default MODLIB Michal Suchanek
2023-07-17 19:13                 ` [PATCH v3] depmod: Handle installing modules under a prefix Masahiro Yamada
2023-07-12 14:00 ` [PATCH kmod v2 1/4] man/depmod.d: Fix incorrect /usr/lib search path Michal Suchanek
2023-07-12 14:00 ` [PATCH kmod v2 2/4] libkmod, depmod: Load modprobe.d, depmod.d from $prefix/lib Michal Suchanek
2023-07-14 14:16   ` Nicolas Schier
2023-07-14 14:34     ` Michal Suchánek
2023-07-12 14:00 ` [PATCH kmod v2 3/4] kmod: Add config command to show compile time configuration as JSON Michal Suchanek
2023-07-14 13:52   ` Jan Engelhardt
2023-07-14 14:02     ` Michal Suchánek
2023-07-14 14:12       ` Jan Engelhardt
2023-07-14 15:26   ` Nicolas Schier
2023-07-14 16:58     ` Michal Suchánek
2023-07-12 14:00 ` [PATCH kmod v2 4/4] libkmod, depmod, modprobe: Search for kernel modules under ${module_prefix} Michal Suchanek
2023-07-14 13:54   ` Jan Engelhardt
2023-07-17 10:39 ` [PATCH kmod v4 0/4] kmod /usr support Michal Suchanek
2023-07-17 10:39   ` [PATCH kmod v4 1/4] man/depmod.d: Fix incorrect /usr/lib search path Michal Suchanek
2023-07-17 10:39   ` [PATCH kmod v4 2/4] libkmod, depmod: Load modprobe.d, depmod.d from $prefix/lib Michal Suchanek
2023-07-17 10:39   ` [PATCH kmod v4 3/4] kmod: Add config command to show compile time configuration as JSON Michal Suchanek
2023-07-17 10:39   ` [PATCH kmod v4 4/4] libkmod, depmod, modprobe: Make directory for kernel modules configurable Michal Suchanek
2023-07-17 19:28     ` Jan Engelhardt
2023-07-18  8:43       ` Michal Suchánek
2023-07-18  9:41         ` Jan Engelhardt
2023-07-18 10:29           ` Michal Suchánek
2023-07-18 12:17             ` Jan Engelhardt
2023-07-18 12:27               ` Michal Suchánek
2023-07-18 12:42                 ` Jan Engelhardt
2023-07-18 13:45                   ` Michal Suchánek
2023-07-17 20:12     ` Lucas De Marchi
2023-07-18  8:32       ` Michal Suchánek
2023-07-17 10:40   ` [PATCH v4] depmod: Handle installing modules under a prefix Michal Suchanek
2023-07-18 12:01   ` [PATCH kmod v5 0/5] kmod /usr support Michal Suchanek
2023-07-18 12:01     ` [PATCH kmod v5 1/5] configure: Detect openssl sm3 support Michal Suchanek
2023-07-18 12:01     ` [PATCH kmod v5 2/5] man/depmod.d: Fix incorrect /usr/lib search path Michal Suchanek
2023-07-18 12:01     ` Michal Suchanek [this message]
2023-07-18 12:01     ` [PATCH kmod v5 4/5] kmod: Add pkgconfig file with kmod compile time configuration Michal Suchanek
2023-07-18 12:01     ` [PATCH kmod v5 5/5] libkmod, depmod, modprobe: Make directory for kernel modules configurable Michal Suchanek
2023-10-17 17:50       ` Lucas De Marchi
2023-10-18  1:25         ` Jan Engelhardt
2023-11-09 17:40           ` Michal Suchánek
2023-11-09 17:44         ` Michal Suchánek
2023-11-10 12:13         ` [PATCH 0/2] kmod /usr support Michal Suchanek
2023-11-10 12:13           ` [PATCH 1/2] libkmod, depmod, modprobe: Make directory for kernel modules configurable Michal Suchanek
2023-11-10 12:13           ` [PATCH 2/2] configure: Check that provided paths are absolute Michal Suchanek
2023-12-06 18:36           ` [PATCH 0/2] kmod /usr support Lucas De Marchi
2023-12-19  8:37             ` Masahiro Yamada
2023-11-13  9:27         ` [PATCH kmod v5 5/5] libkmod, depmod, modprobe: Make directory for kernel modules configurable Michal Suchánek
2023-07-18 12:03     ` [PATCH v5] depmod: Handle installing modules under a prefix Michal Suchanek
2023-07-18 12:14       ` Masahiro Yamada
2023-08-17 16:37     ` [PATCH kmod v5 0/5] kmod /usr support Michal Suchánek
2023-08-19 11:25       ` Masahiro Yamada
2023-08-21  6:22         ` Michal Suchánek
2023-09-11 19:50         ` Michal Suchánek
2023-10-17 15:45     ` Michal Suchánek
2023-10-17 16:18       ` Lucas De Marchi
2023-10-17 16:40         ` Michal Suchánek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a290343ce32e2a3c25b134e4f27c13b26e06c9e0.1689681454.git.msuchanek@suse.de \
    --to=msuchanek@suse.de \
    --cc=jengelh@inai.de \
    --cc=jslaby@suse.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=lucas.de.marchi@gmail.com \
    --cc=masahiroy@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.