From patchwork Tue Jul 11 15:31:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Michal_Such=C3=A1nek?= X-Patchwork-Id: 118628 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp591111vqm; Tue, 11 Jul 2023 09:10:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlEEBFUKHQj4CHbIqAOCSVJCXGkYcetc/nip9ZSuwaaSsm3mKjocW2RXzbh2KOkWlBt7G/Fs X-Received: by 2002:a05:6a00:99f:b0:681:9004:3a20 with SMTP id u31-20020a056a00099f00b0068190043a20mr22038572pfg.7.1689091856653; Tue, 11 Jul 2023 09:10:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689091856; cv=none; d=google.com; s=arc-20160816; b=ZGkf2hYxPgLNVaULfBEm9wxV07aezYw3ucZqSjehCUwuezvzCv07S5bisiCUGXIMbn lvmC2z5yETOOwU8H3xRMuGF6EgsX0QK4ryvdJFA2LSK6j9tAx3JPcdq1ae0wJ2a2VNO+ zhUfEL6PON+SBeYAmj8+uk2v7L83V/9bcaTCqOocc3N4qxdLzIbw6t5eQFZwb9jR+CG+ Rr9xdKVnGT4f4P+byQ4vjCDD3tEFXnxmhWhFpHNwMXtA/xqENS/SuErWCtDLx6myCeke 4iJ79n/oALpvIRix9IQ28kZDTCUw8XshY0a57IfKkid7hjWmmjTXcox75gATVQvsHZBE Jgfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=Zi7pcLLSWwiwPJzQ1FjSFjmrtTNu/4ArWWuzhomcHJc=; fh=AVdnBkCzYGOB5oRrOKcaACuRLonL9A4Pn6PwCHl69B0=; b=YUzOGL/KKjlkVTPnv2s02u6ZP9gCwiiZZn/nqOhf1I0s4sUepmhnZMtLGgW0ARJA8v CHzgCMvPAA5Tmxko9himPOI0myNjR0gSZirQXqOCcE5YONzwYS208/c5ke4jmEK172g8 G7g/01QFnRs8OjaosUopEaOoqTgg0Y4KiqSXXbVnDa23tjKYYJm8Ur5ZmwZwVsa9ISUE JUN7IT0pSQR1IgVGQ9t3Ga0oeEgwTHN33cnXCeYAS62A+qc710JWQTcQKtLiJKtcE1PT m209mMkmzYq+kbw+DaB6wX/+hMHgBs0G1t9t5/+8jFjFaVpVYeisDmGwkP4a6adQnEf2 rBrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=11rlUDi0; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=lCK2GUpc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c18-20020a624e12000000b006785d3c33b6si1632107pfb.285.2023.07.11.09.10.43; Tue, 11 Jul 2023 09:10:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=11rlUDi0; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=lCK2GUpc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232587AbjGKPcb (ORCPT + 99 others); Tue, 11 Jul 2023 11:32:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232416AbjGKPcW (ORCPT ); Tue, 11 Jul 2023 11:32:22 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7178610DD; Tue, 11 Jul 2023 08:32:20 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id E8BBD1FE69; Tue, 11 Jul 2023 15:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689089538; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zi7pcLLSWwiwPJzQ1FjSFjmrtTNu/4ArWWuzhomcHJc=; b=11rlUDi0iRT+FZ1dJVq2XpnOoKesESjm/Sz/jXG81aNHOSVgoc00DdEHn8BE1KLgZ5/hZr XpIebYValJ/XH7l81ist0Q/klJr4RcXkldgdb+2Xqgp9C0hzsEBQpfPjO8Awf3lJQdgE4s wqZxUko6f9L6vVjQ9peIxhG9Sf2yrOE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689089538; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zi7pcLLSWwiwPJzQ1FjSFjmrtTNu/4ArWWuzhomcHJc=; b=lCK2GUpcORnC0BJBdv6ftKKI3DAAHHDyQyU8Yld7IgMcbXLUTODHNN5TclHAxNSXErasmH IIfVm2+DgnM2arBw== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id A49212C145; Tue, 11 Jul 2023 15:32:18 +0000 (UTC) From: Michal Suchanek To: linux-modules@vger.kernel.org Cc: Michal Suchanek , Takashi Iwai , Lucas De Marchi , =?utf-8?q?Michal_Koutn=C3=BD?= , Jiri Slaby , Jan Engelhardt , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] libkmod, depmod: Load modprobe.d, depmod.d from $prefix/lib. Date: Tue, 11 Jul 2023 17:31:17 +0200 Message-ID: <20230711153126.28876-3-msuchanek@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711153126.28876-1-msuchanek@suse.de> References: <20230711153126.28876-1-msuchanek@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771141182455921419 X-GMAIL-MSGID: 1771141182455921419 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 seach directories. Cc: Takashi Iwai Signed-off-by: Michal Suchanek --- Makefile.am | 1 + libkmod/libkmod.c | 3 ++- man/Makefile.am | 9 +++++++-- man/depmod.d.xml | 1 + man/modprobe.d.xml | 1 + tools/depmod.c | 1 + 6 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8ba85c91a0f3..7aa5bfa5638d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,6 +19,7 @@ AM_CPPFLAGS = \ -include $(top_builddir)/config.h \ -I$(top_srcdir) \ -DSYSCONFDIR=\""$(sysconfdir)"\" \ + -DPREFIX=\""$(prefix)"\" \ ${zlib_CFLAGS} AM_CFLAGS = $(OUR_CFLAGS) diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index 2670f9a4611a..13c82b069e84 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", + PREFIX "/lib/modprobe.d", "/lib/modprobe.d", NULL }; @@ -237,7 +238,7 @@ 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 + * /usr/local/lib/modprobe.d and PREFIX/lib/modprobe.d. Give an empty * vector if configuration should not be read. This array must * be null terminated. * diff --git a/man/Makefile.am b/man/Makefile.am index 11514d52a190..ad07c30bbd24 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 [ -n '$(prefix)' ] ; then \ + sed -e 's|@PREFIX@|$(prefix)|g' $< ; \ + else \ + sed -e '/@PREFIX@/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..431ebca6654b 100644 --- a/man/depmod.d.xml +++ b/man/depmod.d.xml @@ -40,6 +40,7 @@ /lib/depmod.d/*.conf + @PREFIX@/lib/depmod.d/*.conf /usr/local/lib/depmod.d/*.conf /run/depmod.d/*.conf /etc/depmod.d/*.conf diff --git a/man/modprobe.d.xml b/man/modprobe.d.xml index 0ab3e9110a7e..e8a91d7668af 100644 --- a/man/modprobe.d.xml +++ b/man/modprobe.d.xml @@ -41,6 +41,7 @@ /lib/modprobe.d/*.conf + @PREFIX@/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf /etc/modprobe.d/*.conf diff --git a/tools/depmod.c b/tools/depmod.c index 1d1d41db860f..7e9339923809 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", + PREFIX "/lib/depmod.d", "/lib/depmod.d", NULL };