fix: Listening on abstract domain sockets (#7020)

When passed a socket name that starts with @, go will listen on an
abstract unix domain socket. Forgejo breaks this by assuming the socket
name is a file path and normalizing it to an absolute path.

This small commit prevents treating the socket name as a filesystem path
if it starts with @.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7020
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Mewp <codeberg.org@mewp.pl>
Co-committed-by: Mewp <codeberg.org@mewp.pl>
This commit is contained in:
Mewp 2025-03-09 16:06:52 +00:00 committed by Gusted
parent 584c504e25
commit 377052c90c
4 changed files with 35 additions and 4 deletions

View file

@ -73,3 +73,16 @@ MAX_USER_REDIRECTS = 8`
assert.EqualValues(t, 3, Service.UsernameCooldownPeriod)
assert.EqualValues(t, 8, Service.MaxUserRedirects)
}
func TestUnixSocketAbstractNamespace(t *testing.T) {
iniStr := `
[server]
PROTOCOL=http+unix
HTTP_ADDR=@forgejo
`
cfg, err := NewConfigProviderFromData(iniStr)
require.NoError(t, err)
loadServerFrom(cfg)
assert.EqualValues(t, "@forgejo", HTTPAddr)
}