summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortylermurphy534 <tylermurphy534@gmail.com>2022-11-09 00:51:47 -0500
committertylermurphy534 <tylermurphy534@gmail.com>2022-11-09 00:51:47 -0500
commitf36e11177342206419f22e46d7e121f0731cce9a (patch)
tree8248d3a3ad38071c75f9a5ac25b9347f2cb89a89
parentaur support (diff)
downloadcrab-f36e11177342206419f22e46d7e121f0731cce9a.tar.gz
crab-f36e11177342206419f22e46d7e121f0731cce9a.tar.bz2
crab-f36e11177342206419f22e46d7e121f0731cce9a.zip
fix session pid, add uninstall sh file
-rw-r--r--deployments/aur/.SRCINFO6
-rw-r--r--deployments/aur/PKGBUILD30
-rwxr-xr-xinstall.sh7
-rw-r--r--readme.md8
-rw-r--r--src/main.rs9
-rw-r--r--uninstall.sh16
6 files changed, 41 insertions, 35 deletions
diff --git a/deployments/aur/.SRCINFO b/deployments/aur/.SRCINFO
index 6f109a1..e7c3eed 100644
--- a/deployments/aur/.SRCINFO
+++ b/deployments/aur/.SRCINFO
@@ -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
diff --git a/deployments/aur/PKGBUILD b/deployments/aur/PKGBUILD
index 924509d..0749257 100644
--- a/deployments/aur/PKGBUILD
+++ b/deployments/aur/PKGBUILD
@@ -5,38 +5,24 @@
# 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
- cargo build --release
+ cd crab
+ cargo build --release
}
package() {
- cd crab
+ 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
}
diff --git a/install.sh b/install.sh
index 8cbb06c..716d9b1 100755
--- a/install.sh
+++ b/install.sh
@@ -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
diff --git a/readme.md b/readme.md
index 470f1e5..0e4aff8 100644
--- a/readme.md
+++ b/readme.md
@@ -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
```
diff --git a/src/main.rs b/src/main.rs
index cd10277..9061ade 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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) {
diff --git a/uninstall.sh b/uninstall.sh
new file mode 100644
index 0000000..f6cba7f
--- /dev/null
+++ b/uninstall.sh
@@ -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