Skip to content

Commit

Permalink
Fix #251 and some bitrot in enter_grain
Browse files Browse the repository at this point in the history
This is one commit instead of two because we didn't want to bloat the
repository with two updates to the executable. We should really just
remove the binary from the repo and build it; see #253

The bitrot:

With #![feature(alloc_system)] I get an error from the rust toolchain
that the feature has been removed. We don't appear to actually be using
this anyway, so let's just remove it.
  • Loading branch information
zenhack committed Jan 31, 2020
1 parent bc0860e commit 8ce6bd4
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 8ce6bd4

Please sign in to comment.