sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit a6c194fc749699155abc7d44cba2add1da3360b3
parent 63f8d388b1212e659df47f2434c58730d433ab7c
Author: Michael Forney <mforney@mforney.org>
Date:   Fri Jul  8 10:24:11 -0700

touch: Respect caller's umask

Currently, if the caller has a umask of 002 or 000, the file gets created as 644
anyway.

Also, add O_WRONLY to the open call, since POSIX says that "Applications shall
specify exactly one of the first five values (file access modes) below in the
value of oflag".

Diffstat:
touch.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/touch.c b/touch.c @@ -38,7 +38,7 @@ touch(const char *file) return; } - if ((fd = open(file, O_CREAT | O_EXCL, 0644)) < 0) + if ((fd = open(file, O_WRONLY | O_CREAT | O_EXCL, 0666)) < 0) eprintf("open %s:", file); close(fd);