From ea4011697f98e147d9c4d475cf8d57b9342c6f5f Mon Sep 17 00:00:00 2001 From: LeChatP Date: Mon, 9 Sep 2024 19:08:20 +0200 Subject: [PATCH] Fixes and workflow --- .github/workflows/build.yml | 5 ++++- .github/workflows/pkg.yml | 7 ++++--- .github/workflows/quality.yml | 8 +------- .github/workflows/tests.yml | 11 ++++------- xtask/src/deploy/debian.rs | 6 +++--- xtask/src/install/dependencies.rs | 2 +- 6 files changed, 17 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e4ea797e..976b7bb8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,6 +12,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable - name: Configure PAM run: | sudo bash -c 'echo "#%PAM-1.0 @@ -25,7 +28,7 @@ jobs: session requisite pam_permit.so session required pam_permit.so" | tee /etc/pam.d/sr' - name: Install RootAsRole - run: cargo xtask install -d -i -p sudo + run: cargo xtask install -bia - name: Add read access on config on rootasrole... Because Github Actions... run: sudo chmod a+r /etc/security/rootasrole.json - name: print config diff --git a/.github/workflows/pkg.yml b/.github/workflows/pkg.yml index dce81e65..db24834f 100644 --- a/.github/workflows/pkg.yml +++ b/.github/workflows/pkg.yml @@ -1,9 +1,10 @@ name: Deploy pkg to GitHub Packages -## only triger manual +## never trigger this workflow automatically on: - workflow_dispatch: - + push: + branches: + - no-trigger jobs: deploy: diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index f051fc94..bc17b09a 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -37,13 +37,7 @@ jobs: profile: minimal toolchain: stable components: clippy - override: true - - - name: Install Dependencies - run: ./dependencies.sh -yd - - - name: Configure - run: sudo ./configure.sh -yd + override: false # if pull request review only - uses: mbrobbel/rustfmt-check@master diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0dcb81b0..5fae657e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,14 +24,11 @@ jobs: - name: Install sudo run: apt install sudo -y - - name: Install Dependencies - run: ./dependencies.sh -yd - - - name: Install file configuration - run: sudo bash ./configure.sh -yd + - name: Install RootAsRole + run: cargo xtask install -bia - name: run tests with coverage - run: cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --bin chsr --bin sr --exclude-files capable* capable-ebpf/src/vmlinux.rs capable/src/main.rs build.rs --out Xml + run: cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --bin chsr --bin sr --exclude-files build.rs xtask* --out Xml - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 @@ -42,7 +39,7 @@ jobs: flags: unittests - name: run tests with coverage as Admin - run: sudo -E /usr/local/cargo/bin/cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --bin chsr --bin sr --exclude-files capable* capable-ebpf/src/vmlinux.rs capable/src/main.rs build.rs --out Xml + run: sudo -E /usr/local/cargo/bin/cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --bin chsr --bin sr --exclude-files xtask* build.rs --out Xml - name: Upload coverage reports to Codecov as Admin uses: codecov/codecov-action@v3 diff --git a/xtask/src/deploy/debian.rs b/xtask/src/deploy/debian.rs index dbc94f1d..e596a3a1 100644 --- a/xtask/src/deploy/debian.rs +++ b/xtask/src/deploy/debian.rs @@ -4,13 +4,13 @@ use anyhow::Context; use crate::{ install::{self, dependencies::install_dependencies, InstallDependenciesOptions, Profile}, - util::{get_os, OsTarget}, + util::{detect_priv_bin, get_os, OsTarget}, }; use super::setup_maint_scripts; fn dependencies(os: &OsTarget, priv_bin: Option) -> Result { - install_dependencies(os, &["upx", "dpkg"], priv_bin) + install_dependencies(os, &["upx"], priv_bin) .context("failed to install packaging dependencies") } @@ -21,7 +21,7 @@ pub fn make_deb( ) -> Result<(), anyhow::Error> { let os = get_os(os)?; - dependencies(&os, priv_bin.clone())?; + dependencies(&os, priv_bin.clone().or(detect_priv_bin()))?; install::dependencies(InstallDependenciesOptions { os: Some(os), diff --git a/xtask/src/install/dependencies.rs b/xtask/src/install/dependencies.rs index ae951d2b..b0676461 100644 --- a/xtask/src/install/dependencies.rs +++ b/xtask/src/install/dependencies.rs @@ -60,7 +60,7 @@ fn get_dependencies(os: &OsTarget, dev: &bool) -> &'static [&'static str] { fn is_priv_bin_necessary(os: &OsTarget) -> Result { match os { - OsTarget::ArchLinux => Ok(geteuid().is_root()), + OsTarget::ArchLinux => Ok(!geteuid().is_root()), _ => { let mut state = CapState::get_current()?; if state.permitted.has(capctl::Cap::DAC_OVERRIDE)