pub struct User<A> {
pub user: String,
pub uid: usize,
pub gid: usize,
pub name: String,
pub home: String,
pub shell: String,
/* private fields */
}Expand description
A struct representing a Redox user.
Currently maps to an entry in the /etc/passwd file.
A should be a type from crate::auth.
§Unset vs. Blank Passwords
A note on unset passwords vs. blank passwords. A blank password
is a hash field that is completely blank (aka, ""). According
to this crate, successful login is only allowed if the input
password is blank as well.
An unset password is one whose hash is not empty (""), but
also not a valid serialized argon2rs hashing session. This
hash always returns false upon attempted verification. The
most commonly used hash for an unset password is "!", but
this crate makes no distinction. The most common way to unset
the password is to use User::unset_passwd.
Fields§
§user: StringUsername (login name)
uid: usizeUser id
gid: usizeGroup id
name: StringReal name (human readable, can contain spaces)
home: StringHome directory path
shell: StringShell path
Implementations§
Source§impl<A: Default> User<A>
impl<A: Default> User<A>
Sourcepub fn shell_cmd(&self) -> Command
pub fn shell_cmd(&self) -> Command
Get a Command to run the user’s default shell (see User::login_cmd
for more docs).
Sourcepub fn login_cmd<T>(&self, cmd: T) -> Command
pub fn login_cmd<T>(&self, cmd: T) -> Command
Provide a login command for the user, which is any entry point for
starting a user’s session, whether a shell (use User::shell_cmd
instead) or a graphical init.
The Command will use the user’s uid and gid, its current_dir
will be set to the user’s home directory, and the follwing enviroment
variables will be populated:
USERset to the user’suserfield.UIDset to the user’suidfield.GROUPSset the user’sgidfield.HOMEset to the user’shomefield.SHELLset to the user’sshellfield.
Source§impl User<Full>
impl User<Full>
Sourcepub fn set_passwd(&mut self, password: impl AsRef<str>) -> Result<(), Error>
pub fn set_passwd(&mut self, password: impl AsRef<str>) -> Result<(), Error>
Set the password for a user. Make sure that password
is actually what the user wants as their password (this doesn’t).
To set the password blank, pass "" as password.
Note that password is taken as a reference, so it is up to the caller
to properly zero sensitive memory (see zeroize on crates.io).
Sourcepub fn unset_passwd(&mut self)
pub fn unset_passwd(&mut self)
Unset the password (User::verify_passwd always returns false).
Sourcepub fn verify_passwd(&self, password: impl AsRef<str>) -> bool
pub fn verify_passwd(&self, password: impl AsRef<str>) -> bool
Verify the password. If the hash is empty, this only returns true if
password is also empty.
Note that this is a blocking operation if the password is incorrect.
See Config::auth_delay to set the wait time. Default is 3 seconds.
Note that password is taken as a reference, so it is up to the caller
to properly zero sensitive memory (see zeroize on crates.io).
Sourcepub fn is_passwd_blank(&self) -> bool
pub fn is_passwd_blank(&self) -> bool
Determine if the hash for the password is blank (User::verify_passwd
returns true only when the password is blank).
Sourcepub fn is_passwd_unset(&self) -> bool
pub fn is_passwd_unset(&self) -> bool
Determine if the hash for the password is unset
(User::verify_passwd returns false regardless of input).