Version of emscripten/emsdk:
A process-wide umask(0077) seems to be ignored by open(..., O_CREAT, 0666) and mkdir(). The created file keeps the raw mode instead of mode & ~umask.
Failing command line in full:
$ emcc -O0 -Wall umask.c -o a.out.js
$ node a.out.js
mode: 666 (expect 600)
The same program on native Linux prints mode: 600 (expect 600).
Example code snippet:
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
int main(void) {
mkdir("/tmp/xsv_test", 0755);
umask(0077);
int fd = open("/tmp/xsv_test/f.txt", O_WRONLY | O_CREAT | O_TRUNC, 0666);
write(fd, "x", 1);
close(fd);
struct stat st;
stat("/tmp/xsv_test/f.txt", &st);
printf("mode: %o (expect 600)\n", st.st_mode & 0777);
return ((st.st_mode & 0777) == 0600) ? 0 : 1;
}
Version of emscripten/emsdk:
A process-wide
umask(0077)seems to be ignored byopen(..., O_CREAT, 0666)andmkdir(). The created file keeps the raw mode instead ofmode & ~umask.Failing command line in full:
The same program on native Linux prints
mode: 600 (expect 600).Example code snippet: