Skip to content

Commit 66c6072

Browse files
Robert Marshallbalasankarc
authored andcommitted
Generate SELinux policy module with package
- Compile the SELinux policy module files from the base type enforcement files during the package build - The SELinux policy applies to more than RHEL 7, so move the type enforcement files out of the specific path for clarity Closes https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/8231 Signed-off-by: Robert Marshall <[email protected]>
1 parent 8a7af5d commit 66c6072

File tree

10 files changed

+19
-6
lines changed

10 files changed

+19
-6
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ variables:
4242
# To be used for images that exist only on dev.gitlab.org
4343
DEV_BUILDER_IMAGE_REGISTRY: 'dev.gitlab.org:5005/cookbooks/gitlab-omnibus-builder'
4444
PUBLIC_BUILDER_IMAGE_REGISTRY: "registry.gitlab.com/gitlab-org/gitlab-omnibus-builder"
45-
BUILDER_IMAGE_REVISION: "4.28.0"
45+
BUILDER_IMAGE_REVISION: "4.30.0"
4646
# The registry to pull the assets image from
4747
ASSET_REGISTRY: "${CI_REGISTRY}"
4848
ASSET_SYNC_EXISTING_REMOTE_FILES: "keep"

config/projects/gitlab.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
require "#{Omnibus::Config.project_root}/lib/gitlab/util"
2323
require "#{Omnibus::Config.project_root}/lib/gitlab/ohai_helper.rb"
2424
require "#{Omnibus::Config.project_root}/lib/gitlab/openssl_helper"
25+
require "#{Omnibus::Config.project_root}/files/gitlab-cookbooks/package/libraries/helpers/selinux_distro_helper.rb"
2526

2627
gitlab_package_name = Build::Info::Package.name
2728
gitlab_package_file = File.join(Omnibus::Config.project_dir, 'gitlab', "#{gitlab_package_name}.rb")
@@ -104,6 +105,7 @@
104105
end
105106

106107
dependency 'cacerts'
108+
dependency 'gitlab-selinux' if SELinuxDistroHelper.selinux_supported?
107109
dependency 'redis'
108110
dependency 'nginx'
109111
dependency 'mixlib-log'
@@ -146,7 +148,7 @@
146148
dependency 'gitlab-psql'
147149
dependency 'gitlab-redis-cli'
148150
dependency 'gitlab-healthcheck'
149-
dependency 'gitlab-selinux'
151+
150152
dependency 'gitlab-scripts'
151153
dependency 'gitlab-config-template'
152154

config/software/gitlab-selinux.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@
2525
source path: File.expand_path('files/gitlab-selinux', Omnibus::Config.project_root)
2626

2727
build do
28+
policy_directory = File.expand_path('files/gitlab-selinux', Omnibus::Config.project_root)
29+
30+
# Only type enforcement (te) is provided in the current policy
31+
Dir.glob("#{policy_directory}/*.te").each do |te_file|
32+
mod_file = te_file.sub(/\.te$/, ".mod")
33+
policy_file = te_file.sub(/\.te$/, ".pp")
34+
35+
command "checkmodule -M -m -o #{mod_file} #{te_file}", cwd: policy_directory
36+
command "semodule_package -o #{policy_file} -m #{mod_file}", cwd: policy_directory
37+
end
38+
2839
mkdir "#{install_dir}/embedded/selinux"
29-
sync './', "#{install_dir}/embedded/selinux/"
40+
copy "#{policy_directory}/*.pp", "#{install_dir}/embedded/selinux"
3041
end

files/gitlab-cookbooks/gitlab/recipes/selinux.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717

1818
if SELinuxDistroHelper.selinux_supported?
1919
ssh_keygen_module = 'gitlab-7.2.0-ssh-keygen'
20-
execute "semodule -i /opt/gitlab/embedded/selinux/rhel/7/#{ssh_keygen_module}.pp" do
20+
execute "semodule -i /opt/gitlab/embedded/selinux/#{ssh_keygen_module}.pp" do
2121
not_if "getenforce | grep Disabled"
2222
not_if "semodule -l | grep '^#{ssh_keygen_module}\\s'"
2323
end
2424

2525
authorized_keys_module = 'gitlab-10.5.0-ssh-authorized-keys'
26-
execute "semodule -i /opt/gitlab/embedded/selinux/rhel/7/#{authorized_keys_module}.pp" do
26+
execute "semodule -i /opt/gitlab/embedded/selinux/#{authorized_keys_module}.pp" do
2727
not_if "getenforce | grep Disabled"
2828
not_if "semodule -l | grep '^#{authorized_keys_module}\\s'"
2929
end
3030

3131
gitlab_shell_module = 'gitlab-13.5.0-gitlab-shell'
32-
execute "semodule -i /opt/gitlab/embedded/selinux/rhel/7/#{gitlab_shell_module}.pp" do
32+
execute "semodule -i /opt/gitlab/embedded/selinux/#{gitlab_shell_module}.pp" do
3333
not_if "getenforce | grep Disabled"
3434
not_if "semodule -l | grep '^#{gitlab_shell_module}\\s'"
3535
end
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)