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:779–793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

777}
778
779static bool socket_peer_is_current_user(int fd) {
780#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
781 uid_t peer_uid = (uid_t)-1;
782 gid_t peer_gid = (gid_t)-1;
783 return getpeereid(fd, &peer_uid, &peer_gid) == 0 && peer_uid == geteuid();
784#elif defined(__linux__)
785 struct ucred credentials;
786 socklen_t length = sizeof(credentials);
787 return getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &credentials, &length) == 0 &&
788 length == sizeof(credentials) && credentials.uid == geteuid();
789#else
790 (void)fd;
791 return false;
792#endif
793}
794
795static int connection_read_full(cbm_daemon_ipc_connection_t *connection, void *buffer,
796 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