pub struct PolicyIndex { /* private fields */ }Expand description
An index for facilitating fast lookup of common abstractions inside parsed binary policy data
structures. Typically, data is indexed by an enum that describes a well-known value and the
index stores the offset of the data in the binary policy to avoid scanning a collection to find
an element that contains a matching string. For example, the policy contains a collection of
classes that are identified by string names included in each collection entry. However,
policy_index.classes(KernelClass::Process).unwrap() yields the offset in the policy’s
collection of classes where the “process” class resides.
Implementations§
Source§impl PolicyIndex
impl PolicyIndex
Sourcepub fn new(parsed_policy: ParsedPolicy) -> Result<Self, Error>
pub fn new(parsed_policy: ParsedPolicy) -> Result<Self, Error>
Constructs a PolicyIndex that indexes over well-known policy elements.
[Class]es and [Permission]s used by the kernel are amongst the indexed elements.
The policy’s handle_unknown() configuration determines whether the policy can be loaded even
if it omits classes or permissions expected by the kernel, and whether to allow or deny those
permissions if so.
Sourcepub fn kernel_permission_to_access_vector<P: Into<KernelPermission>>(
&self,
permission: P,
) -> Option<AccessVector>
pub fn kernel_permission_to_access_vector<P: Into<KernelPermission>>( &self, permission: P, ) -> Option<AccessVector>
Returns the policy entry for a well-known kernel object class permission.
Sourcepub fn compute_create_context_with_name(
&self,
source: &SecurityContext,
target: &SecurityContext,
class: ObjectClass,
name: NullessByteStr<'_>,
) -> Option<SecurityContext>
pub fn compute_create_context_with_name( &self, source: &SecurityContext, target: &SecurityContext, class: ObjectClass, name: NullessByteStr<'_>, ) -> Option<SecurityContext>
Returns the security context that should be applied to a newly created SELinux
object according to source and target security contexts, as well as the new object’s
class.
If no filename-transition rule matches the supplied arguments then None is returned, and
the caller should fall-back to filename-independent labeling via
[compute_create_context()]
Sourcepub fn compute_create_context(
&self,
source: &SecurityContext,
target: &SecurityContext,
class: ObjectClass,
) -> SecurityContext
pub fn compute_create_context( &self, source: &SecurityContext, target: &SecurityContext, class: ObjectClass, ) -> SecurityContext
Returns the security context that should be applied to a newly created SELinux
object according to source and target security contexts, as well as the new object’s
class.
Computation follows the “create” algorithm for labeling newly created objects:
- user is taken from the
source. - role, type and range are taken from the matching transition rules, if any.
- role, type and range fall-back to the
sourceortargetvalues according to policy.
If no transitions apply, and the policy does not explicitly specify defaults then the
role, type and range values have defaults chosen based on the class:
- For “process”, and socket-like classes, role, type and range are taken from the
source. - Otherwise role is “object_r”, type is taken from
targetand range is set to the low level of thesourcerange.
Methods from Deref<Target = ParsedPolicy>§
Trait Implementations§
Source§impl Debug for PolicyIndex
impl Debug for PolicyIndex
Auto Trait Implementations§
impl Freeze for PolicyIndex
impl RefUnwindSafe for PolicyIndex
impl Send for PolicyIndex
impl Sync for PolicyIndex
impl Unpin for PolicyIndex
impl UnsafeUnpin for PolicyIndex
impl UnwindSafe for PolicyIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more