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

Source from the content-addressed store, hash-verified

852}
853
854static bool socket_peer_is_current_user(int fd) {
855#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
856 uid_t peer_uid = (uid_t)-1;
857 gid_t peer_gid = (gid_t)-1;
858 return getpeereid(fd, &peer_uid, &peer_gid) == 0 && peer_uid == geteuid();
859#elif defined(__linux__)
860 struct ucred credentials;
861 socklen_t length = sizeof(credentials);
862 return getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &credentials, &length) == 0 &&
863 length == sizeof(credentials) && credentials.uid == geteuid();
864#else
865 (void)fd;
866 return false;
867#endif
868}
869
870static int connection_read_full(cbm_daemon_ipc_connection_t *connection, void *buffer,
871 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