]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod, depmod: Load modprobe.d, depmod.d from ${prefix}/lib.
authorMichal Suchanek <msuchanek@suse.de>
Tue, 18 Jul 2023 12:01:54 +0000 (14:01 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 17 Oct 2023 17:27:59 +0000 (12:27 -0500)
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>
Link: https://lore.kernel.org/r/a290343ce32e2a3c25b134e4f27c13b26e06c9e0.1689681454.git.msuchanek@suse.de
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Makefile.am
configure.ac
libkmod/libkmod.c
man/Makefile.am
man/depmod.d.xml
man/modprobe.d.xml
tools/depmod.c

index 5b7abfe6a20e41b61150af59f41355a64a02a75e..e6630a36e18c4b0a26f0f998db38c77d9b9909d9 100644 (file)
@@ -19,6 +19,7 @@ AM_CPPFLAGS = \
        -include $(top_builddir)/config.h \
        -I$(top_srcdir) \
        -DSYSCONFDIR=\""$(sysconfdir)"\" \
+       -DDISTCONFDIR=\""$(distconfdir)"\" \
        ${zlib_CFLAGS}
 
 AM_CFLAGS = $(OUR_CFLAGS)
index e5bceeaa1722d6c42c008a2cef67d0eaa8e48530..fd88d1fbdbf7f8b42c9fdc862a5955e65556bee6 100644 (file)
@@ -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}
index 1b8773cdf4527c2baa1ab4290a25a1fffb25609b..57fac1cb9f7bfbe68f3c3d6532e54d9ed358e927 100644 (file)
@@ -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
 };
@@ -272,9 +273,9 @@ static enum kmod_file_compression_type get_kernel_compression(struct kmod_ctx *c
  *                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.
index 11514d52a1904a13303b299c1a8b5b64c1f05388..2fea8e46bf2facc664e935c97cb5360a5f186bb1 100644 (file)
@@ -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 -
index 8d3d821cddc857500a06f82599bd81a8c03084fe..f282a39cc840451fa56cf58537bccc855a548f4c 100644 (file)
@@ -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>
index 0ab3e9110a7e718ec1f75fb9e07b784bb960724f..2bf6537f07e66d9ff5a4d1817b25e54d7f402613 100644 (file)
@@ -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>
index 1d1d41db860ffa699264042eef194bbee735345a..630fef9c8fb0fa1a03d80e9122f33b80a9c0ea3c 100644 (file)
@@ -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
 };