From 578b6011598e51ab6f747d4a94e56bae8ed3699f Mon Sep 17 00:00:00 2001 From: Christian Ebner Date: Mon, 27 May 2019 13:01:38 +0200 Subject: [PATCH] src/pxar/encoder.rs: Don't bail if endpoint does not support xattrs. The encoder bailed if a endpoint which did not support xattrs was encountered. Instead of bailing, we ignore these errors and simply do not store xattrs for such endpoints. Signed-off-by: Christian Ebner --- src/pxar/encoder.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pxar/encoder.rs b/src/pxar/encoder.rs index 2aea76f1..38e3d055 100644 --- a/src/pxar/encoder.rs +++ b/src/pxar/encoder.rs @@ -238,6 +238,10 @@ impl <'a, W: Write> Encoder<'a, W> { let xattr_names = match xattr::flistxattr(fd) { Ok(names) => names, + // Do not bail if the underlying endpoint does not supports xattrs + Err(Errno::EOPNOTSUPP) => return Ok((xattrs, fcaps)), + // Do not bail if the endpoint cannot carry xattrs (such as symlinks) + Err(Errno::EBADF) => return Ok((xattrs, fcaps)), Err(err) => bail!("read_xattrs failed for {:?} - {}", self.full_path(), err), }; @@ -293,8 +297,16 @@ impl <'a, W: Write> Encoder<'a, W> { // to create a path for acl_get_file(). acl_get_fd() only allows to get // ACL_TYPE_ACCESS attributes. let proc_path = Path::new("/proc/self/fd/").join(fd.to_string()); - let acl = acl::ACL::get_file(&proc_path, acl_type) - .map_err(|err| format_err!("error while reading ACL - {}", err))?; + let acl = match acl::ACL::get_file(&proc_path, acl_type) { + Ok(acl) => acl, + // Don't bail if underlying endpoint does not support acls + Err(Errno::EOPNOTSUPP) => return Ok(ret), + // Don't bail if the endpoint cannot carry acls + Err(Errno::EBADF) => return Ok(ret), + // Don't bail if there is no data + Err(Errno::ENODATA) => return Ok(ret), + Err(err) => bail!("error while reading ACL - {}", err), + }; self.process_acl(acl, acl_type) }