[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Coreutils-gotchas
From: |
Assaf Gordon |
Subject: |
Re: Coreutils-gotchas |
Date: |
Wed, 16 Dec 2015 15:29:47 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 |
On 12/16/2015 01:52 PM, Pádraig Brady wrote:
On 16/12/15 18:45, Assaf Gordon wrote:
The recent "touch -d yesterday" might be a 'gotcha'
( http://lists.gnu.org/archive/html/bug-coreutils/2015-12/msg00041.html ) .
<...>
That's a Linux gotcha if anything.
I fear the page will get too noisy/large if including such system policies.
I agree that we should not focus on system-specific policies, but allow me to
present two counter points:
1. The '-d now' usage is a feature by gnu coreutils which specifically passes
NULL to the syscall (instead of a non-null timespec containing the current
time) - as such isn't instinctively clear to the user that there's a different
mechanism in place (and the comment in touch.c:157 indicates that this is a
special case, a feature which doesn't exist in other 'touch' implementations).
And it passes NULL to the syscall regardless of which operating system is used.
2. The "NULL = current-time" feature seems to have the same relaxed permission
requirements on other common operating systems, and in POSIX:
From man page of FreeBSD,OpenBSD futimens(2) and Mac OS X futimes(2):
===
If times is NULL, the access and modification times are set to the cur-
rent time. The caller must be the owner of the file, have permission to
write the file, or be the super-user.
If times is non-NULL, [...] The caller must be the owner of the file or be
the super-user.
===
From man page of OpenSolaris 5.11 futimens(2) and POSIX (
http://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html ):
===
Only a process with the effective user ID equal to the user
ID of the file, or with write access to the file, or with
appropriate privileges may use futimens() or utimensat()
with a null pointer as the times argument [...]
Only a process with the effective user ID equal to the user ID of
the file or with appropriate privileges may use futimens()
or utimensat() with a non-null times argument [...]
===
So one could say that "time=NULL" requiring only write-permission while
"time!=NULL" requires ownership is not linux-specific,
and because GNU coreutils' 'touch' is one of the few user-land utilities that
exposes this ability,
it might be useful to mention it somewhere.
just my 2 cents,
- assaf