diff options
| author | Richard Markiewicz <rmarkiewicz@devolutions.net> | 2020-06-15 10:44:25 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2020-06-15 11:15:51 -0700 |
| commit | 59301ab3f80991086519124d020edbe94a74615c (patch) | |
| tree | af16a8b3dbf74457c7aee21f1ca32bb76ebaaaa1 | |
| parent | 2f288bddf5b501f029d080835f439ecd9c0eae47 (diff) | |
| download | nng-59301ab3f80991086519124d020edbe94a74615c.tar.gz nng-59301ab3f80991086519124d020edbe94a74615c.tar.bz2 nng-59301ab3f80991086519124d020edbe94a74615c.zip | |
nng: support NNG_OPT_IPC_PEER_PID on modern macOS systems
| -rw-r--r-- | CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/platform/posix/posix_ipcconn.c | 6 | ||||
| -rw-r--r-- | tests/ipc.c | 3 |
3 files changed, 6 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 700a0e08..7125e572 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -341,6 +341,7 @@ else () nng_check_sym(SO_PEERCRED sys/socket.h NNG_HAVE_SOPEERCRED) nng_check_struct_member(sockpeercred uid sys/socket.h NNG_HAVE_SOCKPEERCRED) nng_check_sym(LOCAL_PEERCRED sys/un.h NNG_HAVE_LOCALPEERCRED) + nng_check_sym(LOCAL_PEERPID sys/un.h NNG_HAVE_LOCALPEERPID) nng_check_sym(getpeerucred ucred.h NNG_HAVE_GETPEERUCRED) nng_check_sym(atomic_flag_test_and_set stdatomic.h NNG_HAVE_STDATOMIC) diff --git a/src/platform/posix/posix_ipcconn.c b/src/platform/posix/posix_ipcconn.c index e4d783f3..8dded3a3 100644 --- a/src/platform/posix/posix_ipcconn.c +++ b/src/platform/posix/posix_ipcconn.c @@ -318,7 +318,7 @@ ipc_peerid(ipc_conn *c, uint64_t *euid, uint64_t *egid, uint64_t *prid, uint64_t *znid) { int fd = nni_posix_pfd_fd(c->pfd); -#if defined(NNG_HAVE_GETPEEREID) +#if defined(NNG_HAVE_GETPEEREID) && !defined(NNG_HAVE_LOCALPEERCRED) uid_t uid; gid_t gid; @@ -373,7 +373,7 @@ ipc_peerid(ipc_conn *c, uint64_t *euid, uint64_t *egid, uint64_t *prid, *egid = xu.cr_gid; *prid = (uint64_t) -1; *znid = (uint64_t) -1; -#if defined(LOCAL_PEERPID) // present (undocumented) on macOS +#if defined(NNG_HAVE_LOCALPEERPID) // documented on macOS since 10.8 { pid_t pid; if (getsockopt(fd, SOL_LOCAL, LOCAL_PEERPID, &pid, &len) == @@ -381,7 +381,7 @@ ipc_peerid(ipc_conn *c, uint64_t *euid, uint64_t *egid, uint64_t *prid, *prid = (uint64_t) pid; } } -#endif // LOCAL_PEERPID +#endif // NNG_HAVE_LOCALPEERPID return (0); #else if (fd < 0) { diff --git a/tests/ipc.c b/tests/ipc.c index 2446cda1..8abff2f6 100644 --- a/tests/ipc.c +++ b/tests/ipc.c @@ -63,7 +63,8 @@ check_props(nng_msg *msg) So(nng_pipe_getopt_uint64(p, NNG_OPT_IPC_PEER_GID, &id) == 0); So(id == (uint64_t) getgid()); -#if defined(NNG_HAVE_SOPEERCRED) || defined(NNG_HAVE_GETPEERUCRED) +#if defined(NNG_HAVE_SOPEERCRED) || defined(NNG_HAVE_GETPEERUCRED) || \ + (defined(NNG_HAVE_LOCALPEERCRED) && defined(NNG_HAVE_LOCALPEERPID)) So(nng_pipe_getopt_uint64(p, NNG_OPT_IPC_PEER_PID, &id) == 0); So(id == (uint64_t) getpid()); #else |
