Struct redox_users::AllUsers[][src]

pub struct AllUsers { /* fields omitted */ }

Struct encapsulating all users on the system

AllUsers is a struct providing (borrowed) access to all the users and groups on the system.

Notes

Note that everything in this section also applies to AllGroups

  • If you mutate anything owned by an AllUsers, you must call the save method in order for those changes to be applied to the system.
  • The API here is kept small on purpose in order to reduce the surface area for security exploitation. Most mutating actions can be accomplished via the get_mut_by_id and get_mut_by_name functions.

Shadowfile handling

This implementation of redox-users uses a shadowfile implemented primarily by this struct. The constructor provided takes a boolean which indicates to AllUsers that the shadowfile is nessasary. AllUsers populates the hash fields of each user struct that it parses from /etc/passwd with info from /et/shadow. If a user attempts to perform an action that requires this info while passing false to AllUsers, the User handling the action will panic.

Methods

impl AllUsers
[src]

Create a new AllUsers Pass true if you need to authenticate a password, else, false (see Shadowfile Handling)

Get an iterator over all system users

Mutable version of iter

Borrow the User representing a user for a given username.

Examples

Basic usage:

let users = AllUsers::new(false).unwrap();
let user = users.get_by_id(0).unwrap();

Mutable version of 'get_by_name'

Borrow the User representing given user ID.

Examples

Basic usage:

let users = AllUsers::new(false).unwrap();
let user = users.get_by_id(0).unwrap();

Mutable version of get_by_id

Provides an unused user id, defined as "unused" by the system defaults, between 1000 and 6000

Examples

let users = AllUsers::new(false).unwrap();
let uid = users.get_unique_id().expect("no available uid");

Adds a user with the specified attributes to the AllUsers instance. Note that the user's password is set unset (see Unset vs Blank Passwords) during this call.

This function is classified as a mutating operation, and users must therefore call save in order for the new user to be applied to the system.

Panics

This function will panic if true was not passed to AllUsers::new (see Shadowfile handling)

Remove a user from the system. This is a mutating operation, and users of the crate must therefore call save in order for changes to be applied to the system.

User-id version of remove_by_name

Syncs the data stored in the AllUsers instance to the filesystem. To apply changes to the system from an AllUsers, you MUST call this function! This function currently does a bunch of fs I/O so it is error-prone.

Auto Trait Implementations

impl Send for AllUsers

impl Sync for AllUsers