mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-25 09:14:53 +08:00
core: Skip chmod
for abstract unix sockets (#5596)
because those aren't real paths on the filesystem and thus can't be `chmod`ed
This commit is contained in:
parent
22927e278d
commit
119e8794bc
15
listeners.go
15
listeners.go
|
@ -151,6 +151,7 @@ func (na NetworkAddress) listen(ctx context.Context, portOffset uint, config net
|
||||||
var err error
|
var err error
|
||||||
var address string
|
var address string
|
||||||
var unixFileMode fs.FileMode
|
var unixFileMode fs.FileMode
|
||||||
|
var isAbtractUnixSocket bool
|
||||||
|
|
||||||
// split unix socket addr early so lnKey
|
// split unix socket addr early so lnKey
|
||||||
// is independent of permissions bits
|
// is independent of permissions bits
|
||||||
|
@ -160,6 +161,7 @@ func (na NetworkAddress) listen(ctx context.Context, portOffset uint, config net
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
isAbtractUnixSocket = strings.HasPrefix(address, "@")
|
||||||
} else {
|
} else {
|
||||||
address = na.JoinHostPort(portOffset)
|
address = na.JoinHostPort(portOffset)
|
||||||
}
|
}
|
||||||
|
@ -167,8 +169,11 @@ func (na NetworkAddress) listen(ctx context.Context, portOffset uint, config net
|
||||||
// if this is a unix socket, see if we already have it open,
|
// if this is a unix socket, see if we already have it open,
|
||||||
// force socket permissions on it and return early
|
// force socket permissions on it and return early
|
||||||
if socket, err := reuseUnixSocket(na.Network, address); socket != nil || err != nil {
|
if socket, err := reuseUnixSocket(na.Network, address); socket != nil || err != nil {
|
||||||
if err := os.Chmod(address, unixFileMode); err != nil {
|
if !isAbtractUnixSocket {
|
||||||
return nil, fmt.Errorf("unable to set permissions (%s) on %s: %v", unixFileMode, address, err)
|
if err := os.Chmod(address, unixFileMode); err != nil {
|
||||||
|
return nil, fmt.Errorf("unable to set permissions (%s) on %s: %v", unixFileMode, address, err)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return socket, err
|
return socket, err
|
||||||
}
|
}
|
||||||
|
@ -211,8 +216,10 @@ func (na NetworkAddress) listen(ctx context.Context, portOffset uint, config net
|
||||||
}
|
}
|
||||||
|
|
||||||
if IsUnixNetwork(na.Network) {
|
if IsUnixNetwork(na.Network) {
|
||||||
if err := os.Chmod(address, unixFileMode); err != nil {
|
if !isAbtractUnixSocket {
|
||||||
return nil, fmt.Errorf("unable to set permissions (%s) on %s: %v", unixFileMode, address, err)
|
if err := os.Chmod(address, unixFileMode); err != nil {
|
||||||
|
return nil, fmt.Errorf("unable to set permissions (%s) on %s: %v", unixFileMode, address, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user