|
|
@@ -1,4 +1,3 @@
|
|
|
-use std::string::raw::from_buf;
|
|
|
use std::ptr::read;
|
|
|
use std::ptr;
|
|
|
use std::collections::HashMap;
|
|
|
@@ -57,7 +56,7 @@ impl Unix {
|
|
|
let infoptr = unsafe { c::getpwuid(uid as i32) };
|
|
|
let info = unsafe { infoptr.as_ref().unwrap() }; // the user has to have a name
|
|
|
|
|
|
- let username = unsafe { from_buf(info.pw_name as *const u8) };
|
|
|
+ let username = unsafe { String::from_raw_buf(info.pw_name as *const u8) };
|
|
|
|
|
|
let mut user_names = HashMap::new();
|
|
|
user_names.insert(uid as u32, Some(username.clone()));
|
|
|
@@ -93,7 +92,7 @@ impl Unix {
|
|
|
pub fn load_user(&mut self, uid: u32) {
|
|
|
let pw = unsafe { c::getpwuid(uid as i32) };
|
|
|
if pw.is_not_null() {
|
|
|
- let username = unsafe { Some(from_buf(read(pw).pw_name as *const u8)) };
|
|
|
+ let username = unsafe { Some(String::from_raw_buf(read(pw).pw_name as *const u8)) };
|
|
|
self.user_names.insert(uid, username);
|
|
|
}
|
|
|
else {
|
|
|
@@ -116,7 +115,7 @@ impl Unix {
|
|
|
if username == ptr::null() {
|
|
|
return false;
|
|
|
}
|
|
|
- else if unsafe { from_buf(username as *const u8) } == *uname {
|
|
|
+ else if unsafe { String::from_raw_buf(username as *const u8) } == *uname {
|
|
|
return true;
|
|
|
}
|
|
|
else {
|
|
|
@@ -135,7 +134,7 @@ impl Unix {
|
|
|
self.groups.insert(gid, false);
|
|
|
},
|
|
|
Some(r) => {
|
|
|
- let group_name = unsafe { Some(from_buf(r.gr_name as *const u8)) };
|
|
|
+ let group_name = unsafe { Some(String::from_raw_buf(r.gr_name as *const u8)) };
|
|
|
if !self.groups.contains_key(&gid) {
|
|
|
self.groups.insert(gid, Unix::group_membership(r.gr_mem, &self.username));
|
|
|
}
|