Xattr based exclusion on Linux doesn't work because of incorrect xattr name

Hi,

The feature to exclude entries by the xattr value duplicacy_exclude on Linux can’t be used in current form.

All xattrs on Linux are in the format namespace.attribute (source xattr(7) - Linux manual page), duplicacy expecting attribute name to be just duplicacy_exclude can’t be satisfied, trying to set such xattr (setfattr -n duplicacy_exclude testfile) results in “Operation not supported”.

To the best of my understanding duplicacy_exclude attribute belongs to the user namespace, so the fix should be just to here: src/duplicacy_utils_linux.go check for presence of user.duplicacy_exclude key.

To be sure, I’ve also tested that github.com/pkg/xattr used in duplicity doesn’t strip the user. prefix, the prefix is even visible in the readme of that package and I’ve tested behavior with:

package main

import (
	"fmt"
	"os"

	"github.com/pkg/xattr"
)

func main() {
	testFile := os.Args[1]
	fmt.Printf("%s file xattrs:\n", testFile)
	attributes, _ := xattr.List(testFile)
	for _, name := range attributes {
		attribute, err := xattr.Get(testFile, name)
		if err == nil {
			fmt.Printf("%s = '%s'\n", name, attribute)
		}
	}
}

(it’s just a modified copy of src/duplicacy_utils_others.go:L50)

Thanks!

1 Like

You’re right. I’ll change it to user.duplicacy_exclude.

2 Likes