}
#endif /* HAVE_AF_PACKET */
+
+#ifdef HAVE_PEERCRED
+
+int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
+{
+ struct ucred cr;
+ socklen_t crl = sizeof(struct ucred);
+ int ret;
+
+ ret = getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &crl);
+ if (ret == 0) {
+ *peer_pid = cr.pid;
+ } else {
+ *peer_pid = -1;
+ }
+ return ret;
+}
+
+#else /* HAVE_PEERCRED */
+
+#ifdef _AIX_
+
+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;
+
+ ret = getsockopt(fd, SOL_SOCKET, SO_PEERID, &cr, &crl);
+ if (ret == 0) {
+ *peer_pid = cr.pid;
+ } else {
+ *peer_pid = -1;
+ }
+ return ret;
+}
+
+#else /* _AIX_ */
+
+int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
+{
+ /* Not implemented */
+ *peer_pid = -1;
+ return ENOSYS;
+}
+
+#endif /* _AIX_ */
+
+#endif /* HAVE_PEERCRED */
ctdb_sock_addr *src, ctdb_sock_addr *dst,
uint32_t *ack_seq, uint32_t *seq,
int *rst, uint16_t *window);
-int ctdb_get_peer_pid(const int fd, pid_t *peer_pid);
/* From system_util.c */
void ctdb_wait_for_process_to_exit(pid_t pid);
bool ctdb_sys_check_iface_exists(const char *iface);
+int ctdb_get_peer_pid(const int fd, pid_t *peer_pid);
#endif /* __CTDB_SYSTEM_H__ */
return -1;
}
-
-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;
-}
return -1;
}
-
-int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
-{
- /* FIXME FreeBSD: get_peer_pid not implemented */
- return 1;
-}
return -1;
}
-
-int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
-{
- /* FIXME GNU/Hurd: get_peer_pid not implemented */
- return 1;
-}
return -1;
}
-
-int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
-{
- /* FIXME kFreeBSD: get_peer_pid not implemented */
- return 1;
-}
return -1;
}
-
-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;
-}