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

Remove RHC credentials from the system after registration (HMS-3814) #627

Merged
merged 9 commits into from
Apr 25, 2024

Conversation

achilleas-k
Copy link
Member

This PR swaps out the org.osbuild.first-boot stage with an org.osbuild.systemd.unit.create stage that runs the same commands and explicitly adds the rm command for the condition file as the last command. The file name and service description are changed to describe the purpose of the service.

The stage is functionally identical with the previous one with one main difference: the organisation ID and the activation key are not included in the service file but in a separate environment file in /etc which also acts as the condition file and gets removed after the service runs for the first time.

Not that on ostree-based systems, putting the environment file in /etc prior to building the commit and then rming it on boot means that the file remains in /usr/etc, in the base system, until a system update removes it.

thozza
thozza previously approved these changes Apr 23, 2024
Copy link
Member

@thozza thozza left a comment

Choose a reason for hiding this comment

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

LGTM. I've added one suggestion.

cmd/build/main.go Outdated Show resolved Hide resolved
Add the distro.ImageOptions struct to the build configs used by the
build and gen-manifests commands.
Annotate it with json tags to control the serialised keys.
Move "ostree" under "options".
Update test scripts that read or set configs to follow the new
structure.
The function was incorrectly named New...StageOptions but it was
creating a Stage.
Update the options of the org.osbuild.systemd.unit.create stage with the
new After option.
Replace the org.osbuild.first-boot stage with an
org.osbuild.systemd.unit.create stage that runs the same commands.  Add
the 'rm' command that gets added by the first-boot stage, but put it at
the end.

Also, unlike the service created by osbuild's first-boot stage, our
current service also includes an install section.

The file name and service description are changed to describe the
purpose of the service.

Otherwise the two are functionally identical.
Create the file in /etc that will act as both the EnvironmentFile and
the ConditionPathExists for the service.  This file includes the org ID
and activation key.  When the service runs, the file is removed so that
the service doesn't run again (only runs on first boot) and the org ID
and key are removed from the system.

Rename the file to osbuild-subscription-register.env to make its purpose
clearer.
Update subscription stage tests to match the commands run by the
systemd.unit.create stage (was first-boot).
Prepend the rm command to all command lists passed to the
CheckSystemdStageOptions() function and verify the ConditionPathExists
value and the file being rm-ed are the same.
Copy link
Member

@thozza thozza left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@achilleas-k achilleas-k added this pull request to the merge queue Apr 25, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 25, 2024
@achilleas-k
Copy link
Member Author

This will need to be rebased once #632 is merged.

@achilleas-k achilleas-k added this pull request to the merge queue Apr 25, 2024
Merged via the queue into osbuild:main with commit b6e4e16 Apr 25, 2024
16 checks passed
@achilleas-k achilleas-k deleted the rhc-env branch April 26, 2024 13:55
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.

None yet

3 participants