3.4 Query
You read a token's contents by information class. The generic reader handles any class getxattr-style; typed convenience wrappers cover the common ones.
ssize_t ;
ssize_t ; /* CLASS_USER */
peios_token_queryreads the classinfo_class(KACS_TOKEN_CLASS_*) intobufusing the two-call protocol. Classes that return SID arrays or ACLs are parsed afterward with the<peios/security.h>views — for example readCLASS_GROUPSinto a buffer, thenpeios_sid_array_parseit.peios_token_useris the same two-call read specialized to the user SID (CLASS_USER): probe withsid_buf == NULL, cap == 0, then retrieve.
For the common scalar classes there are typed helpers that write through a
mandatory non-NULL out-pointer and return 0 / -1:
;
;
int ; /* CLASS_TYPE */
int ; /* CLASS_IMPERSONATION_LEVEL */
int ; /* CLASS_INTERACTIVITY_SCOPE */
int ; /* CLASS_GUID */
int ; /* CLASS_STATISTICS */
int ; /* CLASS_INTEGRITY_LEVEL */
int ; /* CLASS_PRIVILEGES */
peios_token_impersonation_level reads the token's impersonation level
(KACS_IMLEVEL_*): the ceiling on everything captured from, conveyed by, or
duplicated out of it — on a primary token as much as an impersonation one,
since the level only ever ratchets down (Kernel TRM §3.5.1). A manager handed
a token over a socket reads this before deciding what the token can become; a
token below Impersonation cannot be turned into a primary token for a new
process.
peios_token_interactivity_scope reads the token's interactive-environment
scope. It is not a logon-session identifier. To read the token's uint64_t
LogonSession LUID, use peios_token_statistics and inspect auth_id; that
helper returns the complete fixed-width statistics record.
peios_token_guid writes the immutable 16-byte token GUID used by KMES. The
caller supplies 16 writable bytes; the helper leaves them unchanged on
failure. The result contains raw bytes in KMES order. The query requires
TOKEN_QUERY; kernels predating KACS_TOKEN_CLASS_GUID return
EINVAL. Deploy the supporting kernel before consumers. The statistics record
and its LUID remain unchanged.
peios_token_privileges returns all four privilege words at once: which
privileges are present, which are enabled, which are enabled_by_default,
and which have been used (the audit trail of privilege use).
Errors (all query calls): EACCES (handle lacks QUERY), EINVAL (unknown
class), ERANGE (non-probe buffer too small), EFAULT (bad buffer pointer).
The typed helpers add EINVAL (NULL out-pointer, or an unexpected payload
shape).