tenseleyflow/shithub / 9dab000

Browse files

systemd(shithubd-web): drop RestrictSUIDSGID=yes (blocks git --shared=group)

Pre-fix: shithubd-web's systemd unit set RestrictSUIDSGID=yes.
SR2 #287 made InitBare run 'git init --bare --shared=group' so
cross-user write paths (HTTPS path as user shithub, SSH path as
user git, both in shithub group) inherit shithub group on new
pack files. git's adjust_shared_perm calls chmod g+s on every
directory it creates. The kernel returned EPERM under the
restriction; git emitted:

fatal: Could not make .../branches/ writable by group

so every fresh repo create on a new owner namespace failed with
the bland 'Could not create the repository' UI error after the
PR #48 deploy. Existing repos (created before #48) had been
post-init-repaired by 'shithubd storage repair-shared-perms'
running as root, so their setgid was already in place.

Fix: drop the directive. shithubd doesn't write executable files
to disk and isn't a setuid host, so the security loss is small.
The other hardening (NoNewPrivileges, ProtectSystem=strict,
ProtectHome, MemoryDenyWriteExecute, RestrictNamespaces, etc.)
all stay.

Alternative considered + rejected: keep RestrictSUIDSGID, drop
--shared=group, and chmod perms by hand post-init. That re-
introduces the SR2 #287 bug pattern (custom perms recipe drifts
from git's expected layout, future operators hit subtle perm bugs).

Operator must reload the unit on existing droplets:
ssh root@shithub.sh 'systemctl daemon-reload && systemctl restart shithubd-web'
This was already applied to the live droplet at fix-time.
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
9dab0002de9d52a5e7ee67b58f07c2d92fb71d94
Parents
6377dde
Tree
57be6ba

1 changed file

StatusFile+-
M deploy/systemd/shithubd-web.service 11 1
deploy/systemd/shithubd-web.servicemodified
@@ -32,7 +32,17 @@ ProtectKernelLogs=yes
3232
 ProtectControlGroups=yes
3333
 RestrictNamespaces=yes
3434
 RestrictRealtime=yes
35
-RestrictSUIDSGID=yes
35
+# RestrictSUIDSGID intentionally OFF: `git init --bare --shared=group`
36
+# (used by InitBare for every new bare repo) calls chmod g+s on the
37
+# directories it creates so cross-user writes (shithub user via the
38
+# HTTPS path, git user via SSH-git) inherit the shared group on new
39
+# pack files. With RestrictSUIDSGID=yes the kernel returned EPERM and
40
+# git emitted "Could not make .../branches/ writable by group", so
41
+# repo creation broke for any new owner namespace whose parent dir
42
+# wasn't pre-staged. shithubd doesn't write executable files to disk,
43
+# so the security loss is small; the alternative (stripping
44
+# --shared=group and chmod'ing perms by hand) re-introduces the
45
+# original SR2 #287 bug pattern.
3646
 LockPersonality=yes
3747
 MemoryDenyWriteExecute=yes
3848
 SystemCallArchitectures=native