fix regression test file permission problems
By simply using the current user/group instead of backup:backup
This commit is contained in:
parent
89145cde34
commit
ac81ed17b9
@ -12,17 +12,27 @@ pub const BACKUP_GROUP_NAME: &str = "backup";
|
|||||||
|
|
||||||
/// Return User info for the 'backup' user (``getpwnam_r(3)``)
|
/// Return User info for the 'backup' user (``getpwnam_r(3)``)
|
||||||
pub fn backup_user() -> Result<nix::unistd::User, Error> {
|
pub fn backup_user() -> Result<nix::unistd::User, Error> {
|
||||||
match nix::unistd::User::from_name(BACKUP_USER_NAME)? {
|
if cfg!(test) {
|
||||||
Some(user) => Ok(user),
|
// fix permission problems with regressions test (when run as non-root).
|
||||||
None => bail!("Unable to lookup backup user."),
|
Ok(nix::unistd::User::from_uid(nix::unistd::Uid::current())?.unwrap())
|
||||||
|
} else {
|
||||||
|
match nix::unistd::User::from_name(BACKUP_USER_NAME)? {
|
||||||
|
Some(user) => Ok(user),
|
||||||
|
None => bail!("Unable to lookup backup user."),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return Group info for the 'backup' group (``getgrnam(3)``)
|
/// Return Group info for the 'backup' group (``getgrnam(3)``)
|
||||||
pub fn backup_group() -> Result<nix::unistd::Group, Error> {
|
pub fn backup_group() -> Result<nix::unistd::Group, Error> {
|
||||||
match nix::unistd::Group::from_name(BACKUP_GROUP_NAME)? {
|
if cfg!(test) {
|
||||||
Some(group) => Ok(group),
|
// fix permission problems with regressions test (when run as non-root).
|
||||||
None => bail!("Unable to lookup backup user."),
|
Ok(nix::unistd::Group::from_gid(nix::unistd::Gid::current())?.unwrap())
|
||||||
|
} else {
|
||||||
|
match nix::unistd::Group::from_name(BACKUP_GROUP_NAME)? {
|
||||||
|
Some(group) => Ok(group),
|
||||||
|
None => bail!("Unable to lookup backup user."),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user