Skip to content

Commit 5e8515e

Browse files
dschogitster
authored andcommitted
maintenance(systemd): support the Windows Subsystem for Linux
When running in the Windows Subsystem for Linux (WSL), it is usually necessary to use the Git Credential Manager for authentication when performing the background fetches. This requires interoperability between the Windows Subsystem for Linux and the Windows host to work, which uses so-called vsocks, i.e. sockets intended for communcations between virtual machines and the host they are running on. However, when Git is configured to run background maintenance via `systemd`, the address families available to those maintenance processes are restricted, and did not include `AF_VSOCK`. This leads to problems e.g. when a background fetch tries to access github.com: systemd[437]: Starting Optimize Git repositories data... git[747387]: WSL (747387) ERROR: UtilBindVsockAnyPort:285: socket failed 97 git[747381]: fatal: could not read Username for 'https://github.com': No such device or address git[747381]: error: failed to prefetch remotes git[747381]: error: task 'prefetch' failed systemd[437]: [email protected]: Main process exited, code=exited, status=1/FAILURE systemd[437]: [email protected]: Failed with result 'exit-code'. systemd[437]: Failed to start Optimize Git repositories data. Address this (pun intended) by adding the `AF_VSOCK` address family to the allow list. This fixes microsoft#604. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 43c8a30 commit 5e8515e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2397,7 +2397,7 @@ static int systemd_timer_write_unit_templates(const char *exec_path)
23972397
"LockPersonality=yes\n"
23982398
"MemoryDenyWriteExecute=yes\n"
23992399
"NoNewPrivileges=yes\n"
2400-
"RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6\n"
2400+
"RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_VSOCK\n"
24012401
"RestrictNamespaces=yes\n"
24022402
"RestrictRealtime=yes\n"
24032403
"RestrictSUIDSGID=yes\n"

0 commit comments

Comments
 (0)