aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/ipc/ipc.c68
-rw-r--r--src/transport/ipc/ipc.h19
2 files changed, 87 insertions, 0 deletions
diff --git a/src/transport/ipc/ipc.c b/src/transport/ipc/ipc.c
index 3dbccb50..e5f3d533 100644
--- a/src/transport/ipc/ipc.c
+++ b/src/transport/ipc/ipc.c
@@ -537,6 +537,54 @@ nni_ipc_pipe_get_addr(void *arg, void *buf, size_t *szp, int typ)
return (nni_copyout_sockaddr(&p->sa, buf, szp, typ));
}
+static int
+nni_ipc_pipe_get_peer_uid(void *arg, void *buf, size_t *szp, int typ)
+{
+ nni_ipc_pipe *p = arg;
+ uint64_t id;
+ int rv;
+ if ((rv = nni_plat_ipc_pipe_get_peer_uid(p->ipp, &id)) != 0) {
+ return (rv);
+ }
+ return (nni_copyout_u64(id, buf, szp, typ));
+}
+
+static int
+nni_ipc_pipe_get_peer_gid(void *arg, void *buf, size_t *szp, int typ)
+{
+ nni_ipc_pipe *p = arg;
+ uint64_t id;
+ int rv;
+ if ((rv = nni_plat_ipc_pipe_get_peer_gid(p->ipp, &id)) != 0) {
+ return (rv);
+ }
+ return (nni_copyout_u64(id, buf, szp, typ));
+}
+
+static int
+nni_ipc_pipe_get_peer_pid(void *arg, void *buf, size_t *szp, int typ)
+{
+ nni_ipc_pipe *p = arg;
+ uint64_t id;
+ int rv;
+ if ((rv = nni_plat_ipc_pipe_get_peer_pid(p->ipp, &id)) != 0) {
+ return (rv);
+ }
+ return (nni_copyout_u64(id, buf, szp, typ));
+}
+
+static int
+nni_ipc_pipe_get_peer_zoneid(void *arg, void *buf, size_t *szp, int typ)
+{
+ nni_ipc_pipe *p = arg;
+ uint64_t id;
+ int rv;
+ if ((rv = nni_plat_ipc_pipe_get_peer_zoneid(p->ipp, &id)) != 0) {
+ return (rv);
+ }
+ return (nni_copyout_u64(id, buf, szp, typ));
+}
+
static void
nni_ipc_ep_fini(void *arg)
{
@@ -785,6 +833,26 @@ static nni_tran_pipe_option nni_ipc_pipe_options[] = {
.po_type = NNI_TYPE_SOCKADDR,
.po_getopt = nni_ipc_pipe_get_addr,
},
+ {
+ .po_name = NNG_OPT_IPC_PEER_UID,
+ .po_type = NNI_TYPE_UINT64,
+ .po_getopt = nni_ipc_pipe_get_peer_uid,
+ },
+ {
+ .po_name = NNG_OPT_IPC_PEER_GID,
+ .po_type = NNI_TYPE_UINT64,
+ .po_getopt = nni_ipc_pipe_get_peer_gid,
+ },
+ {
+ .po_name = NNG_OPT_IPC_PEER_PID,
+ .po_type = NNI_TYPE_UINT64,
+ .po_getopt = nni_ipc_pipe_get_peer_pid,
+ },
+ {
+ .po_name = NNG_OPT_IPC_PEER_ZONEID,
+ .po_type = NNI_TYPE_UINT64,
+ .po_getopt = nni_ipc_pipe_get_peer_zoneid,
+ },
// terminate list
{
.po_name = NULL,
diff --git a/src/transport/ipc/ipc.h b/src/transport/ipc/ipc.h
index 42cbdb08..497fb2b5 100644
--- a/src/transport/ipc/ipc.h
+++ b/src/transport/ipc/ipc.h
@@ -28,4 +28,23 @@ NNG_DECL int nng_ipc_register(void);
// this for security.
#define NNG_OPT_IPC_PERMISSIONS "ipc:permissions"
+// Peer UID. This is only available on POSIX style systems.
+#define NNG_OPT_IPC_PEER_UID "ipc:peer-uid"
+
+// Peer GID (primary group). This is only available on POSIX style systems.
+#define NNG_OPT_IPC_PEER_GID "ipc:peer-gid"
+
+// Peer process ID. Available on Windows, Linux, and SunOS.
+// In theory we could obtain this with the first message sent,
+// but we have elected not to do this for now. (Nice RFE for a FreeBSD
+// guru though.)
+#define NNG_OPT_IPC_PEER_PID "ipc:peer-pid"
+
+// Peer Zone ID. Only on SunOS systems. (Linux containers have no
+// definable kernel identity; they are a user-land fabrication made up
+// from various pieces of different namespaces. FreeBSD does have
+// something called JailIDs, but it isn't obvious how to determine this,
+// or even if processes can use IPC across jail boundaries.)
+#define NNG_OPT_IPC_PEER_ZONEID "ipc:peer-zoneid"
+
#endif // NNG_TRANSPORT_IPC_IPC_H