|
|
|
@ -26,17 +26,7 @@ pub fn get_users() -> std::vec::Vec<Passwd> {
|
|
|
|
|
let mut users = vec!();
|
|
|
|
|
|
|
|
|
|
unsafe {
|
|
|
|
|
// This could maybe be simplified but there's no point
|
|
|
|
|
macro_rules! from_cstr {
|
|
|
|
|
($x:expr, $fmt:literal) => {
|
|
|
|
|
match std::ffi::CStr::from_ptr($x).to_owned().into_string() {
|
|
|
|
|
Ok(v) => v,
|
|
|
|
|
Err(v) => {
|
|
|
|
|
warn!($fmt, v);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
($x:expr, $fmt:literal, $usr:expr) => {
|
|
|
|
|
match std::ffi::CStr::from_ptr($x).to_owned().into_string() {
|
|
|
|
|
Ok(v) => v,
|
|
|
|
@ -60,7 +50,8 @@ pub fn get_users() -> std::vec::Vec<Passwd> {
|
|
|
|
|
let my_passwd = *passwd;
|
|
|
|
|
let name = from_cstr!(
|
|
|
|
|
my_passwd.pw_name,
|
|
|
|
|
"User {} has invalid UTF-8 characters, skipping"
|
|
|
|
|
"{}User {} has invalid UTF-8 characters, skipping",
|
|
|
|
|
"" // Lol
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
users.push(Passwd{
|
|
|
|
|