-
Notifications
You must be signed in to change notification settings - Fork 109
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
stages: ensure we do not allow \n in the ssh key or anaconda breaks #1772
Conversation
There was a bug found in osbuild/bootc-image-builder#363 where a stray newlnine in the ssh key broke the kickstart file.
We've had the |
Closing for now based on the comment from achilleas |
I looked into this a bit now, if a user passed a config that contains a "\n" in the json it would result in the following. Here is a test that shows what happens (note the \n at the end of "some-ssh-key" in the test input):
so this was never valid input and would always break the kickstart file. I have no strong opinion here fwiw, I am happy to also fix this implicitly via eg. diff --git a/stages/org.osbuild.kickstart b/stages/org.osbuild.kickstart
index 21d03ace..3a84c4b5 100755
--- a/stages/org.osbuild.kickstart
+++ b/stages/org.osbuild.kickstart
@@ -62,7 +62,7 @@ def make_users(users: Dict) -> List[str]:
key = opts.get("key")
if key:
- res.append(f'sshkey --username {name} "{key}"')
+ res.append(f'sshkey --username {name} "{key.strip()}"')
return res
diff --git a/stages/test/test_kickstart.py b/stages/test/test_kickstart.py
index 9bd65ef6..6aaab4ee 100644
--- a/stages/test/test_kickstart.py
+++ b/stages/test/test_kickstart.py
@@ -241,6 +241,8 @@ TEST_INPUT = [
({"ostreecontainer": {"transport": "dir", "url": "/run/install/repo/container", }, },
"ostreecontainer --url=/run/install/repo/container --transport=dir",),
({"bootloader": {"append": "karg1 karg2=0"}}, "bootloader --append='karg1 karg2=0'"),
+ ({"users": {"foo": {"key": "some-ssh-key\n"}}},
+ 'sshkey --username foo "some-ssh-key"'),
]
|
Stripping is a good idea, I think. I'm curious, does |
Without passing value judgement I just want to point out that it is OK to narrow the schema if the previous schema could not lead to any valid image (which I think is what @achilleas-k is also trying to figure out) :) |
Yes, exactly :) |
I did a bit of research, so pykickstart is really about single lines (unless But maybe a different idea is more fruitful, I opened #1789 with the idea to just run |
Closing for now as there seems to be no clear consensus that this is the right fix (and #1789 may actually be a nicer way to solve the general issue even if only at build time instead of statically). |
There was a bug found in
osbuild/bootc-image-builder#363
where a stray newlnine in the ssh key broke the kickstart file.