diff --git a/Cargo.lock b/Cargo.lock index a483b7a..fdcc2b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,4 +2,4 @@ # It is not intended for manual editing. [[package]] name = "singer" -version = "0.1.0" +version = "0.1.1" diff --git a/Cargo.toml b/Cargo.toml index 39ff6d4..b174efa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "singer" -version = "0.1.1" +version = "0.1.2" authors = ["Celeste "] edition = "2018" diff --git a/src/main.rs b/src/main.rs index 9927275..5a1f004 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ -use std::io::{Write, BufReader, BufRead}; +use std::io::{Write, BufReader, BufRead, Read}; use std::net::{TcpListener, TcpStream}; use std::fs; +use std::fs::File; use std::string::{String}; use std::process::Command; @@ -31,7 +32,7 @@ fn process(request: Vec) -> String { let mut homedir1 = String::from_utf8_lossy(&homedir.stdout).to_string(); homedir1.pop(); - if path_exist(format!("{}/.yes_finger", homedir1)) { + if path_exist(format!("{}/.singerrc", homedir1)) { let foutput = Command::new("sh") .arg("-c") .arg(format!("getent passwd {} | cut -d: -f7", input)) @@ -47,8 +48,16 @@ fn process(request: Vec) -> String { let mut shell = String::from_utf8_lossy(&foutput.stdout).to_string(); gecos.pop(); shell.pop(); - - output = format!("Login: {}\nName: {}\nDirectory: {}\nShell: {}", input, gecos, homedir1, shell); + + let mut file = File::open(format!("{}/.singerrc", homedir1)).unwrap(); + let mut object = String::new(); + file.read_to_string(&mut object).unwrap(); + object.pop(); + if object != "" { + output = format!("Login: {}\nName: {}\nDirectory: {}\nShell: {}\nNotes:\n{}", input, gecos, homedir1, shell, object); + } else { + output = format!("Login: {}\nName: {}\nDirectory: {}\nShell: {}", input, gecos, homedir1, shell); + } } else { output = "The requested user does not exist.".to_string(); }