From 650f29a7c69ffd06f7fed934225fed8c0cd7a386 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Sat, 1 Jun 2024 15:59:09 +0200 Subject: [PATCH] don't set up passwd/group files --- backend/cmd/httpd/sandbox.ha | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/backend/cmd/httpd/sandbox.ha b/backend/cmd/httpd/sandbox.ha index c2e656a..0f05086 100644 --- a/backend/cmd/httpd/sandbox.ha +++ b/backend/cmd/httpd/sandbox.ha @@ -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);