public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup 0/2] conditionally skip pxar metadata reference test
@ 2024-06-06  8:17 Christian Ebner
  2024-06-06  8:17 ` [pbs-devel] [PATCH proxmox-backup 1/2] client: pxar: do not attempt to set uid/gid in test Christian Ebner
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christian Ebner @ 2024-06-06  8:17 UTC (permalink / raw)
  To: pbs-devel

When running as user with uid/gid not equal to 1000/1000, the test to
create a pxar archive with previous metadata reference would fail, as
the created test directories and files do not get the expected ownership
set because of lack of permissions.

Therefore these patches do:
- not even attempt to set the uid/gid for the folders, as without
  permissions these are not set anyways.
- only execute the test on the condition that euid and egid are 1000

Tested by running the tests via:
`cargo test --workspace --release -- --nocapture`

For root user and user with uid/gid 1000. Without the patches the test
fails for the root user, with the patches applied it passes for both.

Christian Ebner (2):
  client: pxar: do not attempt to set uid/gid in test
  client: pxar: conditionally skip metadata reference test

 pbs-client/src/pxar/create.rs | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 1/2] client: pxar: do not attempt to set uid/gid in test
  2024-06-06  8:17 [pbs-devel] [PATCH proxmox-backup 0/2] conditionally skip pxar metadata reference test Christian Ebner
@ 2024-06-06  8:17 ` Christian Ebner
  2024-06-06  8:17 ` [pbs-devel] [PATCH proxmox-backup 2/2] client: pxar: conditionally skip metadata reference test Christian Ebner
  2024-06-06  8:54 ` [pbs-devel] applied: [PATCH proxmox-backup 0/2] conditionally skip pxar " Fabian Grünbichler
  2 siblings, 0 replies; 4+ messages in thread
From: Christian Ebner @ 2024-06-06  8:17 UTC (permalink / raw)
  To: pbs-devel

Setting the uid/gid for the files and folders of the test directory
structure will not work when lacking the permissions.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 pbs-client/src/pxar/create.rs | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs
index fcfb9a09c..d5eb7bd02 100644
--- a/pbs-client/src/pxar/create.rs
+++ b/pbs-client/src/pxar/create.rs
@@ -1814,16 +1814,14 @@ mod tests {
         );
 
         let dir_metadata = Metadata {
-            stat: pxar::Stat::default().mode(0o777u64).set_dir().gid(0).uid(0),
+            stat: pxar::Stat::default().mode(0o777u64).set_dir(),
             ..Default::default()
         };
 
         let file_metadata = Metadata {
             stat: pxar::Stat::default()
                 .mode(0o777u64)
-                .set_regular_file()
-                .gid(0)
-                .uid(0),
+                .set_regular_file(),
             ..Default::default()
         };
 
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 2/2] client: pxar: conditionally skip metadata reference test
  2024-06-06  8:17 [pbs-devel] [PATCH proxmox-backup 0/2] conditionally skip pxar metadata reference test Christian Ebner
  2024-06-06  8:17 ` [pbs-devel] [PATCH proxmox-backup 1/2] client: pxar: do not attempt to set uid/gid in test Christian Ebner
@ 2024-06-06  8:17 ` Christian Ebner
  2024-06-06  8:54 ` [pbs-devel] applied: [PATCH proxmox-backup 0/2] conditionally skip pxar " Fabian Grünbichler
  2 siblings, 0 replies; 4+ messages in thread
From: Christian Ebner @ 2024-06-06  8:17 UTC (permalink / raw)
  To: pbs-devel

The test will fail for all users not having euid/egid set to
1000/1000, as the reference test folder structure cannot be created
with the expected ownership.
Therefore, skip over the test if either euid or egid do not match
this condition.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 pbs-client/src/pxar/create.rs | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs
index d5eb7bd02..56c82fe4d 100644
--- a/pbs-client/src/pxar/create.rs
+++ b/pbs-client/src/pxar/create.rs
@@ -1859,6 +1859,14 @@ mod tests {
 
     #[test]
     fn test_create_archive_with_reference() -> Result<(), Error> {
+        let euid = unsafe { libc::geteuid() };
+        let egid = unsafe { libc::getegid() };
+
+        if euid != 1000 || egid != 1000 {
+            // skip test, cannot create test folder structure with correct ownership
+            return Ok(());
+        }
+
         let mut testdir = PathBuf::from("./target/testout");
         testdir.push(std::module_path!());
 
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pbs-devel] applied: [PATCH proxmox-backup 0/2] conditionally skip pxar metadata reference test
  2024-06-06  8:17 [pbs-devel] [PATCH proxmox-backup 0/2] conditionally skip pxar metadata reference test Christian Ebner
  2024-06-06  8:17 ` [pbs-devel] [PATCH proxmox-backup 1/2] client: pxar: do not attempt to set uid/gid in test Christian Ebner
  2024-06-06  8:17 ` [pbs-devel] [PATCH proxmox-backup 2/2] client: pxar: conditionally skip metadata reference test Christian Ebner
@ 2024-06-06  8:54 ` Fabian Grünbichler
  2 siblings, 0 replies; 4+ messages in thread
From: Fabian Grünbichler @ 2024-06-06  8:54 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion

thanks!

On June 6, 2024 10:17 am, Christian Ebner wrote:
> When running as user with uid/gid not equal to 1000/1000, the test to
> create a pxar archive with previous metadata reference would fail, as
> the created test directories and files do not get the expected ownership
> set because of lack of permissions.
> 
> Therefore these patches do:
> - not even attempt to set the uid/gid for the folders, as without
>   permissions these are not set anyways.
> - only execute the test on the condition that euid and egid are 1000
> 
> Tested by running the tests via:
> `cargo test --workspace --release -- --nocapture`
> 
> For root user and user with uid/gid 1000. Without the patches the test
> fails for the root user, with the patches applied it passes for both.
> 
> Christian Ebner (2):
>   client: pxar: do not attempt to set uid/gid in test
>   client: pxar: conditionally skip metadata reference test
> 
>  pbs-client/src/pxar/create.rs | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> -- 
> 2.39.2
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 
> 


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-06-06  8:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-06  8:17 [pbs-devel] [PATCH proxmox-backup 0/2] conditionally skip pxar metadata reference test Christian Ebner
2024-06-06  8:17 ` [pbs-devel] [PATCH proxmox-backup 1/2] client: pxar: do not attempt to set uid/gid in test Christian Ebner
2024-06-06  8:17 ` [pbs-devel] [PATCH proxmox-backup 2/2] client: pxar: conditionally skip metadata reference test Christian Ebner
2024-06-06  8:54 ` [pbs-devel] applied: [PATCH proxmox-backup 0/2] conditionally skip pxar " Fabian Grünbichler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal