Skip to content

Commit

Permalink
Merge pull request #56 from LeChatP/develop
Browse files Browse the repository at this point in the history
Fix Installation steps
  • Loading branch information
LeChatP authored Sep 13, 2024
2 parents eeb41db + 5fd0a0d commit b38ccbe
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "*"
Expand Down
42 changes: 32 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/LeChatP/RootAsRole>`
### 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

Expand Down Expand Up @@ -159,16 +183,14 @@ This doesn't mean that earlier versions of these distributions are incompatible;
## Contributors
Ahmad Samer Wazan : <[email protected]>
Eddie Billoir : <[email protected]>
Ahmad Samer Wazan : <[email protected]>
Rémi Venant: <[email protected]>
Guillaume Daumas : <[email protected]>
Eddie Billoir : <[email protected]>
Anderson Hemlee : <[email protected]>
Romain Laborde : <[email protected]>
## About Logo
Expand Down
11 changes: 9 additions & 2 deletions resources/rh/postinst.sh
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
4 changes: 1 addition & 3 deletions resources/rh/prerm.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
#!/bin/sh

chattr -i /etc/security/rootasrole.json || true
chattr -i /etc/security/rootasrole.json 2>/dev/null || true

0 comments on commit b38ccbe

Please sign in to comment.