Add smith editor, hashing in login, update ion
This commit is contained in:
parent
6911093696
commit
3ff51e6e5f
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -22,3 +22,6 @@
|
|||
[submodule "programs/extrautils"]
|
||||
path = programs/extrautils
|
||||
url = https://github.com/redox-os/extrautils.git
|
||||
[submodule "programs/smith"]
|
||||
path = programs/smith
|
||||
url = https://github.com/redox-os/Smith.git
|
||||
|
|
3
Makefile
3
Makefile
|
@ -266,7 +266,8 @@ $(BUILD)/filesystem.bin: \
|
|||
extrautils \
|
||||
schemes \
|
||||
filesystem/bin/ion \
|
||||
filesystem/bin/login
|
||||
filesystem/bin/login \
|
||||
filesystem/bin/smith
|
||||
rm -rf $@ $(BUILD)/filesystem/
|
||||
echo exit | cargo run --manifest-path schemes/redoxfs/Cargo.toml --bin redoxfs-utility $@
|
||||
mkdir -p $(BUILD)/filesystem/
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit cbb3c3003f654d09cd3b3cf1a179469bb1b558b3
|
||||
Subproject commit d0a2e0a224bc1c57718d58b7b2d1cd8d1c80d052
|
|
@ -3,4 +3,14 @@ name = "login"
|
|||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
liner = "*"
|
||||
syscall = { path = "../../syscall/" }
|
||||
|
||||
[dependencies.octavo]
|
||||
git = "https://github.com/libOctavo/octavo"
|
||||
default-features = false
|
||||
features = ["digest"]
|
||||
|
||||
[replace]
|
||||
"libc:0.2.16" = { git = "https://github.com/redox-os/liblibc.git", branch = "new_kernel" }
|
||||
"rustc-serialize:0.3.19" = { git = "https://github.com/redox-os/rustc-serialize.git" }
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
extern crate liner;
|
||||
extern crate octavo;
|
||||
extern crate syscall;
|
||||
|
||||
use std::env;
|
||||
use liner::Context;
|
||||
use octavo::octavo_digest::Digest;
|
||||
use octavo::octavo_digest::sha3::Sha512;
|
||||
use std::process::Command;
|
||||
use std::thread;
|
||||
use std::{env, thread};
|
||||
|
||||
pub fn main() {
|
||||
let mut args = env::args().skip(1);
|
||||
|
@ -11,8 +15,6 @@ pub fn main() {
|
|||
let sh = args.next().expect("login: no sh provided");
|
||||
let sh_args: Vec<String> = args.collect();
|
||||
|
||||
env::set_current_dir("file:").expect("login: failed to cd to file:");
|
||||
|
||||
let _ = syscall::close(2);
|
||||
let _ = syscall::close(1);
|
||||
let _ = syscall::close(0);
|
||||
|
@ -21,18 +23,42 @@ pub fn main() {
|
|||
let _ = syscall::open(&tty, syscall::flag::O_RDWR);
|
||||
let _ = syscall::open(&tty, syscall::flag::O_RDWR);
|
||||
|
||||
env::set_var("COLUMNS", "80");
|
||||
env::set_var("LINES", "30");
|
||||
env::set_var("TTY", &tty);
|
||||
|
||||
thread::spawn(move || {
|
||||
let mut con = Context::new();
|
||||
|
||||
loop {
|
||||
let user = con.read_line("\x1B[1mredox login:\x1B[0m ", &mut |_| {}).expect("login: failed to read user");
|
||||
|
||||
if ! user.is_empty() {
|
||||
let password = con.read_line("\x1B[1mpassword:\x1B[0m ", &mut |_| {}).expect("login: failed to read user");
|
||||
|
||||
let mut output = vec![0; Sha512::output_bytes()];
|
||||
let mut hash = Sha512::default();
|
||||
hash.update(&password.as_bytes());
|
||||
hash.result(&mut output);
|
||||
|
||||
print!("hash: ");
|
||||
for b in output.iter() {
|
||||
print!("{:X} ", b);
|
||||
}
|
||||
println!("");
|
||||
|
||||
let home = "file:home";
|
||||
|
||||
env::set_current_dir(home).expect("login: failed to cd to home");
|
||||
|
||||
let mut command = Command::new(&sh);
|
||||
for arg in sh_args.iter() {
|
||||
command.arg(arg);
|
||||
}
|
||||
|
||||
command.env("HOME", "file:home");
|
||||
command.env("USER", &user);
|
||||
command.env("HOME", home);
|
||||
command.env("PATH", "file:bin");
|
||||
command.env("COLUMNS", "80");
|
||||
command.env("LINES", "30");
|
||||
command.env("TTY", &tty);
|
||||
|
||||
match command.spawn() {
|
||||
Ok(mut child) => match child.wait() {
|
||||
|
@ -42,5 +68,6 @@ pub fn main() {
|
|||
Err(err) => panic!("login: failed to execute '{}': {}", sh, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
1
programs/smith
Submodule
1
programs/smith
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 23405d7cd9f59d37dbaa6b07fe3ab66b065beff5
|
Loading…
Reference in a new issue