From 04501939d206b0e05564099c90ae476bd10b4311 Mon Sep 17 00:00:00 2001 From: Celeste Date: Thu, 23 Dec 2021 18:02:25 +0000 Subject: [PATCH] Change to using .singerrc and add the optional Notes section, also add license and readme file. --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 17 +++++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) 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(); }