Xattr on FreeBSD ... Good Luck ?

Wesley W. Terpstra wesley at terpstra.ca
Thu Nov 2 02:14:29 GMT 2006


On Nov 2, 2006, at 2:14 AM, Wesley W. Terpstra wrote:
>> What is your reason for wanting to get rid of the '%' from the fake
>> stat attribute?  Do some implementations not allow a % in the key?
>
> No, but others are using 'reverse-DNS naming style' and this seems  
> to be standard-ish. That means a '.' and not a '%'.
> Did you check the second link in my original email?: http:// 
> www.freedesktop.org/wiki/CommonExtendedAttributes

One more detail: FAKE_XATTR should only include the "user." on linux.

> Here's a general question: should linux really be sync'ing system  
> and root namespaces?
> I don't think even root has permission to write arbitrary stuff in  
> system..?
> For the FreeBSD case, I dropped the system namespace.

I've read around a bit, and it seems that the tar people also took  
this approach:
	http://lists.freebsd.org/pipermail/posix1e/2006-March/thread.html#482
That is: don't copy the system namespace at all
Only sync the root namespace if explicitly requested. ==> In our case  
I'd say that's -a run as root.

So, osx&bsd already skip over the system namespaces (osx hides it and  
the bsd API needs a different 2nd parameter).
I propose linux do the same (rsync_xal_get):

         for (left = name_size, name = namebuf; left > 0 ; left -=  
len, name += l
                 rsync_xa *rxas;

                 len = strlen(name) + 1;

+#ifdef HAVE_LINUX_XATTRS
+            if (strncmp(name, USER_PREFIX, UPRE_LEN) != 0 &&
+                (strncmp(name, ROOT_PREFIX, RPRE_LEN) != 0 || ! 
am_root))
+                     continue;
+#else
+           /* On systems without a root namespace, we emulate it  
with a fake prefix */
+           if (strncmp(name, ROOT_PREFIX, RPRE_LEN) == 0 && !am_root)
+                     continue;
+#endif


> If you want to continue to sync root.*, then there is a problem  
> right now with linux->{mac,bsd}->linux. I didn't catch that case  
> before, sorry.
> root.foo (linux) -> root.foo (osx) -> user.root.foo (linux)

Since neither osx nor bsd have a root namespace, probably the second  
step is the mistake.
When they transmit 'root.' *, they should not prepend 'user.'

#ifdef HAVE_LINUX_XATTRS
                        	/* Linux already puts the namespace in the  
key. */
        	                write_int(f, rxa->name_len);
                         write_int(f, rxa->datum_len);
#else
                         /* Other platforms need the namespace added in,
                          * so use the "user." namespace for all  
keys, except root. */
                         if (strncmp(rxa->name, ROOT_PREFIX,  
RPRE_LEN) =! 0) {
				write_int(f, rxa->name_len + UPRE_LEN);
                         	write_int(f, rxa->datum_len);
                         	write_buf(f, USER_PREFIX, UPRE_LEN);
			} else {
         	                write_int(f, rxa->name_len);
	                        write_int(f, rxa->datum_len);
			}
#endif

Of course, this begs the question of how many namespaces should we  
allow.
I say: only 'user' and 'root' for now.

Oie. This interacts with the fake-super as well... You can't write to  
root.* if you aren't root, so we would have to fake this too...

What do you think? Is this going in the right direction?



More information about the rsync mailing list