Use the right magic sauce in the mount command

This commit is contained in:
Ana Hobden 2022-11-02 09:10:44 -07:00
parent 997364ad41
commit e079f3ade0
2 changed files with 13 additions and 20 deletions

View file

@ -80,26 +80,18 @@ impl CreateApfsVolume {
};
let name_with_qoutes = format!("\"{name}\"");
let encrypted_command;
let mount_command = if encrypt {
vec![
"/bin/sh",
"-c",
"/usr/bin/security",
"find-generic-password",
"-s",
name_with_qoutes.as_str(),
"-w",
"|",
"/usr/sbin/diskutil",
"apfs",
"unlockVolume",
&name,
"-mountpoint",
"/nix",
"-stdinpassphrase",
]
encrypted_command = format!("/usr/bin/security find-generic-password -s {name_with_qoutes} -w | /usr/sbin/diskutil apfs unlockVolume {name_with_qoutes} -mountpoint /nix -stdinpassphrase");
vec!["/bin/sh", "-c", encrypted_command.as_str()]
} else {
vec!["/usr/sbin/diskutil", "mount", "-mountPoint", "/nix", &name]
vec![
"/usr/sbin/diskutil",
"mount",
"-mountPoint",
"/nix",
name_with_qoutes.as_str(),
]
};
// TODO(@hoverbear): Use plist lib we have in tree...
let mount_plist = format!(

View file

@ -82,9 +82,10 @@ impl Planner for DarwinMulti {
};
if self.volume_encrypt == false {
self.volume_encrypt = execute_command(Command::new("/usr/bin/fdesetup").arg("isactive"))
self.volume_encrypt = Command::new("/usr/bin/fdesetup")
.arg("isactive")
.status()
.await?
.status
.code()
.map(|v| if v == 0 { false } else { true })
.unwrap_or(false)