set

Function set 

Source
pub fn set(mode: Mode) -> Result<(ResUid, ResGid), Errno>
Expand description

Set the Mode. This function can never be misused to lock out the process from returning to the original, or any other mode. This function returns an error if the mode could not be changed. Otherwise, it returns the old mode for use in restore().

§Examples

user::set(user::Mode::Real).unwrap();

§Notes

  • user::set(Mode::Original) is functionally identical to user::revert()
  • user::set(Mode::Existing) is a no-op.

§Thread Safety

This function is not thread safe. Multiple threads can change the state using this function. If you need to ensure that everything executed between a set() and restore() block is run under the desired user, use run_as or its mode-specific variants.