* Added an Audit step for FreeBSD and DragonFly. Allows for auditing the packages to be disabled since they are breaking steps. Current behaivor is the default, where if the audit fails topgrade stops. Can be disabled in the [misc] section independenly from other sections
35 lines
1.1 KiB
Rust
35 lines
1.1 KiB
Rust
use crate::command::CommandExt;
|
|
use crate::execution_context::ExecutionContext;
|
|
use crate::terminal::print_separator;
|
|
use crate::utils::{require_option, REQUIRE_SUDO};
|
|
use crate::Step;
|
|
use color_eyre::eyre::Result;
|
|
use std::process::Command;
|
|
|
|
pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
|
|
let sudo = require_option(ctx.sudo().as_ref(), REQUIRE_SUDO.to_string())?;
|
|
print_separator("DragonFly BSD Packages");
|
|
let mut cmd = ctx.run_type().execute(sudo);
|
|
cmd.args(["/usr/local/sbin/pkg", "upgrade"]);
|
|
if ctx.config().yes(Step::System) {
|
|
cmd.arg("-y");
|
|
}
|
|
cmd.status_checked()
|
|
}
|
|
|
|
pub fn audit_packages(ctx: &ExecutionContext) -> Result<()> {
|
|
let sudo = require_option(ctx.sudo().as_ref(), REQUIRE_SUDO.to_string())?;
|
|
|
|
print_separator("DragonFly BSD Audit");
|
|
|
|
#[allow(clippy::disallowed_methods)]
|
|
if !Command::new(sudo)
|
|
.args(["/usr/local/sbin/pkg", "audit", "-Fr"])
|
|
.status()?
|
|
.success()
|
|
{
|
|
println!("The package audit was successful, but vulnerable packages still remain on the system");
|
|
}
|
|
Ok(())
|
|
}
|