Open
Description
OpenBSD and NetBSD define passwd
as the following:
struct passwd {
char *pw_name;
char *pw_passwd;
uid_t pw_uid;
gid_t pw_gid;
time_t pw_change;
char *pw_class;
char *pw_gecos;
char *pw_dir;
char *pw_shell;
time_t pw_expire;
};
macOS, FreeBSD, and DragonFly BSD define passwd
as the following:
struct passwd {
char *pw_name;
char *pw_passwd;
uid_t pw_uid;
gid_t pw_gid;
time_t pw_change;
char *pw_class;
char *pw_gecos;
char *pw_dir;
char *pw_shell;
time_t pw_expire;
int pw_fields;
};
Currently passwd
only conforms to how glibc and musl define it:
struct passwd {
char *pw_name;
char *pw_passwd;
uid_t pw_uid;
gid_t pw_gid;
char *pw_gecos;
char *pw_dir;
char *pw_shell;
};
Should passwd
be defined like below:
pub struct passwd {
pub pw_name: *mut c_char,
pub pw_passwd: *mut c_char,
pub pw_uid: crate::uid_t,
pub pw_gid: crate::gid_t,
#[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "macos", target_os = "netbsd", target_os = "openbsd"))]
pub pw_change: crate::time_t,
#[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "macos", target_os = "netbsd", target_os = "openbsd"))]
pub pw_class: *mut c_char,
pub pw_gecos: *mut c_char,
pub pw_dir: *mut c_char,
pub pw_shell: *mut c_char,
#[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "macos", target_os = "netbsd", target_os = "openbsd"))]
pub pw_expire: crate::time_t,
#[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "macos"))]
pub pw_fields: c_int,
}