From 0d2f805af6e95f6764c914dca60292ff95f9f732 Mon Sep 17 00:00:00 2001 From: jpandre Date: Thu, 2 Oct 2008 07:42:54 +0000 Subject: [PATCH] Made the interface to get/set an NTFS ACL available in non-Posix ACL builds --- src/ntfs-3g.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index 4c164442..b04aaf39 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -1698,12 +1698,12 @@ close_inode: static const char nf_ns_xattr_preffix[] = "user."; static const int nf_ns_xattr_preffix_len = 5; +static const char nf_ns_xattr_ntfs[] = "system.ntfs_acl"; #if POSIXACLS static const char nf_ns_xattr_posix_access[] = "system.posix_acl_access"; static const char nf_ns_xattr_posix_default[] = "system.posix_acl_default"; -static const char nf_ns_xattr_ntfs[] = "system.ntfs_acl"; /* * Check whether access to an ACL as an extended attribute @@ -1892,10 +1892,9 @@ static int ntfs_fuse_getxattr(const char *path, const char *name, ntfs_attr *na = NULL; ntfschar *lename = NULL; int res, lename_len; - -#if POSIXACLS struct SECURITY_CONTEXT security; +#if POSIXACLS /* * hijack Posix/NTFS ACL retrieval, whatever mode * was selected for xattr (from the user's point @@ -1925,6 +1924,35 @@ static int ntfs_fuse_getxattr(const char *path, const char *name, res = -errno; return (res); } +#else + /* + * Only hijack NTFS ACL retrieval if POSIX ACLS + * option is not selected + * Access control is done by fuse + */ + if (!strcmp(name,nf_ns_xattr_ntfs)) { + if (ntfs_fuse_is_named_data_stream(path)) + res = -EINVAL; /* n/a for named data streams. */ + else { + ni = ntfs_pathname_to_inode(ctx->vol, NULL, path); + if (ni) { + /* user mapping not mandatory */ + ntfs_fuse_fill_security_context(&security); + /* + * the returned value is the needed + * size. If it is too small, no copy + * is done, and the caller has to + * issue a new call with correct size. + */ + res = ntfs_get_ntfs_acl(&security,path, + name,value,size,ni); + if (ntfs_inode_close(ni)) + set_fuse_error(&res); + } else + res = -errno; + } + return (res); + } #endif if (ctx->streams == NF_STREAMS_INTERFACE_WINDOWS) return ntfs_fuse_getxattr_windows(path, name, value, size); @@ -1971,10 +1999,9 @@ static int ntfs_fuse_setxattr(const char *path, const char *name, ntfs_attr *na = NULL; ntfschar *lename = NULL; int res, lename_len; - -#if POSIXACLS struct SECURITY_CONTEXT security; +#if POSIXACLS /* * hijack Posix/NTFS ACL retrieval, whatever mode * was selected for xattr (from the user's point @@ -2001,6 +2028,29 @@ static int ntfs_fuse_setxattr(const char *path, const char *name, res = -errno; return (res); } +#else + /* + * Only hijack NTFS ACL setting if POSIX ACLS + * option is not selected + * Access control is done by fuse + */ + if (!strcmp(name,nf_ns_xattr_ntfs)) { + if (ntfs_fuse_is_named_data_stream(path)) + res = -EINVAL; /* n/a for named data streams. */ + else { + ni = ntfs_pathname_to_inode(ctx->vol, NULL, path); + if (ni) { + /* user mapping not mandatory */ + ntfs_fuse_fill_security_context(&security); + res = ntfs_set_ntfs_acl(&security,path, + name,value,size,ni); + if (ntfs_inode_close(ni)) + set_fuse_error(&res); + } else + res = -errno; + } + return (res); + } #endif if (ctx->streams != NF_STREAMS_INTERFACE_XATTR) return -EOPNOTSUPP;