Change to using .singerrc and add the optional Notes section, also add license and readme file.

This commit is contained in:
abbie 2021-12-23 18:02:25 +00:00
parent d801ab8dc5
commit 04501939d2
No known key found for this signature in database
GPG key ID: 04DDE463F9200F87
3 changed files with 15 additions and 6 deletions

2
Cargo.lock generated
View file

@ -2,4 +2,4 @@
# It is not intended for manual editing.
[[package]]
name = "singer"
version = "0.1.0"
version = "0.1.1"

View file

@ -1,6 +1,6 @@
[package]
name = "singer"
version = "0.1.1"
version = "0.1.2"
authors = ["Celeste <colean@colean.cc>"]
edition = "2018"

View file

@ -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<u8>) -> 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))
@ -48,7 +49,15 @@ fn process(request: Vec<u8>) -> 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();
}