From 6a04ce1711e0a9c237d91d2e9e5737483a03d704 Mon Sep 17 00:00:00 2001 From: LeChatP Date: Fri, 13 Sep 2024 12:03:23 +0200 Subject: [PATCH 1/4] fixing post installation process for rpm package --- resources/rh/postinst.sh | 12 +++++++++--- resources/rh/prerm.sh | 2 -- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/resources/rh/postinst.sh b/resources/rh/postinst.sh index 93e6de3..eed1881 100644 --- a/resources/rh/postinst.sh +++ b/resources/rh/postinst.sh @@ -1,17 +1,23 @@ -#!/bin/sh +if [[ -z ${SUDO_USER+x} ]]; then INSTALL_USER=`id -urn`; else INSTALL_USER=$SUDO_USER; fi + filesystem() { df -T "$1" | awk 'NR==2 {print $2}' } configure() { - sed -i "s/ROOTADMINISTRATOR/$(id -urn)/g" /etc/security/rootasrole.json + echo "Configuring rootasrole.json" + sed -i "s/ROOTADMINISTRATOR/$INSTALL_USER/g" /etc/security/rootasrole.json FS=$(filesystem /etc/security/rootasrole.json) case $FS in "ext2" | "ext3" | "ext4" | "xfs" | "btrfs" | "ocfs2" | "jfs" | "reiserfs") + echo "Setting immutable attribute on /etc/security/rootasrole.json" chattr +i /etc/security/rootasrole.json ;; *) - sed -i "s/\"CAP_LINUX_IMMUTABLE\"//g" /etc/security/rootasrole.json + echo "filesystem $FS does not support immutable attribute" + echo "Removing immutable parameter from /etc/security/rootasrole.json" + sed -i "s/\"immutable\": true/\"immutable\": false/g" /etc/security/rootasrole.json + sed -i "s;\"CAP_LINUX_IMMUTABLE\";;g" /etc/security/rootasrole.json ;; esac } diff --git a/resources/rh/prerm.sh b/resources/rh/prerm.sh index 368fb33..ac5c174 100644 --- a/resources/rh/prerm.sh +++ b/resources/rh/prerm.sh @@ -1,3 +1 @@ -#!/bin/sh - chattr -i /etc/security/rootasrole.json || true \ No newline at end of file From 45f3ace36f115991a39a7a7c277bffcce07f4f32 Mon Sep 17 00:00:00 2001 From: LeChatP Date: Fri, 13 Sep 2024 12:03:44 +0200 Subject: [PATCH 2/4] chore: Update installation instructions and dependencies --- README.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a1d97d2..0fc0043 100644 --- a/README.md +++ b/README.md @@ -37,20 +37,37 @@ ## Installation -### Prerequisites +### Prerequisites (for compilation) * [Rust](https://www.rust-lang.org/tools/install) >= 1.76.0 * You can install Rust by running the following command: ```sh curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` -* [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) +* [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) + * You can install git by running the following commands depending on your distribution: + Ubuntu : `sudo apt-get install git`, RedHat : `sudo yum install git`, ArchLinux : `sudo pacman -S git` +* [clang](https://clang.llvm.org/get_started.html) + * You can install clang by running the following commands depending on your distribution: + Ubuntu : `sudo apt-get install clang`, RedHat : `sudo yum install clang`, ArchLinux : `sudo pacman -S clang` + ### How to install sr and chsr 1. `git clone ` 1. `cd RootAsRole` - 1. `sudo cargo xtask install -i -b` + 1. `cargo xtask install -bip sudo` + +Or you can use deb or rpm packages and install them with apt or rpm commands. + +```sh +sudo apt install rootasrole_3.0.0_amd64.deb +``` + +```sh +sudo rpm -i rootasrole-3.0.0-1.x86_64.rpm +``` + ### Additional Installation Options From 7524316d332b1ce50f79b4239794513cefa9798d Mon Sep 17 00:00:00 2001 From: LeChatP Date: Fri, 13 Sep 2024 12:06:22 +0200 Subject: [PATCH 3/4] chore: Update installation instructions to include building from source --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0fc0043..81eb323 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Ubuntu : `sudo apt-get install clang`, RedHat : `sudo yum install clang`, ArchLinux : `sudo pacman -S clang` -### How to install sr and chsr +### How to install sr and chsr by building from source 1. `git clone ` 1. `cd RootAsRole` From 5fd0a0d6b14efdfaafcf689759df3650e4fc050e Mon Sep 17 00:00:00 2001 From: LeChatP Date: Fri, 13 Sep 2024 21:13:42 +0200 Subject: [PATCH 4/4] Fix rpm building. --- Cargo.toml | 4 ++-- README.md | 23 ++++++++++++++--------- resources/rh/postinst.sh | 3 ++- resources/rh/prerm.sh | 2 +- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9ebe0f0..f7dfc38 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -132,10 +132,10 @@ assets = [ { source = "target/man/fr/chsr.8.gz", dest = "/usr/share/man/fr/man8/chsr.8.gz", user = "root", group = "root", mode = "0644", doc = true } ] post_install_script = "resources/rh/postinst.sh" -post_install_script_prog = [ "/bin/sh", "-c" ] +post_install_script_flags = 0b101 pre_uninstall_script = "resources/rh/prerm.sh" -pre_uninstall_script_prog = [ "/bin/sh", "-c" ] +pre_uninstall_script_flags = 0b101 [package.metadata.generate-rpm.requires] pam = "*" diff --git a/README.md b/README.md index 81eb323..dbe1935 100644 --- a/README.md +++ b/README.md @@ -44,21 +44,28 @@ ```sh curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` + (Do not forget to add the cargo bin directory to your PATH with `. "$HOME/.cargo/env"` command) * [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) * You can install git by running the following commands depending on your distribution: Ubuntu : `sudo apt-get install git`, RedHat : `sudo yum install git`, ArchLinux : `sudo pacman -S git` -* [clang](https://clang.llvm.org/get_started.html) +* [clang](https://clang.llvm.org/get_started.html) (or gcc, but clang is highly recommended) * You can install clang by running the following commands depending on your distribution: Ubuntu : `sudo apt-get install clang`, RedHat : `sudo yum install clang`, ArchLinux : `sudo pacman -S clang` +Then the xtask installation will install the rest of the dependencies for you. -### How to install sr and chsr by building from source +### Install from source - 1. `git clone ` + 1. `git clone https://github.com/LeChatP/RootAsRole` 1. `cd RootAsRole` 1. `cargo xtask install -bip sudo` -Or you can use deb or rpm packages and install them with apt or rpm commands. + +### Install from precompiled binaries + +You can download the precompiled binaries from the [release page](https://github.com/LeChatP/RootAsRole/releases). + +Then you can install the package with the following commands: ```sh sudo apt install rootasrole_3.0.0_amd64.deb @@ -176,16 +183,14 @@ This doesn't mean that earlier versions of these distributions are incompatible; ## Contributors -Ahmad Samer Wazan : +Eddie Billoir : + +Ahmad Samer Wazan : RĂ©mi Venant: Guillaume Daumas : -Eddie Billoir : - -Anderson Hemlee : - Romain Laborde : ## About Logo diff --git a/resources/rh/postinst.sh b/resources/rh/postinst.sh index eed1881..e98c427 100644 --- a/resources/rh/postinst.sh +++ b/resources/rh/postinst.sh @@ -1,4 +1,5 @@ -if [[ -z ${SUDO_USER+x} ]]; then INSTALL_USER=`id -urn`; else INSTALL_USER=$SUDO_USER; fi +#!/bin/sh +if [ -z ${SUDO_USER+x} ]; then INSTALL_USER=$(id -urn); else INSTALL_USER=$SUDO_USER; fi filesystem() { df -T "$1" | awk 'NR==2 {print $2}' diff --git a/resources/rh/prerm.sh b/resources/rh/prerm.sh index ac5c174..c0a05ad 100644 --- a/resources/rh/prerm.sh +++ b/resources/rh/prerm.sh @@ -1 +1 @@ -chattr -i /etc/security/rootasrole.json || true \ No newline at end of file +chattr -i /etc/security/rootasrole.json 2>/dev/null || true \ No newline at end of file