[RFC] vfs_fruit uses wrong xattr name for Mac metadata on FreeBSD

Ralph Böhme slow at samba.org
Sat Jan 21 14:35:07 UTC 2017


Folks,

I've been made aware of an unfortunate bug in vfs_fruit that causes it to use
the wrong xattr name

  netatalk.Metadata

instead of the intended

  org.netatalk.Metadata

on FreeBSD (remember, this is FreeBSD, so no namespace prefix in the xattr name,
see below...).

<https://bugzilla.samba.org/show_bug.cgi?id=12490>

This affects the default vfs_fruit setting "fruit:metadata=netatalk" which is
meant to result in a config where Samba and Netatalk use the same xattrs for the
Mac related stuff.

Netatalk of course uses (again, FreeBSD, no namespace prefix)

  org.netatalk.Metadata

As a result Samba and Netatlk are *not* using the same xattr. :/

The bug is FreeBSD only as I had put this little piece of insanity in
vfs_fruit.c:

  #define NETATALK_META_XATTR "org.netatalk.Metadata"

  #if defined(HAVE_ATTROPEN) || defined(FREEBSD)
    #define AFPINFO_EA_NETATALK NETATALK_META_XATTR
  #else
    #define AFPINFO_EA_NETATALK "user." NETATALK_META_XATTR
  #endif

I had added this back at the time, because the FreeBSD xattr API doesn't put a
namespace prefix into the xattr name, it uses a seperate int arg to specify
that. I faintly remember I actually tested this on FreeBSD back then...

Now unfortunately in libreplace we assume that the caller prefixed the xattr
name with a namespace string, and in the case of FreeBSD we then chop it of and
convert it to the required int arg.

Fwiw, I belief we get this wrong on Solaris where we don't strip of the
namespace prefix (which we should imo, Solaris doesn't use namespaces at all)
but now it's probably too late to change it).

I'm trying to think of the best way to fix this mess. We can't simply change the
xattr name we use, as that would break existing installations.

So, what are the options?

I guess the only sane fix is to change the xattr name and add conversion code
that renames it on-access. The conversion code is required to be called at least
in the list xattr VFS functions and in the getters.

The on-access conversion would be configurable via a boolean option (so on/off),
we would enable it by default for 4.6 and then possibly disable it by default
for 4.7 (to get rid of the performance impact in the long run).

Thoughts? Thanks!

Cheerio!
-slow



More information about the samba-technical mailing list