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

Re: [PATCH 1/2] credential-cache--daemon: allow a concurrently created socket dir

From
Farid Zakaria <farid.m.zakaria@gmail.com>
Date
Nov 4, 2026, 18:25 UTC
Message-ID
<DMMMYT4Q87N3.W2MQQMHI76I6@gmail.com>
In-Reply-To
<aumUxF1uVtVC4qYj@pks.im>
On Tue Nov 3, 2026 at 12:01 AM PST, Patrick Steinhardt wrote:
Show 22 quoted lines
> On Sun, Nov 01, 2026 at 03:29:25PM -0800, Farid Zakaria wrote:
>> diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c
>> index 65cc619bec..0dfa11e2ec 100644
>> --- a/builtin/credential-cache--daemon.c
>> +++ b/builtin/credential-cache--daemon.c
>> @@ -273,8 +273,18 @@ static void init_socket_directory(const char *path)
>>  		 */
>>  		if (safe_create_leading_directories_const(the_repository, dir) < 0)
>>  			die_errno("unable to create directories for '%s'", dir);
>
> It's quite curious that we use `safe_create_leading_directories()` here.
> As documented in "path.h", the `safe_...()` functions should only ever
> be used for creating directories in the ".git" directory itself. In
> particular, applying "core.sharedRepostiory" to the leading directories
> of our credential daemon is never going to result in anything good at
> all.
>
> So we should call `safe_create_leadingdirectories_no_share_const()`
> instead, which does not apply "core.sharedRepository". I know that's not
> introduced by your patch, but would you mind maybe fixing that in a
> preparatory commit?
>
Sure, I'll add that as the first patch in v2.
Show 22 quoted lines
>> -		if (mkdir(dir, 0700) < 0)
>> -			die_errno("unable to mkdir '%s'", dir);
>> +		if (mkdir(dir, 0700) < 0) {
>> +			if (errno != EEXIST)
>> +				die_errno("unable to mkdir '%s'", dir);
>
> Makes sense.
>
>> +			/*
>> +			 * Another daemon created it first; check it like one
>> +			 * that already existed.
>> +			 */
>> +			if (stat(dir, &st))
>> +				die_errno("unable to stat '%s'", dir);
>> +			if (st.st_mode & 077)
>> +				die(_(permissions_advice), dir);
>> +		}
>
> A bit of a shame that we duplicate this logic, but I don't see an
> obvious way for how to avoid that.
>
> Patrick
Previous: Patrick SteinhardtNext: Jeff King
Message 4 of 14 in “credential-cache: fix two races when daemons start at once”
  1. 0/2 credential-cache: fix two races when daemons start at onceFarid Zakaria, Nov 1, 2026
  2. 1/2 credential-cache--daemon: allow a concurrently created socket dirFarid Zakaria, Nov 1, 2026
  3. Patrick SteinhardtNov 3, 2026
  4. Farid ZakariaNov 4, 2026
  5. Jeff KingNov 4, 2026
  6. 2/2 credential-cache--daemon: do not take over a running daemon's socketFarid Zakaria, Nov 1, 2026
  7. Patrick SteinhardtNov 3, 2026
  8. Farid ZakariaNov 4, 2026
  9. Junio C HamanoNov 3, 2026
  10. Jeff KingNov 4, 2026
  11. 0/3 credential-cache: fix two races when daemons start at onceFarid Zakaria, Nov 4, 2026
  12. 1/3 credential-cache--daemon: do not apply core.sharedRepositoryFarid Zakaria, Nov 4, 2026
  13. 2/3 credential-cache--daemon: allow a concurrently created socket dirFarid Zakaria, Nov 4, 2026
  14. 3/3 credential-cache--daemon: do not take over a running daemon's socketFarid Zakaria, Nov 4, 2026

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.