Detect fdesetup properly (#361)

This commit is contained in:
Ana Hobden 2023-03-22 10:59:04 -07:00 committed by GitHub
parent 9ab29d5e36
commit 11834a3aab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -107,17 +107,21 @@ impl Planner for Macos {
};
let encrypt = if self.encrypt == None {
Command::new("/usr/bin/fdesetup")
let output = Command::new("/usr/bin/fdesetup")
.arg("isactive")
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.process_group(0)
.status()
.output()
.await
.map_err(|e| PlannerError::Custom(Box::new(e)))?
.code()
.map(|v| if v == 0 { false } else { true })
.unwrap_or(false)
.map_err(|e| PlannerError::Custom(Box::new(e)))?;
let stdout = String::from_utf8_lossy(&output.stdout);
if stdout == "true" {
true
} else {
false
}
} else {
false
};