[hackers] [sbase] touch(1) permissions correction

From: Ali H. Fardan <raiz_AT_firemail.cc>
Date: Thu, 01 Sep 2016 20:13:33 +0300

from a security prespective, touch should not allow
everyone to have write permissions to the file, if
someones needs such a permission, chmod(1) can be
used later.
I have tried touch(1) from coreutils and OpenBSD,
both set the default permissions to 644.

Raiz

diff --git a/touch.c b/touch.c
index 6e63bf8..a849901 100644
--- a/touch.c
+++ b/touch.c
_AT_@ -26,7 +26,7 @@ touch(const char *file)
                  eprintf("utimensat %s:", file);
          if (cflag)
                  return;
- if ((fd = open(file, O_WRONLY | O_CREAT | O_EXCL, 0666)) < 0)
+ if ((fd = open(file, O_WRONLY | O_CREAT | O_EXCL, 0644)) < 0)
                  eprintf("open %s:", file);
          ret = futimens(fd, times);
          close(fd);
Received on Thu Sep 01 2016 - 19:13:33 CEST

This archive was generated by hypermail 2.3.0 : Thu Sep 01 2016 - 19:24:14 CEST