remove tools::getpwnam_ugid, impl. crate::backup::backup_user()

And use new nix::unistd::User struct.
This commit is contained in:
Dietmar Maurer
2019-12-19 10:20:13 +01:00
parent 8bf4559b4e
commit f74a03da1f
7 changed files with 45 additions and 55 deletions

View File

@ -199,19 +199,6 @@ where
Ok(())
}
/// Returns the Unix uid/gid for the sepcified system user.
pub fn getpwnam_ugid(username: &str) -> Result<(libc::uid_t, libc::gid_t), Error> {
let c_username = std::ffi::CString::new(username).unwrap();
let info = unsafe { libc::getpwnam(c_username.as_ptr()) };
if info.is_null() {
bail!("getpwnam '{}' failed", username);
}
let info = unsafe { *info };
Ok((info.pw_uid, info.pw_gid))
}
pub fn json_object_to_query(data: Value) -> Result<String, Error> {
let mut query = url::form_urlencoded::Serializer::new(String::new());