Commit b9806f6
Roy Lin
fix(box): base64-encode exec args/env so quotes survive libkrun env passing
A container command or env value containing a double-quote was corrupted reaching
the guest: `a3s-box run alpine -- sh -c 'echo "a b"'` failed with the guest sh
reporting 'unterminated quoted string' (plain spaces and quote-free values were
fine). a3s-box passes the command byte-clean end-to-end (cmd Vec<String> -> one
BOX_EXEC_ARG_<i> env var each -> clean KEY=VALUE CStrings -> krun_set_exec), so
the corruption is in libkrun/libkrunfw's env delivery to guest PID 1 — the same
layer whose space-truncation quirk the per-arg BOX_EXEC_ARG design already works
around.
Work around it completely at the a3s-box layer: the runtime now base64-encodes
(URL-safe, no padding — A-Za-z0-9-_ only) the BOX_EXEC_EXEC / ARG_<i> / WORKDIR /
USER / ENV_<k> VALUES and sets BOX_EXEC_B64=1; guest-init decodes them in
ExecConfig::from_env (falling back to the raw value if the marker is absent or a
value fails to decode, so old runtime + new guest still works). base64 contains
no byte that libkrun mishandles, so any container command/env now reaches the
container exactly as written.
Found by comprehensive real-OCI testing. clippy -D warnings clean on runtime +
x86_64-unknown-linux-musl. KVM verification (the repro + no regression) to follow.1 parent 8589a5d commit b9806f6
2 files changed
Lines changed: 44 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
250 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
251 | 270 | | |
252 | 271 | | |
253 | 272 | | |
254 | 273 | | |
255 | 274 | | |
256 | 275 | | |
257 | 276 | | |
258 | | - | |
| 277 | + | |
259 | 278 | | |
260 | 279 | | |
261 | 280 | | |
262 | 281 | | |
263 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
264 | 285 | | |
265 | 286 | | |
266 | 287 | | |
267 | 288 | | |
| 289 | + | |
268 | 290 | | |
269 | 291 | | |
270 | | - | |
| 292 | + | |
271 | 293 | | |
272 | 294 | | |
273 | 295 | | |
274 | | - | |
| 296 | + | |
275 | 297 | | |
276 | 298 | | |
277 | 299 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
138 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
139 | 144 | | |
140 | | - | |
| 145 | + | |
| 146 | + | |
141 | 147 | | |
142 | 148 | | |
143 | 149 | | |
144 | | - | |
| 150 | + | |
145 | 151 | | |
146 | 152 | | |
147 | 153 | | |
| |||
157 | 163 | | |
158 | 164 | | |
159 | 165 | | |
160 | | - | |
| 166 | + | |
161 | 167 | | |
162 | 168 | | |
163 | 169 | | |
164 | 170 | | |
165 | 171 | | |
166 | 172 | | |
167 | 173 | | |
168 | | - | |
| 174 | + | |
169 | 175 | | |
170 | 176 | | |
171 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
172 | 181 | | |
173 | | - | |
| 182 | + | |
174 | 183 | | |
175 | 184 | | |
176 | 185 | | |
| |||
0 commit comments