ww build: honor Go output permission modes
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* `path` is acceptable iff it's either an archive ("!<arch>\n") or
|
||||
* an ELF file ("\x7fELF"). Distros often ship lib<name>.so as a GNU
|
||||
@@ -121,17 +121,23 @@ main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE *f = fopen(out, "wb");
|
||||
/* BuildInstallFunc creates ordinary linked commands with 0777 and lets the
|
||||
* caller's umask select the installed mode. Public ww builds link into a
|
||||
* fresh transaction stage, whose inode is later renamed to the output. */
|
||||
int fd = open(out, O_WRONLY | O_CREAT | O_TRUNC, 0777);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "w6l: cannot open %s\n", out);
|
||||
return 1;
|
||||
}
|
||||
FILE *f = fdopen(fd, "wb");
|
||||
if (f == NULL) {
|
||||
close(fd);
|
||||
(void)unlink(out);
|
||||
fprintf(stderr, "w6l: cannot open %s\n", out);
|
||||
return 1;
|
||||
}
|
||||
int rc = l_emit_elf(&l, f, base, base + 0x1000 + entry->val);
|
||||
fclose(f);
|
||||
if (rc == 0 && chmod(out, 0755) != 0) {
|
||||
fprintf(stderr, "w6l: cannot make %s executable\n", out);
|
||||
rc = 1;
|
||||
}
|
||||
free(inputs);
|
||||
return rc;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user