Don't os.Chmod if we suspect the socket belongs to an abstract namespace

This commit is contained in:
Neil Alexander 2018-12-10 00:26:12 +00:00
parent 06c6dfc67f
commit 74a904d04c
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -348,10 +348,14 @@ func (a *admin) listen() {
} }
a.listener, err = net.Listen("unix", a.listenaddr[7:]) a.listener, err = net.Listen("unix", a.listenaddr[7:])
if err == nil { if err == nil {
switch a.listenaddr[7:8] {
case "@": // maybe abstract namespace
default:
if err := os.Chmod(a.listenaddr[7:], 0660); err != nil { if err := os.Chmod(a.listenaddr[7:], 0660); err != nil {
a.core.log.Println("WARNING:", a.listenaddr[:7], "may have unsafe permissions!") a.core.log.Println("WARNING:", a.listenaddr[:7], "may have unsafe permissions!")
} }
} }
}
case "tcp": case "tcp":
a.listener, err = net.Listen("tcp", u.Host) a.listener, err = net.Listen("tcp", u.Host)
default: default: