Fix sudo nginx and psql commands to use full paths

- Change nginx command from 'nginx' to '/run/current-system/sw/bin/nginx'
- Change psql command from 'psql' to '/run/current-system/sw/bin/psql'
- This ensures sudo rules can properly match the commands with full paths
This commit is contained in:
Christoffer Martinsson 2025-10-13 14:51:41 +02:00
parent 92d6b42837
commit 7af4f09ca2

View File

@ -526,7 +526,7 @@ impl ServiceCollector {
async fn get_postgres_connections(&self) -> Option<String> { async fn get_postgres_connections(&self) -> Option<String> {
let output = Command::new("sudo") let output = Command::new("sudo")
.args(["-u", "postgres", "psql", "-t", "-c", "SELECT count(*) FROM pg_stat_activity WHERE state = 'active';"]) .args(["-u", "postgres", "/run/current-system/sw/bin/psql", "-t", "-c", "SELECT count(*) FROM pg_stat_activity WHERE state = 'active';"])
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.stderr(Stdio::piped()) .stderr(Stdio::piped())
.output() .output()
@ -585,10 +585,10 @@ impl ServiceCollector {
None => { None => {
// Fallback to default nginx -T // Fallback to default nginx -T
let mut cmd = if self.is_running_as_root() { let mut cmd = if self.is_running_as_root() {
Command::new("nginx") Command::new("/run/current-system/sw/bin/nginx")
} else { } else {
let mut cmd = Command::new("sudo"); let mut cmd = Command::new("sudo");
cmd.arg("nginx"); cmd.arg("/run/current-system/sw/bin/nginx");
cmd cmd
}; };
@ -615,10 +615,10 @@ impl ServiceCollector {
// Use the specific config file // Use the specific config file
let mut cmd = if self.is_running_as_root() { let mut cmd = if self.is_running_as_root() {
Command::new("nginx") Command::new("/run/current-system/sw/bin/nginx")
} else { } else {
let mut cmd = Command::new("sudo"); let mut cmd = Command::new("sudo");
cmd.arg("nginx"); cmd.arg("/run/current-system/sw/bin/nginx");
cmd cmd
}; };