Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some bitrot in enter_grain #252

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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