Hi,

Mingye Wang wrote on 8/19/20 5:10 PM:
Hi,
On Wed, Aug 19, 2020 at 9:06 PM Jean-Pierre André
<jean-pierre.an...@wanadoo.fr> wrote:
Linux uses the extended attribute paradigm for data which
are not really extended attribute, in particular for security
data (Posix ACLs, SELinux, ...), and ntfs-3g has added more
such attributes (reparse data, object_id, etc.)
macOS does the same thing, but under an "openxattr" namespace starting
with com.apple. Examples include[1] and [2].

   [1]: 
https://eclecticlight.co/2020/01/30/quarantine-sip-and-macl-macos-per-file-security-controls/
   [2]: https://github.com/osxfuse/osxfuse/wiki/Mount-options#extended_security

Thanks for the clarification.
Is changing ENODATA to ENOATTR likely to be safe for
data which is not perceived as an extended attribute ?
No, so some careful choosing will be needed. Examples should include:
* ntfs_fuse_getxattr(), ntfs_fuse_setxattr()
* the bunch of stuff called from ntfs_xattr_system_getxattr() and
ntfs_xattr_system_setxattr()

These are all the situations...

Attached is a patch for returning ENOATTR for genuine
extended attributes (among them com.apple.something),
however still returning ENODATA for "smuggled" ones
(system.something).

Please test and report.

Also, you mentioned ea.c, dealing with EAs which were not
used by Windows until Windows 10. Is MacOS making some
use of EAs, and more precisely are EAs used on MacOS to
implement the generic concept of extended attributes ?
Oops, I did not realize until now that the ea.c is referring to the
OS/2 compatible EA, not the ADS. Apologies for the confusion. (The
xattr.c stuff does end up referencing ea via "system." attributes
though.)

ok.

Jean-Pierre

Now, Linux does not define ENOATTR any more, though
there still are mentions of it in several man pages.
That's... unhelpful of Linux to do that.

Regards,
Mingye


--- include/ntfs-3g/compat.h.ref	2020-08-05 11:35:04.765963100 +0200
+++ include/ntfs-3g/compat.h	2020-08-19 08:59:48.557245900 +0200
@@ -4,7 +4,7 @@
  * Copyright (c) 2002 Richard Russon
  * Copyright (c) 2002-2004 Anton Altaparmakov
  * Copyright (c) 2008-2009 Szabolcs Szakacsits
- * Copyright (c) 2019      Jean-Pierre Andre
+ * Copyright (c) 2019-2020 Jean-Pierre Andre
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -32,12 +32,16 @@
 #include <sys/param.h>
 #endif
 
-#include <errno.h>	/* ENODATA */
+#include <errno.h>	/* Base error codes, depend on the OS */
 
 #ifndef ENODATA
 #define ENODATA ENOENT
 #endif
 
+#ifndef ENOATTR
+#define ENOATTR ENODATA
+#endif
+
 #ifndef ELIBBAD
 #define ELIBBAD ENOEXEC
 #endif
--- src/lowntfs-3g.c.ref	2020-08-05 11:35:04.874405900 +0200
+++ src/lowntfs-3g.c	2020-08-19 09:03:39.319870000 +0200
@@ -3673,7 +3673,7 @@
 		/* trusted only readable by root */
 	if ((namespace == XATTRNS_TRUSTED)
 	    && security.uid) {
-		res = -ENODATA;
+		res = -ENOATTR;
 		goto out;
 	}
 #endif
@@ -3684,7 +3684,7 @@
 	}
 		/* Return with no result for symlinks, fifo, etc. */
 	if (!user_xattrs_allowed(ctx, ni)) {
-		res = -ENODATA;
+		res = -ENOATTR;
 		goto exit;
 	}
 		/* otherwise file must be readable */
@@ -3701,7 +3701,7 @@
 	}
 	na = ntfs_attr_open(ni, AT_DATA, lename, lename_len);
 	if (!na) {
-		res = -ENODATA;
+		res = -ENOATTR;
 		goto exit;
 	}
 	rsize = na->data_size;
@@ -3912,7 +3912,7 @@
 	}
 	if (!na) {
 		if (flags == XATTR_REPLACE) {
-			res = -ENODATA;
+			res = -ENOATTR;
 			goto exit;
 		}
 		if (ntfs_attr_add(ni, AT_DATA, lename, lename_len, NULL, 0)) {
@@ -4150,7 +4150,7 @@
 	}
 	if (ntfs_attr_remove(ni, AT_DATA, lename, lename_len)) {
 		if (errno == ENOENT)
-			errno = ENODATA;
+			errno = ENOATTR;
 		res = -errno;
 	}
 	if (!res) {
--- src/ntfs-3g.c.ref	2020-08-14 17:57:06.000000000 +0200
+++ src/ntfs-3g.c	2020-08-19 09:02:18.592845200 +0200
@@ -3236,14 +3236,14 @@
 		/* trusted only readable by root */
 	if ((namespace == XATTRNS_TRUSTED)
 	    && security.uid)
-		    return -ENODATA;
+		    return -ENOATTR;
 #endif
 	ni = ntfs_pathname_to_inode(ctx->vol, NULL, path);
 	if (!ni)
 		return -errno;
 		/* Return with no result for symlinks, fifo, etc. */
 	if (!user_xattrs_allowed(ctx, ni)) {
-		res = -ENODATA;
+		res = -ENOATTR;
 		goto exit;
 	}
 		/* otherwise file must be readable */
@@ -3260,7 +3260,7 @@
 	}
 	na = ntfs_attr_open(ni, AT_DATA, lename, lename_len);
 	if (!na) {
-		res = -ENODATA;
+		res = -ENOATTR;
 		goto exit;
 	}
 	rsize = na->data_size;
@@ -3450,7 +3450,7 @@
 	}
 	if (!na) {
 		if (flags == XATTR_REPLACE) {
-			res = -ENODATA;
+			res = -ENOATTR;
 			goto exit;
 		}
 		if (ntfs_attr_add(ni, AT_DATA, lename, lename_len, NULL, 0)) {
@@ -3680,7 +3680,7 @@
 	}
 	if (ntfs_attr_remove(ni, AT_DATA, lename, lename_len)) {
 		if (errno == ENOENT)
-			errno = ENODATA;
+			errno = ENOATTR;
 		res = -errno;
 	}
 	if (!res) {
_______________________________________________
ntfs-3g-devel mailing list
ntfs-3g-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ntfs-3g-devel

Reply via email to