Fix invalid setsockopt(..., SCM_PASSCRED) call in systemd integration

It should be SetsockoptInt, not SetsockoptByte, see socket(7).
This commit is contained in:
fox.cpp 2019-12-02 23:44:14 +03:00
parent 3fe1504659
commit 42ca9042ee
No known key found for this signature in database
GPG key ID: E76D97CCEDE90B6C

View file

@ -45,11 +45,16 @@ func setScmPassCred(sock *net.UnixConn) error {
if err != nil {
return err
}
var sockoptErr error
if err := sConn.Control(func(fd uintptr) {
syscall.SetsockoptByte(int(fd), syscall.SOL_SOCKET, syscall.SO_PASSCRED, 1)
sockoptErr = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_PASSCRED, 1)
}); err != nil {
return err
}
if sockoptErr != nil {
return sockoptErr
}
return nil
}
@ -64,7 +69,7 @@ func systemdStatus(status SDStatus, desc string) {
defer sock.Close()
if err := setScmPassCred(sock); err != nil {
log.Println("failed to set SCM_PASSCRED on the socket for communication with systemd:", err)
log.Println("systemd: failed to set SCM_PASSCRED on the socket:", err)
}
if desc != "" {