1
Fork 0

don't set up passwd/group files

This commit is contained in:
Jan-Erik Rediger 2024-06-01 15:59:09 +02:00
parent 8d80d6f8ab
commit 650f29a7c6

View file

@ -41,10 +41,6 @@ export fn run_code(code: str) (str, str) = {
home_dir(&args, uid);
let (passwd_r, group_r) = passwd_files(&args, uid, gid);
defer io::close(passwd_r)!;
defer io::close(group_r)!;
let code_path = fmt::asprintf("{}/main.ha", app_dir);
defer free(code_path);
let code_fp = os::create(code_path, 0o644)!;
@ -79,37 +75,6 @@ export fn run_code(code: str) (str, str) = {
return (stdout, stderr);
};
fn passwd_files(args: *[]str, uid: u32, gid: u32) (io::file, io::file) = {
const passwd = `root:x:0:0:root:/root:/bin/bash
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin`;
const group = `root:x:0:
nogroup:x:65534:`;
let uid = fmt::asprintf("{}", uid);
// defer free(uid);
let gid = fmt::asprintf("{}", gid);
// defer free(gid);
let (passwd_r, passwd_w) = exec::pipe();
io::writeall(passwd_w, strings::toutf8(passwd))!;
io::close(passwd_w)!;
let (group_r, group_w) = exec::pipe();
io::writeall(group_w, strings::toutf8(group))!;
io::close(group_w)!;
append(args, "--file");
append(args, fmt::asprintf("{}", passwd_r: int));
append(args, "/etc/passwd");
append(args, "--file");
append(args, fmt::asprintf("{}", group_r: int));
append(args, "/etc/group");
return (passwd_r, group_r);
};
fn home_dir(args: *[]str, uid: u32) void = {
let user_dir = fmt::asprintf("/run/user/{}", uid);
let home_dir = fmt::asprintf("{}/home", user_dir);