ww build: honor Go output permission modes

This commit is contained in:
2026-08-20 22:03:09 +09:00
parent 77168fd891
commit 84f5e68709
8 changed files with 513 additions and 9 deletions

View File

@@ -302,8 +302,10 @@ export fn main(argc: i32, argv: **u8) i32 = {
return 1;
};
// Pinned Go's BuildInstallFunc creates an ordinary linked command with
// 0o777; open applies the invoking process's umask to this fresh stage.
let flags: os.flag = os.flag.WRONLY | os.flag.CREATE | os.flag.TRUNC;
let fd: i32 = os.open(pathstr(outpath), flags, 493i32); // 0o755
let fd: i32 = os.open(pathstr(outpath), flags, 511i32); // 0o777
if (fd < 0) {
let m: str = "w6l: cannot open output\n";
os.write(2, m.ptr, m.len: u64);

View File

@@ -5896,8 +5896,10 @@ fn fileequal(a: *u8, b: *u8) bool = {
fn copyfilestage(src: *u8, dst: *u8) i32 = {
let in: i32 = os.open(pathstr(src), os.flag.RDONLY, 0i32);
if (in < 0) { return -1; };
// BuildInstallFunc gives non-link outputs base mode 0o666; the fresh
// publication stage applies the invoking process's umask at creation.
let out: i32 = os.open(pathstr(dst),
os.flag.WRONLY | os.flag.CREATE | os.flag.TRUNC, 420i32);
os.flag.WRONLY | os.flag.CREATE | os.flag.TRUNC, 438i32);
if (out < 0) { os.close(in); return -1; };
let buf: [65536]u8;
let bad: bool = false;