summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs9
1 files changed, 5 insertions, 4 deletions
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) {