remove absolute paths when executing binaries
we set the paths manually, so this is ok Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
committed by
Dietmar Maurer
parent
0b99e5aebc
commit
cbef49bf4f
@ -32,12 +32,6 @@ pub use lvm::*;
|
||||
mod smart;
|
||||
pub use smart::*;
|
||||
|
||||
pub const SGDISK_BIN_PATH: &str = "/usr/sbin/sgdisk";
|
||||
pub const LSBLK_BIN_PATH: &str = "/usr/bin/lsblk";
|
||||
pub const BLOCKDEV_BIN_PATH: &str = "/sbin/blockdev";
|
||||
pub const MKFS_BIN_PATH: &str = "/sbin/mkfs";
|
||||
pub const BLKID_BIN_PATH: &str = "/sbin/blkid";
|
||||
|
||||
lazy_static::lazy_static!{
|
||||
static ref ISCSI_PATH_REGEX: regex::Regex =
|
||||
regex::Regex::new(r"host[^/]*/session[^/]*").unwrap();
|
||||
@ -564,7 +558,7 @@ pub struct BlockDevStat {
|
||||
/// Use lsblk to read partition type uuids.
|
||||
pub fn get_partition_type_info() -> Result<HashMap<String, Vec<String>>, Error> {
|
||||
|
||||
let mut command = std::process::Command::new(LSBLK_BIN_PATH);
|
||||
let mut command = std::process::Command::new("lsblk");
|
||||
command.args(&["--json", "-o", "path,parttype"]);
|
||||
|
||||
let output = crate::tools::run_command(command, None)?;
|
||||
@ -861,7 +855,7 @@ pub fn reread_partition_table(disk: &Disk) -> Result<(), Error> {
|
||||
None => bail!("disk {:?} has no node in /dev", disk.syspath()),
|
||||
};
|
||||
|
||||
let mut command = std::process::Command::new(BLOCKDEV_BIN_PATH);
|
||||
let mut command = std::process::Command::new("blockdev");
|
||||
command.arg("--rereadpt");
|
||||
command.arg(disk_path);
|
||||
|
||||
@ -880,7 +874,7 @@ pub fn inititialize_gpt_disk(disk: &Disk, uuid: Option<&str>) -> Result<(), Erro
|
||||
|
||||
let uuid = uuid.unwrap_or("R"); // R .. random disk GUID
|
||||
|
||||
let mut command = std::process::Command::new(SGDISK_BIN_PATH);
|
||||
let mut command = std::process::Command::new("sgdisk");
|
||||
command.arg(disk_path);
|
||||
command.args(&["-U", uuid]);
|
||||
|
||||
@ -897,7 +891,7 @@ pub fn create_single_linux_partition(disk: &Disk) -> Result<Disk, Error> {
|
||||
None => bail!("disk {:?} has no node in /dev", disk.syspath()),
|
||||
};
|
||||
|
||||
let mut command = std::process::Command::new(SGDISK_BIN_PATH);
|
||||
let mut command = std::process::Command::new("sgdisk");
|
||||
command.args(&["-n1", "-t1:8300"]);
|
||||
command.arg(disk_path);
|
||||
|
||||
@ -950,7 +944,7 @@ pub fn create_file_system(disk: &Disk, fs_type: FileSystemType) -> Result<(), Er
|
||||
|
||||
let fs_type = fs_type.to_string();
|
||||
|
||||
let mut command = std::process::Command::new(MKFS_BIN_PATH);
|
||||
let mut command = std::process::Command::new("mkfs");
|
||||
command.args(&["-t", &fs_type]);
|
||||
command.arg(disk_path);
|
||||
|
||||
@ -988,7 +982,7 @@ pub fn get_fs_uuid(disk: &Disk) -> Result<String, Error> {
|
||||
None => bail!("disk {:?} has no node in /dev", disk.syspath()),
|
||||
};
|
||||
|
||||
let mut command = std::process::Command::new(BLKID_BIN_PATH);
|
||||
let mut command = std::process::Command::new("blkid");
|
||||
command.args(&["-o", "export"]);
|
||||
command.arg(disk_path);
|
||||
|
||||
|
@ -20,7 +20,7 @@ pub fn get_lvm_devices(
|
||||
partition_type_map: &HashMap<String, Vec<String>>,
|
||||
) -> Result<HashSet<u64>, Error> {
|
||||
|
||||
const PVS_BIN_PATH: &str = "/sbin/pvs";
|
||||
const PVS_BIN_PATH: &str = "pvs";
|
||||
|
||||
let mut command = std::process::Command::new(PVS_BIN_PATH);
|
||||
command.args(&["--reportformat", "json", "--noheadings", "--readonly", "-o", "pv_name"]);
|
||||
|
@ -76,7 +76,7 @@ pub fn get_smart_data(
|
||||
health_only: bool,
|
||||
) -> Result<SmartData, Error> {
|
||||
|
||||
const SMARTCTL_BIN_PATH: &str = "/usr/sbin/smartctl";
|
||||
const SMARTCTL_BIN_PATH: &str = "smartctl";
|
||||
|
||||
let mut command = std::process::Command::new(SMARTCTL_BIN_PATH);
|
||||
command.arg("-H");
|
||||
|
@ -7,8 +7,6 @@ pub mod time;
|
||||
|
||||
use anyhow::{bail, Error};
|
||||
|
||||
pub const SYSTEMCTL_BIN_PATH: &str = "/usr/bin/systemctl";
|
||||
|
||||
/// Escape strings for usage in systemd unit names
|
||||
pub fn escape_unit(mut unit: &str, is_path: bool) -> String {
|
||||
|
||||
@ -77,7 +75,7 @@ pub fn unescape_unit(text: &str) -> Result<String, Error> {
|
||||
|
||||
pub fn reload_daemon() -> Result<(), Error> {
|
||||
|
||||
let mut command = std::process::Command::new(SYSTEMCTL_BIN_PATH);
|
||||
let mut command = std::process::Command::new("systemctl");
|
||||
command.arg("daemon-reload");
|
||||
|
||||
crate::tools::run_command(command, None)?;
|
||||
@ -87,7 +85,7 @@ pub fn reload_daemon() -> Result<(), Error> {
|
||||
|
||||
pub fn enable_unit(unit: &str) -> Result<(), Error> {
|
||||
|
||||
let mut command = std::process::Command::new(SYSTEMCTL_BIN_PATH);
|
||||
let mut command = std::process::Command::new("systemctl");
|
||||
command.arg("enable");
|
||||
command.arg(unit);
|
||||
|
||||
@ -98,7 +96,7 @@ pub fn enable_unit(unit: &str) -> Result<(), Error> {
|
||||
|
||||
pub fn start_unit(unit: &str) -> Result<(), Error> {
|
||||
|
||||
let mut command = std::process::Command::new(SYSTEMCTL_BIN_PATH);
|
||||
let mut command = std::process::Command::new("systemctl");
|
||||
command.arg("start");
|
||||
command.arg(unit);
|
||||
|
||||
@ -109,7 +107,7 @@ pub fn start_unit(unit: &str) -> Result<(), Error> {
|
||||
|
||||
pub fn stop_unit(unit: &str) -> Result<(), Error> {
|
||||
|
||||
let mut command = std::process::Command::new(SYSTEMCTL_BIN_PATH);
|
||||
let mut command = std::process::Command::new("systemctl");
|
||||
command.arg("stop");
|
||||
command.arg(unit);
|
||||
|
||||
|
Reference in New Issue
Block a user