git » go-net » unix-separados » tree

[unix-separados] / unix / cred_linux.go

// Copyright 2016 The Go Authors.  All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package unix

func getPeerCredentials(fd uintptr) (*UnixPeerCreds, error) {
	cred, err := getSockoptUcred(fd, sysSOL_SOCKET, sysSO_PEERCRED)
	if err != nil {
		return nil, err
	}

	return &UnixPeerCreds{int(cred.Uid), int(cred.Gid), int(cred.Pid)}, nil
}