{"thread":{"id":"60219","subject":"[PATCH] maintenance(systemd): support the Windows Subsystem for Linux","startedAt":"2023-09-10T08:30:28Z","lastAt":"2023-09-10T08:30:28Z","messageCount":1,"participants":["Johannes Schindelin via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"481645","messageId":"pull.1586.git.1694334620260.gitgitgadget@gmail.com","threadId":"60219","inReplyTo":null,"subject":"[PATCH] maintenance(systemd): support the Windows Subsystem for Linux","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-09-10T08:30:20Z","receivedAt":"2023-09-10T08:30:28Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nWhen running in the Windows Subsystem for Linux (WSL), it is usually\nnecessary to use the Git Credential Manager for authentication when\nperforming the background fetches.\n\nThis requires interoperability between the Windows Subsystem for Linux\nand the Windows host to work, which uses so-called vsocks, i.e. sockets\nintended for communcations between virtual machines and the host they\nare running on.\n\nHowever, when Git is configured to run background maintenance via\n`systemd`, the address families available to those maintenance processes\nare restricted, and did not include `AF_VSOCK`. This leads to problems\ne.g. when a background fetch tries to access github.com:\n\n\tsystemd[437]: Starting Optimize Git repositories data...\n\tgit[747387]: WSL (747387) ERROR: UtilBindVsockAnyPort:285: socket failed 97\n\tgit[747381]: fatal: could not read Username for 'https://github.com': No such device or address\n\tgit[747381]: error: failed to prefetch remotes\n\tgit[747381]: error: task 'prefetch' failed\n\tsystemd[437]: git-maintenance@hourly.service: Main process exited, code=exited, status=1/FAILURE\n\tsystemd[437]: git-maintenance@hourly.service: Failed with result 'exit-code'.\n\tsystemd[437]: Failed to start Optimize Git repositories data.\n\nAddress this (pun intended) by adding the `AF_VSOCK` address family to\nthe allow list.\n\nThis fixes https://github.com/microsoft/git/issues/604.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n    maintenance(systemd): support the Windows Subsystem for Linux\n    \n    https://github.com/microsoft/git/issues/604 reports a bug where git\n    maintenance start does not work in the Windows Subsystem for Linux\n    (WSL), and this patch fixes it.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1586%2Fdscho%2Fscheduled-maintenance-in-wsl-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1586/dscho/scheduled-maintenance-in-wsl-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/1586\n\n builtin/gc.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 5c4315f0d81..719cae9a88a 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -2397,7 +2397,7 @@ static int systemd_timer_write_unit_templates(const char *exec_path)\n \t       \"LockPersonality=yes\\n\"\n \t       \"MemoryDenyWriteExecute=yes\\n\"\n \t       \"NoNewPrivileges=yes\\n\"\n-\t       \"RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6\\n\"\n+\t       \"RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_VSOCK\\n\"\n \t       \"RestrictNamespaces=yes\\n\"\n \t       \"RestrictRealtime=yes\\n\"\n \t       \"RestrictSUIDSGID=yes\\n\"\n\nbase-commit: 43c8a30d150ecede9709c1f2527c8fba92c65f40\n-- \ngitgitgadget\n"}]}