* [pbs-devel] [PATCH proxmox-backup] fix regression test file permission problems
@ 2021-07-21 6:12 Dietmar Maurer
2021-07-21 7:30 ` [pbs-devel] applied: " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Dietmar Maurer @ 2021-07-21 6:12 UTC (permalink / raw)
To: pbs-devel
By simply using the current user/group instead of backup:backup
---
src/backup/mod.rs | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/backup/mod.rs b/src/backup/mod.rs
index 31bd1b3b..20b6b3ca 100644
--- a/src/backup/mod.rs
+++ b/src/backup/mod.rs
@@ -12,17 +12,27 @@ pub const BACKUP_GROUP_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."),
+ if cfg!(test) {
+ // fix permission problems with regressions test (when run as non-root).
+ 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)``)
pub fn backup_group() -> Result<nix::unistd::Group, Error> {
- match nix::unistd::Group::from_name(BACKUP_GROUP_NAME)? {
- Some(group) => Ok(group),
- None => bail!("Unable to lookup backup user."),
+ if cfg!(test) {
+ // fix permission problems with regressions test (when run as non-root).
+ 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."),
+ }
}
}
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pbs-devel] applied: [PATCH proxmox-backup] fix regression test file permission problems
2021-07-21 6:12 [pbs-devel] [PATCH proxmox-backup] fix regression test file permission problems Dietmar Maurer
@ 2021-07-21 7:30 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2021-07-21 7:30 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Dietmar Maurer
On 21.07.21 08:12, Dietmar Maurer wrote:
> By simply using the current user/group instead of backup:backup
> ---
> src/backup/mod.rs | 22 ++++++++++++++++------
> 1 file changed, 16 insertions(+), 6 deletions(-)
>
>
applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-21 7:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-21 6:12 [pbs-devel] [PATCH proxmox-backup] fix regression test file permission problems Dietmar Maurer
2021-07-21 7:30 ` [pbs-devel] applied: " Thomas Lamprecht
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal