Struct ContextRestore

Source
pub struct ContextRestore<'labeler, T: BackEnd> { /* private fields */ }
Expand description

Restore file(s) default SELinux security contexts.

Implementations§

Source§

impl<'labeler, T> ContextRestore<'labeler, T>
where T: BackEnd,

Source

pub fn with_labeler(labeler: &'labeler mut Labeler<T>) -> Self

Set a labeling handle for relabeling.

See: selinux_restorecon_set_sehandle().

Source

pub fn labeler(&self) -> Option<&&'labeler mut Labeler<T>>

Get the labeling handle to be used for relabeling.

Source

pub fn set_alternative_root_path( &mut self, path: impl AsRef<Path>, ) -> Result<()>

Set an alternate root path for relabeling.

See: selinux_restorecon_set_alt_rootpath().

Source

pub fn add_exclude_list<P>( &mut self, exclusion_patterns: impl IntoIterator<Item = P>, ) -> Result<()>
where P: AsRef<Path>,

Add to the list of directories to be excluded from relabeling.

See: selinux_restorecon_set_exclude_list().

Source

pub fn restore_context_of_file_system_entry( self, path: impl AsRef<Path>, threads_count: usize, flags: RestoreFlags, ) -> Result<Option<u64>>

Restore file(s) default SELinux security contexts.

If threads_count is zero, then:

  • If selinux_restorecon_parallel() is supported by libselinux (version 3.4 or later), then this operation will use as many threads as the number of online processor cores present.
  • Otherwise, this operation will run in one thread.

When this method succeeds:

  • If flags includes RestoreFlags::COUNT_ERRORS, then this returns Ok(Some(N)) where N is the number of errors that were ignored while walking the file system tree specified by path.
  • Otherwise, Ok(None) is returned.

See: selinux_restorecon(), selinux_restorecon_parallel().

Source

pub fn manage_security_sehash_xattr_entries( dir_path: impl AsRef<Path>, flags: XAttrFlags, ) -> Result<DirectoryXAttributesIter>

Manage default security.sehash extended attribute entries added by selinux_restorecon(), setfiles() or restorecon().

See: selinux_restorecon_xattr().

Trait Implementations§

Source§

impl<'labeler, T: Debug + BackEnd> Debug for ContextRestore<'labeler, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'labeler, T: Default + BackEnd> Default for ContextRestore<'labeler, T>

Source§

fn default() -> ContextRestore<'labeler, T>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'labeler, T> Freeze for ContextRestore<'labeler, T>

§

impl<'labeler, T> RefUnwindSafe for ContextRestore<'labeler, T>
where T: RefUnwindSafe,

§

impl<'labeler, T> !Send for ContextRestore<'labeler, T>

§

impl<'labeler, T> !Sync for ContextRestore<'labeler, T>

§

impl<'labeler, T> Unpin for ContextRestore<'labeler, T>

§

impl<'labeler, T> !UnwindSafe for ContextRestore<'labeler, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.