From: Chris PeBenito <pebenito@ieee.org>
To: Ashish Mishra <ashishm@mvista.com>
Cc: Richard Haines <richard_c_haines@btinternet.com>,
Steve Lawrence <slawrence@owlcyberdefense.com>,
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: Mon, 14 Dec 2020 10:16:36 -0500 [thread overview]
Message-ID: <33c70a8e-09be-d779-33ec-a07cbf22440f@ieee.org> (raw)
In-Reply-To: <CAP2OjcjQFgjM_scEgPmu3wka8M=HGWaWQ0Wyb96GkVRwg+zOjA@mail.gmail.com>
On 12/13/20 12:06 PM, Ashish Mishra wrote:
> 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 ?
I don't understand what you're asking.
> 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
The mail list archive is here: https://lore.kernel.org/selinux-refpolicy/
> On Thu, Dec 10, 2020 at 3:32 AM Chris PeBenito <pebenito@ieee.org> 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
--
Chris PeBenito
prev parent reply other threads:[~2020-12-14 15:17 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
2020-12-09 22:02 ` Chris PeBenito
2020-12-13 17:06 ` Ashish Mishra
2020-12-14 15:16 ` Chris PeBenito [this message]
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=33c70a8e-09be-d779-33ec-a07cbf22440f@ieee.org \
--to=pebenito@ieee.org \
--cc=ashishm@mvista.com \
--cc=paul@paul-moore.com \
--cc=richard_c_haines@btinternet.com \
--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).