Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
LeChatP committed Sep 5, 2024
1 parent 7496618 commit 017fbce
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 149 deletions.
62 changes: 0 additions & 62 deletions Makefile

This file was deleted.

25 changes: 0 additions & 25 deletions Makefile.toml.off

This file was deleted.

31 changes: 4 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,40 +44,17 @@
```sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
* [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)

### How to Install sr and chsr

Requirement: rustc >= 1.70.0
### How to install sr and chsr

1. `git clone <https://github.com/LeChatP/RootAsRole>`
1. `cd RootAsRole`
1. `cargo xtask install`
1. `cargo xtask install -i`

### Additional Installation Options

<pre>
<u><b>Usage</b></u>: cargo xtask install [OPTIONS]

<u><b>Options</b></u>:
<b>--debug</b>
Build the target with debug profile (default is release)
<b>-t, --toolchain</b> &lt;TOOLCHAIN&gt;
The toolchain to use for building sr and chsr [default: stable]
<b>--ebpf-toolchain</b> &lt;EBPF_TOOLCHAIN&gt;
[default: bpfel-unknown-none] [possible values: bpfel-unknown-none, bpfeb-unknown-none]
<b>-b, --clean</b>
Clean the target directory before building
<b>--ebpf-build</b> &lt;EBPF_BUILD&gt;
Set the endianness of the BPF target [default: bpfel-unknown-none] [possible values: bpfel-unknown-none, bpfeb-unknown-none]
<b>--build-ebpf</b>
Build the eBPF, requires nightly toolchain. Asks to install the nightly toolchain with rustup if not found
<b>--os</b> &lt;OS&gt;
The OS target for PAM configuration [possible values: debian, ubuntu, redhat, fedora, centos, archlinux]
<b>-a, --clean-after</b>
Clean the target directory after installing
<b>-h, --help</b>
Print help
</pre>
To know more about options, you can run `cargo xtask install --help`.

**[What does the installation do?](https://lechatp.github.io/RootAsRole/guide/installation.html#what-does-the-installation-script-do)**

Expand Down
26 changes: 0 additions & 26 deletions makepkg.sh

This file was deleted.

17 changes: 16 additions & 1 deletion xtask/src/install/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ fn update_package_manager() -> Result<(), anyhow::Error> {
Ok(())
}

fn required_dependencies(os: &OsTarget) -> Vec<&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"],
}
}

fn development_dependencies(os: &OsTarget) -> Vec<&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"],
}
}

pub fn install(opts: InstallDependenciesOptions) -> Result<(), anyhow::Error> {
update_package_manager()?;
// dependencies are : libpam and libpcre2
Expand All @@ -40,7 +56,6 @@ pub fn install(opts: InstallDependenciesOptions) -> Result<(), anyhow::Error> {
})
.context("Failed to detect the OS")?
};

match os {
OsTarget::Debian | OsTarget::Ubuntu => {
let _ = std::process::Command::new("apt-get")
Expand Down
14 changes: 6 additions & 8 deletions xtask/src/install/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@ pub const SR_DEST: &str = "/usr/bin/sr";
pub const CHSR_DEST: &str = "/usr/bin/chsr";
pub const CAPABLE_DEST: &str = "/usr/bin/capable";

/// Options for the install command
/// This command may use multiple toolchains.
/// By default `capable` use the nightly toolchain and `sr` and `chsr` use the stable toolchain.
/// `capable` eBPF requires nightly, but binaries like `sr` and `chsr` can be built at >=version 1.70.0.
/// Nightly toolchain are not recommended for production use, as they are not stable. So `capable` is for testing purposes.
/// Indeed, capable purpose is to obtain a set of Linux capabilities from a generic command, to help people to configure their RootAsRole configuration.
/// But if you don't want several toolchains installed, you can use the nightly toolchain for everything, or just not compile the eBPF program.

#[derive(Debug, Parser, Clone)]
pub struct InstallOptions {

Expand Down Expand Up @@ -64,6 +57,10 @@ pub struct InstallDependenciesOptions {
/// Install dependencies before building
#[clap(long, short = 'i')]
pub install_dependencies: bool,

/// Install development dependencies for compiling
#[clap(long, short = 'd')]
pub dev: bool,
}

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -279,6 +276,7 @@ pub(crate) fn install(opts: &InstallOptions) -> Result<(), anyhow::Error> {
dependencies(InstallDependenciesOptions {
os: opts.os.clone(),
install_dependencies: true,
dev: true,
})?;
}
if ! opts.no_build {
Expand Down

0 comments on commit 017fbce

Please sign in to comment.