Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes for release package #1889

Merged
merged 2 commits into from
Jan 6, 2022
Merged

Conversation

bcressey
Copy link
Contributor

@bcressey bcressey commented Jan 4, 2022

Issue number:
N/A

Description of changes:
Make prepare-local.service depend on selinux-policy-files.service, since otherwise the setfiles command can fail if the file contexts haven't been copied yet. I've only seen this on a system that was failing to boot for other reasons, but in theory it could affect the most recent release.

Simplify the default target symlink, which was flagged by the symlinks tool while troubleshooting broken symlinks for the systemd upgrade.

Testing done:

Verified that the new dependency was used for prepare-local.service.

bash-5.0# systemctl list-dependencies prepare-local
prepare-local.service
● ├─local.mount
● ├─selinux-policy-files.service
● └─system.slice

Verified that the simplified symlink was correct for default.target.

bash-5.0# ls -latr /usr/lib/systemd/system/default.target
lrwxrwxrwx. 1 root root 20 Jan  4 01:39 /usr/lib/systemd/system/default.target -> preconfigured.target

Verified that the two services can't be manually restarted:

bash-5.0# systemctl restart prepare-local selinux-policy-files
Failed to restart prepare-local.service: Operation refused, unit prepare-local.service may be requested by dependency only (it is configured to refuse manual start/stop).
See system logs and 'systemctl status prepare-local.service' for details.
Failed to restart selinux-policy-files.service: Operation refused, unit selinux-policy-files.service may be requested by dependency only (it is configured to refuse manual start/stop).
See system logs and 'systemctl status selinux-policy-files.service' for details.

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
Copy link
Contributor

@zmrow zmrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕹️

In order for `setfiles` to work, the SELinux file contexts must have
been copied into `/etc`.

The dependency is specified with "Wants" rather than "Requires" to
avoid restarting the service if selinux-policy-files is restarted for
any reason. Subsequent runs would fail and put the system in a bad
state until the next reboot.

Add RefuseManualStop / RefuseManualStart to both services to indicate
the risk during interactive use by an administrator.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
@bcressey
Copy link
Contributor Author

bcressey commented Jan 6, 2022

The above change switches to Wants rather than Requires since the latter means that we'd attempt to re-run prepare-local.service if selinux-policy-files.service is ever restarted, and it's not supposed to run more than once.

I've also added RefuseManualStop / RefuseManualStart to these two oneshots to deter restarts.

Copy link
Contributor

@zmrow zmrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔩

@bcressey bcressey merged commit d8698d9 into bottlerocket-os:develop Jan 6, 2022
@bcressey bcressey deleted the release-fixes branch January 6, 2022 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants