MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / socket_peer_is_current_user

Function socket_peer_is_current_user

src/daemon/ipc.c:786–800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

784}
785
786static bool socket_peer_is_current_user(int fd) {
787#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
788 uid_t peer_uid = (uid_t)-1;
789 gid_t peer_gid = (gid_t)-1;
790 return getpeereid(fd, &peer_uid, &peer_gid) == 0 && peer_uid == geteuid();
791#elif defined(__linux__)
792 struct ucred credentials;
793 socklen_t length = sizeof(credentials);
794 return getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &credentials, &length) == 0 &&
795 length == sizeof(credentials) && credentials.uid == geteuid();
796#else
797 (void)fd;
798 return false;
799#endif
800}
801
802static int connection_read_full(cbm_daemon_ipc_connection_t *connection, void *buffer,
803 size_t length, uint64_t deadline_ms) {

Callers 4

cbm_daemon_ipc_acceptFunction · 0.85
cbm_daemon_ipc_connectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected