Commit 3739258
authored
fix(entrypoint): relax config permissions before write after CAP_DAC_OVERRIDE drop (#2659)
## Summary
Fix the `test/e2e/test-runtime-overrides.sh` E2E crash at baseline
config capture. After PR #917 drops `CAP_DAC_OVERRIDE` via `capsh`, root
can no longer write to 444-mode config files. The three runtime override
functions (`apply_model_override`, `apply_cors_override`,
`apply_slack_token_override`) now temporarily relax permissions to 644
before writing and re-lock to 444 afterward, using `CAP_FOWNER` which is
retained by design.
## Related Issue
Fixes #2653
## Changes
- **`scripts/lib/sandbox-init.sh`**: Add `relax_config_for_write()` /
`lock_config_after_write()` shared helpers that `chmod 644`/`chmod 444`
with symlink guards
- **`scripts/nemoclaw-start.sh`**: Wrap python3 write + hash
recomputation in all three override functions with the new helpers
- **`scripts/nemoclaw-start.sh`**: Tighten `apply_model_override()`
trigger guard — only fire when `NEMOCLAW_MODEL_OVERRIDE` or
`NEMOCLAW_INFERENCE_API_OVERRIDE` is explicitly set (Dockerfile ENV
defaults no longer trigger spurious override runs)
- **`test/e2e/test-runtime-overrides.sh`**: Create timestamped log file
matching CI artifact glob `test-runtime-overrides-*.log`, replace all
`2>/dev/null` with `2>>"$LOG_FILE"`
- **`test/e2e/test-runtime-overrides.sh`**: Update tests 3-5, 9-11, 14
to pair standalone parameters with `NEMOCLAW_MODEL_OVERRIDE` (matching
the tightened trigger guard)
## Type of Change
- [x] Code change (feature, bug fix, or refactor)
- [ ] Code change with doc updates
- [ ] Doc only (prose changes, no code sample modifications)
- [ ] Doc only (includes code sample changes)
## Verification
- [ ] `npx prek run --all-files` passes
- [x] `npm test` passes
- [x] Tests added or updated for new or changed behavior
- [x] No secrets, API keys, or credentials committed
- [ ] Docs updated for user-facing behavior changes
- [ ] `make docs` builds without warnings (doc changes only)
- [ ] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)
## AI Disclosure
- [x] AI-assisted — tool: Claude Code (pi agent)
---
Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Overrides now only apply when explicit override flags are set,
preventing unintended changes.
* Safer config writes: permissions are temporarily relaxed with strict
safety checks (rejecting unsafe targets, skipping missing files), clear
security errors on failure, recompute verification only on successful
writes, and permissions are always restored; write/hash failures are
surfaced.
* **Tests**
* Improved test logging with timestamped artifacts and preserved stderr;
runtime override tests updated to cover model-override scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>1 parent 04ea838 commit 3739258
4 files changed
Lines changed: 143 additions & 32 deletions
File tree
- scripts
- lib
- test
- e2e
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
146 | 192 | | |
147 | 193 | | |
148 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
197 | 201 | | |
198 | 202 | | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
| |||
272 | 273 | | |
273 | 274 | | |
274 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
275 | 281 | | |
276 | 282 | | |
277 | 283 | | |
278 | | - | |
| 284 | + | |
279 | 285 | | |
280 | 286 | | |
281 | 287 | | |
| |||
311 | 317 | | |
312 | 318 | | |
313 | 319 | | |
314 | | - | |
315 | | - | |
316 | | - | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
317 | 332 | | |
318 | 333 | | |
319 | 334 | | |
| |||
356 | 371 | | |
357 | 372 | | |
358 | 373 | | |
359 | | - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
360 | 380 | | |
361 | 381 | | |
362 | 382 | | |
| |||
373 | 393 | | |
374 | 394 | | |
375 | 395 | | |
376 | | - | |
377 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
378 | 407 | | |
379 | 408 | | |
380 | 409 | | |
| |||
431 | 460 | | |
432 | 461 | | |
433 | 462 | | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
434 | 468 | | |
435 | 469 | | |
436 | | - | |
| 470 | + | |
437 | 471 | | |
438 | 472 | | |
439 | 473 | | |
| |||
463 | 497 | | |
464 | 498 | | |
465 | 499 | | |
466 | | - | |
467 | | - | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
468 | 511 | | |
469 | 512 | | |
470 | 513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
39 | 47 | | |
40 | 48 | | |
41 | 49 | | |
| 50 | + | |
42 | 51 | | |
43 | 52 | | |
44 | 53 | | |
45 | | - | |
| 54 | + | |
46 | 55 | | |
47 | 56 | | |
48 | 57 | | |
| |||
53 | 62 | | |
54 | 63 | | |
55 | 64 | | |
| 65 | + | |
| 66 | + | |
56 | 67 | | |
57 | 68 | | |
58 | 69 | | |
| |||
83 | 94 | | |
84 | 95 | | |
85 | 96 | | |
86 | | - | |
| 97 | + | |
87 | 98 | | |
88 | 99 | | |
89 | 100 | | |
| |||
104 | 115 | | |
105 | 116 | | |
106 | 117 | | |
107 | | - | |
| 118 | + | |
108 | 119 | | |
109 | 120 | | |
110 | 121 | | |
111 | 122 | | |
112 | 123 | | |
113 | 124 | | |
114 | 125 | | |
| 126 | + | |
| 127 | + | |
115 | 128 | | |
116 | | - | |
117 | | - | |
| 129 | + | |
| 130 | + | |
118 | 131 | | |
119 | 132 | | |
120 | 133 | | |
| |||
124 | 137 | | |
125 | 138 | | |
126 | 139 | | |
127 | | - | |
128 | | - | |
| 140 | + | |
| 141 | + | |
129 | 142 | | |
130 | 143 | | |
131 | 144 | | |
| |||
135 | 148 | | |
136 | 149 | | |
137 | 150 | | |
138 | | - | |
139 | | - | |
| 151 | + | |
| 152 | + | |
140 | 153 | | |
141 | 154 | | |
142 | 155 | | |
| |||
190 | 203 | | |
191 | 204 | | |
192 | 205 | | |
193 | | - | |
| 206 | + | |
194 | 207 | | |
195 | 208 | | |
196 | 209 | | |
197 | 210 | | |
198 | 211 | | |
199 | 212 | | |
200 | 213 | | |
201 | | - | |
| 214 | + | |
202 | 215 | | |
203 | 216 | | |
204 | 217 | | |
205 | 218 | | |
206 | 219 | | |
207 | 220 | | |
208 | 221 | | |
209 | | - | |
| 222 | + | |
210 | 223 | | |
211 | 224 | | |
212 | 225 | | |
| |||
232 | 245 | | |
233 | 246 | | |
234 | 247 | | |
235 | | - | |
| 248 | + | |
236 | 249 | | |
237 | 250 | | |
238 | 251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
404 | | - | |
| 404 | + | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
408 | 411 | | |
409 | 412 | | |
410 | 413 | | |
411 | | - | |
412 | | - | |
413 | | - | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
414 | 423 | | |
415 | 424 | | |
416 | 425 | | |
| |||
0 commit comments