[−][src]Struct redox_users::AllUsers
AllUsers
provides
(borrowed) access to all the users on the system.
Note that this struct implements All
for
a bunch of convenient access functions.
Notes
Note that everything in this section also applies to
AllGroups
- If you mutate anything owned by an
AllUsers
, you must call thesave
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
andget_mut_by_name
functions.
Shadowfile handling
This implementation of redox-users uses a shadowfile implemented primarily
by this struct. AllUsers
respects the auth_enabled
status of the Config
that is was passed. If auth is enabled, it populates the
hash fields of each user struct that it parses from /etc/passwd
with
info from /et/shadow
. If a caller attempts to perform an action that
requires this info with an AllUsers
config that does not have auth enabled,
the User
handling action will panic.
Methods
impl AllUsers
[src]
pub fn new(config: Config) -> Result<AllUsers>
[src]
See Shadowfile Handling for configuration information regarding this constructor.
pub fn add_user(
&mut self,
login: &str,
uid: usize,
gid: usize,
name: &str,
home: &str,
shell: &str
) -> Result<()>
[src]
&mut self,
login: &str,
uid: usize,
gid: usize,
name: &str,
home: &str,
shell: &str
) -> Result<()>
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 the Config
passed to AllUsers::new
does not have authentication enabled (see
Shadowfile handling
).
pub fn save(&self) -> Result<()>
[src]
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!
Trait Implementations
impl All for AllUsers
[src]
fn iter(&self) -> Iter<Self::Gruser>
[src]
Get an iterator borrowing all User
's or Group
's on the system. Read more
fn iter_mut(&mut self) -> IterMut<Self::Gruser>
[src]
Get an iterator mutably borrowing all User
's or Group
's on the system. Read more
fn get_by_name(
&self,
name: impl AsRef<str>
) -> Option<&Self::Gruser>
[src]
&self,
name: impl AsRef<str>
) -> Option<&Self::Gruser>
Borrow the User
or Group
with a given name. Read more
fn get_mut_by_name(
&mut self,
name: impl AsRef<str>
) -> Option<&mut Self::Gruser>
[src]
&mut self,
name: impl AsRef<str>
) -> Option<&mut Self::Gruser>
Mutable version of get_by_name
.
fn get_by_id(&self, id: usize) -> Option<&Self::Gruser>
[src]
Borrow the User
or Group
with the given ID. Read more
fn get_mut_by_id(&mut self, id: usize) -> Option<&mut Self::Gruser>
[src]
Mutable version of get_by_id
.
fn get_unique_id(&self) -> Option<usize>
[src]
Provides an unused id based on the min and max values in the Config
passed to the All
's constructor. Read more
fn remove_by_name(
&mut self,
name: impl AsRef<str>
)
[src]
&mut self,
name: impl AsRef<str>
)
Remove a User
or Group
from this All
given it's name. This won't provide an indication of whether the user was removed or not, but is guaranteed to work if a user with the specified name exists. Read more
fn remove_by_id(&mut self, id: usize)
[src]
Id version of remove_by_name
.
impl Debug for AllUsers
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,