Skip to content

Commit

Permalink
nspawn: and also add comment, making clear chdir() should come late
Browse files Browse the repository at this point in the history
  • Loading branch information
poettering committed Feb 6, 2024
1 parent f94025a commit 83d5dab
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/nspawn/nspawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -3522,6 +3522,9 @@ static int inner_child(
if (!barrier_place_and_sync(barrier)) /* #5 */
return log_error_errno(SYNTHETIC_ERRNO(ESRCH), "Parent died too early");

/* Note, this should be done this late (💣 and not moved earlier! 💣), so that all namespacing
* changes are already in effect by now, so that any resolved paths here definitely reference
* resources inside the container, and not outside of them. */
if (arg_chdir)
if (chdir(arg_chdir) < 0)
return log_error_errno(errno, "Failed to change to specified working directory %s: %m", arg_chdir);
Expand Down

0 comments on commit 83d5dab

Please sign in to comment.