git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/1] freshen_file(): use NULL `times' for implicit current-time

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Apr 15, 2020, 23:48 UTC
Message-ID
<20200415234847.GI2751707@camp.crustytoothpaste.net>
In-Reply-To
<xmqq4ktk5t4h.fsf@gitster.c.googlers.com>
On 2020-04-15 at 21:36:14, Junio C Hamano wrote:
Show 18 quoted lines
> luciano.rocha@booking.com writes:
> 
> > Update freshen_file() to use a NULL `times', semantically equivalent to
> > the currently setup, with an explicit `actime' and `modtime' set to the
> > "current time", but with the advantage that it works with other files
> > not owned by the current user.
> >
> > Fixes an issue on shared repos with a split index, where eventually a
> > user's operation creates a shared index, and another user will later do
> > an operation that will try to update its freshness, but will instead
> > raise a warning:
> >   $ git status
> >   warning: could not freshen shared index '.git/sharedindex.bd736fa10e0519593fefdb2aec253534470865b2'
> 
> A couple of questions:
> 
>  - Does utime(fn, NULL) work for any non-owner user, or does the
>    user need to have write access to it?
The Linux man page says the following:
  Changing timestamps is permitted when: either the process has
  appropriate privileges, or the effective user ID equals the user ID of
  the file, or times is NULL and the process has write permission for
  the file.

So the answer is the user needs to have write access with utime(fn, NULL), but the same EUID (or root) with a specific time. I believe this behavior is because it doesn't make sense to restrict the operation which uses the current time since a user with write permissions could just run open(2) and write(2) instead with the same effect, just less efficiently.

(We've discussed this on the list before, but "appropriate privileges" is POSIX-speak for "root access" or the equivalent in an alternate system, such as capabilities.)

-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 8 in “freshen_file(): use NULL `times' for implicit current-time”
  1. 1/1 freshen_file(): use NULL `times' for implicit current-timeluciano.rocha@booking.com, Apr 14, 2020
  2. Jeff KingApr 14, 2020
  3. luciano.rocha@booking.comApr 15, 2020
  4. Jeff KingApr 15, 2020
  5. Junio C HamanoApr 15, 2020
  6. Junio C HamanoApr 15, 2020
  7. brian m. carlsonApr 15, 2020
  8. Junio C HamanoApr 16, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.