mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
id: linux specific pline()
This commit is contained in:
parent
0956ab8804
commit
1b8307e9d9
1 changed files with 26 additions and 0 deletions
26
id/id.rs
26
id/id.rs
|
@ -256,6 +256,7 @@ fn pretty(possible_pw: Option<c_passwd>) {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn pline(possible_pw: Option<c_passwd>) {
|
||||
let pw = if possible_pw.is_none() {
|
||||
unsafe { read(getpwuid(getuid() as i32)) }
|
||||
|
@ -284,6 +285,31 @@ fn pline(possible_pw: Option<c_passwd>) {
|
|||
pw_shell);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn pline(possible_pw: Option<c_passwd>) {
|
||||
let pw = if possible_pw.is_none() {
|
||||
unsafe { read(getpwuid(getuid() as i32)) }
|
||||
} else {
|
||||
possible_pw.unwrap()
|
||||
};
|
||||
|
||||
let pw_name = unsafe { from_c_str(pw.pw_name) };
|
||||
let pw_passwd = unsafe { from_c_str(pw.pw_passwd)};
|
||||
let pw_gecos = unsafe { from_c_str(pw.pw_gecos) };
|
||||
let pw_dir = unsafe { from_c_str(pw.pw_dir) };
|
||||
let pw_shell = unsafe { from_c_str(pw.pw_shell) };
|
||||
|
||||
println!(
|
||||
"{:s}:{:s}:{:d}:{:d}:{:s}:{:s}:{:s}",
|
||||
pw_name,
|
||||
pw_passwd,
|
||||
pw.pw_uid,
|
||||
pw.pw_gid,
|
||||
pw_gecos,
|
||||
pw_dir,
|
||||
pw_shell);
|
||||
}
|
||||
|
||||
static NGROUPS: i32 = 20;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue