Re: twisted dav : xattrprops on linux
(Let's chat on the mailing list; I don't always respond to direct mail, get too much and all that.) That's a weird rule... Does it make sense for this to be hidden in the xattr library? Perhaps not... I kinda hate to so this on OS X just because Linux is weird. -wsv On Sep 9, 2006, at 9:52 AM, Vincent Kraeutler wrote:
wilfredo,
just stumbled across what looks like a minor issue with xattrs on linux: it seems that when writing xattrs, normal users are _required_ (at least on ext2/ext3) to prefix all attribute names with "user.". i.e. it is not possible to carry out
import xattr xx = xattr.xattr("testFile") xx["foo"] = "bar"
while
xx["user.foo"] = "bar"
works. if that is indeed the case, i would be tempted to suggest prefixing twisted.web2.dav.xattrprops.xattrPropertyStore.deadPropertyXattrPrefix with "user.", i.e. replace "WebDAV:" with "user.WebDAV:" to enhance portability.
i hope i am making sense.
kind regards, v.
On Mon, 2006-09-11 at 15:12 -0700, Wilfredo Sánchez Vega wrote:
(Let's chat on the mailing list; I don't always respond to direct mail, get too much and all that.)
That's a weird rule...
Does it make sense for this to be hidden in the xattr library? Perhaps not... I kinda hate to so this on OS X just because Linux is weird.
It's not that weird. Quoting from "man 5 attr": Attribute names are zero-terminated strings. The attribute name is always specified in the fully qualified namespace.attribute form, eg. user.mime_type, trusted.md5sum, system.posix_acl_access, or security.selinux. According to http://en.wikipedia.org/wiki/Extended_file_attributes FreeBSD also requires that arbitrary xattr's be in the user. namespace. I suspect this should be hidden in the xattr library. -- Stuart Jansen <sjansen@gurulabs.com> Guru Labs, L.C.
Hi Wilfredo, On Mon, Sep 11, 2006 at 03:12:51PM -0700, Wilfredo Sánchez Vega wrote:
(Let's chat on the mailing list; I don't always respond to direct mail, get too much and all that.)
That's a weird rule...
Does it make sense for this to be hidden in the xattr library? Perhaps not... I kinda hate to so this on OS X just because Linux is weird. I'm using this in twisted to fix this:
--- twisted/web2/dav/xattrprops.py.orig 2006-09-05 22:09:03.000000000 +0200 +++ twisted/web2/dav/xattrprops.py 2006-09-05 23:12:17.000000000 +0200 @@ -32,6 +32,7 @@ __all__ = ["xattrPropertyStore"] import urllib +import sys import xattr @@ -58,8 +59,11 @@ # # Dead properties are stored as extended attributes on disk. In order to # avoid conflicts with other attributes, prefix dead property names. - # - deadPropertyXattrPrefix = "WebDAV:" + # Linux additionally needs everything in the user namespace + if sys.platform == 'linux2': + deadPropertyXattrPrefix = "user.WebDav:" + else: + deadPropertyXattrPrefix = "WebDAV:" def _encode(clazz, name): # This looks clean and hardcodes the namespace at exactly one place. Addingt this to xattr doesn't seem reasonable since there are other namespaces. Cheers, -- Guido
Thanks, Guido. I've committed this on the Twisted branch we're using and closed the bug. The question remains as to how "correct" this is really. Is the "user." prefix a Linux system-wide restriction, or is it a per- filesystem thing? If it's the latter, that means we'd have to check the filesystem type (which I don't know how to do from Python, offhand) every time we want to write a property. That may be a downer, performance, wise. Something to keep an eye on. -wsv On Sep 12, 2006, at 12:11 AM, Guido Guenther wrote:
Hi Wilfredo, On Mon, Sep 11, 2006 at 03:12:51PM -0700, Wilfredo Sánchez Vega wrote:
(Let's chat on the mailing list; I don't always respond to direct mail, get too much and all that.)
That's a weird rule...
Does it make sense for this to be hidden in the xattr library? Perhaps not... I kinda hate to so this on OS X just because Linux is weird. I'm using this in twisted to fix this:
--- twisted/web2/dav/xattrprops.py.orig 2006-09-05 22:09:03.000000000 +0200 +++ twisted/web2/dav/xattrprops.py 2006-09-05 23:12:17.000000000 +0200 @@ -32,6 +32,7 @@ __all__ = ["xattrPropertyStore"]
import urllib +import sys
import xattr
@@ -58,8 +59,11 @@ # # Dead properties are stored as extended attributes on disk. In order to # avoid conflicts with other attributes, prefix dead property names. - # - deadPropertyXattrPrefix = "WebDAV:" + # Linux additionally needs everything in the user namespace + if sys.platform == 'linux2': + deadPropertyXattrPrefix = "user.WebDav:" + else: + deadPropertyXattrPrefix = "WebDAV:"
def _encode(clazz, name): #
This looks clean and hardcodes the namespace at exactly one place. Addingt this to xattr doesn't seem reasonable since there are other namespaces. Cheers, -- Guido
On Tue, Sep 12, 2006 at 08:19:40AM -0700, Wilfredo Sánchez Vega wrote:
The question remains as to how "correct" this is really. Is the "user." prefix a Linux system-wide restriction, or is it a per- filesystem thing? If it's the latter, that means we'd have to check the filesystem type (which I don't know how to do from Python, offhand) every time we want to write a property. That may be a downer, performance, wise. AFAIK this is a Linux (VFS layer) thing and not a per filesystem thing (see include/linux/xattr.h). Cheers, -- Guido
OK, cool. That's good news. -wsv On Sep 12, 2006, at 1:38 PM, Guido Guenther wrote:
On Tue, Sep 12, 2006 at 08:19:40AM -0700, Wilfredo Sánchez Vega wrote:
The question remains as to how "correct" this is really. Is the "user." prefix a Linux system-wide restriction, or is it a per- filesystem thing? If it's the latter, that means we'd have to check the filesystem type (which I don't know how to do from Python, offhand) every time we want to write a property. That may be a downer, performance, wise. AFAIK this is a Linux (VFS layer) thing and not a per filesystem thing (see include/linux/xattr.h). Cheers, -- Guido
i agree. i have found this extra little tidbit: http://www.penguin-soft.com/penguin/man/5/attr.html i.e. it seems like xattrs are also used for storing permission bits, ACL's etc. on some platforms. i.e. information that sometimes should not be modifiable by the owner of the file. i'm not sure i'm happy about the way it seems to be implemented, and i agree with you that it's likely not worth introducing an extra wart (especially since it's very easy to override deadPropertyXattrPrefix later on), but i certainly wanted to have it mentioned. all the best, v. Wilfredo Sánchez Vega wrote:
(Let's chat on the mailing list; I don't always respond to direct mail, get too much and all that.)
That's a weird rule...
Does it make sense for this to be hidden in the xattr library? Perhaps not... I kinda hate to so this on OS X just because Linux is weird.
-wsv
On Sep 9, 2006, at 9:52 AM, Vincent Kraeutler wrote:
wilfredo,
just stumbled across what looks like a minor issue with xattrs on linux: it seems that when writing xattrs, normal users are _required_ (at least on ext2/ext3) to prefix all attribute names with "user.". i.e. it is not possible to carry out
import xattr xx = xattr.xattr("testFile") xx["foo"] = "bar"
while
xx["user.foo"] = "bar"
works. if that is indeed the case, i would be tempted to suggest prefixing twisted.web2.dav.xattrprops.xattrPropertyStore.deadPropertyXattrPrefix with "user.", i.e. replace "WebDAV:" with "user.WebDAV:" to enhance portability.
i hope i am making sense.
kind regards, v.
participants (4)
-
Guido Guenther
-
Stuart Jansen
-
Vincent Kraeutler
-
Wilfredo Sánchez Vega