The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/4529
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Stéphane Graber <[email protected]>
From a1783b173cb370600006ddb8cacbcbad3ee02259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <[email protected]> Date: Thu, 3 May 2018 10:38:45 +0200 Subject: [PATCH] xattr: Support empty values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <[email protected]> --- lxd/container_lxc.go | 8 ++++---- shared/util_linux.go | 13 +++++++------ shared/util_linux_test.go | 1 + 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go index c1d7845b1..26376e62e 100644 --- a/lxd/container_lxc.go +++ b/lxd/container_lxc.go @@ -5961,23 +5961,23 @@ func (c *containerLXC) tarStoreFile(linkmap map[uint64]string, offset int, tw *t if link == "" { hdr.Xattrs, err = shared.GetAllXattr(path) if err != nil { - return fmt.Errorf("failed to read xattr: %s", err) + return fmt.Errorf("Failed to read xattr for '%s': %s", path, err) } } if err := tw.WriteHeader(hdr); err != nil { - return fmt.Errorf("failed to write tar header: %s", err) + return fmt.Errorf("Failed to write tar header: %s", err) } if hdr.Typeflag == tar.TypeReg { f, err := os.Open(path) if err != nil { - return fmt.Errorf("failed to open the file: %s", err) + return fmt.Errorf("Failed to open the file: %s", err) } defer f.Close() if _, err := io.Copy(tw, f); err != nil { - return fmt.Errorf("failed to copy file content: %s", err) + return fmt.Errorf("Failed to copy file content: %s", err) } } diff --git a/shared/util_linux.go b/shared/util_linux.go index e0d0056d8..b6d83794f 100644 --- a/shared/util_linux.go +++ b/shared/util_linux.go @@ -473,15 +473,16 @@ func GetAllXattr(path string) (xattrs map[string]string, err error) { if err != nil || pre < 0 { return nil, err } - if pre == 0 { - return nil, fmt.Errorf("No valid extended attribute value found.") - } dest = make([]byte, pre) - post, err = syscall.Getxattr(path, xattr, dest) - if err != nil || post < 0 { - return nil, err + post := 0 + if pre > 0 { + post, err = syscall.Getxattr(path, xattr, dest) + if err != nil || post < 0 { + return nil, err + } } + if post != pre { return nil, e1 } diff --git a/shared/util_linux_test.go b/shared/util_linux_test.go index 36e20e879..bd54fae4b 100644 --- a/shared/util_linux_test.go +++ b/shared/util_linux_test.go @@ -13,6 +13,7 @@ func TestGetAllXattr(t *testing.T) { testxattr = map[string]string{ "user.checksum": "asdfsf13434qwf1324", "user.random": "This is a test", + "user.empty": "", } ) xattrFile, err := ioutil.TempFile("", "")
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
