[go: up one dir, main page]

Function users::switch_user_group [] [src]

pub fn switch_user_group(uid: uid_t, gid: gid_t) -> Result<SwitchUserGuardError>

Safely switch user and group for the current scope. Requires root access.

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

Use with care! Possible security issues can happen, as Rust doesn't guarantee running the destructor! If in doubt run drop() method on the guard value manually!