From bf322dfbf37c5b1ea392e6f36775a06cde96a942 Mon Sep 17 00:00:00 2001 From: Benjamin Riefenstahl Date: Fri, 10 Dec 2021 20:44:26 +0000 Subject: [PATCH] ape/mkstemp: better options Use O_EXCL and make the file descriptor writeable. This is more usefull and it conforms to Single Unix and other specs. --- sys/src/ape/lib/ap/gen/mkstemp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/src/ape/lib/ap/gen/mkstemp.c b/sys/src/ape/lib/ap/gen/mkstemp.c index ef2169b59..7dd6e2dde 100644 --- a/sys/src/ape/lib/ap/gen/mkstemp.c +++ b/sys/src/ape/lib/ap/gen/mkstemp.c @@ -1,6 +1,7 @@ #include #include #include +#include int mkstemp(char *template) @@ -14,7 +15,7 @@ mkstemp(char *template) for(i=0; i<20; i++){ strcpy(s, template); mktemp(s); - if((fd = creat(s, 0666)) >= 0){ + if((fd = open(s, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0){ strcpy(template, s); free(s); return fd;