Have different c_passwd structs for different OSes

This commit is contained in:
Ben S
2015-05-05 20:16:17 +01:00
parent d4234b64c1
commit 1c7cdad0ff
2 changed files with 21 additions and 7 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ documentation = "http://bsago.me/doc/users/"
homepage = "https://github.com/ogham/rust-users"
license = "MIT"
readme = "README.md"
version = "0.4.0"
version = "0.4.1"
[dependencies]
libc = "0.1.1"
+20 -6
View File
@@ -127,6 +127,7 @@ use std::collections::hash_map::Entry::{Occupied, Vacant};
pub mod mock;
/// The trait for the `OSUsers` object.
pub trait Users {
@@ -149,20 +150,33 @@ pub trait Users {
fn get_current_username(&mut self) -> Option<String>;
}
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
#[repr(C)]
struct c_passwd {
pub pw_name: *const c_char, // login name
pub pw_passwd: *const c_char,
pub pw_name: *const c_char, // user name
pub pw_passwd: *const c_char, // password field
pub pw_uid: uid_t, // user ID
pub pw_gid: gid_t, // group ID
pub pw_gecos: *const c_char, // full name
pub pw_dir: *const c_char, // login dir
pub pw_shell: *const c_char, // login shell
pub pw_change: time_t,
pub pw_change: time_t, // password change time
pub pw_class: *const c_char,
pub pw_gecos: *const c_char,
pub pw_dir: *const c_char, // user's home directory
pub pw_shell: *const c_char, // user's shell
pub pw_expire: time_t, // password expiry time
}
#[cfg(target_os = "linux")]
#[repr(C)]
struct c_passwd {
pub pw_name: *const c_char, // user name
pub pw_passwd: *const c_char, // password field
pub pw_uid: uid_t, // user ID
pub pw_gid: gid_t, // group ID
pub pw_gecos: *const c_char,
pub pw_dir: *const c_char, // user's home directory
pub pw_shell: *const c_char, // user's shell
}
#[repr(C)]
struct c_group {
pub gr_name: *const c_char, // group name