diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-05-03 14:28:44 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-05-03 15:14:45 -0700 |
| commit | afd555af4fba0acbf16c174dd9dece24181a1a38 (patch) | |
| tree | 9d49fec85c58ecad9a034a98e092627968494bc0 /src/platform/posix/posix_ipc.c | |
| parent | fa986e725f08e30eab68e16765b2cf71613b871c (diff) | |
| download | nng-afd555af4fba0acbf16c174dd9dece24181a1a38.tar.gz nng-afd555af4fba0acbf16c174dd9dece24181a1a38.tar.bz2 nng-afd555af4fba0acbf16c174dd9dece24181a1a38.zip | |
fixes #383 Would like peerid for IPC
We offer uid, gid, process id, and even zone id where we have them.
Docs and tests are provided.
Diffstat (limited to 'src/platform/posix/posix_ipc.c')
| -rw-r--r-- | src/platform/posix/posix_ipc.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/platform/posix/posix_ipc.c b/src/platform/posix/posix_ipc.c index c1bb9292..5ba3c8fb 100644 --- a/src/platform/posix/posix_ipc.c +++ b/src/platform/posix/posix_ipc.c @@ -183,4 +183,68 @@ nni_plat_ipc_pipe_recv(nni_plat_ipc_pipe *p, nni_aio *aio) nni_posix_pipedesc_recv((void *) p, aio); } +int +nni_plat_ipc_pipe_get_peer_uid(nni_plat_ipc_pipe *p, uint64_t *uid) +{ + int rv; + uint64_t ignore; + + if ((rv = nni_posix_pipedesc_get_peerid( + (void *) p, uid, &ignore, &ignore, &ignore)) != 0) { + return (rv); + } + return (0); +} + +int +nni_plat_ipc_pipe_get_peer_gid(nni_plat_ipc_pipe *p, uint64_t *gid) +{ + int rv; + uint64_t ignore; + + if ((rv = nni_posix_pipedesc_get_peerid( + (void *) p, &ignore, gid, &ignore, &ignore)) != 0) { + return (rv); + } + return (0); +} + +int +nni_plat_ipc_pipe_get_peer_zoneid(nni_plat_ipc_pipe *p, uint64_t *zid) +{ + int rv; + uint64_t ignore; + uint64_t id; + + if ((rv = nni_posix_pipedesc_get_peerid( + (void *) p, &ignore, &ignore, &ignore, &id)) != 0) { + return (rv); + } + if (id == (uint64_t) -1) { + // NB: -1 is not a legal zone id (illumos/Solaris) + return (NNG_ENOTSUP); + } + *zid = id; + return (0); +} + +int +nni_plat_ipc_pipe_get_peer_pid(nni_plat_ipc_pipe *p, uint64_t *pid) +{ + int rv; + uint64_t ignore; + uint64_t id; + + if ((rv = nni_posix_pipedesc_get_peerid( + (void *) p, &ignore, &ignore, &id, &ignore)) != 0) { + return (rv); + } + if (id == (uint64_t) -1) { + // NB: -1 is not a legal process id + return (NNG_ENOTSUP); + } + *pid = id; + return (0); +} + #endif // NNG_PLATFORM_POSIX |
