Correctly use salt
This commit is contained in:
+1
-3
@@ -17,8 +17,6 @@ pub fn main() {
|
||||
let _ = syscall::open(&tty, syscall::flag::O_RDWR);
|
||||
let _ = syscall::open(&tty, syscall::flag::O_RDWR);
|
||||
|
||||
env::set_current_dir("file:").unwrap();
|
||||
|
||||
env::set_var("TTY", &tty);
|
||||
{
|
||||
let mut path = [0; 4096];
|
||||
@@ -37,7 +35,7 @@ pub fn main() {
|
||||
loop {
|
||||
//stdout.write(b"\x1Bc").unwrap();
|
||||
let _ = stdout.flush();
|
||||
match Command::new("file:bin/login").spawn() {
|
||||
match Command::new("login").spawn() {
|
||||
Ok(mut child) => match child.wait() {
|
||||
Ok(_status) => (), //println!("getty: waited for login: {:?}", status.code()),
|
||||
Err(err) => panic!("getty: failed to wait for login: {}", err)
|
||||
|
||||
+1
-3
@@ -48,11 +48,9 @@ pub fn main() {
|
||||
stdout.write(b"\n").unwrap();
|
||||
let _ = stdout.flush();
|
||||
|
||||
let password_hash = Passwd::encode(&password);
|
||||
|
||||
for line in passwd_string.lines() {
|
||||
if let Ok(passwd) = Passwd::parse(line) {
|
||||
if user == passwd.user && password_hash == passwd.hash {
|
||||
if user == passwd.user && passwd.verify(&password) {
|
||||
passwd_option = Some(passwd);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
extern crate termion;
|
||||
extern crate userutils;
|
||||
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
let passwd = env::args().nth(1).unwrap();
|
||||
let salt = env::args().nth(2).unwrap();
|
||||
println!("{}", userutils::Passwd::encode(&passwd, &salt));
|
||||
}
|
||||
+2
-4
@@ -26,7 +26,7 @@ pub fn main() {
|
||||
let uid = syscall::getuid().unwrap();
|
||||
|
||||
let mut passwd_string = String::new();
|
||||
File::open("file:etc/passwd").unwrap().read_to_string(&mut passwd_string).unwrap();
|
||||
File::open("/etc/passwd").unwrap().read_to_string(&mut passwd_string).unwrap();
|
||||
|
||||
let mut passwd_option = None;
|
||||
for line in passwd_string.lines() {
|
||||
@@ -46,11 +46,9 @@ pub fn main() {
|
||||
stdout.write(b"\n").unwrap();
|
||||
let _ = stdout.flush();
|
||||
|
||||
let password_hash = Passwd::encode(&password);
|
||||
|
||||
for line in passwd_string.lines() {
|
||||
if let Ok(passwd) = Passwd::parse(line) {
|
||||
if user == passwd.user && password_hash == passwd.hash {
|
||||
if user == passwd.user && passwd.verify(&password) {
|
||||
passwd_option = Some(passwd);
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ pub fn main() {
|
||||
|
||||
if uid != 0 {
|
||||
let mut passwd_string = String::new();
|
||||
File::open("file:etc/passwd").unwrap().read_to_string(&mut passwd_string).unwrap();
|
||||
File::open("/etc/passwd").unwrap().read_to_string(&mut passwd_string).unwrap();
|
||||
|
||||
let mut passwd_option = None;
|
||||
for line in passwd_string.lines() {
|
||||
@@ -32,7 +32,7 @@ pub fn main() {
|
||||
let passwd = passwd_option.expect("sudo: user not found in passwd");
|
||||
|
||||
let mut group_string = String::new();
|
||||
File::open("file:etc/group").unwrap().read_to_string(&mut group_string).unwrap();
|
||||
File::open("/etc/group").unwrap().read_to_string(&mut group_string).unwrap();
|
||||
|
||||
let mut group_option = None;
|
||||
for line in group_string.lines() {
|
||||
|
||||
Reference in New Issue
Block a user