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

Always pass -a "${VOLUME}" and -s "Nix Store" to macOS volume stuff #1418

Merged
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
5 changes: 3 additions & 2 deletions src/action/macos/create_volume_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
execute_command,
};

use super::get_disk_info_for_label;
use super::{get_disk_info_for_label, KEYCHAIN_NIX_STORE_SERVICE};

/** Create a plist for a `launchctl` service to mount the given `apfs_volume_label` on the given `mount_point`.
*/
Expand Down Expand Up @@ -265,10 +265,11 @@ async fn generate_mount_plist(
encrypt: bool,
) -> Result<LaunchctlMountPlist, ActionErrorKind> {
let apfs_volume_label_with_quotes = format!("\"{apfs_volume_label}\"");
let nix_store_with_quotes = format!("\"{KEYCHAIN_NIX_STORE_SERVICE}\"");
// The official Nix scripts uppercase the UUID, so we do as well for compatibility.
let uuid_string = uuid.to_string().to_uppercase();
let mount_command = if encrypt {
let encrypted_command = format!("/usr/bin/security find-generic-password -s {apfs_volume_label_with_quotes} -w | /usr/sbin/diskutil apfs unlockVolume {apfs_volume_label_with_quotes} -mountpoint {mount_point:?} -stdinpassphrase");
let encrypted_command = format!("/usr/bin/security find-generic-password -a {apfs_volume_label_with_quotes} -s {nix_store_with_quotes} -w | /usr/sbin/diskutil apfs unlockVolume {apfs_volume_label_with_quotes} -mountpoint {mount_point:?} -stdinpassphrase");
vec!["/bin/sh".into(), "-c".into(), encrypted_command]
} else {
vec![
Expand Down
8 changes: 4 additions & 4 deletions src/action/macos/encrypt_apfs_volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{
use tokio::{io::AsyncWriteExt as _, process::Command};
use tracing::{span, Span};

use super::CreateApfsVolume;
use super::{CreateApfsVolume, KEYCHAIN_NIX_STORE_SERVICE};

/**
Encrypt an APFS volume
Expand Down Expand Up @@ -44,7 +44,7 @@ impl EncryptApfsVolume {
command.args(["find-generic-password", "-a"]);
command.arg(&name);
command.arg("-s");
command.arg("Nix Store");
command.arg(KEYCHAIN_NIX_STORE_SERVICE);
command.arg("-l");
command.arg(format!("{} encryption password", disk.display()));
command.arg("-D");
Expand Down Expand Up @@ -207,7 +207,7 @@ impl Action for EncryptApfsVolume {
"-a",
self.name.as_str(),
"-s",
"Nix Store",
KEYCHAIN_NIX_STORE_SERVICE,
"-l",
format!("{} encryption password", disk_str).as_str(),
"-D",
Expand Down Expand Up @@ -324,7 +324,7 @@ impl Action for EncryptApfsVolume {
"-a",
self.name.as_str(),
"-s",
self.name.as_str(),
KEYCHAIN_NIX_STORE_SERVICE,
"-l",
format!("{} encryption password", disk_str).as_str(),
"-D",
Expand Down
1 change: 1 addition & 0 deletions src/action/macos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ use crate::execute_command;
use super::ActionErrorKind;

pub const DARWIN_LAUNCHD_DOMAIN: &str = "system";
pub const KEYCHAIN_NIX_STORE_SERVICE: &str = "Nix Store";

pub(crate) async fn get_disk_info_for_label(
apfs_volume_label: &str,
Expand Down
Loading