From: Dietmar Maurer <dietmar@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] fix regression test file permission problems
Date: Wed, 21 Jul 2021 08:12:51 +0200 [thread overview]
Message-ID: <20210721061251.747710-1-dietmar@proxmox.com> (raw)
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
next reply other threads:[~2021-07-21 6:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-21 6:12 Dietmar Maurer [this message]
2021-07-21 7:30 ` [pbs-devel] applied: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210721061251.747710-1-dietmar@proxmox.com \
--to=dietmar@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.