Skip to contentSkip to conversation

modprobe.d: load from /usr/lib.

PATCH In review Michal Suchanek 3 participants 6 messages Jan 12, 2021 – May 30, 2021 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 modprobe.d: load from /usr/lib.

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.

Cc Marcus Rückert <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Dominique Leuenberger <[email protected]>
---
 Makefile.am        | 1 +
 libkmod/libkmod.c  | 1 +
 man/modprobe.d.xml | 1 +
 3 files changed, 3 insertions(+)
Makefile.am +1 -0
index b29e943a4d29..702a665f0334 100644
@@ -19,6 +19,7 @@ AM_CPPFLAGS = \
 	-include $(top_builddir)/config.h \
 	-I$(top_srcdir) \
 	-DSYSCONFDIR=\""$(sysconfdir)"\" \
+	-DPREFIX=\""$(prefix)"\" \
 	${zlib_CFLAGS}
 
 AM_CFLAGS = $(OUR_CFLAGS)
libkmod/libkmod.c +1 -0
index 43423d63a889..9399c6c902f8 100644
@@ -65,6 +65,7 @@ static const char *default_config_paths[] = {
 	SYSCONFDIR "/modprobe.d",
 	"/run/modprobe.d",
 	"/lib/modprobe.d",
+	PREFIX "/lib/modprobe.d",
 	NULL
 };
 
man/modprobe.d.xml +1 -0
index 211af8488abb..ae5a83986a52 100644
@@ -40,6 +40,7 @@
   </refnamediv>
 
   <refsynopsisdiv>
+    <para><filename>/usr/lib/modprobe.d/*.conf</filename></para>
     <para><filename>/lib/modprobe.d/*.conf</filename></para>
     <para><filename>/etc/modprobe.d/*.conf</filename></para>
     <para><filename>/run/modprobe.d/*.conf</filename></para>
Signature · 1 line
2.26.2
#1 lore raw
Quoted 4 lines · Michal Suchanek

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.

/lib came from module-init-tools and we kept it for compatibility. It became a non-issue when distros
decided to just merge them and do a symlink /lib -> /usr/lib following
https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/

what distros didn't do that?

I also fear the solution you want here is not so simple since now the configs will be added twice
if there is the symlink. And if we just drop /lib and start using /usr/lib we break compatibility.

Lucas De Marchi

Quoted 50 lines
Cc Marcus Rückert <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Dominique Leuenberger <[email protected]>
---
 Makefile.am        | 1 +
 libkmod/libkmod.c  | 1 +
 man/modprobe.d.xml | 1 +
 3 files changed, 3 insertions(+)
Makefile.am +1 -0
index b29e943a4d29..702a665f0334 100644
@@ -19,6 +19,7 @@ AM_CPPFLAGS = \
        -include $(top_builddir)/config.h \
        -I$(top_srcdir) \
        -DSYSCONFDIR=\""$(sysconfdir)"\" \
+       -DPREFIX=\""$(prefix)"\" \
        ${zlib_CFLAGS}
 
 AM_CFLAGS = $(OUR_CFLAGS)
libkmod/libkmod.c +1 -0
index 43423d63a889..9399c6c902f8 100644
@@ -65,6 +65,7 @@ static const char *default_config_paths[] = {
        SYSCONFDIR "/modprobe.d",
        "/run/modprobe.d",
        "/lib/modprobe.d",
+       PREFIX "/lib/modprobe.d",
        NULL
 };
 
man/modprobe.d.xml +1 -1
index 211af8488abb..ae5a83986a52 100644
@@ -40,6 +40,7 @@
   </refnamediv>
 
   <refsynopsisdiv>
+    <para><filename>/usr/lib/modprobe.d/*.conf</filename></para>
     <para><filename>/lib/modprobe.d/*.conf</filename></para>
     <para><filename>/etc/modprobe.d/*.conf</filename></para>
     <para><filename>/run/modprobe.d/*.conf</filename></para>
--

2.26.2

#2 lore raw
Quoted 6 lines · Lucas De Marchi
Quoted 4 lines · Michal Suchanek

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.

Quoted 6 lines

/lib came from module-init-tools and we kept it for compatibility. It became a non-issue when distros
decided to just merge them and do a symlink /lib -> /usr/lib following
https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/

what distros didn't do that?

FWiW, we decided not to do TheUsrMerge at all.

Signature · 1 line
ldv
#3 lore raw
Quoted 8 lines · Dmitry V. Levin
Quoted 6 lines · Lucas De Marchi
Quoted 4 lines · Michal Suchanek

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.

Quoted 8 lines
Quoted 6 lines

/lib came from module-init-tools and we kept it for compatibility. It became a non-issue when distros
decided to just merge them and do a symlink /lib -> /usr/lib following
https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/

what distros didn't do that?

FWiW, we decided not to do TheUsrMerge at all.

It looks like we will need to put this behind a compilation option
then: --enable-split-usr.
Then we only add the additional dir if split-usr is being used.

If it's not used, we may actually change the path and corresponding docs to move it to /usr,
but that is another separate change.

thanks
Lucas De Marchi

Quoted 4 lines

--
ldv

#4 lore raw

Hello,

Quoted 14 lines · Lucas De Marchi
Quoted 13 lines · Dmitry V. Levin
Quoted 11 lines · Lucas De Marchi
Quoted 4 lines · Michal Suchanek

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.

/lib came from module-init-tools and we kept it for compatibility. It became a non-issue when distros
decided to just merge them and do a symlink /lib -> /usr/lib following
https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

what distros didn't do that?

FWiW, we decided not to do TheUsrMerge at all.

It looks like we will need to put this behind a compilation option
then: --enable-split-usr.
Then we only add the additional dir if split-usr is being used.

We could also stat the directories and skip the current one if it's the same as the last one.

Quoted 4 lines

If it's not used, we may actually change the path and corresponding docs to move it to /usr,
but that is another separate change.

Yes, the man page uses hardcoded paths rather than the actual paths. There is no support for expanding configure variables in it at the moment.

Thanks

Michal

#5 lore raw
In reply to Lucas De Marchi
Quoted 11 lines · Lucas De Marchi
Quoted 4 lines · Michal Suchanek

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.

/lib came from module-init-tools and we kept it for compatibility. It became a non-issue when distros
decided to just merge them and do a symlink /lib -> /usr/lib following
https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/

Quoted 6 lines

what distros didn't do that?

I also fear the solution you want here is not so simple since now the configs will be added twice
if there is the symlink. And if we just drop /lib and start using /usr/lib we break compatibility.

Ins't there already a mechanism in place that loads only one file with the same name (so that files in /etc can override files in /lib)?

Then even if the same directory is seached twice because of symlinks it has no effect, right?

Also there is depmod.d which is documented as /lib but is actually searched in /usr/lib.

Thanks

Michal

Quoted 53 lines

Lucas De Marchi

Quoted 50 lines
Cc Marcus Rückert <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Dominique Leuenberger <[email protected]>
---
 Makefile.am        | 1 +
 libkmod/libkmod.c  | 1 +
 man/modprobe.d.xml | 1 +
 3 files changed, 3 insertions(+)
Makefile.am +1 -0
index b29e943a4d29..702a665f0334 100644
@@ -19,6 +19,7 @@ AM_CPPFLAGS = \
        -include $(top_builddir)/config.h \
        -I$(top_srcdir) \
        -DSYSCONFDIR=\""$(sysconfdir)"\" \
+       -DPREFIX=\""$(prefix)"\" \
        ${zlib_CFLAGS}
 
 AM_CFLAGS = $(OUR_CFLAGS)
libkmod/libkmod.c +1 -0
index 43423d63a889..9399c6c902f8 100644
@@ -65,6 +65,7 @@ static const char *default_config_paths[] = {
        SYSCONFDIR "/modprobe.d",
        "/run/modprobe.d",
        "/lib/modprobe.d",
+       PREFIX "/lib/modprobe.d",
        NULL
 };
 
man/modprobe.d.xml +1 -1
index 211af8488abb..ae5a83986a52 100644
@@ -40,6 +40,7 @@
   </refnamediv>
 
   <refsynopsisdiv>
+    <para><filename>/usr/lib/modprobe.d/*.conf</filename></para>
     <para><filename>/lib/modprobe.d/*.conf</filename></para>
     <para><filename>/etc/modprobe.d/*.conf</filename></para>
     <para><filename>/run/modprobe.d/*.conf</filename></para>
--

2.26.2