Skip to content
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

Don't delete encryption password until volume deletion succeeds #1306

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions src/action/macos/create_determinate_nix_volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,37 +301,55 @@ impl Action for CreateDeterminateNixVolume {
let mut errors = vec![];

if let Err(err) = self.enable_ownership.try_revert().await {
errors.push(err)
};
errors.push(err);
}

if let Err(err) = self.kickstart_launchctl_service.try_revert().await {
errors.push(err)
errors.push(err);
}

if let Err(err) = self.bootstrap_volume.try_revert().await {
errors.push(err)
errors.push(err);
}

if let Err(err) = self.setup_volume_daemon.try_revert().await {
errors.push(err)
}
if let Err(err) = self.encrypt_volume.try_revert().await {
errors.push(err)
errors.push(err);
}

if let Err(err) = self.create_fstab_entry.try_revert().await {
errors.push(err)
errors.push(err);
}

if let Err(err) = self.unmount_volume.try_revert().await {
errors.push(err)
errors.push(err);
}

let mut revert_create_volume_failed = false;
if let Err(err) = self.create_volume.try_revert().await {
errors.push(err)
revert_create_volume_failed = true;
errors.push(err);
}

// Intentionally happens after the create_volume step so we can avoid deleting the
// encryption password if volume deletion failed
if revert_create_volume_failed {
tracing::debug!(
"Not reverting encrypt_volume step (which would delete the disk encryption \
password) because deleting the volume failed"
);
} else {
if let Err(err) = self.encrypt_volume.try_revert().await {
errors.push(err);
}
}

// Purposefully not reversed
if let Err(err) = self.create_or_append_synthetic_conf.try_revert().await {
errors.push(err)
errors.push(err);
}

if let Err(err) = self.create_synthetic_objects.try_revert().await {
errors.push(err)
errors.push(err);
}

if let Err(err) = self.create_directory.try_revert().await {
Expand Down
47 changes: 32 additions & 15 deletions src/action/macos/create_nix_volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,40 +273,57 @@ impl Action for CreateNixVolume {
let mut errors = vec![];

if let Err(err) = self.enable_ownership.try_revert().await {
errors.push(err)
};
errors.push(err);
}

if let Err(err) = self.kickstart_launchctl_service.try_revert().await {
errors.push(err)
errors.push(err);
}

if let Err(err) = self.bootstrap_volume.try_revert().await {
errors.push(err)
errors.push(err);
}

if let Err(err) = self.setup_volume_daemon.try_revert().await {
errors.push(err)
errors.push(err);
}

if let Some(encrypt_volume) = &mut self.encrypt_volume {
if let Err(err) = encrypt_volume.try_revert().await {
errors.push(err)
}
}
if let Err(err) = self.create_fstab_entry.try_revert().await {
errors.push(err)
errors.push(err);
}

if let Err(err) = self.unmount_volume.try_revert().await {
errors.push(err)
errors.push(err);
}

let mut revert_create_volume_failed = false;
if let Err(err) = self.create_volume.try_revert().await {
errors.push(err)
revert_create_volume_failed = true;
errors.push(err);
}

// Intentionally happens after the create_volume step so we can avoid deleting the
// encryption password if volume deletion failed
if let Some(encrypt_volume) = &mut self.encrypt_volume {
if revert_create_volume_failed {
tracing::debug!(
"Not reverting encrypt_volume step (which would delete the disk encryption \
password) because deleting the volume failed"
);
} else {
if let Err(err) = encrypt_volume.try_revert().await {
errors.push(err);
}
}
}

// Purposefully not reversed
if let Err(err) = self.create_or_append_synthetic_conf.try_revert().await {
errors.push(err)
errors.push(err);
}

if let Err(err) = self.create_synthetic_objects.try_revert().await {
errors.push(err)
errors.push(err);
}

if errors.is_empty() {
Expand Down
Loading