Skip to content

Commit

Permalink
Merge pull request #252 from zenhack/enter-grain-toolchain-bitrot
Browse files Browse the repository at this point in the history
Fix some bitrot in enter_grain
  • Loading branch information
ocdtrekkie authored Feb 1, 2020
2 parents bc0860e + 8ce6bd4 commit 06438b4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
6 changes: 5 additions & 1 deletion helpers/enter-grain-source/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions helpers/enter-grain-source/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#![feature(alloc_system)]
extern crate alloc_system;

// use std::env;
use std::fs::File;
use std::fs::{File, metadata};
use std::os::unix::fs::MetadataExt;
use std::io::Read;
use std::ptr;
use std::env;
Expand Down Expand Up @@ -74,13 +72,12 @@ fn wait_all_children() {
}
}

fn setuid_setgid_1000() {
// These are the right UID & GID because they are what Sandstorm
// uses inside the user namespace.
let one_thousand = 1000usize;
fn setuid_setgid() {
let meta = metadata("/var").unwrap();

unsafe {
syscall!(SETUID, one_thousand);
syscall!(SETGID, one_thousand);
syscall!(SETUID, meta.uid());
syscall!(SETGID, meta.gid());
}
}

Expand Down Expand Up @@ -173,7 +170,7 @@ fn main() {
let fork_result = fork();
if fork_result == 0 {
// in the child
setuid_setgid_1000();
setuid_setgid();
execve_bash(result);
} else {
// in the parent
Expand Down
Binary file modified helpers/enter_grain
Binary file not shown.
2 changes: 1 addition & 1 deletion helpers/enter_grain.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11198904136a7e8079d41ef50af613d21786b5b8 enter_grain
3e1a80bd7ca1f61de6b3044e904947264e6f6e53 enter_grain

0 comments on commit 06438b4

Please sign in to comment.