selinux-refpolicy.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Haines <richard_c_haines@btinternet.com>
To: Steve Lawrence <slawrence@owlcyberdefense.com>,
	Ashish Mishra <ashishm@mvista.com>,
	Chris PeBenito <pebenito@ieee.org>
Cc: selinux-refpolicy@vger.kernel.org, Paul Moore <paul@paul-moore.com>
Subject: Re: How is policy.31 created from modules under /usr/share/selinux
Date: Wed, 09 Dec 2020 16:13:43 +0000	[thread overview]
Message-ID: <cb30c0ce026bbad58666570dd92e172c4ae95955.camel@btinternet.com> (raw)
In-Reply-To: <217b4754-6f3b-cf71-b0be-440f8517312a@owlcyberdefense.com>

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.




  reply	other threads:[~2020-12-09 16:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-05 19:19 How is policy.31 created from modules under /usr/share/selinux Ashish Mishra
2020-12-06 15:29 ` Richard Haines
2020-12-06 16:30   ` Ashish Mishra
2020-12-06 17:15     ` Richard Haines
2020-12-07  1:21       ` Ashish Mishra
2020-12-07 12:39         ` Richard Haines
2020-12-07 13:26           ` Ashish Mishra
2020-12-08 15:36             ` Chris PeBenito
2020-12-08 15:58               ` Ashish Mishra
2020-12-09  9:53                 ` Richard Haines
2020-12-09 14:12                   ` Ashish Mishra
2020-12-09 14:37                     ` Richard Haines
2020-12-09 15:07                       ` Steve Lawrence
2020-12-09 16:13                         ` Richard Haines [this message]
2020-12-09 22:02                           ` Chris PeBenito
2020-12-13 17:06                             ` Ashish Mishra
2020-12-14 15:16                               ` Chris PeBenito

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cb30c0ce026bbad58666570dd92e172c4ae95955.camel@btinternet.com \
    --to=richard_c_haines@btinternet.com \
    --cc=ashishm@mvista.com \
    --cc=paul@paul-moore.com \
    --cc=pebenito@ieee.org \
    --cc=selinux-refpolicy@vger.kernel.org \
    --cc=slawrence@owlcyberdefense.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).