set SO_PASSCRED on listening socket to avoid this problem:

4dde1cb060
networking
brl 10 years ago
parent 5c9f8b40ad
commit 93715e7602

@ -42,6 +42,9 @@ func NewServer(address string, factory MsgFactory, log *logging.Logger, handlers
}
listener, err := net.ListenUnix("unix", &net.UnixAddr{address, "unix"})
if err := setPassCred(listener); err != nil {
return nil, errors.New("Failed to set SO_PASSCRED on listening socket: " + err.Error())
}
if err != nil {
md.close()
return nil, err

@ -1,17 +1,16 @@
package ipc
import (
"net"
"reflect"
"syscall"
)
func setPassCred(c net.Conn) error {
func setPassCred(c interface{}) error {
fd := reflectFD(c)
return syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_PASSCRED, 1)
}
func reflectFD(c net.Conn) int {
func reflectFD(c interface{}) int {
sysfd := extractField(c, "fd", "sysfd")
return int(sysfd.Int())
}

Loading…
Cancel
Save