fix session pid, add uninstall sh file

This commit is contained in:
tylermurphy534 2022-11-09 00:51:47 -05:00
parent c0f8085da8
commit f36e111773
6 changed files with 41 additions and 35 deletions

View file

@ -1,10 +1,12 @@
pkgbase = crab
pkgdesc = A rusty permission authentication system
pkgver = 0.0.1
pkgver = 0.0.2
pkgrel = 1
url = https://g.tylerm.dev/tylermurphy534/crab.git
arch = x86_64
license = GPL
arch = i686
license = GPL3
makedepends = cargo
source = git+https://g.tylerm.dev/tylermurphy534/crab.git
md5sums = SKIP

View file

@ -5,29 +5,15 @@
# Maintainer: Tyler Murphy <tylermurphy534@gmail.com>
pkgname=crab
pkgver=0.0.1
pkgver=0.0.2
pkgrel=1
epoch=
pkgdesc="A rusty permission authentication system"
arch=(x86_64)
arch=('x86_64' 'i686')
url="https://g.tylerm.dev/tylermurphy534/crab.git"
license=('GPL')
groups=()
depends=()
makedepends=()
checkdepends=()
optdepends=()
provides=()
conflicts=()
replaces=()
backup=()
options=()
install=
changelog=
license=('GPL3')
makedepends=('cargo')
source=("git+$url")
noextract=()
md5sums=('SKIP')
validpgpkeys=()
build() {
cd crab
@ -38,5 +24,5 @@ package() {
cd crab
install -D --mode=6755 --owner=root --group=root ./target/release/crab ${pkgdir}/usr/bin/crab
install -D --mode=660 --owner=root --group=root pam ${pkgdir}/etc/pam.d/crab
install -D --mode=664 --owner=root --group=root conf ${pkgdir}/usr/share/crab/crab.conf
install -D --mode=660 --owner=root --group=root conf ${pkgdir}/usr/share/crab/crab.conf
}

View file

@ -6,11 +6,12 @@ if [[ $(/usr/bin/id -u) -ne 0 ]]; then
fi
# Copy executable to bin
cp ./target/release/crab /bin/crab
cp ./target/release/crab /usr/bin/crab
chown root:root /bin/crab
chmod 6755 /bin/crab
# Set up config files
cp pam /etc/pam.d/crab
cp -n conf /etc/crab.conf
chmod 660 /etc/crab.conf
mkdir /usr/share/crab
cp conf /usr/share/crab/crab.conf
chmod 660 /usr/share/crab/crab.conf

View file

@ -1,16 +1,16 @@
# **Crab**
`Crab`, a.k.a `Cool Rust Authentication Binary` is a rusty replacement for sudo and doas on Linux systems
`Crab`, a.k.a `Cool Rust Authentication Binary` is a rusty replacement for sudo or doas on Linux systems.
# Installation
### From Source
First run `cargo install --release` to compile the binary.
Then run `install.sh` as the root user to install files.
Then run `install.sh` as root to install crab.
### Arch Based Systems
If you are on arch-linux, the pakage is avaliable on the AUR as `crab-git`.
If you are on arch-linux, crab is avaliable on the AUR as `crab`.
# Configuration
Crab supports multiple users and persistence. Each line of the config is the username, then `true` of `false` if the crab authentication persists, seperated by a space.
Crab supports multiple users with persistence. Each line of the config is the username, then `true` of `false` if the crab authentication persists.
For Example
```

View file

@ -17,11 +17,13 @@ const ERROR_AUTH_FAILED: u8 = 5;
const ERROR_RUN_ROOT: u8 = 6;
const SUCCESS: u8 = 0;
const PERSIST_TIME: u64 = 60 * 3;
fn main() -> ExitCode {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
eprintln!("Invalid argument count.");
println!("usage: crab command [args]");
return ExitCode::from(ERROR_ARGS);
}
let config = match config("/etc/crab.conf") {
@ -135,7 +137,7 @@ fn get_terminal_process() -> Option<i32> {
Ok(data) => data,
Err(_) => return None
};
Some(stat.tty_nr)
Some(stat.session)
}
fn is_file_root_only(id: &i32) -> bool {
@ -181,7 +183,6 @@ fn write_terminal_config(id: &i32, data: &str) -> Result<(), Box<dyn std::error:
Ok(())
}
fn get_persist(user: &str) -> bool {
let json = match get_terminal_config() {
Some(data) => data,
@ -191,7 +192,7 @@ fn get_persist(user: &str) -> bool {
Some(data) => data,
None => return false
};
return now() - timestamp < 60 * 3;
return now() - timestamp < PERSIST_TIME;
}
fn set_persist(user: &str) {

16
uninstall.sh Normal file
View file

@ -0,0 +1,16 @@
#!/bin/bash
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
echo "Please run this as root"
exit
fi
# Delete crab files
rm /usr/bin/crab
chown root:root /bin/crab
chmod 6755 /bin/crab
# Set up config files
cp pam /etc/pam.d/crab
cp -n conf /etc/crab.conf
chmod 660 /etc/crab.conf