def CapExec.sets

bend-osdev-caps@0.1.0.0 · exec.bend:30

import bend-osdev-caps@0.1.0.0/exec.bend as Exec
import Base
import bend-osdev-caps@0.1.0.0/caps.bend as C

30# capabilities(7):
31#   P'(ambient)     = (file is privileged) ? 0 : P(ambient)
32#   P'(permitted)   = (P(inheritable) & F(inheritable)) |
33#                     (F(permitted) & P(bounding)) | P'(ambient)
34#   P'(effective)   = F(effective) ? P'(permitted) : P'(ambient)
35#   P'(inheritable) = P(inheritable)
36#   P'(bounding)    = P(bounding)
37def CapExec.sets(fl: CapExecFlags, s: C.CapState) -> C.CapState:
38  match fl s:
39    case CapExecFlags{priv, feff, fp, fi} C.CapState{p, +i, e, +b, a}:
40      +a2 = CapExec.ambient(priv, a)
41      +p2 = C.CapSet.union(C.CapSet.union(C.CapSet.inter(i, fi), C.CapSet.inter(fp, b)), a2)
42      C.CapState{p2, i, CapExec.effective(feff, p2, a2), b, a2}

Uses (6)

Used by (12)