From 50005129ab0a5c5f2422460e6d7c19616e5e1124 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 17 Dec 2004 03:39:29 +0000 Subject: r4242: added support for storing xattrs in a tdb. This allows all advanced NT attributes (streams, EAs, NT ACLs, timestamps etc) to be used on filesystems that don't support xattrs. It also allows for large streams, although they are very inefficient. I won't enable this by default, as I really wrote it as a way of testing large stream support while still using ext3, but perhaps with a bit more work this could be generally usable. To enable this use: posix:eadb = /home/test/myeas.tdb (This used to be commit 0c927d912cb65754351189d3a0442004a14aa5c6) --- source4/ntvfs/posix/xattr_system.c | 134 +++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 source4/ntvfs/posix/xattr_system.c (limited to 'source4/ntvfs/posix/xattr_system.c') diff --git a/source4/ntvfs/posix/xattr_system.c b/source4/ntvfs/posix/xattr_system.c new file mode 100644 index 0000000000..c86ee0bd87 --- /dev/null +++ b/source4/ntvfs/posix/xattr_system.c @@ -0,0 +1,134 @@ +/* + Unix SMB/CIFS implementation. + + POSIX NTVFS backend - xattr support using filesystem xattrs + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "system/filesys.h" +#include "vfs_posix.h" + +/* + pull a xattr as a blob, from either a file or a file descriptor +*/ +NTSTATUS pull_xattr_blob_system(struct pvfs_state *pvfs, + TALLOC_CTX *mem_ctx, + const char *attr_name, + const char *fname, + int fd, + size_t estimated_size, + DATA_BLOB *blob) +{ +#if HAVE_XATTR_SUPPORT + int ret; + + *blob = data_blob_talloc(mem_ctx, NULL, estimated_size); + if (blob->data == NULL) { + return NT_STATUS_NO_MEMORY; + } + +again: + if (fd != -1) { + ret = fgetxattr(fd, attr_name, blob->data, estimated_size); + } else { + ret = getxattr(fname, attr_name, blob->data, estimated_size); + } + if (ret == -1 && errno == ERANGE) { + estimated_size *= 2; + blob->data = talloc_realloc(mem_ctx, blob->data, estimated_size); + if (blob->data == NULL) { + return NT_STATUS_NO_MEMORY; + } + blob->length = estimated_size; + goto again; + } + + if (ret == -1) { + data_blob_free(blob); + return pvfs_map_errno(pvfs, errno); + } + + blob->length = ret; + + return NT_STATUS_OK; +#else + return NT_STATUS_NOT_SUPPORTED; +#endif +} + +/* + push a xattr as a blob, from either a file or a file descriptor +*/ +NTSTATUS push_xattr_blob_system(struct pvfs_state *pvfs, + const char *attr_name, + const char *fname, + int fd, + const DATA_BLOB *blob) +{ +#if HAVE_XATTR_SUPPORT + int ret; + + if (fd != -1) { + ret = fsetxattr(fd, attr_name, blob->data, blob->length, 0); + } else { + ret = setxattr(fname, attr_name, blob->data, blob->length, 0); + } + if (ret == -1) { + return pvfs_map_errno(pvfs, errno); + } + + return NT_STATUS_OK; +#else + return NT_STATUS_NOT_SUPPORTED; +#endif +} + + +/* + delete a xattr +*/ +NTSTATUS delete_xattr_system(struct pvfs_state *pvfs, const char *attr_name, + const char *fname, int fd) +{ +#if HAVE_XATTR_SUPPORT + int ret; + + if (fd != -1) { + ret = fremovexattr(fd, attr_name); + } else { + ret = removexattr(fname, attr_name); + } + if (ret == -1) { + return pvfs_map_errno(pvfs, errno); + } + + return NT_STATUS_OK; +#else + return NT_STATUS_NOT_SUPPORTED; +#endif +} + +/* + unlink a file - cleanup any xattrs +*/ +NTSTATUS unlink_xattr_system(struct pvfs_state *pvfs, const char *fname) +{ + /* nothing needs to be done for filesystem based xattrs */ + return NT_STATUS_OK; +} -- cgit From 11ce2cfd70df264c5c91b4daaa9a01c5abc673b0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 7 Jan 2005 04:39:16 +0000 Subject: r4591: - converted the other _p talloc functions to not need _p - added #if TALLOC_DEPRECATED around the _p functions - fixes the code that broke from the above while doing this I fixed quite a number of places that were incorrectly using the non type-safe talloc functions to use the type safe ones. Some were even doing multiplies for array allocation, which is potentially unsafe. (This used to be commit 6e7754abd0c225527fb38363996a6e241b87b37e) --- source4/ntvfs/posix/xattr_system.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/posix/xattr_system.c') diff --git a/source4/ntvfs/posix/xattr_system.c b/source4/ntvfs/posix/xattr_system.c index c86ee0bd87..f19177f44c 100644 --- a/source4/ntvfs/posix/xattr_system.c +++ b/source4/ntvfs/posix/xattr_system.c @@ -51,7 +51,8 @@ again: } if (ret == -1 && errno == ERANGE) { estimated_size *= 2; - blob->data = talloc_realloc(mem_ctx, blob->data, estimated_size); + blob->data = talloc_realloc(mem_ctx, blob->data, + uint8_t, estimated_size); if (blob->data == NULL) { return NT_STATUS_NO_MEMORY; } -- cgit From e82aad1ce39a6b7a2e51b9e2cb494d74ec70e158 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 10 Feb 2005 05:09:35 +0000 Subject: r5298: - got rid of pstring.h from includes.h. This at least makes it a bit less likely that anyone will use pstring for new code - got rid of winbind_client.h from includes.h. This one triggered a huge change, as winbind_client.h was including system/filesys.h and defining the old uint32 and uint16 types, as well as its own pstring and fstring. (This used to be commit 9db6c79e902ec538108d6b7d3324039aabe1704f) --- source4/ntvfs/posix/xattr_system.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/ntvfs/posix/xattr_system.c') diff --git a/source4/ntvfs/posix/xattr_system.c b/source4/ntvfs/posix/xattr_system.c index f19177f44c..3b8becf6fe 100644 --- a/source4/ntvfs/posix/xattr_system.c +++ b/source4/ntvfs/posix/xattr_system.c @@ -21,7 +21,6 @@ */ #include "includes.h" -#include "system/filesys.h" #include "vfs_posix.h" /* -- cgit From 289bc557ebbad8c3ad8b24a37eb48a5d4de43ee2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 2 May 2005 15:59:34 +0000 Subject: r6580: fixed the bug that caused the truncation of the main file on a stream open with openx and the 'truncate if exists' flag (This used to be commit aa82b105d5871b3ca693a0757bb48cc589d88824) --- source4/ntvfs/posix/xattr_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/posix/xattr_system.c') diff --git a/source4/ntvfs/posix/xattr_system.c b/source4/ntvfs/posix/xattr_system.c index 3b8becf6fe..4101b69ed7 100644 --- a/source4/ntvfs/posix/xattr_system.c +++ b/source4/ntvfs/posix/xattr_system.c @@ -37,7 +37,7 @@ NTSTATUS pull_xattr_blob_system(struct pvfs_state *pvfs, #if HAVE_XATTR_SUPPORT int ret; - *blob = data_blob_talloc(mem_ctx, NULL, estimated_size); + *blob = data_blob_talloc(mem_ctx, NULL, estimated_size+16); if (blob->data == NULL) { return NT_STATUS_NO_MEMORY; } -- cgit From f6a3c29ede4482bdad7362bc990fe567c5714163 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 2 Jun 2006 14:06:30 +0000 Subject: r16004: - move #ifdef outof the real functions - hopefully all build-farm hosts have ENOTSUP... metze (This used to be commit 62c64f1ddc71436aab6a2f3f2ecc3e6dcb752db9) --- source4/ntvfs/posix/xattr_system.c | 51 +++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 12 deletions(-) (limited to 'source4/ntvfs/posix/xattr_system.c') diff --git a/source4/ntvfs/posix/xattr_system.c b/source4/ntvfs/posix/xattr_system.c index 4101b69ed7..757ccefe11 100644 --- a/source4/ntvfs/posix/xattr_system.c +++ b/source4/ntvfs/posix/xattr_system.c @@ -23,6 +23,45 @@ #include "includes.h" #include "vfs_posix.h" +#if !defined(HAVE_XATTR_SUPPORT) +static ssize_t _none_fgetxattr(int fd, const char *name, void *value, size_t size) +{ + errno = ENOTSUP; + return -1; +} +static ssize_t _none_getxattr(const char *path, const char *name, void *value, size_t size) +{ + errno = ENOTSUP; + return -1; +} +static ssize_t _none_fsetxattr(int fd, const char *name, void *value, size_t size, int flags) +{ + errno = ENOTSUP; + return -1; +} +static ssize_t _none_setxattr(const char *path, const char *name, void *value, size_t size, int flags) +{ + errno = ENOTSUP; + return -1; +} +static ssize_t _none_fremovexattr(int fd, const char *name) +{ + errno = ENOTSUP; + return -1; +} +static ssize_t _none_removexattr(const char *path, const char *name) +{ + errno = ENOTSUP; + return -1; +} +#define fgetxattr _none_fgetxattr +#define getxattr _none_getxattr +#define fsetxattr _none_fsetxattr +#define setxattr _none_setxattr +#define fremovexattr _none_fremovexattr +#define removexattr _none_removexattr +#endif + /* pull a xattr as a blob, from either a file or a file descriptor */ @@ -34,7 +73,6 @@ NTSTATUS pull_xattr_blob_system(struct pvfs_state *pvfs, size_t estimated_size, DATA_BLOB *blob) { -#if HAVE_XATTR_SUPPORT int ret; *blob = data_blob_talloc(mem_ctx, NULL, estimated_size+16); @@ -67,9 +105,6 @@ again: blob->length = ret; return NT_STATUS_OK; -#else - return NT_STATUS_NOT_SUPPORTED; -#endif } /* @@ -81,7 +116,6 @@ NTSTATUS push_xattr_blob_system(struct pvfs_state *pvfs, int fd, const DATA_BLOB *blob) { -#if HAVE_XATTR_SUPPORT int ret; if (fd != -1) { @@ -94,9 +128,6 @@ NTSTATUS push_xattr_blob_system(struct pvfs_state *pvfs, } return NT_STATUS_OK; -#else - return NT_STATUS_NOT_SUPPORTED; -#endif } @@ -106,7 +137,6 @@ NTSTATUS push_xattr_blob_system(struct pvfs_state *pvfs, NTSTATUS delete_xattr_system(struct pvfs_state *pvfs, const char *attr_name, const char *fname, int fd) { -#if HAVE_XATTR_SUPPORT int ret; if (fd != -1) { @@ -119,9 +149,6 @@ NTSTATUS delete_xattr_system(struct pvfs_state *pvfs, const char *attr_name, } return NT_STATUS_OK; -#else - return NT_STATUS_NOT_SUPPORTED; -#endif } /* -- cgit From 8f553ab4a1e5f2affb614c0824d4d77291343861 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 2 Jun 2006 14:22:56 +0000 Subject: r16005: add support for XATTR's on MacOS Thanks to Bjoern Jacke for his help. metze (This used to be commit 8f8480e453ced38cbf27d0a1a45843c5eb126016) --- source4/ntvfs/posix/xattr_system.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/posix/xattr_system.c') diff --git a/source4/ntvfs/posix/xattr_system.c b/source4/ntvfs/posix/xattr_system.c index 757ccefe11..58edf47bfc 100644 --- a/source4/ntvfs/posix/xattr_system.c +++ b/source4/ntvfs/posix/xattr_system.c @@ -23,7 +23,38 @@ #include "includes.h" #include "vfs_posix.h" -#if !defined(HAVE_XATTR_SUPPORT) +#if defined(HAVE_XATTR_SUPPORT) && defined(XATTR_ADDITIONAL_OPTIONS) +static ssize_t _wrap_fgetxattr(int fd, const char *name, void *value, size_t size) +{ + return fgetxattr(fd, name, value, size, 0, 0); +} +static ssize_t _wrap_getxattr(const char *path, const char *name, void *value, size_t size) +{ + return getxattr(path, name, value, size, 0, 0); +} +static ssize_t _wrap_fsetxattr(int fd, const char *name, void *value, size_t size, int flags) +{ + return fsetxattr(fd, name, value, size, 0, flags); +} +static ssize_t _wrap_setxattr(const char *path, const char *name, void *value, size_t size, int flags) +{ + return setxattr(path, name, value, size, 0, flags); +} +static ssize_t _wrap_fremovexattr(int fd, const char *name) +{ + return fremovexattr(fd, name, 0); +} +static ssize_t _wrap_removexattr(const char *path, const char *name) +{ + return removexattr(path, name, 0); +} +#define fgetxattr _wrap_fgetxattr +#define getxattr _wrap_getxattr +#define fsetxattr _wrap_fsetxattr +#define setxattr _wrap_setxattr +#define fremovexattr _wrap_fremovexattr +#define removexattr _wrap_removexattr +#elif !defined(HAVE_XATTR_SUPPORT) static ssize_t _none_fgetxattr(int fd, const char *name, void *value, size_t size) { errno = ENOTSUP; -- cgit From 9a9a99b90a086af0ec67a46932c0b2322e716cea Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 2 Jun 2006 14:26:15 +0000 Subject: r16006: only (f)getxattr returns ssize_t metze (This used to be commit d4af8da7c9b4c510ceb1ef96f6ff4bbf717a16d9) --- source4/ntvfs/posix/xattr_system.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/ntvfs/posix/xattr_system.c') diff --git a/source4/ntvfs/posix/xattr_system.c b/source4/ntvfs/posix/xattr_system.c index 58edf47bfc..81bac6caec 100644 --- a/source4/ntvfs/posix/xattr_system.c +++ b/source4/ntvfs/posix/xattr_system.c @@ -32,19 +32,19 @@ static ssize_t _wrap_getxattr(const char *path, const char *name, void *value, s { return getxattr(path, name, value, size, 0, 0); } -static ssize_t _wrap_fsetxattr(int fd, const char *name, void *value, size_t size, int flags) +static int _wrap_fsetxattr(int fd, const char *name, void *value, size_t size, int flags) { return fsetxattr(fd, name, value, size, 0, flags); } -static ssize_t _wrap_setxattr(const char *path, const char *name, void *value, size_t size, int flags) +static int _wrap_setxattr(const char *path, const char *name, void *value, size_t size, int flags) { return setxattr(path, name, value, size, 0, flags); } -static ssize_t _wrap_fremovexattr(int fd, const char *name) +static int _wrap_fremovexattr(int fd, const char *name) { return fremovexattr(fd, name, 0); } -static ssize_t _wrap_removexattr(const char *path, const char *name) +static int _wrap_removexattr(const char *path, const char *name) { return removexattr(path, name, 0); } @@ -65,22 +65,22 @@ static ssize_t _none_getxattr(const char *path, const char *name, void *value, s errno = ENOTSUP; return -1; } -static ssize_t _none_fsetxattr(int fd, const char *name, void *value, size_t size, int flags) +static int _none_fsetxattr(int fd, const char *name, void *value, size_t size, int flags) { errno = ENOTSUP; return -1; } -static ssize_t _none_setxattr(const char *path, const char *name, void *value, size_t size, int flags) +static int _none_setxattr(const char *path, const char *name, void *value, size_t size, int flags) { errno = ENOTSUP; return -1; } -static ssize_t _none_fremovexattr(int fd, const char *name) +static int _none_fremovexattr(int fd, const char *name) { errno = ENOTSUP; return -1; } -static ssize_t _none_removexattr(const char *path, const char *name) +static int _none_removexattr(const char *path, const char *name) { errno = ENOTSUP; return -1; -- cgit From 22367ca76eaa2e84cee81fdbb005486ec857e64d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 2 Jun 2006 14:38:50 +0000 Subject: r16008: make debugging easier, and use the os name in the function name (I'll add a bsd wrapping later) metze (This used to be commit 2ce4a2da29dd18b92580014cc765c0f950fb74df) --- source4/ntvfs/posix/xattr_system.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source4/ntvfs/posix/xattr_system.c') diff --git a/source4/ntvfs/posix/xattr_system.c b/source4/ntvfs/posix/xattr_system.c index 81bac6caec..11d8df2933 100644 --- a/source4/ntvfs/posix/xattr_system.c +++ b/source4/ntvfs/posix/xattr_system.c @@ -24,36 +24,36 @@ #include "vfs_posix.h" #if defined(HAVE_XATTR_SUPPORT) && defined(XATTR_ADDITIONAL_OPTIONS) -static ssize_t _wrap_fgetxattr(int fd, const char *name, void *value, size_t size) +static ssize_t _wrap_darwin_fgetxattr(int fd, const char *name, void *value, size_t size) { return fgetxattr(fd, name, value, size, 0, 0); } -static ssize_t _wrap_getxattr(const char *path, const char *name, void *value, size_t size) +static ssize_t _wrap_darwin_getxattr(const char *path, const char *name, void *value, size_t size) { return getxattr(path, name, value, size, 0, 0); } -static int _wrap_fsetxattr(int fd, const char *name, void *value, size_t size, int flags) +static int _wrap_darwin_fsetxattr(int fd, const char *name, void *value, size_t size, int flags) { return fsetxattr(fd, name, value, size, 0, flags); } -static int _wrap_setxattr(const char *path, const char *name, void *value, size_t size, int flags) +static int _wrap_darwin_setxattr(const char *path, const char *name, void *value, size_t size, int flags) { return setxattr(path, name, value, size, 0, flags); } -static int _wrap_fremovexattr(int fd, const char *name) +static int _wrap_darwin_fremovexattr(int fd, const char *name) { return fremovexattr(fd, name, 0); } -static int _wrap_removexattr(const char *path, const char *name) +static int _wrap_darwin_removexattr(const char *path, const char *name) { return removexattr(path, name, 0); } -#define fgetxattr _wrap_fgetxattr -#define getxattr _wrap_getxattr -#define fsetxattr _wrap_fsetxattr -#define setxattr _wrap_setxattr -#define fremovexattr _wrap_fremovexattr -#define removexattr _wrap_removexattr +#define fgetxattr _wrap_darwin_fgetxattr +#define getxattr _wrap_darwin_getxattr +#define fsetxattr _wrap_darwin_fsetxattr +#define setxattr _wrap_darwin_setxattr +#define fremovexattr _wrap_darwin_fremovexattr +#define removexattr _wrap_darwin_removexattr #elif !defined(HAVE_XATTR_SUPPORT) static ssize_t _none_fgetxattr(int fd, const char *name, void *value, size_t size) { -- cgit From dc4ccc6f6575bc98f17eccebd7e058eedaff02aa Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 3 Jun 2006 09:38:22 +0000 Subject: r16024: OpenBSD doesn't have ENOTSUP so use ENOSYS metze (This used to be commit 505d55de69e1c5a9e763534dd392caac79e49ff1) --- source4/ntvfs/posix/xattr_system.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/ntvfs/posix/xattr_system.c') diff --git a/source4/ntvfs/posix/xattr_system.c b/source4/ntvfs/posix/xattr_system.c index 11d8df2933..958f57e0fd 100644 --- a/source4/ntvfs/posix/xattr_system.c +++ b/source4/ntvfs/posix/xattr_system.c @@ -57,32 +57,32 @@ static int _wrap_darwin_removexattr(const char *path, const char *name) #elif !defined(HAVE_XATTR_SUPPORT) static ssize_t _none_fgetxattr(int fd, const char *name, void *value, size_t size) { - errno = ENOTSUP; + errno = ENOSYS; return -1; } static ssize_t _none_getxattr(const char *path, const char *name, void *value, size_t size) { - errno = ENOTSUP; + errno = ENOSYS; return -1; } static int _none_fsetxattr(int fd, const char *name, void *value, size_t size, int flags) { - errno = ENOTSUP; + errno = ENOSYS; return -1; } static int _none_setxattr(const char *path, const char *name, void *value, size_t size, int flags) { - errno = ENOTSUP; + errno = ENOSYS; return -1; } static int _none_fremovexattr(int fd, const char *name) { - errno = ENOTSUP; + errno = ENOSYS; return -1; } static int _none_removexattr(const char *path, const char *name) { - errno = ENOTSUP; + errno = ENOSYS; return -1; } #define fgetxattr _none_fgetxattr -- cgit From ca62ddd8d901cce923d1cda958793054f80b1f57 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 5 Jun 2006 21:48:29 +0000 Subject: r16051: Move the XATTR compatability code into a new file, so I can use it for the getntacl utility. Andrew Bartlett (This used to be commit b1e0d4747b412929e1d4e24d6d9e504df3ddc824) --- source4/ntvfs/posix/xattr_system.c | 83 ++++---------------------------------- 1 file changed, 7 insertions(+), 76 deletions(-) (limited to 'source4/ntvfs/posix/xattr_system.c') diff --git a/source4/ntvfs/posix/xattr_system.c b/source4/ntvfs/posix/xattr_system.c index 958f57e0fd..9dca13e5c2 100644 --- a/source4/ntvfs/posix/xattr_system.c +++ b/source4/ntvfs/posix/xattr_system.c @@ -22,76 +22,7 @@ #include "includes.h" #include "vfs_posix.h" - -#if defined(HAVE_XATTR_SUPPORT) && defined(XATTR_ADDITIONAL_OPTIONS) -static ssize_t _wrap_darwin_fgetxattr(int fd, const char *name, void *value, size_t size) -{ - return fgetxattr(fd, name, value, size, 0, 0); -} -static ssize_t _wrap_darwin_getxattr(const char *path, const char *name, void *value, size_t size) -{ - return getxattr(path, name, value, size, 0, 0); -} -static int _wrap_darwin_fsetxattr(int fd, const char *name, void *value, size_t size, int flags) -{ - return fsetxattr(fd, name, value, size, 0, flags); -} -static int _wrap_darwin_setxattr(const char *path, const char *name, void *value, size_t size, int flags) -{ - return setxattr(path, name, value, size, 0, flags); -} -static int _wrap_darwin_fremovexattr(int fd, const char *name) -{ - return fremovexattr(fd, name, 0); -} -static int _wrap_darwin_removexattr(const char *path, const char *name) -{ - return removexattr(path, name, 0); -} -#define fgetxattr _wrap_darwin_fgetxattr -#define getxattr _wrap_darwin_getxattr -#define fsetxattr _wrap_darwin_fsetxattr -#define setxattr _wrap_darwin_setxattr -#define fremovexattr _wrap_darwin_fremovexattr -#define removexattr _wrap_darwin_removexattr -#elif !defined(HAVE_XATTR_SUPPORT) -static ssize_t _none_fgetxattr(int fd, const char *name, void *value, size_t size) -{ - errno = ENOSYS; - return -1; -} -static ssize_t _none_getxattr(const char *path, const char *name, void *value, size_t size) -{ - errno = ENOSYS; - return -1; -} -static int _none_fsetxattr(int fd, const char *name, void *value, size_t size, int flags) -{ - errno = ENOSYS; - return -1; -} -static int _none_setxattr(const char *path, const char *name, void *value, size_t size, int flags) -{ - errno = ENOSYS; - return -1; -} -static int _none_fremovexattr(int fd, const char *name) -{ - errno = ENOSYS; - return -1; -} -static int _none_removexattr(const char *path, const char *name) -{ - errno = ENOSYS; - return -1; -} -#define fgetxattr _none_fgetxattr -#define getxattr _none_getxattr -#define fsetxattr _none_fsetxattr -#define setxattr _none_setxattr -#define fremovexattr _none_fremovexattr -#define removexattr _none_removexattr -#endif +#include "lib/util/wrap_xattr.h" /* pull a xattr as a blob, from either a file or a file descriptor @@ -113,9 +44,9 @@ NTSTATUS pull_xattr_blob_system(struct pvfs_state *pvfs, again: if (fd != -1) { - ret = fgetxattr(fd, attr_name, blob->data, estimated_size); + ret = wrap_fgetxattr(fd, attr_name, blob->data, estimated_size); } else { - ret = getxattr(fname, attr_name, blob->data, estimated_size); + ret = wrap_getxattr(fname, attr_name, blob->data, estimated_size); } if (ret == -1 && errno == ERANGE) { estimated_size *= 2; @@ -150,9 +81,9 @@ NTSTATUS push_xattr_blob_system(struct pvfs_state *pvfs, int ret; if (fd != -1) { - ret = fsetxattr(fd, attr_name, blob->data, blob->length, 0); + ret = wrap_fsetxattr(fd, attr_name, blob->data, blob->length, 0); } else { - ret = setxattr(fname, attr_name, blob->data, blob->length, 0); + ret = wrap_setxattr(fname, attr_name, blob->data, blob->length, 0); } if (ret == -1) { return pvfs_map_errno(pvfs, errno); @@ -171,9 +102,9 @@ NTSTATUS delete_xattr_system(struct pvfs_state *pvfs, const char *attr_name, int ret; if (fd != -1) { - ret = fremovexattr(fd, attr_name); + ret = wrap_fremovexattr(fd, attr_name); } else { - ret = removexattr(fname, attr_name); + ret = wrap_removexattr(fname, attr_name); } if (ret == -1) { return pvfs_map_errno(pvfs, errno); -- cgit From b0f6a94d9aab979b277c7dbd82b03aa0ce3d1a2f Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 9 Sep 2006 23:50:44 +0000 Subject: r18314: Handle the case where a dir has the sticky bit set and the OS gives back EPERM when trying to access user xattrs. Just pretend no attributes are set. Simo. (This used to be commit 53463ca7969e76f9fb2bc7c5a023d23732e422f5) --- source4/ntvfs/posix/xattr_system.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'source4/ntvfs/posix/xattr_system.c') diff --git a/source4/ntvfs/posix/xattr_system.c b/source4/ntvfs/posix/xattr_system.c index 9dca13e5c2..ab2337c200 100644 --- a/source4/ntvfs/posix/xattr_system.c +++ b/source4/ntvfs/posix/xattr_system.c @@ -58,6 +58,30 @@ again: blob->length = estimated_size; goto again; } + if (ret == -1 && errno == EPERM) { + struct stat statbuf; + + if (fd != -1) { + ret = fstat(fd, &statbuf); + } else { + ret = stat(fname, &statbuf); + } + if (ret == 0) { + /* check if this is a directory and the sticky bit is set */ + if (S_ISDIR(statbuf.st_mode) && (statbuf.st_mode & S_ISVTX)) { + /* pretend we could not find the xattr */ + + data_blob_free(blob); + return NT_STATUS_NOT_FOUND; + + } else { + /* if not this was probably a legittimate error + * reset ret and errno to the correct values */ + errno = EPERM; + ret = -1; + } + } + } if (ret == -1) { data_blob_free(blob); -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/ntvfs/posix/xattr_system.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/ntvfs/posix/xattr_system.c') diff --git a/source4/ntvfs/posix/xattr_system.c b/source4/ntvfs/posix/xattr_system.c index ab2337c200..7283d716b4 100644 --- a/source4/ntvfs/posix/xattr_system.c +++ b/source4/ntvfs/posix/xattr_system.c @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 1d12c640666c574b537d254a07af404e61445f6b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 24 Jul 2008 14:19:49 +1000 Subject: fixed spelling error (This used to be commit 341f64834e13cdbc7d4742a4652ae39b70a4231f) --- source4/ntvfs/posix/xattr_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/posix/xattr_system.c') diff --git a/source4/ntvfs/posix/xattr_system.c b/source4/ntvfs/posix/xattr_system.c index 7283d716b4..9a89f2a338 100644 --- a/source4/ntvfs/posix/xattr_system.c +++ b/source4/ntvfs/posix/xattr_system.c @@ -74,7 +74,7 @@ again: return NT_STATUS_NOT_FOUND; } else { - /* if not this was probably a legittimate error + /* if not this was probably a legitimate error * reset ret and errno to the correct values */ errno = EPERM; ret = -1; -- cgit