Skip to content

Commit 64370c4

Browse files
committed
install: Move re-exec earlier
As the comment says everything we do before `prepare_install` is something we might do *twice* so let's keep it as early as possible. Looking at the history of this code (and its logical inputs) I believe there's no reason for its placement in the middle of this function other than just "stuff appeared before it organically". Yes, it means some argument validation will happen after the re-exec but that's fine. Signed-off-by: Colin Walters <[email protected]>
1 parent 3604dbb commit 64370c4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/src/install.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,13 @@ pub(crate) async fn install_to_filesystem(
16361636
opts: InstallToFilesystemOpts,
16371637
targeting_host_root: bool,
16381638
) -> Result<()> {
1639+
// Gather global state, destructuring the provided options.
1640+
// IMPORTANT: We might re-execute the current process in this function (for SELinux among other things)
1641+
// IMPORTANT: and hence anything that is done before MUST BE IDEMPOTENT.
1642+
// IMPORTANT: In practice, we should only be gathering information before this point,
1643+
// IMPORTANT: and not performing any mutations at all.
1644+
let state = prepare_install(opts.config_opts, opts.source_opts, opts.target_opts).await?;
1645+
// And the last bit of state here is the fsopts, which we also destructure now.
16391646
let mut fsopts = opts.filesystem_opts;
16401647

16411648
// Check that the target is a directory
@@ -1674,13 +1681,6 @@ pub(crate) async fn install_to_filesystem(
16741681
rootfs_fd
16751682
};
16761683

1677-
// Gather global state, destructuring the provided options.
1678-
// IMPORTANT: We might re-execute the current process in this function (for SELinux among other things)
1679-
// IMPORTANT: and hence anything that is done before MUST BE IDEMPOTENT.
1680-
// IMPORTANT: In practice, we should only be gathering information before this point,
1681-
// IMPORTANT: and not performing any mutations at all.
1682-
let state = prepare_install(opts.config_opts, opts.source_opts, opts.target_opts).await?;
1683-
16841684
// Check to see if this happens to be the real host root
16851685
if !fsopts.acknowledge_destructive {
16861686
warn_on_host_root(&rootfs_fd)?;

0 commit comments

Comments
 (0)