-
Notifications
You must be signed in to change notification settings - Fork 680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getpwnam
is missing
#862
Comments
Is this a request to add that functionality or are you planning on adding it? |
Hi, I was planning on implementing it. There are a few related functions that are also missing, e.g. I haven't implemented the others yet, but I have finished this one. (Tested only on FreeBSD, append to use libc::time_t;
#[derive(Debug, Default)]
pub struct Passwd {
pub name: CString,
pub passwd: CString,
pub uid: uid_t,
pub gid: gid_t,
pub change: time_t,
pub class: CString,
pub gecos: CString,
pub dir: CString,
pub shell: CString,
pub expire: time_t
}
pub fn getpwnam<S: Into<Vec<u8>>>(name: S) -> Result<Option<Passwd>> {
let pw = unsafe { libc::getpwnam(CString::new(name).unwrap().as_ptr()).as_ref() };
unsafe {
match pw {
None => {return Ok(None)},
Some(pw) =>
Ok( Some( Passwd {
name: CString::new(CStr::from_ptr(pw.pw_name).to_bytes()).unwrap(),
passwd: CString::new(CStr::from_ptr(pw.pw_passwd).to_bytes()).unwrap(),
class: CString::new(CStr::from_ptr(pw.pw_class).to_bytes()).unwrap(),
gecos: CString::new(CStr::from_ptr(pw.pw_gecos).to_bytes()).unwrap(),
dir: CString::new(CStr::from_ptr(pw.pw_dir).to_bytes()).unwrap(),
shell: CString::new(CStr::from_ptr(pw.pw_shell).to_bytes()).unwrap(),
uid: pw.pw_uid,
gid: pw.pw_gid,
change: pw.pw_change,
expire: pw.pw_expire
} ) )
}
}
} |
@ctrlcctrlv Thanks for your hard work! |
@ctrlcctrlv To address your question directed to me, there isn't a real order to how we triage PRs or even code. Sometimes older things come to the top of my queue because I'm more familiar with the API it's implementing or even because it was the most recent email. So pinging is definitely the right idea. @kristate Thanks for reviewing their code! We heavily rely on the community to help us. I see myself more of a project manager than a coder when it comes to |
You can use pwd crate if you need this NOW. |
Note that if you search for things like |
There is This issue may even be closed? |
No description provided.
The text was updated successfully, but these errors were encountered: