Commit 1eb10f4
unix-socket: handle long socket pathnames
On many systems, the sockaddr_un.sun_path field is quite
small. Even on Linux, it is only 108 characters. A user of
the credential-cache daemon can easily surpass this,
especially if their home directory is in a deep directory
tree (since the default location expands ~/.git-credentials).
We can hack around this in the unix-socket.[ch] code by
doing a chdir() to the enclosing directory, feeding the
relative basename to the socket functions, and then
restoring the working directory.
This introduces several new possible error cases for
creating a socket, including an irrecoverable one in the
case that we can't restore the working directory. In the
case of the credential-cache code, we could perhaps get away
with simply chdir()-ing to the socket directory and never
coming back. However, I'd rather do it at the lower level
for a few reasons:
1. It keeps the hackery behind an opaque interface instead
of polluting the main program logic.
2. A hack in credential-cache won't help any unix-socket
users who come along later.
3. The chdir trickery isn't that likely to fail (basically
it's only a problem if your cwd is missing or goes away
while you're running). And because we only enable the
hack when we get a too-long name, it can only fail in
cases that would have failed under the previous code
anyway.
Signed-off-by: Jeff King <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>1 parent 98c2924 commit 1eb10f4
1 file changed
+66
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
13 | 39 | | |
14 | 40 | | |
15 | | - | |
16 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
17 | 68 | | |
18 | 69 | | |
19 | 70 | | |
| 71 | + | |
20 | 72 | | |
21 | 73 | | |
22 | 74 | | |
23 | 75 | | |
24 | 76 | | |
25 | 77 | | |
| 78 | + | |
26 | 79 | | |
27 | | - | |
| 80 | + | |
| 81 | + | |
28 | 82 | | |
29 | 83 | | |
| 84 | + | |
30 | 85 | | |
31 | 86 | | |
32 | 87 | | |
| 88 | + | |
33 | 89 | | |
34 | 90 | | |
35 | 91 | | |
36 | 92 | | |
37 | 93 | | |
38 | 94 | | |
39 | 95 | | |
| 96 | + | |
40 | 97 | | |
41 | | - | |
| 98 | + | |
| 99 | + | |
42 | 100 | | |
43 | 101 | | |
44 | 102 | | |
45 | 103 | | |
| 104 | + | |
46 | 105 | | |
47 | 106 | | |
48 | 107 | | |
49 | 108 | | |
50 | 109 | | |
| 110 | + | |
51 | 111 | | |
52 | 112 | | |
53 | 113 | | |
54 | 114 | | |
| 115 | + | |
55 | 116 | | |
56 | 117 | | |
0 commit comments