From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7D27C433FE for ; Sun, 13 Dec 2020 17:07:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 758DB2313B for ; Sun, 13 Dec 2020 17:07:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390429AbgLMRHX (ORCPT ); Sun, 13 Dec 2020 12:07:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726472AbgLMRHW (ORCPT ); Sun, 13 Dec 2020 12:07:22 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70A51C0613CF for ; Sun, 13 Dec 2020 09:06:42 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id i9so14068007wrc.4 for ; Sun, 13 Dec 2020 09:06:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mvista-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yLwjOB6Rs5v8TKb5yyCeaCqgsN6FYm4bUxw1TGXT44k=; b=uN+RqseciHdawvhUX6eMjKlJeG+asJfLViq5oZjDi7mzf7wvxGBhNtjdtBGzQfh5Hg 8w/jwDI/5O1Xogm5H0aMoYGXtWSWD+ebUwZoty412BsaRKaKoD9xETb+OyDG/QPhwhHA /0JbbRpwltqlMJWjBdteSXwdaHoC+1ZioiPo4YnftJttqY3RAGVql2l0xehY/4D0U15D IP72K3RGC0zg/C3+59dhFXnUW2OUeSBkjZ30m/cXqLz3NscrxLv/JKK4yx1nOOqTVatu 44+31MaB1fNFpS7i+XVdtOQyaKOOSXHNhaTD1WcO/3JeuYw1nqQCv7qiVNFJrMJqqeZx 8fcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yLwjOB6Rs5v8TKb5yyCeaCqgsN6FYm4bUxw1TGXT44k=; b=cYCni2ssjpinn3qRuenV79VJWUGRjqf+ONdgGUG6PUQfXbz/CvalgfDIwlQ/yPgkFl VehXxmA1vhyck5lfzhp+qz0ncl+aAmBqexmswiWRFFdxxE0G5Iq74T0vVTChr0NL2JkP SAj5GgBDgwwynRpJY1hmLVsW+KW7eKDfVCpehUcWb8iqHik0NZNNbSZRo/Zzkc7+M7/R R3x0wL0Go+rhy9dLfni4K1UM0Nlxts7TLFA0L4VacNPmBYqqAqLqCuKI45CJIoxUfe1f X6v/pkqdiYdlIYF5Up48vwVlURIxzXN9Qv2W0eNzLA7b4IAZGiyAXxS9e1GkdkM6jdjT 7ycA== X-Gm-Message-State: AOAM533JlSh50HxIZUPf8yYD/FyMSnXRmXEXBoX6U7RtMRUiVFgakbb4 twtbCoaAnk+/go4U211zV+f1BiDqZbfvTHcVDF8mrA== X-Google-Smtp-Source: ABdhPJyK4fSTvaG/RE4xfVHklDuhORmHmSi5vhxqK6aSNWSo7NT59jssxfTQpMYuqTrzhvH3HRH9tZlL6yY+gT/u2qM= X-Received: by 2002:a5d:4e86:: with SMTP id e6mr25272929wru.33.1607879198511; Sun, 13 Dec 2020 09:06:38 -0800 (PST) MIME-Version: 1.0 References: <858c9383f7c75e1e39bafaeab6388cd6af902c4f.camel@btinternet.com> <0b58a502b5036e8b92b274068fbea53ca915992e.camel@btinternet.com> <2806a33b-87ad-61b1-9143-5a24d770a180@ieee.org> <1b218c6ab1380164cd6c1c774fa4cd3db6d8eb8c.camel@btinternet.com> <217b4754-6f3b-cf71-b0be-440f8517312a@owlcyberdefense.com> <950fdabd-07a4-0446-3a3d-4928a14e5962@ieee.org> In-Reply-To: <950fdabd-07a4-0446-3a3d-4928a14e5962@ieee.org> From: Ashish Mishra Date: Sun, 13 Dec 2020 22:36:27 +0530 Message-ID: Subject: Re: How is policy.31 created from modules under /usr/share/selinux To: Chris PeBenito Cc: Richard Haines , Steve Lawrence , selinux-refpolicy@vger.kernel.org, Paul Moore Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org Hi Chris / Richard / Steve , I tried the suggested approach w.r.t Monolithic & also the patch suggested . It seems it's creating policy.31 under DESTDIR directories . a) Is there anything I can check specifically and share observations ? b) Any link where we have this thread available for future reference. I wanted to know if we have any archive which can be accessed like other community Something like https://lists.yoctoproject.org/g/poky/topics Thanks , Ashish On Thu, Dec 10, 2020 at 3:32 AM Chris PeBenito wrote: > > On 12/9/20 11:13 AM, Richard Haines wrote: > > On Wed, 2020-12-09 at 10:07 -0500, Steve Lawrence wrote: > >> > >> On 12/9/20 9:37 AM, Richard Haines wrote: > >>> On Wed, 2020-12-09 at 19:42 +0530, Ashish Mishra wrote: > >>>> Hi Richard , > >>>> > >>>> Will check with the monolithic policy to check the behavior of > >>>> the > >>>> semodule as you suggested. > >>>> > >>>> Is there any similar approach / workaround for modular one? > >>> > >>> I've only had a quick look at code and I could see two ways to fix: > >>> 1) Modify the Rules.modular part of the make file to move or copy > >>> the > >>> policy and file contexts set of files over to $DESTDIR. > >>> 2) Modify semodule/semanage to handle $DESTDIR. I think this would > >>> be > >>> more difficult to fix as lots go on here. > >>> > >> > >> semodule does accept the -p option to change the root, so we could > >> feed > >> DESTDIR into that. For example, a minimally tested patch: > >> > >> diff --git a/Rules.modular b/Rules.modular > >> index d6224e95..64d953dc 100644 > >> --- a/Rules.modular > >> +++ b/Rules.modular > >> @@ -55,8 +55,8 @@ load: $(instpkg) $(appfiles) > >> # make sure two directories exist since they are not > >> # created by semanage > >> @echo "Loading configured modules." > >> - @$(INSTALL) -d -m 0755 $(policypath) $(dir $(fcpath)) > >> - $(verbose) $(SEMODULE) -s $(NAME) -i $(modpkgdir)/$(notdir > >> $(base_pkg)) $(foreach mod,$(mod_pkgs),-i $(modpkgdir)/$(mod)) > >> + @$(INSTALL) -d -m 0755 $(policypath) $(dir $(fcpath)) > >> $(DESTDIR)/var/lib/selinux > >> + $(verbose) $(SEMODULE) -p $(DESTDIR)/ -s $(NAME) -i > >> $(modpkgdir)/$(notdir $(base_pkg)) $(foreach mod,$(mod_pkgs),-i > >> $(modpkgdir)/$(mod)) > >> > >> ######################################## > >> # > >> > >> > >> Note that we need to create $(DESTDIR)/var/lib/selinux since semanage > >> expects that to already exist. > >> > >> Though, I would suggest that maybe the "install" target should run > >> the > >> above semodule command with the --noreload option to install all > >> files > >> and build the policy binary but not actually load it into the kernel. > >> Then make load just becomes something like > >> > >> semodule -p $(DESTDIR)/ --reload > >> > >> Makes a clear distinction between installing everything that's needed > >> vs actually loading the policy into the kernel. Happy to create a > >> patch > >> if that approach makes sense. > > > > Thanks Steve, that worked for me, however I guess Chris needs to > > comment as the $(DESTDIR)/var/lib/selinux needs to be generated and > > maybe a clarification comment in the README. Also need comment > > regarding the use of --reload/--noreload. > > To my knowledge, the history is that semodule was only intended to run on the > target system. If you wanted to precreate a policy you could > semodule_link+semodule_expand like what is leveraged in the validate target. > > I'd take a patch that changes the Makefile behavior but would like some real > testing first. > > -- > Chris PeBenito