summaryrefslogtreecommitdiff
path: root/source3/modules
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-10-26 11:37:48 -0600
committerVolker Lendecke <vlendec@samba.org>2010-10-27 15:31:59 +0000
commit24ef932a612d75c0e692bd1f17b44db3aba437eb (patch)
treedb60410a14e4bd21c88b572e3f61df4168aee843 /source3/modules
parent5bc2b8f0a494511800696d6d411a426463089e8b (diff)
downloadsamba-24ef932a612d75c0e692bd1f17b44db3aba437eb.tar.gz
samba-24ef932a612d75c0e692bd1f17b44db3aba437eb.tar.bz2
samba-24ef932a612d75c0e692bd1f17b44db3aba437eb.zip
s3: Make gpfs winattrs work again
Autobuild-User: Volker Lendecke <vlendec@samba.org> Autobuild-Date: Wed Oct 27 15:32:00 UTC 2010 on sn-devel-104
Diffstat (limited to 'source3/modules')
-rw-r--r--source3/modules/vfs_gpfs.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 8fbfbdfa9b..694bde7da0 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -22,6 +22,7 @@
*/
#include "includes.h"
+#include "librpc/gen_ndr/ndr_xattr.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_VFS
@@ -926,6 +927,9 @@ static int vfs_gpfs_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t
static int gpfs_set_xattr(struct vfs_handle_struct *handle, const char *path,
const char *name, const void *value, size_t size, int flags){
+ struct xattr_DOSATTRIB dosattrib;
+ enum ndr_err_code ndr_err;
+ DATA_BLOB blob;
const char *attrstr = value;
unsigned int dosmode=0;
struct gpfs_winattr attrs;
@@ -939,11 +943,31 @@ static int gpfs_set_xattr(struct vfs_handle_struct *handle, const char *path,
return SMB_VFS_NEXT_SETXATTR(handle,path,name,value,size,flags);
}
- if (size < 2 || attrstr[0] != '0' || attrstr[1] != 'x' ||
- sscanf(attrstr, "%x", &dosmode) != 1) {
- DEBUG(1,("gpfs_set_xattr: Trying to set badly formed DOSATTRIB on file %s - %s\n", path, attrstr));
- return False;
- }
+ blob.data = (uint8_t *)attrstr;
+ blob.length = size;
+
+ ndr_err = ndr_pull_struct_blob(&blob, talloc_tos(), &dosattrib,
+ (ndr_pull_flags_fn_t)ndr_pull_xattr_DOSATTRIB);
+
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ DEBUG(1, ("gpfs_set_xattr: bad ndr decode "
+ "from EA on file %s: Error = %s\n",
+ path, ndr_errstr(ndr_err)));
+ return false;
+ }
+
+ if (dosattrib.version != 3) {
+ DEBUG(1, ("gpfs_set_xattr: expected dosattrib version 3, got "
+ "%d\n", (int)dosattrib.version));
+ return false;
+ }
+ if (!(dosattrib.info.info3.valid_flags & XATTR_DOSINFO_ATTRIB)) {
+ DEBUG(10, ("gpfs_set_xattr: XATTR_DOSINFO_ATTRIB not "
+ "valid, ignoring\n"));
+ return true;
+ }
+
+ dosmode = dosattrib.info.info3.attrib;
attrs.winAttrs = 0;
/*Just map RD_ONLY, ARCHIVE, SYSTEM and HIDDEN. Ignore the others*/
@@ -1009,9 +1033,9 @@ static ssize_t gpfs_get_xattr(struct vfs_handle_struct *handle, const char *pat
dosmode |= FILE_ATTRIBUTE_READONLY;
}
- snprintf(attrstr, size, "0x%x", dosmode & SAMBA_ATTRIBUTES_MASK);
+ snprintf(attrstr, size, "0x%2.2x", dosmode & SAMBA_ATTRIBUTES_MASK);
DEBUG(10, ("gpfs_get_xattr: returning %s\n",attrstr));
- return size;
+ return 4;
}
static int vfs_gpfs_stat(struct vfs_handle_struct *handle,