fix(702): narrow SystemdRunMachine to ReloadGatewayNginx in hive-priv
This commit is contained in:
parent
10871381f3
commit
efedfc3ea6
1 changed files with 6 additions and 11 deletions
|
|
@ -243,25 +243,20 @@ async fn exec(req: PrivRequest) -> Result<(String, String)> {
|
||||||
Ok((String::new(), String::new()))
|
Ok((String::new(), String::new()))
|
||||||
}
|
}
|
||||||
|
|
||||||
PrivRequest::SystemdRunMachine { ref machine, ref cmd } => {
|
PrivRequest::ReloadGatewayNginx => {
|
||||||
validate_container_name(machine)?;
|
|
||||||
let mut args = vec!["--machine".to_owned(), machine.clone(), "--quiet".to_owned(), "--".to_owned()];
|
|
||||||
args.extend(cmd.iter().cloned());
|
|
||||||
let out = Command::new("systemd-run")
|
let out = Command::new("systemd-run")
|
||||||
.args(&args)
|
.args(["--machine=hive-gateway", "--quiet", "--", "nginx", "-s", "reload"])
|
||||||
.output()
|
.output()
|
||||||
.await
|
.await
|
||||||
.context("invoke systemd-run")?;
|
.context("invoke systemd-run for gateway nginx reload")?;
|
||||||
let stdout = String::from_utf8_lossy(&out.stdout).into_owned();
|
|
||||||
let stderr = String::from_utf8_lossy(&out.stderr).into_owned();
|
|
||||||
if !out.status.success() {
|
if !out.status.success() {
|
||||||
bail!(
|
bail!(
|
||||||
"systemd-run --machine={machine} failed ({}): {}",
|
"gateway nginx reload failed ({}): {}",
|
||||||
out.status,
|
out.status,
|
||||||
stderr.trim()
|
String::from_utf8_lossy(&out.stderr).trim()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Ok((stdout, stderr))
|
Ok((String::new(), String::new()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue