~/bend-docscommunity

transitions.bend checks

raw source on the hub · import bend-osdev-apparmor@0.1.0.0/transitions.bend as Transitions

bend-osdev-apparmor: exec transitions (apparmor.d(5), "Access Modes", "Directed profile transitions", "Attachment Conditionals").

When a confined task executes a path, the profile must grant x on it; the exec mode of the matching allow rules then says where the task goes: ix stays in the profile, ux and Ux leave confinement, px and Px move to the profile named after -> or else to the profile whose attachment best matches the path, cx and Cx do the same among the profile's children; the i and u forms fall back to ix and ux (Ux for PUx and CUx) when no profile is found, and the plain forms fail. Upper case scrubs the environment.

Where several allow rules with exec modes match, a rule whose pattern is literal (no wildcard, no braces) decides over pattern rules, and the rules that decide must agree (apparmor_parser 4.0.1 rejects a profile otherwise when it can tell; see the README, "Experiments"); disagreement is a failure here. Among attachments, a literal one wins, then the longest literal prefix; a tie fails ("If the heuristic can not determine a winner between multiple matches the exec will be denied").

A task in complain mode whose profile grants no x, or whose x comes from no exec rule (default_allow), stays in its profile. A profile in unconfined mode executes as an unconfined task: the profile whose attachment matches, else unconfined.

8 imports
import Base
import ./text.bend as X
import ./glob.bend as G
import ./perm.bend as P
import ./options.bend as O
import ./profile.bend as PR
import ./rule_file.bend as F
import ./eval.bend as V

Types

type AaTarget source · line 33 · raw

Data

type AaExecWhy source · line 41 · raw

Data

type AaExecResult source · line 53 · raw

Data

type AaAttach source · line 92 · raw

Data

type AaXSel source · line 136 · raw

Data

type AaXSels source · line 154 · raw

Data

the exec rules among the matching ones: literal ones and pattern ones

type AaXPick source · line 198 · raw

Data

the selection the list agrees on: None for an empty list, a conflict otherwise

Definitions

def AaExecResult.ok source · line 57 · raw

@r:AaExecResult -> Bool

def AaTarget.show source · line 64 · raw

@t:AaTarget -> String

def AaExecResult.show source · line 73 · raw

@r:AaExecResult -> String

def AaAttach.rank source · line 97 · raw

@a:AaAttach -> U32

def AaAttach.better source · line 107 · raw

@+best:AaAttach -> @+r:U32 -> @name:List<&2, U32> -> AaAttach

the better of the best so far and a candidate of rank r

def AaAttach.rank_of source · line 111 · raw

@m:Maybe<&2, 0x2b280a281d356b8e5cd7b338ab267df1/glob.AaGlob> -> @+path:List<&2, U32> -> U32

def AaAttach.join source · line 118 · raw

@+prefix:List<&2, U32> -> @name:List<&2, U32> -> List<&2, U32>

def AaAttach.best source · line 127 · raw

@ps:List<&2, 0x2b280a281d356b8e5cd7b338ab267df1/profile.AaProfile> -> @+path:List<&2, U32> -> @+prefix:List<&2, U32> -> @+best:AaAttach -> AaAttach

the profile of the list whose attachment best matches the path; prefix: the full name of the parent, for children

def AaXSel.target_eq source · line 139 · raw

@a:Maybe<&2, List<&2, U32>> -> @b:Maybe<&2, List<&2, U32>> -> Bool

def AaXSel.eq source · line 148 · raw

@a:AaXSel -> @b:AaXSel -> Bool

def AaXSels.add source · line 157 · raw

@s:AaXSels -> @lit:Bool -> @x:AaXSel -> AaXSels

def AaXSels.rule.go source · line 166 · raw

@deny:Bool -> @s:AaXSels -> @lit:Bool -> @x:AaXSel -> AaXSels

def AaXSels.rule source · line 173 · raw

@s:AaXSels -> @r:0x2b280a281d356b8e5cd7b338ab267df1/rule_file.AaFileRule -> AaXSels

def AaXSels.of source · line 182 · raw

@rs:List<&2, 0x2b280a281d356b8e5cd7b338ab267df1/rule_file.AaFileRule> -> @s:AaXSels -> AaXSels

def AaXSel.all_eq source · line 190 · raw

@xs:List<&2, AaXSel> -> @+x:AaXSel -> Bool

every selection agrees with x

def AaXPick.of source · line 203 · raw

@xs:List<&2, AaXSel> -> AaXPick

def AaXPick.choose source · line 210 · raw

@lit:AaXPick -> @pat:AaXPick -> AaXPick

def AaXPick.sels source · line 219 · raw

@s:AaXSels -> AaXPick

def AaXPick.rules source · line 225 · raw

@rs:List<&2, 0x2b280a281d356b8e5cd7b338ab267df1/rule_file.AaFileRule> -> AaXPick

the exec mode the matching rules rs give

def AaTrans.fallback source · line 230 · raw

@fb:0x2b280a281d356b8e5cd7b338ab267df1/rule_file.AaXFallback -> @scrub:Bool -> @d:0x2b280a281d356b8e5cd7b338ab267df1/eval.AaDecision -> AaExecResult

def AaTrans.attached source · line 239 · raw

@a:AaAttach -> @fb:0x2b280a281d356b8e5cd7b338ab267df1/rule_file.AaXFallback -> @scrub:Bool -> @d:0x2b280a281d356b8e5cd7b338ab267df1/eval.AaDecision -> AaExecResult

def AaTrans.named source · line 248 · raw

@m:Maybe<&2, 0x2b280a281d356b8e5cd7b338ab267df1/profile.AaProfile> -> @name:List<&2, U32> -> @fb:0x2b280a281d356b8e5cd7b338ab267df1/rule_file.AaXFallback -> @scrub:Bool -> @d:0x2b280a281d356b8e5cd7b338ab267df1/eval.AaDecision -> AaExecResult

def AaTrans.px source · line 256 · raw

@tg:Maybe<&2, List<&2, U32>> -> @pol:0x2b280a281d356b8e5cd7b338ab267df1/profile.AaPolicy -> @+path:List<&2, U32> -> @scrub:Bool -> @fb:0x2b280a281d356b8e5cd7b338ab267df1/rule_file.AaXFallback -> @d:0x2b280a281d356b8e5cd7b338ab267df1/eval.AaDecision -> AaExecResult

px: the profile named, else the best attachment in the namespace

def AaTrans.cx source · line 264 · raw

@tg:Maybe<&2, List<&2, U32>> -> @+p:0x2b280a281d356b8e5cd7b338ab267df1/profile.AaProfile -> @+pname:List<&2, U32> -> @+path:List<&2, U32> -> @scrub:Bool -> @fb:0x2b280a281d356b8e5cd7b338ab267df1/rule_file.AaXFallback -> @d:0x2b280a281d356b8e5cd7b338ab267df1/eval.AaDecision -> AaExecResult

cx: the child named, else the child whose attachment matches best

def AaTrans.apply source · line 271 · raw

@sel:AaXSel -> @pol:0x2b280a281d356b8e5cd7b338ab267df1/profile.AaPolicy -> @p:0x2b280a281d356b8e5cd7b338ab267df1/profile.AaProfile -> @pname:List<&2, U32> -> @path:List<&2, U32> -> @d:0x2b280a281d356b8e5cd7b338ab267df1/eval.AaDecision -> AaExecResult

def AaTrans.exec_unconfined source · line 286 · raw

@pol:0x2b280a281d356b8e5cd7b338ab267df1/profile.AaPolicy -> @+path:List<&2, U32> -> AaExecResult

an unconfined task (or a profile in unconfined mode) executing path: the profile whose attachment matches, else unconfined

def AaTrans.exec.pick source · line 289 · raw

@k:AaXPick -> @pol:0x2b280a281d356b8e5cd7b338ab267df1/profile.AaPolicy -> @p:0x2b280a281d356b8e5cd7b338ab267df1/profile.AaProfile -> @pname:List<&2, U32> -> @path:List<&2, U32> -> @d:0x2b280a281d356b8e5cd7b338ab267df1/eval.AaDecision -> AaExecResult

def AaTrans.exec.granted source · line 298 · raw

@ok:Bool -> @+q:0x2b280a281d356b8e5cd7b338ab267df1/rule_file.AaFileQuery -> @pol:0x2b280a281d356b8e5cd7b338ab267df1/profile.AaPolicy -> @+p:0x2b280a281d356b8e5cd7b338ab267df1/profile.AaProfile -> @pname:List<&2, U32> -> @path:List<&2, U32> -> @+d:0x2b280a281d356b8e5cd7b338ab267df1/eval.AaDecision -> AaExecResult

def AaTrans.is_unconfined source · line 305 · raw

@m:0x2b280a281d356b8e5cd7b338ab267df1/profile.AaMode -> Bool

def AaTrans.exec.mode source · line 312 · raw

@unc:Bool -> @opts:0x2b280a281d356b8e5cd7b338ab267df1/options.AaOptions -> @+pol:0x2b280a281d356b8e5cd7b338ab267df1/profile.AaPolicy -> @+p:0x2b280a281d356b8e5cd7b338ab267df1/profile.AaProfile -> @+pname:List<&2, U32> -> @owner:Bool -> @+path:List<&2, U32> -> AaExecResult

def AaTrans.exec.of source · line 321 · raw

@m:Maybe<&2, 0x2b280a281d356b8e5cd7b338ab267df1/profile.AaProfile> -> @opts:0x2b280a281d356b8e5cd7b338ab267df1/options.AaOptions -> @pol:0x2b280a281d356b8e5cd7b338ab267df1/profile.AaPolicy -> @pname:List<&2, U32> -> @owner:Bool -> @path:List<&2, U32> -> AaExecResult

def AaTrans.exec source · line 330 · raw

@opts:0x2b280a281d356b8e5cd7b338ab267df1/options.AaOptions -> @+pol:0x2b280a281d356b8e5cd7b338ab267df1/profile.AaPolicy -> @+pname:List<&2, U32> -> @owner:Bool -> @path:List<&2, U32> -> AaExecResult

a task confined by the profile with full name pname executes path (owner: its fsuid owns the file): where it goes, or why it may not