Initial Commit
- initial default booting image
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
From eff537f7be038120ca06fc7c39f9817ae120ce00 Mon Sep 17 00:00:00 2001
|
||||
From: Dave Sugar <dsugar100@gmail.com>
|
||||
Date: Thu, 15 May 2025 10:05:24 -0400
|
||||
Subject: [PATCH] fix building when dbus module is not enabled
|
||||
|
||||
Signed-off-by: Dave Sugar <dsugar100@gmail.com>
|
||||
Upstream: https://github.com/SELinuxProject/refpolicy/pull/908
|
||||
Signed-off-by: Arnout Vandecappelle <arnout@rnout.be>
|
||||
---
|
||||
policy/modules/system/selinuxutil.te | 7 ++++++-
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/policy/modules/system/selinuxutil.te b/policy/modules/system/selinuxutil.te
|
||||
index 86a6e5503..cd0e8762f 100644
|
||||
--- a/policy/modules/system/selinuxutil.te
|
||||
+++ b/policy/modules/system/selinuxutil.te
|
||||
@@ -99,7 +99,8 @@ role run_init_roles types run_init_t;
|
||||
|
||||
type selinux_dbus_t;
|
||||
type selinux_dbus_exec_t;
|
||||
-dbus_system_domain(selinux_dbus_t, selinux_dbus_exec_t)
|
||||
+domain_type(selinux_dbus_t)
|
||||
+domain_entry_file(selinux_dbus_t, selinux_dbus_exec_t)
|
||||
|
||||
type semanage_t;
|
||||
type semanage_exec_t;
|
||||
@@ -504,6 +505,10 @@ miscfiles_read_localization(selinux_dbus_t)
|
||||
|
||||
seutil_domtrans_semanage(selinux_dbus_t)
|
||||
|
||||
+optional_policy(`
|
||||
+ dbus_system_domain(selinux_dbus_t, selinux_dbus_exec_t)
|
||||
+')
|
||||
+
|
||||
optional_policy(`
|
||||
policykit_dbus_chat(selinux_dbus_t)
|
||||
')
|
||||
--
|
||||
2.49.0
|
||||
|
||||
154
package/refpolicy/Config.in
Normal file
154
package/refpolicy/Config.in
Normal file
@@ -0,0 +1,154 @@
|
||||
config BR2_PACKAGE_REFPOLICY
|
||||
bool "refpolicy"
|
||||
depends on BR2_TOOLCHAIN_HAS_THREADS # libsepol
|
||||
depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5 # libsepol
|
||||
depends on BR2_HOST_GCC_AT_LEAST_5 # host-setools -> host-libsepol
|
||||
# Even though libsepol is not necessary for building, we get
|
||||
# the policy version from libsepol, so we select it, and treat
|
||||
# it like a runtime dependency.
|
||||
select BR2_PACKAGE_LIBSEPOL
|
||||
help
|
||||
The SELinux Reference Policy project (refpolicy) is a
|
||||
complete SELinux policy that can be used as the system
|
||||
policy for a variety of systems and used as the basis for
|
||||
creating other policies. Reference Policy was originally
|
||||
based on the NSA example policy, but aims to accomplish many
|
||||
additional goals.
|
||||
|
||||
The current refpolicy does not fully support Buildroot and
|
||||
needs modifications to work with the default system file
|
||||
layout. These changes should be added as patches to the
|
||||
refpolicy that modify a single SELinux policy.
|
||||
|
||||
The refpolicy works for the most part in permissive
|
||||
mode. Only the basic set of utilities are enabled in the
|
||||
example policy config and some of the pathing in the
|
||||
policies is not correct. Individual policies would need to
|
||||
be tweaked to get everything functioning properly.
|
||||
|
||||
https://github.com/SELinuxProject/refpolicy
|
||||
|
||||
if BR2_PACKAGE_REFPOLICY
|
||||
|
||||
choice
|
||||
prompt "Refpolicy version"
|
||||
default BR2_PACKAGE_REFPOLICY_UPSTREAM_VERSION
|
||||
|
||||
config BR2_PACKAGE_REFPOLICY_UPSTREAM_VERSION
|
||||
bool "Upstream version"
|
||||
# Consider reworking the following when adding new entries:
|
||||
# Upstream refpolicy for openssh expects linux-pam to be used
|
||||
select BR2_PACKAGE_LINUX_PAM if BR2_PACKAGE_OPENSSH \
|
||||
&& BR2_USE_MMU \
|
||||
&& BR2_ENABLE_LOCALE \
|
||||
&& BR2_USE_WCHAR \
|
||||
&& !BR2_STATIC_LIBS \
|
||||
&& BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
|
||||
help
|
||||
Use the refpolicy as provided by Buildroot.
|
||||
|
||||
config BR2_PACKAGE_REFPOLICY_CUSTOM_GIT
|
||||
bool "Custom git repository"
|
||||
help
|
||||
Allows to get the refpolicy from a custom git repository.
|
||||
|
||||
The custom refpolicy must define the full policy explicitly,
|
||||
and must be a fork of the original refpolicy, to have the
|
||||
same build system. When this is selected, only the custom
|
||||
policy definition are taken into account and all the modules
|
||||
of the policy are built into the binary policy.
|
||||
|
||||
endchoice
|
||||
|
||||
if BR2_PACKAGE_REFPOLICY_CUSTOM_GIT
|
||||
|
||||
config BR2_PACKAGE_REFPOLICY_CUSTOM_REPO_URL
|
||||
string "URL of custom repository"
|
||||
|
||||
config BR2_PACKAGE_REFPOLICY_CUSTOM_REPO_VERSION
|
||||
string "Custom repository version"
|
||||
help
|
||||
Revision to use in the typical format used by Git.
|
||||
E.g. a sha id, tag, branch...
|
||||
|
||||
endif
|
||||
|
||||
choice
|
||||
prompt "SELinux default state"
|
||||
default BR2_PACKAGE_REFPOLICY_POLICY_STATE_PERMISSIVE
|
||||
|
||||
config BR2_PACKAGE_REFPOLICY_POLICY_STATE_ENFORCING
|
||||
bool "Enforcing"
|
||||
help
|
||||
SELinux security policy is enforced
|
||||
|
||||
config BR2_PACKAGE_REFPOLICY_POLICY_STATE_PERMISSIVE
|
||||
bool "Permissive"
|
||||
help
|
||||
SELinux prints warnings instead of enforcing
|
||||
|
||||
config BR2_PACKAGE_REFPOLICY_POLICY_STATE_DISABLED
|
||||
bool "Disabled"
|
||||
help
|
||||
No SELinux policy is loaded
|
||||
endchoice
|
||||
|
||||
config BR2_PACKAGE_REFPOLICY_POLICY_STATE
|
||||
string
|
||||
default "permissive" if BR2_PACKAGE_REFPOLICY_POLICY_STATE_PERMISSIVE
|
||||
default "enforcing" if BR2_PACKAGE_REFPOLICY_POLICY_STATE_ENFORCING
|
||||
default "disabled" if BR2_PACKAGE_REFPOLICY_POLICY_STATE_DISABLED
|
||||
|
||||
if BR2_PACKAGE_REFPOLICY_UPSTREAM_VERSION
|
||||
|
||||
config BR2_REFPOLICY_EXTRA_MODULES_DIRS
|
||||
string "Extra modules directories"
|
||||
help
|
||||
Specify a space-separated list of directories containing
|
||||
SELinux modules that will be built into the SELinux
|
||||
policy. The modules will be automatically enabled in the
|
||||
policy.
|
||||
|
||||
Each of those directories must contain the SELinux policy
|
||||
.fc, .if and .te files directly at the top-level, with no
|
||||
sub-directories. Also, you cannot have several modules with
|
||||
the same name in different directories.
|
||||
|
||||
config BR2_REFPOLICY_EXTRA_MODULES
|
||||
string "Extra modules to enable"
|
||||
help
|
||||
List of extra SELinux modules to enable in the refpolicy.
|
||||
|
||||
endif
|
||||
|
||||
config BR2_REFPOLICY_SET_BOOLEANS
|
||||
string "Set policy booleans"
|
||||
help
|
||||
Set default values for policy booleans before compiling the
|
||||
policy (see policy/booleans.conf in the refpolicy
|
||||
README). The value of this option is a space separated list
|
||||
of either plain names (to set that boolean to true), or
|
||||
"name=(true|false)" pairs (to set the given value).
|
||||
|
||||
Boolean values can still be changed at runtime if the policy
|
||||
permits, but such changes cannot be persisted with a
|
||||
monolithic policy.
|
||||
|
||||
config BR2_REFPOLICY_ENABLEAUDIT
|
||||
bool "remove dontaudit rules from policy (debugging only)"
|
||||
help
|
||||
Remove dontaudit rules from policy.conf before compiling the
|
||||
policy. This can be useful for debugging to see "denied"
|
||||
audit log messages that would otherwise be hidden, which
|
||||
show the cause of problems.
|
||||
|
||||
Warning: This option will likely produce a high rate of
|
||||
audit log messages, and should be enabled only for
|
||||
debugging.
|
||||
|
||||
endif
|
||||
|
||||
comment "refpolicy needs a toolchain w/ threads, gcc >= 5, host gcc >= 5"
|
||||
depends on !BR2_TOOLCHAIN_HAS_THREADS || \
|
||||
!BR2_TOOLCHAIN_GCC_AT_LEAST_5 || \
|
||||
!BR2_HOST_GCC_AT_LEAST_5
|
||||
8
package/refpolicy/config
Normal file
8
package/refpolicy/config
Normal file
@@ -0,0 +1,8 @@
|
||||
# This file controls the state of SELinux on the system.
|
||||
# SELINUX= can take one of these three values:
|
||||
# enforcing - SELinux security policy is enforced.
|
||||
# permissive - SELinux prints warnings instead of enforcing.
|
||||
# disabled - No SELinux policy is loaded.
|
||||
SELINUX=disabled
|
||||
|
||||
SELINUXTYPE=targeted
|
||||
5
package/refpolicy/refpolicy.hash
Normal file
5
package/refpolicy/refpolicy.hash
Normal file
@@ -0,0 +1,5 @@
|
||||
# From https://github.com/SELinuxProject/refpolicy/releases
|
||||
sha256 e5b435c934048d01ca4415a1f2670a51e113f26f5d01ad4227c98fbe8dea8d5b refpolicy-2.20250923.tar.bz2
|
||||
|
||||
# Locally computed
|
||||
sha256 204d8eff92f95aac4df6c8122bc1505f468f3a901e5a4cc08940e0ede1938994 COPYING
|
||||
151
package/refpolicy/refpolicy.mk
Normal file
151
package/refpolicy/refpolicy.mk
Normal file
@@ -0,0 +1,151 @@
|
||||
################################################################################
|
||||
#
|
||||
# refpolicy
|
||||
#
|
||||
################################################################################
|
||||
|
||||
REFPOLICY_LICENSE = GPL-2.0
|
||||
REFPOLICY_LICENSE_FILES = COPYING
|
||||
REFPOLICY_CPE_ID_VENDOR = selinuxproject
|
||||
REFPOLICY_INSTALL_STAGING = YES
|
||||
REFPOLICY_DEPENDENCIES = \
|
||||
host-m4 \
|
||||
host-checkpolicy \
|
||||
host-policycoreutils \
|
||||
host-python3 \
|
||||
host-setools \
|
||||
host-gawk \
|
||||
host-libxml2
|
||||
|
||||
ifeq ($(BR2_PACKAGE_REFPOLICY_CUSTOM_GIT),y)
|
||||
REFPOLICY_VERSION = $(call qstrip,$(BR2_PACKAGE_REFPOLICY_CUSTOM_REPO_VERSION))
|
||||
REFPOLICY_SITE = $(call qstrip,$(BR2_PACKAGE_REFPOLICY_CUSTOM_REPO_URL))
|
||||
REFPOLICY_SITE_METHOD = git
|
||||
BR_NO_CHECK_HASH_FOR += $(REFPOLICY_SOURCE)
|
||||
else
|
||||
REFPOLICY_VERSION = 2.20250923
|
||||
REFPOLICY_SOURCE = refpolicy-$(REFPOLICY_VERSION).tar.bz2
|
||||
REFPOLICY_SITE = https://github.com/SELinuxProject/refpolicy/releases/download/RELEASE_$(subst .,_,$(REFPOLICY_VERSION))
|
||||
endif
|
||||
|
||||
# Cannot use multiple threads to build the reference policy
|
||||
REFPOLICY_MAKE = \
|
||||
PYTHON=$(HOST_DIR)/bin/python3 \
|
||||
XMLLINT=$(LIBXML2_HOST_BINARY) \
|
||||
TEST_TOOLCHAIN=$(HOST_DIR) \
|
||||
$(TARGET_MAKE_ENV) \
|
||||
$(MAKE1)
|
||||
|
||||
REFPOLICY_POLICY_VERSION = $(BR2_PACKAGE_LIBSEPOL_POLICY_VERSION)
|
||||
REFPOLICY_POLICY_STATE = \
|
||||
$(call qstrip,$(BR2_PACKAGE_REFPOLICY_POLICY_STATE))
|
||||
|
||||
ifeq ($(BR2_PACKAGE_REFPOLICY_UPSTREAM_VERSION),y)
|
||||
|
||||
# Allow to provide out-of-tree SELinux modules in addition to the ones
|
||||
# in the refpolicy.
|
||||
REFPOLICY_EXTRA_MODULES_DIRS = \
|
||||
$(strip \
|
||||
$(call qstrip,$(BR2_REFPOLICY_EXTRA_MODULES_DIRS)) \
|
||||
$(PACKAGES_SELINUX_EXTRA_MODULES_DIRS))
|
||||
$(foreach dir,$(REFPOLICY_EXTRA_MODULES_DIRS),\
|
||||
$(if $(wildcard $(dir)),,\
|
||||
$(error BR2_REFPOLICY_EXTRA_MODULES_DIRS contains nonexistent directory $(dir))))
|
||||
|
||||
REFPOLICY_MODULES = \
|
||||
application \
|
||||
authlogin \
|
||||
getty \
|
||||
init \
|
||||
libraries \
|
||||
locallogin \
|
||||
logging \
|
||||
miscfiles \
|
||||
modutils \
|
||||
mount \
|
||||
selinuxutil \
|
||||
storage \
|
||||
sysadm \
|
||||
sysnetwork \
|
||||
unconfined \
|
||||
userdomain \
|
||||
$(PACKAGES_SELINUX_MODULES) \
|
||||
$(call qstrip,$(BR2_REFPOLICY_EXTRA_MODULES)) \
|
||||
$(foreach d,$(REFPOLICY_EXTRA_MODULES_DIRS),\
|
||||
$(basename $(notdir $(wildcard $(d)/*.te))))
|
||||
|
||||
define REFPOLICY_COPY_EXTRA_MODULES
|
||||
mkdir -p $(@D)/policy/modules/buildroot
|
||||
rsync -au $(addsuffix /*,$(REFPOLICY_EXTRA_MODULES_DIRS)) \
|
||||
$(@D)/policy/modules/buildroot/
|
||||
if [ ! -f $(@D)/policy/modules/buildroot/metadata.xml ]; then \
|
||||
echo "<summary>Buildroot extra modules</summary>" > \
|
||||
$(@D)/policy/modules/buildroot/metadata.xml; \
|
||||
fi
|
||||
endef
|
||||
|
||||
# In the context of a monolithic policy enabling a piece of the policy as
|
||||
# 'base' or 'module' is equivalent, so we enable them as 'base'.
|
||||
define REFPOLICY_CONFIGURE_MODULES
|
||||
$(SED) "s/ = module/ = no/g" $(@D)/policy/modules.conf
|
||||
$(foreach m,$(sort $(REFPOLICY_MODULES)),
|
||||
$(SED) "/^$(m) =/c\$(m) = base" $(@D)/policy/modules.conf
|
||||
)
|
||||
endef
|
||||
|
||||
endif # BR2_PACKAGE_REFPOLICY_UPSTREAM_VERSION = y
|
||||
|
||||
ifeq ($(BR2_INIT_SYSTEMD),y)
|
||||
define REFPOLICY_CONFIGURE_SYSTEMD
|
||||
$(SED) "/SYSTEMD/c\SYSTEMD = y" $(@D)/build.conf
|
||||
endef
|
||||
endif
|
||||
|
||||
ifeq ($(BR2_REFPOLICY_ENABLEAUDIT),y)
|
||||
define REFPOLICY_CONFIGURE_ENABLEAUDIT
|
||||
$(REFPOLICY_MAKE) -C $(@D) enableaudit
|
||||
endef
|
||||
endif
|
||||
|
||||
# Override defaults for policy booleans. name=(true|false) will result
|
||||
# in the given value, just a name implies "true".
|
||||
define REFPOLICY_CONFIGURE_BOOLEANS
|
||||
$(foreach b,$(call qstrip,$(BR2_REFPOLICY_SET_BOOLEANS)),
|
||||
read -r name value < <(echo "$(subst =, ,$(b))"); \
|
||||
$(SED) "/^$${name} =/c\\$${name} = $${value:-true}" $(@D)/policy/booleans.conf
|
||||
)
|
||||
endef
|
||||
|
||||
define REFPOLICY_CONFIGURE_CMDS
|
||||
$(SED) "/OUTPUT_POLICY/c\OUTPUT_POLICY = $(REFPOLICY_POLICY_VERSION)" \
|
||||
$(@D)/build.conf
|
||||
$(SED) "/MONOLITHIC/c\MONOLITHIC = y" $(@D)/build.conf
|
||||
$(SED) "/NAME/c\NAME = targeted" $(@D)/build.conf
|
||||
$(REFPOLICY_CONFIGURE_SYSTEMD)
|
||||
$(if $(REFPOLICY_EXTRA_MODULES_DIRS), \
|
||||
$(REFPOLICY_COPY_EXTRA_MODULES)
|
||||
)
|
||||
$(REFPOLICY_MAKE) -C $(@D) bare conf
|
||||
$(REFPOLICY_CONFIGURE_ENABLEAUDIT)
|
||||
$(REFPOLICY_CONFIGURE_MODULES)
|
||||
$(REFPOLICY_CONFIGURE_BOOLEANS)
|
||||
endef
|
||||
|
||||
define REFPOLICY_BUILD_CMDS
|
||||
$(REFPOLICY_MAKE) -C $(@D) policy
|
||||
endef
|
||||
|
||||
define REFPOLICY_INSTALL_STAGING_CMDS
|
||||
$(REFPOLICY_MAKE) -C $(@D) DESTDIR=$(STAGING_DIR) \
|
||||
install-src install-headers
|
||||
endef
|
||||
|
||||
define REFPOLICY_INSTALL_TARGET_CMDS
|
||||
$(REFPOLICY_MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install
|
||||
$(INSTALL) -m 0755 -D package/refpolicy/config \
|
||||
$(TARGET_DIR)/etc/selinux/config
|
||||
$(SED) "/^SELINUX=/c\SELINUX=$(REFPOLICY_POLICY_STATE)" \
|
||||
$(TARGET_DIR)/etc/selinux/config
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
||||
Reference in New Issue
Block a user