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

[teleport-update] Adjustments for SELinux #51474

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

sclevine
Copy link
Member

@sclevine sclevine commented Jan 24, 2025

This PR adjusts teleport-update to avoid issues with default SELinux configuration.

These changes are based on research and testing by @vapopov.

When service files are copied atomically using renameio, the initial temporary location adds SELinux contexts that make the file unreadable by systemctl:

# ls -lahZ /lib/systemd/system/teleport.service
-rw-r--r--. 1 root root unconfined_u:object_r:user_tmp_t:s0 436 Jan 22 19:34 /lib/systemd/system/teleport.service

This PR adjusts renameio to use the same target directory when this is relevant:

# ls -lahZ /lib/systemd/system/teleport.service
-rw-r--r--. 1 root root unconfined_u:object_r:systemd_unit_file_t:s0 436 Jan 23 15:28 /lib/systemd/system/teleport.service

These temporarily files are created in the format /etc/systemd/system/.teleport.service1234. This does not appear to interfere with systemd or systemctl.

This PR also adds various checks to make sure that the systemd service file is readable during initial install and update.


The teleport-update binary will be used to enable, disable, and trigger automatic Teleport agent updates. The new auto-updates system manages a local installation of the cluster-specified version of Teleport stored in /opt/teleport.

RFD: #47126
Goal (internal): https://github.com/gravitational/cloud/issues/10289

@vapopov
Copy link
Contributor

vapopov commented Jan 24, 2025

verified on RHEL 9.5

[root@vbox teleport]# ./build/teleport-update link-package
2025-01-23T15:28:43.156-08:00 INFO [UPDATER]   Validating binary name:fdpass-teleport agent/validate.go:68
2025-01-23T15:28:43.159-08:00 INFO [UPDATER]   Binary does not support version command name:fdpass-teleport agent/validate.go:79
2025-01-23T15:28:43.160-08:00 INFO [UPDATER]   Validating binary name:tbot agent/validate.go:68
2025-01-23T15:28:43.184-08:00 INFO [UPDATER]   [stdout] Teleport v17.2.2 git:v17.2.2-0-g61667e2 go1.23.5 agent/logger.go:69
2025-01-23T15:28:43.187-08:00 INFO [UPDATER]   Validating binary name:tctl agent/validate.go:68
2025-01-23T15:28:43.213-08:00 INFO [UPDATER]   [stdout] Teleport v17.2.2 git:v17.2.2-0-g61667e2 go1.23.5 agent/logger.go:69
2025-01-23T15:28:43.216-08:00 INFO [UPDATER]   Validating binary name:teleport agent/validate.go:68
2025-01-23T15:28:43.602-08:00 INFO [UPDATER]   [stdout] Teleport v17.2.2 git:v17.2.2-0-g61667e2 go1.23.5 agent/logger.go:69
2025-01-23T15:28:43.608-08:00 INFO [UPDATER]   Validating binary name:tsh agent/validate.go:68
2025-01-23T15:28:43.694-08:00 INFO [UPDATER]   [stdout] Teleport v17.2.2 git:v17.2.2-0-g61667e2 go1.23.5 agent/logger.go:69
2025-01-23T15:28:43.862-08:00 INFO [UPDATER]   Systemd configuration synced. unit:teleport.service agent/process.go:259
2025-01-23T15:28:43.862-08:00 INFO [UPDATER]   Successfully linked system package installation. agent/updater.go:799

[root@vbox teleport]# ls -lahZ /usr/lib/systemd/system/teleport.service
-rw-r--r--. 1 root root unconfined_u:object_r:systemd_unit_file_t:s0 436 Jan 23 15:28 /usr/lib/systemd/system/teleport.service

[root@vbox teleport]# systemctl status teleport
● teleport.service - Teleport Service

@sclevine sclevine force-pushed the sclevine/autoupdates-selinux branch from be9e382 to ae0889e Compare January 24, 2025 23:04
@sclevine sclevine marked this pull request as ready for review January 24, 2025 23:31
@sclevine sclevine requested review from hugoShaka and vapopov January 24, 2025 23:32
@sclevine sclevine added no-changelog Indicates that a PR does not require a changelog entry teleport-update labels Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Indicates that a PR does not require a changelog entry size/md teleport-update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants