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 a1d97d2..dbe1935 100644 --- a/README.md +++ b/README.md @@ -37,20 +37,44 @@ ## 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) + (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) (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` -### How to install sr and chsr +Then the xtask installation will install the rest of the dependencies for you. - 1. `git clone ` +### Install from source + + 1. `git clone https://github.com/LeChatP/RootAsRole` 1. `cd RootAsRole` - 1. `sudo cargo xtask install -i -b` + 1. `cargo xtask install -bip sudo` + + +### 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 +``` + +```sh +sudo rpm -i rootasrole-3.0.0-1.x86_64.rpm +``` + ### Additional Installation Options @@ -159,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 93e6de3..e98c427 100644 --- a/resources/rh/postinst.sh +++ b/resources/rh/postinst.sh @@ -1,17 +1,24 @@ #!/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..c0a05ad 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 +chattr -i /etc/security/rootasrole.json 2>/dev/null || true \ No newline at end of file