Change to using .singerrc and add the optional Notes section, also add license and readme file.
This commit is contained in:
parent
d801ab8dc5
commit
04501939d2
3 changed files with 15 additions and 6 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2,4 +2,4 @@
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "singer"
|
name = "singer"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "singer"
|
name = "singer"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
authors = ["Celeste <colean@colean.cc>"]
|
authors = ["Celeste <colean@colean.cc>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|
13
src/main.rs
13
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::net::{TcpListener, TcpStream};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
use std::fs::File;
|
||||||
use std::string::{String};
|
use std::string::{String};
|
||||||
use std::process::Command;
|
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();
|
let mut homedir1 = String::from_utf8_lossy(&homedir.stdout).to_string();
|
||||||
homedir1.pop();
|
homedir1.pop();
|
||||||
|
|
||||||
if path_exist(format!("{}/.yes_finger", homedir1)) {
|
if path_exist(format!("{}/.singerrc", homedir1)) {
|
||||||
let foutput = Command::new("sh")
|
let foutput = Command::new("sh")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(format!("getent passwd {} | cut -d: -f7", input))
|
.arg(format!("getent passwd {} | cut -d: -f7", input))
|
||||||
|
@ -48,7 +49,15 @@ fn process(request: Vec<u8>) -> String {
|
||||||
gecos.pop();
|
gecos.pop();
|
||||||
shell.pop();
|
shell.pop();
|
||||||
|
|
||||||
|
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);
|
output = format!("Login: {}\nName: {}\nDirectory: {}\nShell: {}", input, gecos, homedir1, shell);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
output = "The requested user does not exist.".to_string();
|
output = "The requested user does not exist.".to_string();
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue