|
|
@@ -18,12 +18,13 @@ import (
|
|
|
func GetConnIdentity(_ logger.Logf, c net.Conn) (ci *ConnIdentity, err error) {
|
|
|
ci = &ConnIdentity{conn: c, notWindows: true}
|
|
|
_, ci.isUnixSock = c.(*net.UnixConn)
|
|
|
- if ci.creds, err = peercred.Get(c); ci.creds != nil {
|
|
|
+ if creds, err := peercred.Get(c); err == nil {
|
|
|
+ ci.creds = creds
|
|
|
ci.pid, _ = ci.creds.PID()
|
|
|
} else if err == peercred.ErrNotImplemented {
|
|
|
// peercred.Get is not implemented on this OS (such as OpenBSD)
|
|
|
// Just leave creds as nil, as documented.
|
|
|
- } else if err != nil {
|
|
|
+ } else {
|
|
|
return nil, err
|
|
|
}
|
|
|
return ci, nil
|