[][src]Function users::switch::switch_user_group

pub fn switch_user_group(uid: uid_t, gid: gid_t) -> IOResult<SwitchUserGuard>

Sets the effective user and the effective group for the current scope.

Typically, trying to switch to any user or group other than the ones already running the process requires root privileges.

Security considerations

Examples

use users::switch::switch_user_group;
use std::mem::drop;

{
    let guard = switch_user_group(1001, 1001);
    // current and effective user and group IDs are 1001
    drop(guard);
}
// back to the old values