Don't pass relative paths to sudo (fixes #43)

This commit is contained in:
Roey Darwish Dror
2018-07-01 20:24:01 +03:00
parent 3de4b2c5b1
commit ad9cad0525
2 changed files with 9 additions and 9 deletions

View File

@@ -70,7 +70,7 @@ It's dangerous to run yay since Python based AUR packages will be installed in t
} else {
if let Some(sudo) = &sudo {
Command::new(&sudo)
.args(&["pacman", "-Syu"])
.args(&["/usr/bin/pacman", "-Syu"])
.spawn()?
.wait()?
.check()?;
@@ -88,7 +88,7 @@ pub fn upgrade_redhat(
) -> Result<(), failure::Error> {
if let Some(sudo) = &sudo {
Command::new(&sudo)
.args(&["yum", "upgrade"])
.args(&["/usr/bin/yum", "upgrade"])
.spawn()?
.wait()?
.check()?;
@@ -105,7 +105,7 @@ pub fn upgrade_fedora(
) -> Result<(), failure::Error> {
if let Some(sudo) = &sudo {
Command::new(&sudo)
.args(&["dnf", "upgrade"])
.args(&["/usr/bin/dnf", "upgrade"])
.spawn()?
.wait()?
.check()?;
@@ -122,13 +122,13 @@ pub fn upgrade_debian(
) -> Result<(), failure::Error> {
if let Some(sudo) = &sudo {
Command::new(&sudo)
.args(&["apt", "update"])
.args(&["/usr/bin/apt", "update"])
.spawn()?
.wait()?
.check()?;
Command::new(&sudo)
.args(&["apt", "dist-upgrade"])
.args(&["/usr/bin/apt", "dist-upgrade"])
.spawn()?
.wait()?
.check()?;
@@ -139,9 +139,9 @@ pub fn upgrade_debian(
Ok(())
}
pub fn run_needrestart(sudo: &PathBuf) -> Result<(), failure::Error> {
pub fn run_needrestart(sudo: &PathBuf, needrestart: &PathBuf) -> Result<(), failure::Error> {
Command::new(&sudo)
.arg("needrestart")
.arg(needrestart)
.spawn()?
.wait()?
.check()?;

View File

@@ -231,9 +231,9 @@ fn run() -> Result<(), Error> {
}
if let Some(sudo) = &sudo {
if let Some(_) = utils::which("needrestart") {
if let Some(needrestart) = utils::which("needrestart") {
terminal.print_separator("Check for needed restarts");
linux::run_needrestart(&sudo).report("Restarts", &mut reports);
linux::run_needrestart(&sudo, &needrestart).report("Restarts", &mut reports);
}
}
}