4.3 The Check
int ;
Runs the full AccessCheck pipeline. Returns:
0if every right indesiredis granted;-1witherrno == EACCESif any desired right is denied;-1with another errno on a real error (for exampleEBADFfor a badtoken_fd,EINVALfor a malformed SD).
granted, if non-NULL, always receives the granted access mask — even
on denial. This is the useful part: you can request a broad desired and read
back exactly which subset was granted, rather than probing one right at a
time. audit, if non-NULL, receives the audit
outputs.
struct peios_access_request req = ;
uint32_t granted = 0;
int rc = ;
if else if else
libpeios owns the versioned struct kacs_access_check_args under the hood —
it sets caller_size and zeroes the reserved fields so the request stays
forward-compatible across kernel versions. You only ever fill in the
peios_access_request above.
4.3.1 A supplied identity without a token #
int ;
Use this separate entry point when a trusted identity authority supplies a
principal SID, source groups and disclosed claims without creating an OS logon
token. libpeios packs the facts for the stateless kernel query, syscall 1028.
An older kernel returns ENOSYS; no userspace fallback runs. Supplying
SYSTEM's SID computes a hypothetical result; it conveys no SYSTEM authority.
The SD must be valid and have an owner. Set subject.size to its structure size and request.token_fd to -1. Here -1 is a required sentinel and never selects the caller's token. The privilege-intent, PIP, and request-local claim fields must be zero or NULL; local claim knowledge belongs in subject.
Subject group entries contain a SID span and KACS group attributes, including enabled and deny-only flags. A NULL list with zero count is unknown. A non-NULL list with zero count is a complete empty set. A NULL list with nonzero count is invalid. Group, claim, and known-absence arrays are bounded to 1024 entries. Group SIDs must be unique.
Each optional claim context contains typed peios_token_claim values, explicit known-absent names, and a complete flag. These use the same claim encoding and validation as the token builder. With complete equal to zero, any name not in the values or known-absent list remains unknown. With complete equal to one, omitted names are absent. Values and absence assertions must not contradict one another; equivalent names must be unique. Absent names are UTF-8 strings of 1–255 bytes. An omitted claim context is unknown, not an empty set.
Name equivalence follows the KACS conditional evaluator's Unicode lowercase mapping. An absence assertion must cover that entire equivalence class. A source using different name rules needs an adapter; copying its named absence responses directly can turn an existing equivalent claim into an apparent absence. Updated PGSS named disclosure uses this same rule, so its explicit absent_claims supply partial knowledge. Clients and authority must both use the updated Unicode name contract; the superseded ASCII-only development contract is incompatible for this purpose. A complete AllPermitted result can supply complete knowledge; a Filtered result supplies values with partial coverage and no invented absences. Conflicting equivalent values are invalid.
The return value is zero for all three decisions. Inspect out.decision:
| Decision | Meaning |
|---|---|
| PEIOS_SUBJECT_ACCESS_GRANTED | All requested rights were granted |
| PEIOS_SUBJECT_ACCESS_DENIED | The supplied facts establish denial |
| PEIOS_SUBJECT_ACCESS_MISSING_CONTEXT | More context is needed for a safe answer |
Missing-context results carry a zero granted mask and a category bitmask in out.missing. They do not identify restricted claim names or values. A service must not admit a caller using a provisional or partial answer. Missing-data detection is conservative and can request context from an irrelevant branch. Errors return -1 with errno; do not use a returned decision after an error.
The initial identity-only interface reuses KACS DACL, group, conditional, and object-list semantics. It does not invent process privileges, integrity, confinement, or a logon session. Explicit integrity/trust labels, scoped policy, and privilege-sensitive rights report missing execution context. Resource claims can be read from the supplied SD's SACL. This is not a replacement for the full token pipeline or kernel object enforcement.
For object ACEs, supply the object tree and select the node with object_index. Without a tree, the index is zero and GUID-scoped ACEs report missing object context instead of being interpreted as global grants.
Matching SACL audit ACEs emit kacs.audit.subject.checked when the actual
caller holds enabled SeAuditPrivilege. The event's subject describes that
caller; source.supplied-subject.sid is explicitly hypothetical. An optional
AuditContext names the guarded object. No context leaves it unnamed.
Audit-only missing facts require more context while auditing is active; they
do not block the decision when the privilege gate suppresses records or the
extended entry point peios_access_check_subject_ex receives
PEIOS_SUBJECT_NO_AUDIT. Mandatory SACL labels still require execution
context in either mode. Missing-context decisions emit no completed-check
record. Detected audit preparation or submission errors fail the query;
successful submission carries the existing KMES guarantees, without a
durability promise. A service separately records its actual admission outcome.
The kernel copies one bounded request and validates that owned copy. A concurrent writer can produce a torn copy, which is still treated as untrusted input. Requests larger than 1 MiB, excessive collections, conflicting facts, and malformed sections are rejected whole. Typed claims are bounded to 64 KiB per namespace and 1024 values per attribute. The aggregate sum of encoded entry bytes multiplied by max(value count, 1), including descriptor resource claims, cannot exceed 1 MiB; this bounds repeated-offset decoding before allocation. No facts are silently truncated.
The safe Rust wrapper exposes AccessCheck::check_subject and
check_subject_by_type with SuppliedSubject, SuppliedClaims, and an explicit
SubjectAccessDecision. Use audit_context to label the guarded object and
subject_no_audit(true) to suppress this query's audit records. That setter
does not alter real-token checks or service admission events.