fix: remove sudo from apt commands and RestrictSUIDSGID from service
All checks were successful
CI/CD Pipeline / Code Format (push) Successful in 2s
CI/CD Pipeline / Clippy Lints (push) Successful in 1m17s
CI/CD Pipeline / Unit Tests (push) Successful in 56s
CI/CD Pipeline / Security Audit (push) Successful in 15s
CI/CD Pipeline / Build Debian Package (Ubuntu 22.04) (push) Successful in 1m57s
CI/CD Pipeline / Build Arch Package (push) Successful in 1m53s
CI/CD Pipeline / Build Alpine Package (push) Successful in 3m17s
CI/CD Pipeline / Build RPM Package (push) Successful in 3m36s
CI/CD Pipeline / Build Debian Package (push) Successful in 2m11s
All checks were successful
CI/CD Pipeline / Code Format (push) Successful in 2s
CI/CD Pipeline / Clippy Lints (push) Successful in 1m17s
CI/CD Pipeline / Unit Tests (push) Successful in 56s
CI/CD Pipeline / Security Audit (push) Successful in 15s
CI/CD Pipeline / Build Debian Package (Ubuntu 22.04) (push) Successful in 1m57s
CI/CD Pipeline / Build Arch Package (push) Successful in 1m53s
CI/CD Pipeline / Build Alpine Package (push) Successful in 3m17s
CI/CD Pipeline / Build RPM Package (push) Successful in 3m36s
CI/CD Pipeline / Build Debian Package (push) Successful in 2m11s
- Remove sudo from apt command execution (service runs as root) - Remove RestrictSUIDSGID from systemd service (blocks setuid for apt/dpkg) - Remove NoNewPrivileges from systemd service (blocks sudo PERM_SUDOERS) - Bump version to 0.3.2
This commit is contained in:
@ -98,18 +98,9 @@ impl AptBackend {
|
||||
|
||||
/// Run apt command and capture output
|
||||
fn run_apt(&self, args: &[&str]) -> Result<String> {
|
||||
// Use sudo for operations that modify packages (install, upgrade, remove, purge)
|
||||
let needs_sudo = args.first().is_some_and(|&cmd| {
|
||||
matches!(
|
||||
cmd,
|
||||
"install" | "upgrade" | "remove" | "purge" | "dist-upgrade" | "autoremove"
|
||||
)
|
||||
});
|
||||
let (program, cmd_args): (&str, Vec<&str>) = if needs_sudo {
|
||||
("sudo", ["apt"].iter().chain(args.iter()).copied().collect())
|
||||
} else {
|
||||
("apt", args.to_vec())
|
||||
};
|
||||
// Service runs as root - no sudo needed for apt commands
|
||||
let program = "apt";
|
||||
let cmd_args: Vec<&str> = args.to_vec();
|
||||
|
||||
let output = Command::new(program)
|
||||
.args(&cmd_args)
|
||||
|
||||
Reference in New Issue
Block a user