is_unix_socket_user_check library

Whether the user on the other end of a Unix-domain socket may connect.

Classes

Allowed
The peer is user, one of the allowed users.
NotAllowed
The peer is seen, which is not in allowed.
OverflowUid
Linux reported its configured overflow uid, read from /proc/sys/kernel/overflowuid: the peer's user is unmapped in the reader's user namespace.
ReadFailed
getsockopt failed. exception's osError carries the errno, when the runtime gave one.
RefusedUid
The kernel named a uid that UserId.parse refuses: one a kernel uses to say it does not know the user.
ShortAnswer
The kernel wrote fewer bytes than the credentials struct holds.
SocketUserCheck
Decides whether a socket's user may connect: only when the kernel names its user and that user is one of the allowed ones. A connection whose user cannot be read is denied.
SocketUserReader
Reads the user on the other end of a Unix-domain socket from the kernel: Linux's SO_PEERCRED, macOS's LOCAL_PEERCRED.
SocketUserReading
What SocketUserReader.read found on the other end of a socket: a user, or why there is none.
SocketUserVerdict
What SocketUserCheck.decide concluded about a socket. Only Allowed admits the peer; every other case refuses it.
UnknownXucredVersion
macOS answered with an xucred whose cr_version is not XUCRED_VERSION, so its layout is unknown.
Unread
The user could not be read, for the reason in why. It is both a reading and a verdict, so a check hands the reader's answer on unchanged.
UnsupportedKernel
The running kernel is neither Linux nor macOS, so no read was tried.
UserId
A user id that names one real user: never one the kernel uses to say it does not know the user.
UserRead
The kernel named user.
WhyUnread
Why the user on the other end of a socket could not be read. Each case is a different way the kernel's answer fell short, so a caller can switch on it and log what it carries.

Enums

Kernel
The kernels whose peer credentials SocketUserReader knows how to read.

Typedefs

ReadSocketOption = Uint8List Function(Socket socket, RawSocketOption option)
Reads a raw socket option from socket: what getsockopt writes into option's value.