summaryrefslogtreecommitdiff
path: root/src/touch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/touch.c')
-rw-r--r--src/touch.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/touch.c b/src/touch.c
index f9374c07a..8c816e4b4 100644
--- a/src/touch.c
+++ b/src/touch.c
@@ -132,9 +132,11 @@ touch (const char *file)
else if (! (no_create || no_dereference))
{
/* Try to open FILE, creating it if necessary. */
+ int default_permissions =
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
fd = fd_reopen (STDIN_FILENO, file,
O_WRONLY | O_CREAT | O_NONBLOCK | O_NOCTTY,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
+ default_permissions);
/* Don't save a copy of errno if it's EISDIR, since that would lead
touch to give a bogus diagnostic for e.g., `touch /' (assuming