[go: up one dir, main page]

Module entries

Module entries 

Source
Expand description

Get password/group file entry

§Examples:

use uucore::entries::{self, Locate};

let root_group = if cfg!(any(target_os = "linux", target_os = "android")) {
    "root"
} else {
    "wheel"
};

assert_eq!("root", entries::uid2usr(0).unwrap());
assert_eq!(0, entries::usr2uid("root").unwrap());
assert!(entries::gid2grp(0).is_ok());
assert!(entries::grp2gid(root_group).is_ok());

assert!(entries::Passwd::locate(0).is_ok());
assert!(entries::Passwd::locate("0").is_ok());
assert!(entries::Passwd::locate("root").is_ok());

assert!(entries::Group::locate(0).is_ok());
assert!(entries::Group::locate("0").is_ok());
assert!(entries::Group::locate(root_group).is_ok());

Structs§

Group
Passwd

Traits§

Locate
Fetch desired entry.

Functions§

get_groups
From: <https://man7.org/linux/man-pages/man2/getgroups.2.html>
get_groups_gnu
The list of group IDs returned from GNU’s groups and GNU’s id --groups starts with the effective group ID (egid). This is a wrapper for get_groups() to mimic this behavior.
gid2grp
grp2gid
uid2usr
usr2uid