From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v2 1/1] package/libsemanage: add option to manually define policy version
Date: Mon, 23 Dec 2019 22:05:14 +0100 [thread overview]
Message-ID: <20191223220514.1dd1fcaf@windsurf> (raw)
In-Reply-To: <20191215180003.2162894-1-aduskett@gmail.com>
Hello Adam,
On Sun, 15 Dec 2019 10:00:03 -0800
aduskett at gmail.com wrote:
> From: Adam Duskett <Aduskett@gmail.com>
>
> The semodule package derives the maximum SELinux policy version from
> the libsemanage library.
>
> By default, libsemanage returns the highest supported policy version that
> libsepol supports found in include/sepol/policydb/policydb.h and not just from
> the Kernel. However, if the maximum supported SELinux policy version supported
> by the Kernel is lower than the maximum supported policy version from
> libsemanage, if a user attempts to build a policy using the semodule program,
> semodule fails when creating a policy with the error:
> "policydb version X does not match my version range 15-X."
>
> This default value may be overwrriten by setting the policy-version = line in
> /etc/semanage/semanage.conf.
>
> Create an option that allows a user to overwrite the default policy version to
> ensure that semodule works on older kernels.
>
> Signed-off-by: Adam Duskett <Aduskett@gmail.com>
So, I had a more serious look into this. I have some implementation
details which I fixed up locally, but then had some second thoughts.
The thing that made me wonder is that you are adding an option for the
*target* version of libsemanage, but it also affects libsemanage on the
host. But what if you don't have libsemanage on the target? I think it
is not mandatory to have it on the target. In this case, how would you
select the policy version ?
Ideally, the selection of the policy version should be chosen together
with the policy itself, or somewhere close to where the policy
compilation happens.
And it turns out we already have such an option that exists in Buildroot:
config BR2_PACKAGE_REFPOLICY_POLICY_VERSION
string "Policy version"
default "30"
why don't we use this version ?
It's used in refpolicy.mk to create the build.conf:
define REFPOLICY_CONFIGURE_CMDS
$(SED) "/OUTPUT_POLICY/c\OUTPUT_POLICY = $(REFPOLICY_POLICY_VERSION)" \
$(@D)/build.conf
How does this interacts with libsemanage ?
I nevertheless give my minor implementation details below.
> +define LIBSEMANAGE_SET_SEMANAGE_MAX_POLICY_TARGET
> + $(SED) "/policy-version = /c\policy-version = $(LIBSEMANAGE_MAX_POLICY_VERSION)" \
> + $(TARGET_DIR)/etc/selinux/semanage.conf
This command can go directly in LIBSEMANAGE_INSTALL_TARGET_CMDS.
> +endef
> +define LIBSEMANAGE_SET_SEMANAGE_MAX_POLICY_HOST
> + $(SED) "/policy-version = /c\policy-version = $(LIBSEMANAGE_MAX_POLICY_VERSION)" \
> + $(HOST_DIR)/etc/selinux/semanage.conf
This command can go directly in HOST_LIBSEMANAGE_INSTALL_CMDS. The name
of the hook was not very well chosen in any case, as we prefer to have
HOST_ as a prefix rather than a suffix.
Again, these are minor details that I had fixed locally. It's really
the more fundamental questions above that makes me wonder what is the
right solution.
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
prev parent reply other threads:[~2019-12-23 21:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-15 18:00 [Buildroot] [PATCH v2 1/1] package/libsemanage: add option to manually define policy version aduskett at gmail.com
2019-12-23 21:05 ` Thomas Petazzoni [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=20191223220514.1dd1fcaf@windsurf \
--to=thomas.petazzoni@bootlin.com \
--cc=buildroot@busybox.net \
/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