Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2025444pxu; Sun, 13 Dec 2020 11:00:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWfPln6Jxsg8MUBhTHjdzFOjP7Ogb1Dpk9fmhbykCVuJo9qlOWtt23Jq/Ha6BJvo8Y+CCc X-Received: by 2002:a50:d491:: with SMTP id s17mr3421691edi.169.1607886031451; Sun, 13 Dec 2020 11:00:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607886031; cv=none; d=google.com; s=arc-20160816; b=Mtg1mtMVxGFcQWhotu+LOlv5DdaPMYssukUhAtFDFv8bFhfYNxx+oqXzou8tAVqOl3 MXqqczuwbtV7zXp36r4l2FJJPDfnjW2A6HqPlnAw7+2rKMR81Ks/XH6Rnw4D5+o6ba0b 4hPBM/Z6DRPosup+wPeIzcR2du4tXHIjqpBLYLIABFr7jNUX7wwLwUCQsrnQvRErZRDd bltdChdbV1VYJ76ItiWs3hsSxQExWsM4zIas5K1WjO+X5fG24E7lLz1klzg8WrK3fCdj 5e0E62m+WCx/HiacjdVUKTvmLVmUAvHyfb3+unILtZUPKPLdVl7mO6kRxP1GvDJST4Bs OdKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=yLwjOB6Rs5v8TKb5yyCeaCqgsN6FYm4bUxw1TGXT44k=; b=dNN7hutGbwYQ9EbQHVeOO1cRuipVg1oQsfG2phr3E+erdkx0SxAZM5fZt8kXoNtmvl eHRGG+nLKLiIxW2FrZRLF84ZQVwxNlN7YLpjlkkN0nzOO50cj63jAZjrDmYRjsMCPgOD 4JMa6duFO3bvW74zNUX1zNEG0hNcRYfj4YNM+AEtoPfH4tqR4sVlQAE7/5pocKjzH/bu EQyPYK2U4RZGrTT3KVl/eWAiZuWqFqpbdcNywWf1l1SeTzAwlnBUoAXfFk9lb81Q9O6f M7ACacSjphl/YeqyYGgeTmhJRlvt4LVv98cMIZZd5DecispsM3eWBEJcgwbnDdUm4KNQ m+Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mvista-com.20150623.gappssmtp.com header.s=20150623 header.b=uN+Rqsec; spf=pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p1si7997744ejf.418.2020.12.13.11.00.25; Sun, 13 Dec 2020 11:00:31 -0800 (PST) Received-SPF: pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mvista-com.20150623.gappssmtp.com header.s=20150623 header.b=uN+Rqsec; spf=pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390429AbgLMRHX (ORCPT + 16 others); 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-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