diff options
| author | Francisc Simon <37810708+opunix@users.noreply.github.com> | 2018-08-19 17:12:16 +0200 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-08-19 20:12:16 +0500 |
| commit | 9683efb2adee597304151299e5f55e6ab693605a (patch) | |
| tree | e74dd077e5712dd931cf89817b40eceafac231c4 /src/platform | |
| parent | 1d7594451319b353650c87cb5451c7ed7293cd92 (diff) | |
| download | nng-9683efb2adee597304151299e5f55e6ab693605a.tar.gz nng-9683efb2adee597304151299e5f55e6ab693605a.tar.bz2 nng-9683efb2adee597304151299e5f55e6ab693605a.zip | |
fixed compilation error on OpenBSD, missing sockpeercred (#659)
fixed compilation error on OpenBSD, missing sockpeercred
Diffstat (limited to 'src/platform')
| -rw-r--r-- | src/platform/posix/posix_ipcconn.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/platform/posix/posix_ipcconn.c b/src/platform/posix/posix_ipcconn.c index 2b46fb12..5a56d23e 100644 --- a/src/platform/posix/posix_ipcconn.c +++ b/src/platform/posix/posix_ipcconn.c @@ -26,7 +26,7 @@ #include <unistd.h> #if defined(NNG_HAVE_GETPEERUCRED) #include <ucred.h> -#elif defined(NNG_HAVE_LOCALPEERCRED) +#elif defined(NNG_HAVE_LOCALPEERCRED) || defined(NNG_HAVE_SOCKPEERCRED) #include <sys/ucred.h> #endif @@ -350,6 +350,17 @@ ipc_conn_peerid(nni_ipc_conn *c, uint64_t *euid, uint64_t *egid, *znid = ucred_getzoneid(ucp); ucred_free(ucp); return (0); +#elif defined(NNG_HAVE_SOCKPEERCRED) + struct sockpeercred uc; + socklen_t len = sizeof(uc); + if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &uc, &len) != 0) { + return (nni_plat_errno(errno)); + } + *euid = uc.uid; + *egid = uc.gid; + *prid = uc.pid; + *znid = (uint64_t) -1; + return (0); #elif defined(NNG_HAVE_SOPEERCRED) struct ucred uc; socklen_t len = sizeof(uc); |
