Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4319081pxu; Wed, 9 Dec 2020 14:03:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJyX6SGAWz2KJTxACPXuLprv8cxQSda85PFM4Q4Af/XxxGa0dK3bHf8fyJYNa4Su7d3T8EgF X-Received: by 2002:a05:6402:19b0:: with SMTP id o16mr3966909edz.270.1607551427248; Wed, 09 Dec 2020 14:03:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607551427; cv=none; d=google.com; s=arc-20160816; b=GlnnmbSFRUCgxlRlzctPUW/MmCW4fDgmVPNWleO2+uNM1alVtBHIc6ck89L3R63CZO TmxhEWVLSpyGuFWFzWmPg6xkbhM3Z7rM9cJX7TiHo5UTHEILaLmhvmKeBaRyhKT4O1eS SCZkl8PpL8p9f5wVtiTAj8jmH+7/h0VbN6Jgj2eXpdlHNb35Za40Jvig4pNZP6urQSRa dBIRZ2LEJh1qiXMJ6VOTdzKG8CrxOEynWUC2HHaS64+zDb9flAYSudUvNnBibVm9sFhP dRqrNbcDVRt8BJguljlegxehIQJ0pbab5MrkbSQaSVd/+yVhYx+dEtnInEJ4x8HzbZsC 3hww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=PgqamgjbQ6BQe3Ep0QjIGO35HlTghExdlYewB9O8U3I=; b=upE6A4wWu1Z3krF7+IpTEoEMX8iL/hKVMYpd2OpDwm9r0nGbNEcuvS5NKbLiGUczWp Mlc8j/81zXRKQ8Bp6EQddwCqFY2+cMVy+0IfE390n97QmT1loPYxYSv9gsBAWxPe9JiC YzOomcP5X1LbZcq0EPKr89WpRDYrh1wt1+F+iMe3uRli+4WaD6vEFtX9Z0Sj2bf9GpZM 3u9U0mH3T1hDHKGIw1zPkWRJC4bE2Jbun16agfnLjD9pxAFtu0vDbabxZwy5IiBba0Ut EM3Q+2jkjB4iQkGPuPJsN+4e247Xq6R+Hgs0566Ye2/zeLjBoi0jSEwFFXrfJlvwNJyq WqKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ieee.org header.s=google header.b=Pvw0ZmGT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ieee.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id df7si1824510edb.44.2020.12.09.14.03.43; Wed, 09 Dec 2020 14:03:47 -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=@ieee.org header.s=google header.b=Pvw0ZmGT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ieee.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388223AbgLIWDP (ORCPT + 16 others); Wed, 9 Dec 2020 17:03:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729913AbgLIWDP (ORCPT ); Wed, 9 Dec 2020 17:03:15 -0500 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41C27C0613CF for ; Wed, 9 Dec 2020 14:02:35 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id z9so2215094qtn.4 for ; Wed, 09 Dec 2020 14:02:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ieee.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=PgqamgjbQ6BQe3Ep0QjIGO35HlTghExdlYewB9O8U3I=; b=Pvw0ZmGTpxLeYCostRWObkgtwjv2ZjPSafUVgb16PvpFv246pcLxV7AYeRKtkEAc2k UdBIVifKfkWforV1aZyDzbI+2cIboKGQjZII946oLcKKBYtlRSGsqYxiRpHSa2Hcs54G mZuIOz6kmSTCwSwSg6i8dOGd+HzmfnLTftp7E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=PgqamgjbQ6BQe3Ep0QjIGO35HlTghExdlYewB9O8U3I=; b=lZVML+eMgMO1+6GyR8ynZf9V6MCcvKu9mUXCs2Y9ZeLNtz3jL8iRCOyDULCN90qX29 FW37D6/OU94nq3GILH1rSM8CEUNOJ78ADtZ0bGooiP225eEBv1qqh3kEGseeJD1SBxBZ T+fjodfjzenp6cdmT/FYFfUp9KjR1JBuygtkrory8pynFz9A2kllzGlh3kXhZauUFOEe AHrAIE7c0xvuTG73UOfahUiGrWoIpa5LXzrccRz9seC2bCZKnfEfgj5U/u8rM59+E7gf TSn4TjwYUVMGsN6FCmm7saQGG+vLA2QYp3REgiatzaeiRo+jr38+ZmDpbbC7cmAnYw43 TobQ== X-Gm-Message-State: AOAM532d4n0S+j3sApxlK8x8UA/cPwy9ZpxP1VONoIkFEm8yNQTz0Wc2 CaLn6NzwC2eQRB/OFHIF7mW2Sw== X-Received: by 2002:ac8:5c05:: with SMTP id i5mr5420073qti.34.1607551354352; Wed, 09 Dec 2020 14:02:34 -0800 (PST) Received: from fedora.pebenito.net (pool-96-234-173-17.bltmmd.fios.verizon.net. [96.234.173.17]) by smtp.gmail.com with ESMTPSA id j13sm2222293qki.5.2020.12.09.14.02.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Dec 2020 14:02:33 -0800 (PST) Subject: Re: How is policy.31 created from modules under /usr/share/selinux To: Richard Haines , Steve Lawrence , Ashish Mishra Cc: selinux-refpolicy@vger.kernel.org, Paul Moore 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> From: Chris PeBenito Message-ID: <950fdabd-07a4-0446-3a3d-4928a14e5962@ieee.org> Date: Wed, 9 Dec 2020 17:02:32 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org 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