Skip to content

Catch invalid root user kickstart options early [HMS-9378]#1879

Merged
supakeen merged 6 commits into
osbuild:mainfrom
achilleas-k:fix/catch-invalid-root-user-kickstart-early
Oct 9, 2025
Merged

Catch invalid root user kickstart options early [HMS-9378]#1879
supakeen merged 6 commits into
osbuild:mainfrom
achilleas-k:fix/catch-invalid-root-user-kickstart-early

Conversation

@achilleas-k

Copy link
Copy Markdown
Member

In #1806 I changed the behaviour of the kickstart stage so that it returns errors when unsupported root user options are specified. I knew this might cause issues with old working blueprints becoming invalid, but I decided (and I think we all agreed) that errors are preferable to options being silently ignored.

This is now causing panic()s during serialization of stages that write kickstart files, because we currently don't return errors from the serialize() functions in pipelines (see below).

https://github.com/osbuild/images/blob/0a3a48f4bc8ec382d7e31f69535488cbb1e27fc2/pkg/manifest/anaconda_installer_iso_tree.go#L553-L565

This PR adds the same validation earlier in the pipeline generation, in the kickstart.New() function that is called by the manifest instantiation functions. This makes it possible to return an error early instead of causing a panic during serialization.

I think it's generally valid to have the same or similar checks in two places, since the osbuild package can work on its own as an interface for stages. It would be nice if we could unify the checks somehow, but that's an exercise for later, if it would be possible.

I considered putting these checks in the CheckOptions() function(s) as well, but that requires knowing which image type uses kickstarts, and that information isn't available right now (BootISO is true for the ostree-simplified-installers, which don't use kickstarts).

Another solution here would be if we moved user creation out of kickstarts and into the root tree itself for the image installer, but that's a much bigger change that would require some thought. One issue with that change, off the top of my head, is that it could create problems if the same user that's been created in the image already is also set during installation.

@achilleas-k achilleas-k requested a review from a team as a code owner September 17, 2025 18:34
}
}

// This check repeats the same checks that are made in the kickstart stage

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Quick drive-by: can move the checks into a shared helper somehow maybe? It worries me that we have two places now that (almost) do the same thing, it will most likely cause drift if/when we add more checks to one place.

Or we could look at the root of the problem and make serialize() return an error (probably a much bigger PR though)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Quick drive-by: can move the checks into a shared helper somehow maybe? It worries me that we have two places now that (almost) do the same thing, it will most likely cause drift if/when we add more checks to one place.

Yeah I mentioned as much in the PR description, but I couldn't think of an obvious way to do it nicely since they're different types.

Or we could look at the root of the problem and make serialize() return an error (probably a much bigger PR though)

Yes, we should get on this.

Make the Path option in the kickstart stage constructors required and
validate it.
The path was always required in the underlying stage schema, but we
never checked for it here.  This catches problems earlier in the
manifest generation.
@achilleas-k achilleas-k force-pushed the fix/catch-invalid-root-user-kickstart-early branch from b3f8a6a to 247b6c6 Compare September 22, 2025 10:56
Add two tests to each AnacondaISOTree variant test:
- One with a valid user customization in the kickstart.
- One with an invalid root user customization in the kickstart.
The previous message was accidentally set to the same as the container
case.
Validate root user options when creating internal kickstart
customizations from a blueprint.
These validations replicate the same checks made in the kickstart stage
option creation, but by having them here we can catch invalid
customizations earlier and provide better error reporting.
@achilleas-k achilleas-k force-pushed the fix/catch-invalid-root-user-kickstart-early branch from 247b6c6 to 4f76acf Compare September 22, 2025 12:35
@achilleas-k

Copy link
Copy Markdown
Member Author

Rebased and fixed the tests. Also fixed an error message from the other PR.

@thozza thozza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. I think that the validation code duplication is acceptable in this case.

@thozza thozza requested review from supakeen and removed request for lzap October 9, 2025 06:58
@supakeen supakeen added this pull request to the merge queue Oct 9, 2025
Merged via the queue into osbuild:main with commit a4c6d93 Oct 9, 2025
25 checks passed
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.

4 participants