Add permissions to the filesystem, preliminary permissions to the syscalls
This commit is contained in:
parent
478bc20b85
commit
f4a1d06f07
19 changed files with 142 additions and 20 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 648a0d119aaed8f4cf8c856e05e47da421c4074a
|
||||
Subproject commit fe104e72ea1d756556e0d6d98158713f6c3a8a38
|
|
@ -1 +1 @@
|
|||
Subproject commit 6f0ef493c9f48f7b0c8dfe7c2a9a029f68fdda19
|
||||
Subproject commit d6c122a94cd760819f139f2af6ea22e4f4b17151
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
extern crate syscall;
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::io::Write;
|
||||
use std::process::Command;
|
||||
use std::{env, io, str, thread};
|
||||
|
||||
|
|
6
programs/id/Cargo.toml
Normal file
6
programs/id/Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
|||
[package]
|
||||
name = "id"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
syscall = { path = "../../syscall/" }
|
11
programs/id/src/main.rs
Normal file
11
programs/id/src/main.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
#![feature(question_mark)]
|
||||
|
||||
extern crate syscall;
|
||||
|
||||
use std::env;
|
||||
|
||||
pub fn main() {
|
||||
let uid = syscall::getuid().expect("id: failed to get UID");
|
||||
let gid = syscall::getgid().expect("id: failed to get GID");
|
||||
println!("uid={}({}) gid={}({})", uid, env::var("USER").unwrap_or(String::new()), gid, "");
|
||||
}
|
|
@ -7,15 +7,15 @@ use octavo::octavo_digest::Digest;
|
|||
use octavo::octavo_digest::sha3::Sha512;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::process::Command;
|
||||
use std::{env, io, str, thread};
|
||||
use std::process::{Command, CommandExt};
|
||||
use std::{io, str};
|
||||
use termion::input::TermRead;
|
||||
|
||||
pub struct Passwd<'a> {
|
||||
user: &'a str,
|
||||
hash: &'a str,
|
||||
uid: usize,
|
||||
gid: usize,
|
||||
uid: u32,
|
||||
gid: u32,
|
||||
name: &'a str,
|
||||
home: &'a str,
|
||||
shell: &'a str
|
||||
|
@ -27,8 +27,8 @@ impl<'a> Passwd<'a> {
|
|||
|
||||
let user = parts.next().ok_or(())?;
|
||||
let hash = parts.next().ok_or(())?;
|
||||
let uid = parts.next().ok_or(())?.parse::<usize>().or(Err(()))?;
|
||||
let gid = parts.next().ok_or(())?.parse::<usize>().or(Err(()))?;
|
||||
let uid = parts.next().ok_or(())?.parse::<u32>().or(Err(()))?;
|
||||
let gid = parts.next().ok_or(())?.parse::<u32>().or(Err(()))?;
|
||||
let name = parts.next().ok_or(())?;
|
||||
let home = parts.next().ok_or(())?;
|
||||
let shell = parts.next().ok_or(())?;
|
||||
|
@ -118,7 +118,10 @@ pub fn main() {
|
|||
|
||||
let mut command = Command::new(passwd.shell);
|
||||
|
||||
env::set_current_dir(passwd.home).unwrap();
|
||||
command.uid(passwd.uid);
|
||||
command.gid(passwd.gid);
|
||||
|
||||
command.current_dir(passwd.home);
|
||||
|
||||
command.env("USER", &user);
|
||||
command.env("HOME", passwd.home);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue