diff options
Diffstat (limited to 'ctdb/common')
| -rw-r--r-- | ctdb/common/system_aix.c | 11 | ||||
| -rw-r--r-- | ctdb/common/system_linux.c | 12 |
2 files changed, 23 insertions, 0 deletions
diff --git a/ctdb/common/system_aix.c b/ctdb/common/system_aix.c index 1404a82901..c17598a3af 100644 --- a/ctdb/common/system_aix.c +++ b/ctdb/common/system_aix.c @@ -362,3 +362,14 @@ bool ctdb_sys_check_iface_exists(const char *iface) return true; } +int ctdb_get_peer_pid(const int fd, pid_t *peer_pid) +{ + struct peercred_struct cr; + socklen_t crl = sizeof(struct peercred_struct); + int ret; + if ((ret = getsockopt(fd, SOL_SOCKET, SO_PEERID, &cr, &crl) == 0)) { + peer_pid = cr.pid; + } + return ret; +} + diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c index ca2d47580b..cb26dcd654 100644 --- a/ctdb/common/system_linux.c +++ b/ctdb/common/system_linux.c @@ -563,3 +563,15 @@ bool ctdb_sys_check_iface_exists(const char *iface) return true; } + +int ctdb_get_peer_pid(const int fd, pid_t *peer_pid) +{ + struct ucred cr; + socklen_t crl = sizeof(struct ucred); + int ret; + if ((ret = getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &crl) == 0)) { + peer_pid = cr.pid; + } + return ret; +} + |
