Skip to content

Commit

Permalink
fix dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
LeChatP committed Sep 5, 2024
1 parent f695085 commit 84beb21
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 33 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ Our project has been manually tested on (tests in may 2023):
In june 2024, we performed automated `capable` tests with Vagrant on the following distributions:
* ❌ Centos 7 → Kernel too old (3.1)
* ✅ Centos 8
* ❌ Debian 10 → Dev dependencies unavailable, it should work once compiled
* ✅ Debian 11
* ✅ Fedora 37
* ✅ RedHat 9
* ✅ Ubuntu 22.04
* ✅ ArchLinux
* ✅ Almalinux 8
* ✅ RockyLinux 8
This doesn't mean that earlier versions of these distributions are incompatible; it simply indicates they haven't been tested yet. However, if you encounter issues during the compilation process, they are likely due to dependency problems. In theory, the RootAsRole project should work on any Linux distribution with a kernel version of 4.1 or higher. However, since BTF (BPF Type Format) is becoming a mandatory requirement, [the kernel must be compiled with many features enabled](https://github.com/iovisor/bcc/blob/master/INSTALL.md#kernel-configuration).
Expand Down
2 changes: 1 addition & 1 deletion capable
6 changes: 6 additions & 0 deletions xtask/src/ebpf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ pub mod build;
pub mod run;


fn clone() -> Result<(), anyhow::Error> {
let status = std::process::Command::new("git")
.args(&["clone", "", "capable"]).status().context("context")?;
Ok(())
}


pub fn build_all(opts: &BuildOptions) -> Result<(), anyhow::Error> {
build_ebpf(&opts.ebpf.unwrap_or(EbpfArchitecture::default()), &opts.profile).context("Error while building eBPF program")?;
Expand Down
2 changes: 1 addition & 1 deletion xtask/src/install/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ fn retrieve_real_user() -> Result<Option<nix::unistd::User>, anyhow::Error> {
pub fn default_pam_path(os: &OsTarget) -> &'static str {
match os {
OsTarget::Debian | OsTarget::Ubuntu => "resources/debian/deb_sr_pam.conf",
OsTarget::RedHat | OsTarget::CentOS | OsTarget::Fedora => "resources/redhat/rh_sr_pam.conf",
OsTarget::RedHat | OsTarget::AlmaLinux | OsTarget::RockyLinux | OsTarget::Fedora => "resources/rh/rh_sr_pam.conf",
OsTarget::ArchLinux => "resources/arch/arch_sr_pam.conf",
}
}
Expand Down
48 changes: 23 additions & 25 deletions xtask/src/install/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn update_package_manager() -> Result<(), anyhow::Error> {
.arg("update")
.status()?;
},
OsTarget::RedHat | OsTarget::Fedora | OsTarget::CentOS => {
OsTarget::RedHat | OsTarget::Fedora | OsTarget::AlmaLinux | OsTarget::RockyLinux => {
let _ = std::process::Command::new("yum")
.arg("update")
.arg("-y")
Expand All @@ -25,19 +25,28 @@ fn update_package_manager() -> Result<(), anyhow::Error> {
Ok(())
}

fn required_dependencies(os: &OsTarget) -> Vec<&str> {
fn required_dependencies(os: &OsTarget) -> &'static [&'static str] {
match os {
OsTarget::Debian | OsTarget::Ubuntu => vec!["libpam0g", "libpcre2-8-0"],
OsTarget::RedHat => vec!["pcre2"],
OsTarget::ArchLinux | OsTarget::Fedora | OsTarget::CentOS => vec!["pam", "pcre2"],
OsTarget::Debian | OsTarget::Ubuntu => &["libpam0g", "libpcre2-8-0"],
OsTarget::RedHat | OsTarget::AlmaLinux | OsTarget::RockyLinux => &["pcre2"],
OsTarget::ArchLinux | OsTarget::Fedora => &["pam", "pcre2"],
}
}

fn development_dependencies(os: &OsTarget) -> Vec<&str> {
fn development_dependencies(os: &OsTarget) -> &'static [&'static str] {
match os {
OsTarget::Debian | OsTarget::Ubuntu => vec!["libpam0g-dev", "libpcre2-dev"],
OsTarget::RedHat => vec!["pcre2-devel"],
OsTarget::ArchLinux | OsTarget::Fedora | OsTarget::CentOS => vec!["pam-devel", "pcre2-devel"],
OsTarget::Debian | OsTarget::Ubuntu => &["libpam0g-dev", "libpcre2-dev"],
OsTarget::RedHat | OsTarget::AlmaLinux | OsTarget::RockyLinux => &["pcre2-devel", "clang-devel", "openssl-devel", "pam-devel"],
OsTarget::Fedora => &["pam-devel", "pcre2-devel", "clang", "openssl-devel"],
OsTarget::ArchLinux => &["pam-devel", "pcre2-devel", "clang", "libssl", "pkg-config"],
}
}

fn get_dependencies(os: &OsTarget, dev: &bool) -> &'static [&'static str] {
if *dev {
development_dependencies(os)
} else {
required_dependencies(os)
}
}

Expand All @@ -61,39 +70,28 @@ pub fn install(opts: InstallDependenciesOptions) -> Result<(), anyhow::Error> {
let _ = std::process::Command::new("apt-get")
.arg("install")
.arg("-y")
.arg("libpam0g")
.arg("libpcre2-8-0")
.status()?;
},
OsTarget::RedHat => {
let _ = std::process::Command::new("yum")
.arg("install")
.arg("-y")
.arg("pcre2")
.args(get_dependencies(&os, &opts.dev))
.status()?;
},
OsTarget::CentOS => {
OsTarget::RedHat | OsTarget::AlmaLinux | OsTarget::RockyLinux => {
let _ = std::process::Command::new("yum")
.arg("install")
.arg("-y")
.arg("pam")
.arg("pcre2")
.args(get_dependencies(&os, &opts.dev))
.status()?;
},
OsTarget::Fedora => {
let _ = std::process::Command::new("dnf")
.arg("install")
.arg("-y")
.arg("pam")
.arg("pcre2")
.args(get_dependencies(&os, &opts.dev))
.status()?;
}
OsTarget::ArchLinux => {
let _ = std::process::Command::new("pacman")
.arg("-Sy")
.arg("--noconfirm")
.arg("pam")
.arg("pcre2")
.args(get_dependencies(&os, &opts.dev))
.status()?;
},
}
Expand Down
12 changes: 8 additions & 4 deletions xtask/src/install/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ pub enum OsTarget {
RedHat,
#[clap(alias = "fed")]
Fedora,
#[clap(alias = "cen")]
CentOS,
#[clap(alias = "alma")]
AlmaLinux,
#[clap(alias = "rocky")]
RockyLinux,
#[clap(alias = "arch")]
ArchLinux,
}
Expand All @@ -139,8 +141,10 @@ impl OsTarget {
return Ok(OsTarget::RedHat);
} else if os.contains("fedora") {
return Ok(OsTarget::Fedora);
} else if os.contains("centos") {
return Ok(OsTarget::CentOS);
} else if os.contains("almalinux") {
return Ok(OsTarget::AlmaLinux);
} else if os.contains("rocky") {
return Ok(OsTarget::RockyLinux);
} else if os.contains("arch") {
return Ok(OsTarget::ArchLinux);
}
Expand Down

0 comments on commit 84beb21

Please sign in to comment.