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

@ -103,6 +103,8 @@
//!
//! Not sure if this is better. TODO
use failure::*;
// Note: .pcat1 => Proxmox Catalog Format version 1
pub const CATALOG_NAME: &str = "catalog.pcat1.didx";
@ -116,6 +118,17 @@ macro_rules! PROXMOX_BACKUP_READER_PROTOCOL_ID_V1 {
() => { "proxmox-backup-reader-protocol-v1" }
}
/// Unix system user used by proxmox-backup-proxy
pub const BACKUP_USER_NAME: &str = "backup";
/// Return User info for the 'backup' user (``getpwnam_r(3)``)
pub fn backup_user() -> Result<nix::unistd::User, Error> {
match nix::unistd::User::from_name(BACKUP_USER_NAME)? {
Some(user) => Ok(user),
None => bail!("Unable to lookup backup user."),
}
}
mod file_formats;
pub use file_formats::*;