ww build: honor Go output permission modes
This commit is contained in:
27
test/package/umaskexec.c
Normal file
27
test/package/umaskexec.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *end;
|
||||
unsigned long mask;
|
||||
|
||||
if (argc < 3) {
|
||||
fputs("usage: package-umaskexec MASK PROGRAM [ARG ...]\n", stderr);
|
||||
return 2;
|
||||
}
|
||||
errno = 0;
|
||||
mask = strtoul(argv[1], &end, 8);
|
||||
if (errno != 0 || end == argv[1] || *end != '\0' || mask > 0777) {
|
||||
fputs("package-umaskexec: invalid mask\n", stderr);
|
||||
return 2;
|
||||
}
|
||||
umask((mode_t)mask);
|
||||
execv(argv[2], &argv[2]);
|
||||
fputs("package-umaskexec: exec failed\n", stderr);
|
||||
return 127;
|
||||
}
|
||||
Reference in New Issue
Block a user