Struct uu_chown::Passwd

source ·
pub struct Passwd {
    pub name: String,
    pub uid: u32,
    pub gid: u32,
    pub user_info: Option<String>,
    pub user_shell: Option<String>,
    pub user_dir: Option<String>,
    pub user_passwd: Option<String>,
}

Fields§

§name: String

AKA passwd.pw_name

§uid: u32

AKA passwd.pw_uid

§gid: u32

AKA passwd.pw_gid

§user_info: Option<String>

AKA passwd.pw_gecos

§user_shell: Option<String>

AKA passwd.pw_shell

§user_dir: Option<String>

AKA passwd.pw_dir

§user_passwd: Option<String>

AKA passwd.pw_passwd

Implementations§

source§

impl Passwd

source

pub fn belongs_to(&self) -> Vec<u32>

This is a wrapper function for libc::getgrouplist.

From: <https://man7.org/linux/man-pages/man3/getgrouplist.3.html>

If the number of groups of which user is a member is less than or equal to *ngroups, then the value *ngroups is returned. If the user is a member of more than *ngroups groups, then getgrouplist() returns -1. In this case, the value returned in *ngroups can be used to resize the buffer passed to a further call getgrouplist().

However, on macOS/darwin (and maybe others?) getgrouplist does not update ngroups if ngroups is too small. Therefore, if not updated by getgrouplist, ngroups needs to be increased in a loop until getgrouplist stops returning -1.

Trait Implementations§

source§

impl Clone for Passwd

source§

fn clone(&self) -> Passwd

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Passwd

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'a> Locate<&'a str> for Passwd

source§

impl Locate<u32> for Passwd

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.