[PATCH] Adapt nfs4acls to recent coding standards
Volker Lendecke
Volker.Lendecke at SerNet.DE
Wed Aug 12 20:31:37 UTC 2015
Hi!
Attached find a patchset that morphes the nfs4acls
implementation to match what we do these days a bit more.
No change in behaviour intended at least.
Review&push appreciated!
Thanks,
Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From b93e544a2443562c38b35eb92613cab7a6a6bda2 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 12:12:53 +0200
Subject: [PATCH 01/18] nfs4acls: Use ZERO_STRUCTP
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index 9475248..48d0215 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -88,7 +88,7 @@ static int smbacl4_get_vfs_params(
};
int enumval;
- memset(params, 0, sizeof(smbacl4_vfs_params));
+ ZERO_STRUCTP(params);
enumval = lp_parm_enum(SNUM(conn), type_name, "mode",
enum_smbacl4_modes, e_simple);
@@ -313,7 +313,7 @@ static int smbacl4_GetFileOwner(struct connection_struct *conn,
const char *filename,
SMB_STRUCT_STAT *psbuf)
{
- memset(psbuf, 0, sizeof(SMB_STRUCT_STAT));
+ ZERO_STRUCTP(psbuf);
/* Get the stat struct for the owner info. */
if (vfs_stat_smb_basename(conn, filename, psbuf) != 0)
@@ -328,7 +328,7 @@ static int smbacl4_GetFileOwner(struct connection_struct *conn,
static int smbacl4_fGetFileOwner(files_struct *fsp, SMB_STRUCT_STAT *psbuf)
{
- memset(psbuf, 0, sizeof(SMB_STRUCT_STAT));
+ ZERO_STRUCTP(psbuf);
if (fsp->fh->fd == -1) {
return smbacl4_GetFileOwner(fsp->conn,
@@ -711,7 +711,7 @@ static bool smbacl4_fill_ace4(
{
DEBUG(10, ("got ace for %s\n", sid_string_dbg(&ace_nt->trustee)));
- memset(ace_v4, 0, sizeof(SMB_ACE4PROP_T));
+ ZERO_STRUCTP(ace_v4);
/* only ACCESS|DENY supported right now */
ace_v4->aceType = ace_nt->type;
--
1.9.1
From 43f1d0623934e60631a4846e61e82ed99e7131fd Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 12:35:20 +0200
Subject: [PATCH 02/18] nfs4acls: Use an anon struct for SMB4ACL_T
The relevant change:
-typedef struct _SMB4ACL_T {char dontuse;} SMB4ACL_T;
+struct SMB4ACL_T;
We can use anonymous structs to prevent direct use. This patch will
trigger a set of simplifications in the next patches
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 42 ++++++++++++++++++-------------------
source3/modules/nfs4_acls.h | 22 ++++++++++---------
source3/modules/vfs_aixacl2.c | 14 +++++++------
source3/modules/vfs_gpfs.c | 13 ++++++------
source3/modules/vfs_nfs4acl_xattr.c | 28 ++++++++++++-------------
source3/modules/vfs_zfsacl.c | 11 +++++-----
6 files changed, 68 insertions(+), 62 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index 48d0215..3099840 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -42,7 +42,7 @@ typedef struct _SMB_ACE4_INT_T
{
uint32_t magic;
SMB_ACE4PROP_T prop;
- void *next;
+ struct _SMB_ACE4_INT_T *next;
} SMB_ACE4_INT_T;
#define SMB_ACL4_INT_MAGIC 0x29A3E792
@@ -172,7 +172,7 @@ static uint32_t map_windows_ace_flags_to_nfs4_ace_flags(uint32_t win_ace_flags)
return nfs4_ace_flags;
}
-static SMB_ACL4_INT_T *get_validated_aclint(SMB4ACL_T *theacl)
+static SMB_ACL4_INT_T *get_validated_aclint(struct SMB4ACL_T *theacl)
{
SMB_ACL4_INT_T *aclint = (SMB_ACL4_INT_T *)theacl;
if (theacl==NULL)
@@ -208,7 +208,7 @@ static SMB_ACE4_INT_T *get_validated_aceint(SMB4ACE_T *ace)
return aceint;
}
-SMB4ACL_T *smb_create_smb4acl(TALLOC_CTX *mem_ctx)
+struct SMB4ACL_T *smb_create_smb4acl(TALLOC_CTX *mem_ctx)
{
SMB_ACL4_INT_T *theacl = (SMB_ACL4_INT_T *)TALLOC_ZERO_SIZE(
mem_ctx, sizeof(SMB_ACL4_INT_T));
@@ -221,10 +221,10 @@ SMB4ACL_T *smb_create_smb4acl(TALLOC_CTX *mem_ctx)
theacl->magic = SMB_ACL4_INT_MAGIC;
theacl->controlflags = SEC_DESC_SELF_RELATIVE;
/* theacl->first, last = NULL not needed */
- return (SMB4ACL_T *)theacl;
+ return (struct SMB4ACL_T *)theacl;
}
-SMB4ACE_T *smb_add_ace4(SMB4ACL_T *theacl, SMB_ACE4PROP_T *prop)
+SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *theacl, SMB_ACE4PROP_T *prop)
{
SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
SMB_ACE4_INT_T *ace;
@@ -272,7 +272,7 @@ SMB4ACE_T *smb_next_ace4(SMB4ACE_T *ace)
return (SMB4ACE_T *)aceint->next;
}
-SMB4ACE_T *smb_first_ace4(SMB4ACL_T *theacl)
+SMB4ACE_T *smb_first_ace4(struct SMB4ACL_T *theacl)
{
SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
if (aclint==NULL)
@@ -281,7 +281,7 @@ SMB4ACE_T *smb_first_ace4(SMB4ACL_T *theacl)
return (SMB4ACE_T *)aclint->first;
}
-uint32_t smb_get_naces(SMB4ACL_T *theacl)
+uint32_t smb_get_naces(struct SMB4ACL_T *theacl)
{
SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
if (aclint==NULL)
@@ -290,7 +290,7 @@ uint32_t smb_get_naces(SMB4ACL_T *theacl)
return aclint->naces;
}
-uint16_t smbacl4_get_controlflags(SMB4ACL_T *theacl)
+uint16_t smbacl4_get_controlflags(struct SMB4ACL_T *theacl)
{
SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
if (aclint==NULL)
@@ -299,7 +299,7 @@ uint16_t smbacl4_get_controlflags(SMB4ACL_T *theacl)
return aclint->controlflags;
}
-bool smbacl4_set_controlflags(SMB4ACL_T *theacl, uint16_t controlflags)
+bool smbacl4_set_controlflags(struct SMB4ACL_T *theacl, uint16_t controlflags)
{
SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
if (aclint==NULL)
@@ -346,7 +346,7 @@ static int smbacl4_fGetFileOwner(files_struct *fsp, SMB_STRUCT_STAT *psbuf)
static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx,
smbacl4_vfs_params *params,
- SMB4ACL_T *theacl, /* in */
+ struct SMB4ACL_T *theacl, /* in */
struct dom_sid *psid_owner, /* in */
struct dom_sid *psid_group, /* in */
bool is_directory, /* in */
@@ -528,7 +528,7 @@ static NTSTATUS smb_get_nt_acl_nfs4_common(const SMB_STRUCT_STAT *sbuf,
uint32_t security_info,
TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc,
- SMB4ACL_T *theacl)
+ struct SMB4ACL_T *theacl)
{
int good_aces = 0;
struct dom_sid sid_owner, sid_group;
@@ -586,7 +586,7 @@ NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp,
uint32_t security_info,
TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc,
- SMB4ACL_T *theacl)
+ struct SMB4ACL_T *theacl)
{
SMB_STRUCT_STAT sbuf;
smbacl4_vfs_params params;
@@ -611,7 +611,7 @@ NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn,
uint32_t security_info,
TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc,
- SMB4ACL_T *theacl)
+ struct SMB4ACL_T *theacl)
{
SMB_STRUCT_STAT sbuf;
smbacl4_vfs_params params;
@@ -631,7 +631,7 @@ NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn,
mem_ctx, ppdesc, theacl);
}
-static void smbacl4_dump_nfs4acl(int level, SMB4ACL_T *theacl)
+static void smbacl4_dump_nfs4acl(int level, struct SMB4ACL_T *theacl)
{
SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
SMB_ACE4_INT_T *aceint;
@@ -658,7 +658,7 @@ static void smbacl4_dump_nfs4acl(int level, SMB4ACL_T *theacl)
* return ace if found matching; otherwise NULL
*/
static SMB_ACE4PROP_T *smbacl4_find_equal_special(
- SMB4ACL_T *theacl,
+ struct SMB4ACL_T *theacl,
SMB_ACE4PROP_T *aceNew)
{
SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
@@ -795,7 +795,7 @@ static bool smbacl4_fill_ace4(
static int smbacl4_MergeIgnoreReject(
enum smbacl4_acedup_enum acedup,
- SMB4ACL_T *theacl, /* may modify it */
+ struct SMB4ACL_T *theacl, /* may modify it */
SMB_ACE4PROP_T *ace, /* the "new" ACE */
bool *paddNewACE,
int i
@@ -828,7 +828,7 @@ static int smbacl4_MergeIgnoreReject(
}
static int smbacl4_substitute_special(
- SMB4ACL_T *theacl,
+ struct SMB4ACL_T *theacl,
uid_t ownerUID,
gid_t ownerGID
)
@@ -864,7 +864,7 @@ static int smbacl4_substitute_special(
}
static int smbacl4_substitute_simple(
- SMB4ACL_T *theacl,
+ struct SMB4ACL_T *theacl,
uid_t ownerUID,
gid_t ownerGID
)
@@ -905,7 +905,7 @@ static int smbacl4_substitute_simple(
return true; /* OK */
}
-static SMB4ACL_T *smbacl4_win2nfs4(
+static struct SMB4ACL_T *smbacl4_win2nfs4(
TALLOC_CTX *mem_ctx,
const files_struct *fsp,
const struct security_acl *dacl,
@@ -914,7 +914,7 @@ static SMB4ACL_T *smbacl4_win2nfs4(
gid_t ownerGID
)
{
- SMB4ACL_T *theacl;
+ struct SMB4ACL_T *theacl;
uint32_t i;
const char *filename = fsp->fsp_name->base_name;
@@ -964,7 +964,7 @@ NTSTATUS smb_set_nt_acl_nfs4(vfs_handle_struct *handle, files_struct *fsp,
set_nfs4acl_native_fn_t set_nfs4_native)
{
smbacl4_vfs_params params;
- SMB4ACL_T *theacl = NULL;
+ struct SMB4ACL_T *theacl = NULL;
bool result;
SMB_STRUCT_STAT sbuf;
diff --git a/source3/modules/nfs4_acls.h b/source3/modules/nfs4_acls.h
index 1922010..bd1b998 100644
--- a/source3/modules/nfs4_acls.h
+++ b/source3/modules/nfs4_acls.h
@@ -111,43 +111,45 @@ typedef struct _SMB_ACE4PROP_T {
* Never allocate these structures on your own
* use create_smb4acl instead
*/
-typedef struct _SMB4ACL_T {char dontuse;} SMB4ACL_T;
+struct SMB4ACL_T;
typedef struct _SMB4ACE_T {char dontuse;} SMB4ACE_T;
-SMB4ACL_T *smb_create_smb4acl(TALLOC_CTX *mem_ctx);
+struct SMB4ACL_T *smb_create_smb4acl(TALLOC_CTX *mem_ctx);
/* prop's contents are copied */
/* it doesn't change the order, appends */
-SMB4ACE_T *smb_add_ace4(SMB4ACL_T *theacl, SMB_ACE4PROP_T *prop);
+SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *theacl, SMB_ACE4PROP_T *prop);
SMB_ACE4PROP_T *smb_get_ace4(SMB4ACE_T *ace);
/* Returns NULL if none - or error */
-SMB4ACE_T *smb_first_ace4(SMB4ACL_T *theacl);
+SMB4ACE_T *smb_first_ace4(struct SMB4ACL_T *theacl);
/* Returns NULL in the end - or error */
SMB4ACE_T *smb_next_ace4(SMB4ACE_T *ace);
-uint32_t smb_get_naces(SMB4ACL_T *theacl);
+uint32_t smb_get_naces(struct SMB4ACL_T *theacl);
-uint16_t smbacl4_get_controlflags(SMB4ACL_T *theacl);
+uint16_t smbacl4_get_controlflags(struct SMB4ACL_T *theacl);
-bool smbacl4_set_controlflags(SMB4ACL_T *theacl, uint16_t controlflags);
+bool smbacl4_set_controlflags(struct SMB4ACL_T *theacl, uint16_t controlflags);
NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp,
uint32_t security_info,
TALLOC_CTX *mem_ctx,
- struct security_descriptor **ppdesc, SMB4ACL_T *theacl);
+ struct security_descriptor **ppdesc, struct SMB4ACL_T *theacl);
NTSTATUS smb_get_nt_acl_nfs4(connection_struct *conn,
const char *name,
uint32_t security_info,
TALLOC_CTX *mem_ctx,
- struct security_descriptor **ppdesc, SMB4ACL_T *theacl);
+ struct security_descriptor **ppdesc, struct SMB4ACL_T *theacl);
/* Callback function needed to set the native acl
* when applicable */
-typedef bool (*set_nfs4acl_native_fn_t)(vfs_handle_struct *handle, files_struct *, SMB4ACL_T *);
+typedef bool (*set_nfs4acl_native_fn_t)(vfs_handle_struct *handle,
+ files_struct *,
+ struct SMB4ACL_T *);
NTSTATUS smb_set_nt_acl_nfs4(vfs_handle_struct *handle, files_struct *fsp,
uint32_t security_info_sent,
diff --git a/source3/modules/vfs_aixacl2.c b/source3/modules/vfs_aixacl2.c
index 557f950..4a018d6 100644
--- a/source3/modules/vfs_aixacl2.c
+++ b/source3/modules/vfs_aixacl2.c
@@ -94,7 +94,7 @@ static AIXJFS2_ACL_T *aixjfs2_getacl_alloc(const char *fname, acl_type_t *type)
}
static bool aixjfs2_get_nfs4_acl(TALLOC_CTX *mem_ctx, const char *name,
- SMB4ACL_T **ppacl, bool *pretryPosix)
+ struct SMB4ACL_T **ppacl, bool *pretryPosix)
{
int32_t i;
@@ -159,7 +159,7 @@ static NTSTATUS aixjfs2_fget_nt_acl(vfs_handle_struct *handle,
struct security_descriptor **ppdesc)
{
NTSTATUS status;
- SMB4ACL_T *pacl = NULL;
+ struct SMB4ACL_T *pacl = NULL;
bool result;
bool retryPosix = False;
TALLOC_CTX *frame = talloc_stackframe();
@@ -191,7 +191,7 @@ static NTSTATUS aixjfs2_get_nt_acl(vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc)
{
- SMB4ACL_T *pacl = NULL;
+ struct SMB4ACL_T *pacl = NULL;
bool result;
bool retryPosix = False;
@@ -213,7 +213,7 @@ static NTSTATUS aixjfs2_get_nt_acl(vfs_handle_struct *handle,
static int aixjfs2_sys_acl_blob_get_file(vfs_handle_struct *handle, const char *path_p, TALLOC_CTX *mem_ctx, char **blob_description, DATA_BLOB *blob)
{
- SMB4ACL_T *pacl = NULL;
+ struct SMB4ACL_T *pacl = NULL;
bool result;
bool retryPosix = False;
@@ -230,7 +230,7 @@ static int aixjfs2_sys_acl_blob_get_file(vfs_handle_struct *handle, const char *
static int aixjfs2_sys_acl_blob_get_fd(vfs_handle_struct *handle, files_struct *fsp, TALLOC_CTX *mem_ctx, char **blob_description, DATA_BLOB *blob)
{
- SMB4ACL_T *pacl = NULL;
+ struct SMB4ACL_T *pacl = NULL;
bool result;
bool retryPosix = False;
@@ -345,7 +345,9 @@ static int aixjfs2_query_acl_support(
return 1; /* haven't found that ACL type. */
}
-static bool aixjfs2_process_smbacl(vfs_handle_struct *handle, files_struct *fsp, SMB4ACL_T *smbacl)
+static bool aixjfs2_process_smbacl(vfs_handle_struct *handle,
+ files_struct *fsp,
+ struct SMB4ACL_T *smbacl)
{
SMB4ACE_T *smbace;
TALLOC_CTX *mem_ctx;
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 3260d2f..a9d3975 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -435,7 +435,8 @@ again:
* On failure returns -1 if there is system (GPFS) error, check errno.
* Returns 0 on success
*/
-static int gpfs_get_nfs4_acl(TALLOC_CTX *mem_ctx, const char *fname, SMB4ACL_T **ppacl)
+static int gpfs_get_nfs4_acl(TALLOC_CTX *mem_ctx, const char *fname,
+ struct SMB4ACL_T **ppacl)
{
gpfs_aclCount_t i;
struct gpfs_acl *gacl = NULL;
@@ -536,7 +537,7 @@ static NTSTATUS gpfsacl_fget_nt_acl(vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc)
{
- SMB4ACL_T *pacl = NULL;
+ struct SMB4ACL_T *pacl = NULL;
int result;
struct gpfs_config_data *config;
TALLOC_CTX *frame = talloc_stackframe();
@@ -583,7 +584,7 @@ static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle,
uint32_t security_info,
TALLOC_CTX *mem_ctx, struct security_descriptor **ppdesc)
{
- SMB4ACL_T *pacl = NULL;
+ struct SMB4ACL_T *pacl = NULL;
int result;
struct gpfs_config_data *config;
TALLOC_CTX *frame = talloc_stackframe();
@@ -626,7 +627,7 @@ static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle,
static struct gpfs_acl *vfs_gpfs_smbacl2gpfsacl(TALLOC_CTX *mem_ctx,
files_struct *fsp,
- SMB4ACL_T *smbacl,
+ struct SMB4ACL_T *smbacl,
bool controlflags)
{
struct gpfs_acl *gacl;
@@ -719,7 +720,7 @@ static struct gpfs_acl *vfs_gpfs_smbacl2gpfsacl(TALLOC_CTX *mem_ctx,
static bool gpfsacl_process_smbacl(vfs_handle_struct *handle,
files_struct *fsp,
- SMB4ACL_T *smbacl)
+ struct SMB4ACL_T *smbacl)
{
int ret;
struct gpfs_acl *gacl;
@@ -1294,7 +1295,7 @@ static uint32_t gpfsacl_mask_filter(uint32_t aceType, uint32_t aceMask, uint32_t
static int gpfsacl_emu_chmod(vfs_handle_struct *handle,
const char *path, mode_t mode)
{
- SMB4ACL_T *pacl = NULL;
+ struct SMB4ACL_T *pacl = NULL;
int result;
bool haveAllowEntry[SMB_ACE4_WHO_EVERYONE + 1] = {False, False, False, False};
int i;
diff --git a/source3/modules/vfs_nfs4acl_xattr.c b/source3/modules/vfs_nfs4acl_xattr.c
index d5d3e2b..1a8f7cd 100644
--- a/source3/modules/vfs_nfs4acl_xattr.c
+++ b/source3/modules/vfs_nfs4acl_xattr.c
@@ -72,11 +72,11 @@ static DATA_BLOB nfs4acl_acl2blob(TALLOC_CTX *mem_ctx, struct nfs4acl *acl)
static NTSTATUS nfs4_get_nfs4_acl_common(TALLOC_CTX *mem_ctx,
DATA_BLOB *blob,
- SMB4ACL_T **ppacl)
+ struct SMB4ACL_T **ppacl)
{
int i;
struct nfs4acl *nfs4acl = NULL;
- SMB4ACL_T *pacl = NULL;
+ struct SMB4ACL_T *pacl = NULL;
TALLOC_CTX *frame = talloc_stackframe();
nfs4acl = nfs4acl_blob2acl(blob, frame);
@@ -120,7 +120,7 @@ static NTSTATUS nfs4_get_nfs4_acl_common(TALLOC_CTX *mem_ctx,
/* Fetch the NFSv4 ACL from the xattr, and convert into Samba's internal NFSv4 format */
static NTSTATUS nfs4_fget_nfs4_acl(vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
- files_struct *fsp, SMB4ACL_T **ppacl)
+ files_struct *fsp, struct SMB4ACL_T **ppacl)
{
NTSTATUS status;
DATA_BLOB blob = data_blob_null;
@@ -149,7 +149,7 @@ static NTSTATUS nfs4_fget_nfs4_acl(vfs_handle_struct *handle, TALLOC_CTX *mem_ct
/* Fetch the NFSv4 ACL from the xattr, and convert into Samba's internal NFSv4 format */
static NTSTATUS nfs4_get_nfs4_acl(vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
- const char *path, SMB4ACL_T **ppacl)
+ const char *path, struct SMB4ACL_T **ppacl)
{
NTSTATUS status;
DATA_BLOB blob = data_blob_null;
@@ -177,7 +177,7 @@ static NTSTATUS nfs4_get_nfs4_acl(vfs_handle_struct *handle, TALLOC_CTX *mem_ctx
}
static bool nfs4acl_smb4acl2nfs4acl(TALLOC_CTX *mem_ctx,
- SMB4ACL_T *smbacl,
+ struct SMB4ACL_T *smbacl,
struct nfs4acl **pnfs4acl,
bool denymissingspecial)
{
@@ -252,7 +252,7 @@ static bool nfs4acl_smb4acl2nfs4acl(TALLOC_CTX *mem_ctx,
static bool nfs4acl_xattr_set_smb4acl(vfs_handle_struct *handle,
const char *path,
- SMB4ACL_T *smbacl)
+ struct SMB4ACL_T *smbacl)
{
TALLOC_CTX *frame = talloc_stackframe();
struct nfs4acl *nfs4acl;
@@ -290,7 +290,7 @@ static bool nfs4acl_xattr_set_smb4acl(vfs_handle_struct *handle,
/* call-back function processing the NT acl -> NFS4 acl using NFSv4 conv. */
static bool nfs4acl_xattr_fset_smb4acl(vfs_handle_struct *handle,
files_struct *fsp,
- SMB4ACL_T *smbacl)
+ struct SMB4ACL_T *smbacl)
{
TALLOC_CTX *frame = talloc_stackframe();
struct nfs4acl *nfs4acl;
@@ -340,9 +340,9 @@ static NTSTATUS nfs4_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
nfs4acl_xattr_fset_smb4acl);
}
-static SMB4ACL_T *nfs4acls_defaultacl(TALLOC_CTX *mem_ctx)
+static struct SMB4ACL_T *nfs4acls_defaultacl(TALLOC_CTX *mem_ctx)
{
- SMB4ACL_T *pacl = NULL;
+ struct SMB4ACL_T *pacl = NULL;
SMB4ACE_T *pace;
SMB_ACE4PROP_T ace = {
.flags = SMB_ACE4_ID_SPECIAL,
@@ -401,13 +401,13 @@ static SMB4ACL_T *nfs4acls_defaultacl(TALLOC_CTX *mem_ctx)
*
* Todo: Really use mem_ctx after fixing interface of nfs4_acls
*/
-static SMB4ACL_T *nfs4acls_inheritacl(vfs_handle_struct *handle,
+static struct SMB4ACL_T *nfs4acls_inheritacl(vfs_handle_struct *handle,
const char *path,
TALLOC_CTX *mem_ctx)
{
char *parent_dir = NULL;
- SMB4ACL_T *pparentacl = NULL;
- SMB4ACL_T *pchildacl = NULL;
+ struct SMB4ACL_T *pparentacl = NULL;
+ struct SMB4ACL_T *pchildacl = NULL;
SMB4ACE_T *pace;
SMB_ACE4PROP_T ace;
bool isdir;
@@ -521,7 +521,7 @@ static NTSTATUS nfs4acl_xattr_fget_nt_acl(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc)
{
- SMB4ACL_T *pacl;
+ struct SMB4ACL_T *pacl;
NTSTATUS status;
TALLOC_CTX *frame = talloc_stackframe();
@@ -545,7 +545,7 @@ static NTSTATUS nfs4acl_xattr_get_nt_acl(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc)
{
- SMB4ACL_T *pacl;
+ struct SMB4ACL_T *pacl;
NTSTATUS status;
TALLOC_CTX *frame = talloc_stackframe();
diff --git a/source3/modules/vfs_zfsacl.c b/source3/modules/vfs_zfsacl.c
index 82a48ae..8734d60 100644
--- a/source3/modules/vfs_zfsacl.c
+++ b/source3/modules/vfs_zfsacl.c
@@ -42,11 +42,11 @@
*/
static NTSTATUS zfs_get_nt_acl_common(TALLOC_CTX *mem_ctx,
const char *name,
- SMB4ACL_T **ppacl)
+ struct SMB4ACL_T **ppacl)
{
int naces, i;
ace_t *acebuf;
- SMB4ACL_T *pacl;
+ struct SMB4ACL_T *pacl;
/* read the number of file aces */
if((naces = acl(name, ACE_GETACLCNT, 0, NULL)) == -1) {
@@ -105,7 +105,8 @@ static NTSTATUS zfs_get_nt_acl_common(TALLOC_CTX *mem_ctx,
}
/* call-back function processing the NT acl -> ZFS acl using NFSv4 conv. */
-static bool zfs_process_smbacl(vfs_handle_struct *handle, files_struct *fsp, SMB4ACL_T *smbacl)
+static bool zfs_process_smbacl(vfs_handle_struct *handle, files_struct *fsp,
+ struct SMB4ACL_T *smbacl)
{
int naces = smb_get_naces(smbacl), i;
ace_t *acebuf;
@@ -196,7 +197,7 @@ static NTSTATUS zfsacl_fget_nt_acl(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc)
{
- SMB4ACL_T *pacl;
+ struct SMB4ACL_T *pacl;
NTSTATUS status;
TALLOC_CTX *frame = talloc_stackframe();
@@ -218,7 +219,7 @@ static NTSTATUS zfsacl_get_nt_acl(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc)
{
- SMB4ACL_T *pacl;
+ struct SMB4ACL_T *pacl;
NTSTATUS status;
TALLOC_CTX *frame = talloc_stackframe();
--
1.9.1
From 8eb5725dec2f49e0677573e5ca865d12f3863471 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 12:35:20 +0200
Subject: [PATCH 03/18] nfs4acls: Use an anon struct for SMB4ACE_T
-typedef struct _SMB4ACE_T {char dontuse;} SMB4ACE_T;
+struct SMB4ACE_T;
Same as for ACL_T
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 16 ++++++++--------
source3/modules/nfs4_acls.h | 10 +++++-----
source3/modules/vfs_aixacl2.c | 2 +-
source3/modules/vfs_gpfs.c | 4 ++--
source3/modules/vfs_nfs4acl_xattr.c | 8 ++++----
source3/modules/vfs_zfsacl.c | 2 +-
6 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index 3099840..defdf59 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -190,7 +190,7 @@ static SMB_ACL4_INT_T *get_validated_aclint(struct SMB4ACL_T *theacl)
return aclint;
}
-static SMB_ACE4_INT_T *get_validated_aceint(SMB4ACE_T *ace)
+static SMB_ACE4_INT_T *get_validated_aceint(struct SMB4ACE_T *ace)
{
SMB_ACE4_INT_T *aceint = (SMB_ACE4_INT_T *)ace;
if (ace==NULL)
@@ -224,7 +224,7 @@ struct SMB4ACL_T *smb_create_smb4acl(TALLOC_CTX *mem_ctx)
return (struct SMB4ACL_T *)theacl;
}
-SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *theacl, SMB_ACE4PROP_T *prop)
+struct SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *theacl, SMB_ACE4PROP_T *prop)
{
SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
SMB_ACE4_INT_T *ace;
@@ -251,10 +251,10 @@ SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *theacl, SMB_ACE4PROP_T *prop)
}
aclint->naces++;
- return (SMB4ACE_T *)ace;
+ return (struct SMB4ACE_T *)ace;
}
-SMB_ACE4PROP_T *smb_get_ace4(SMB4ACE_T *ace)
+SMB_ACE4PROP_T *smb_get_ace4(struct SMB4ACE_T *ace)
{
SMB_ACE4_INT_T *aceint = get_validated_aceint(ace);
if (aceint==NULL)
@@ -263,22 +263,22 @@ SMB_ACE4PROP_T *smb_get_ace4(SMB4ACE_T *ace)
return &aceint->prop;
}
-SMB4ACE_T *smb_next_ace4(SMB4ACE_T *ace)
+struct SMB4ACE_T *smb_next_ace4(struct SMB4ACE_T *ace)
{
SMB_ACE4_INT_T *aceint = get_validated_aceint(ace);
if (aceint==NULL)
return NULL;
- return (SMB4ACE_T *)aceint->next;
+ return (struct SMB4ACE_T *)aceint->next;
}
-SMB4ACE_T *smb_first_ace4(struct SMB4ACL_T *theacl)
+struct SMB4ACE_T *smb_first_ace4(struct SMB4ACL_T *theacl)
{
SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
if (aclint==NULL)
return NULL;
- return (SMB4ACE_T *)aclint->first;
+ return (struct SMB4ACE_T *)aclint->first;
}
uint32_t smb_get_naces(struct SMB4ACL_T *theacl)
diff --git a/source3/modules/nfs4_acls.h b/source3/modules/nfs4_acls.h
index bd1b998..3749747 100644
--- a/source3/modules/nfs4_acls.h
+++ b/source3/modules/nfs4_acls.h
@@ -112,21 +112,21 @@ typedef struct _SMB_ACE4PROP_T {
* use create_smb4acl instead
*/
struct SMB4ACL_T;
-typedef struct _SMB4ACE_T {char dontuse;} SMB4ACE_T;
+struct SMB4ACE_T;
struct SMB4ACL_T *smb_create_smb4acl(TALLOC_CTX *mem_ctx);
/* prop's contents are copied */
/* it doesn't change the order, appends */
-SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *theacl, SMB_ACE4PROP_T *prop);
+struct SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *theacl, SMB_ACE4PROP_T *prop);
-SMB_ACE4PROP_T *smb_get_ace4(SMB4ACE_T *ace);
+SMB_ACE4PROP_T *smb_get_ace4(struct SMB4ACE_T *ace);
/* Returns NULL if none - or error */
-SMB4ACE_T *smb_first_ace4(struct SMB4ACL_T *theacl);
+struct SMB4ACE_T *smb_first_ace4(struct SMB4ACL_T *theacl);
/* Returns NULL in the end - or error */
-SMB4ACE_T *smb_next_ace4(SMB4ACE_T *ace);
+struct SMB4ACE_T *smb_next_ace4(struct SMB4ACE_T *ace);
uint32_t smb_get_naces(struct SMB4ACL_T *theacl);
diff --git a/source3/modules/vfs_aixacl2.c b/source3/modules/vfs_aixacl2.c
index 4a018d6..a70013d 100644
--- a/source3/modules/vfs_aixacl2.c
+++ b/source3/modules/vfs_aixacl2.c
@@ -349,7 +349,7 @@ static bool aixjfs2_process_smbacl(vfs_handle_struct *handle,
files_struct *fsp,
struct SMB4ACL_T *smbacl)
{
- SMB4ACE_T *smbace;
+ struct SMB4ACE_T *smbace;
TALLOC_CTX *mem_ctx;
nfs4_acl_int_t *jfs2acl;
int32_t entryLen;
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index a9d3975..3e593e1 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -632,7 +632,7 @@ static struct gpfs_acl *vfs_gpfs_smbacl2gpfsacl(TALLOC_CTX *mem_ctx,
{
struct gpfs_acl *gacl;
gpfs_aclLen_t gacl_len;
- SMB4ACE_T *smbace;
+ struct SMB4ACE_T *smbace;
gacl_len = offsetof(gpfs_acl_t, ace_v4) + sizeof(unsigned int)
+ smb_get_naces(smbacl) * sizeof(gpfs_ace_v4_t);
@@ -1300,7 +1300,7 @@ static int gpfsacl_emu_chmod(vfs_handle_struct *handle,
bool haveAllowEntry[SMB_ACE4_WHO_EVERYONE + 1] = {False, False, False, False};
int i;
files_struct fake_fsp = { 0 }; /* TODO: rationalize parametrization */
- SMB4ACE_T *smbace;
+ struct SMB4ACE_T *smbace;
TALLOC_CTX *frame = talloc_stackframe();
DEBUG(10, ("gpfsacl_emu_chmod invoked for %s mode %o\n", path, mode));
diff --git a/source3/modules/vfs_nfs4acl_xattr.c b/source3/modules/vfs_nfs4acl_xattr.c
index 1a8f7cd..b041699 100644
--- a/source3/modules/vfs_nfs4acl_xattr.c
+++ b/source3/modules/vfs_nfs4acl_xattr.c
@@ -182,7 +182,7 @@ static bool nfs4acl_smb4acl2nfs4acl(TALLOC_CTX *mem_ctx,
bool denymissingspecial)
{
struct nfs4acl *nfs4acl;
- SMB4ACE_T *smbace;
+ struct SMB4ACE_T *smbace;
bool have_special_id = false;
int i;
@@ -343,7 +343,7 @@ static NTSTATUS nfs4_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
static struct SMB4ACL_T *nfs4acls_defaultacl(TALLOC_CTX *mem_ctx)
{
struct SMB4ACL_T *pacl = NULL;
- SMB4ACE_T *pace;
+ struct SMB4ACE_T *pace;
SMB_ACE4PROP_T ace = {
.flags = SMB_ACE4_ID_SPECIAL,
.who = {
@@ -408,7 +408,7 @@ static struct SMB4ACL_T *nfs4acls_inheritacl(vfs_handle_struct *handle,
char *parent_dir = NULL;
struct SMB4ACL_T *pparentacl = NULL;
struct SMB4ACL_T *pchildacl = NULL;
- SMB4ACE_T *pace;
+ struct SMB4ACE_T *pace;
SMB_ACE4PROP_T ace;
bool isdir;
struct smb_filename *smb_fname = NULL;
@@ -469,7 +469,7 @@ static struct SMB4ACL_T *nfs4acls_inheritacl(vfs_handle_struct *handle,
for (pace = smb_first_ace4(pparentacl); pace != NULL;
pace = smb_next_ace4(pace)) {
- SMB4ACE_T *pchildace;
+ struct SMB4ACE_T *pchildace;
ace = *smb_get_ace4(pace);
if ((isdir && !(ace.aceFlags & SMB_ACE4_DIRECTORY_INHERIT_ACE)) ||
(!isdir && !(ace.aceFlags & SMB_ACE4_FILE_INHERIT_ACE))) {
diff --git a/source3/modules/vfs_zfsacl.c b/source3/modules/vfs_zfsacl.c
index 8734d60..02cbcdf 100644
--- a/source3/modules/vfs_zfsacl.c
+++ b/source3/modules/vfs_zfsacl.c
@@ -110,7 +110,7 @@ static bool zfs_process_smbacl(vfs_handle_struct *handle, files_struct *fsp,
{
int naces = smb_get_naces(smbacl), i;
ace_t *acebuf;
- SMB4ACE_T *smbace;
+ struct SMB4ACE_T *smbace;
TALLOC_CTX *mem_ctx;
bool have_special_id = false;
--
1.9.1
From 62ee7d5ecf770f2102e9004bb65bfda10e2b5df1 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 12:44:08 +0200
Subject: [PATCH 04/18] nfs4acls: Remove an obsolete comment
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.h | 4 ----
1 file changed, 4 deletions(-)
diff --git a/source3/modules/nfs4_acls.h b/source3/modules/nfs4_acls.h
index 3749747..e11845e 100644
--- a/source3/modules/nfs4_acls.h
+++ b/source3/modules/nfs4_acls.h
@@ -107,10 +107,6 @@ typedef struct _SMB_ACE4PROP_T {
| SMB_ACE4_WRITE_ACL | SMB_ACE4_WRITE_OWNER | SMB_ACE4_SYNCHRONIZE )
} SMB_ACE4PROP_T;
-/*
- * Never allocate these structures on your own
- * use create_smb4acl instead
- */
struct SMB4ACL_T;
struct SMB4ACE_T;
--
1.9.1
From b37f79e4fc9b4426f95fd445df7e7f4380bda9ff Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 12:59:05 +0200
Subject: [PATCH 05/18] nfs4acls: Use SMB4ACL_T instead of _SMB_ACL4_INT_T
We can make the _INT_ structure now be the representation of the
published anonymous struct
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index defdf59..d487666 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -46,7 +46,7 @@ typedef struct _SMB_ACE4_INT_T
} SMB_ACE4_INT_T;
#define SMB_ACL4_INT_MAGIC 0x29A3E792
-typedef struct _SMB_ACL4_INT_T
+typedef struct SMB4ACL_T
{
uint32_t magic;
uint16_t controlflags;
--
1.9.1
From 0296ea3df24c8004fc1f4f118f91eddb14cde6fc Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 13:00:59 +0200
Subject: [PATCH 06/18] nfs4acls: Use SMB4ACE_T instead of _SMB_ACE4_INT_T
We can make the _INT_ structure now be the representation of the
published anonymous struct
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index d487666..c9560f8 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -38,7 +38,7 @@
extern const struct generic_mapping file_generic_mapping;
#define SMB_ACE4_INT_MAGIC 0x76F8A967
-typedef struct _SMB_ACE4_INT_T
+typedef struct SMB4ACE_T
{
uint32_t magic;
SMB_ACE4PROP_T prop;
--
1.9.1
From bdf5f3c988ca709d397fcfdb03984e5e6cd845b4 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 13:02:17 +0200
Subject: [PATCH 07/18] nfs4acls: Remove the SMB_ACL4_INT_T typedef
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index c9560f8..d363d7a 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -46,14 +46,14 @@ typedef struct SMB4ACE_T
} SMB_ACE4_INT_T;
#define SMB_ACL4_INT_MAGIC 0x29A3E792
-typedef struct SMB4ACL_T
+struct SMB4ACL_T
{
uint32_t magic;
uint16_t controlflags;
uint32_t naces;
SMB_ACE4_INT_T *first;
SMB_ACE4_INT_T *last;
-} SMB_ACL4_INT_T;
+};
enum smbacl4_mode_enum {e_simple=0, e_special=1};
enum smbacl4_acedup_enum {e_dontcare=0, e_reject=1, e_ignore=2, e_merge=3};
@@ -172,9 +172,9 @@ static uint32_t map_windows_ace_flags_to_nfs4_ace_flags(uint32_t win_ace_flags)
return nfs4_ace_flags;
}
-static SMB_ACL4_INT_T *get_validated_aclint(struct SMB4ACL_T *theacl)
+static struct SMB4ACL_T *get_validated_aclint(struct SMB4ACL_T *theacl)
{
- SMB_ACL4_INT_T *aclint = (SMB_ACL4_INT_T *)theacl;
+ struct SMB4ACL_T *aclint = (struct SMB4ACL_T *)theacl;
if (theacl==NULL)
{
DEBUG(2, ("acl is NULL\n"));
@@ -210,8 +210,8 @@ static SMB_ACE4_INT_T *get_validated_aceint(struct SMB4ACE_T *ace)
struct SMB4ACL_T *smb_create_smb4acl(TALLOC_CTX *mem_ctx)
{
- SMB_ACL4_INT_T *theacl = (SMB_ACL4_INT_T *)TALLOC_ZERO_SIZE(
- mem_ctx, sizeof(SMB_ACL4_INT_T));
+ struct SMB4ACL_T *theacl = (struct SMB4ACL_T *)TALLOC_ZERO_SIZE(
+ mem_ctx, sizeof(struct SMB4ACL_T));
if (theacl==NULL)
{
DEBUG(0, ("TALLOC_SIZE failed\n"));
@@ -226,7 +226,7 @@ struct SMB4ACL_T *smb_create_smb4acl(TALLOC_CTX *mem_ctx)
struct SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *theacl, SMB_ACE4PROP_T *prop)
{
- SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
+ struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
SMB_ACE4_INT_T *ace;
ace = (SMB_ACE4_INT_T *)TALLOC_ZERO_SIZE(
@@ -274,7 +274,7 @@ struct SMB4ACE_T *smb_next_ace4(struct SMB4ACE_T *ace)
struct SMB4ACE_T *smb_first_ace4(struct SMB4ACL_T *theacl)
{
- SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
+ struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
if (aclint==NULL)
return NULL;
@@ -283,7 +283,7 @@ struct SMB4ACE_T *smb_first_ace4(struct SMB4ACL_T *theacl)
uint32_t smb_get_naces(struct SMB4ACL_T *theacl)
{
- SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
+ struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
if (aclint==NULL)
return 0;
@@ -292,7 +292,7 @@ uint32_t smb_get_naces(struct SMB4ACL_T *theacl)
uint16_t smbacl4_get_controlflags(struct SMB4ACL_T *theacl)
{
- SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
+ struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
if (aclint==NULL)
return 0;
@@ -301,7 +301,7 @@ uint16_t smbacl4_get_controlflags(struct SMB4ACL_T *theacl)
bool smbacl4_set_controlflags(struct SMB4ACL_T *theacl, uint16_t controlflags)
{
- SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
+ struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
if (aclint==NULL)
return false;
@@ -354,7 +354,7 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx,
int *pgood_aces /* out */
)
{
- SMB_ACL4_INT_T *aclint = (SMB_ACL4_INT_T *)theacl;
+ struct SMB4ACL_T *aclint = (struct SMB4ACL_T *)theacl;
SMB_ACE4_INT_T *aceint;
struct security_ace *nt_ace_list = NULL;
int good_aces = 0;
@@ -633,7 +633,7 @@ NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn,
static void smbacl4_dump_nfs4acl(int level, struct SMB4ACL_T *theacl)
{
- SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
+ struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
SMB_ACE4_INT_T *aceint;
DEBUG(level, ("NFS4ACL: size=%d\n", aclint->naces));
@@ -661,7 +661,7 @@ static SMB_ACE4PROP_T *smbacl4_find_equal_special(
struct SMB4ACL_T *theacl,
SMB_ACE4PROP_T *aceNew)
{
- SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
+ struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
SMB_ACE4_INT_T *aceint;
for (aceint = aclint->first; aceint != NULL;
@@ -833,7 +833,7 @@ static int smbacl4_substitute_special(
gid_t ownerGID
)
{
- SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
+ struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
SMB_ACE4_INT_T *aceint;
for(aceint = aclint->first; aceint!=NULL; aceint=(SMB_ACE4_INT_T *)aceint->next) {
@@ -869,7 +869,7 @@ static int smbacl4_substitute_simple(
gid_t ownerGID
)
{
- SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
+ struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
SMB_ACE4_INT_T *aceint;
for(aceint = aclint->first; aceint!=NULL; aceint=(SMB_ACE4_INT_T *)aceint->next) {
--
1.9.1
From 704e26f3a2f584b7d50460b90ff34f9f0f194099 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 13:04:05 +0200
Subject: [PATCH 08/18] nfs4acls: Remove the SMB_ACE4_INT_T typedef
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index d363d7a..8e625d9 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -38,12 +38,12 @@
extern const struct generic_mapping file_generic_mapping;
#define SMB_ACE4_INT_MAGIC 0x76F8A967
-typedef struct SMB4ACE_T
+struct SMB4ACE_T
{
uint32_t magic;
SMB_ACE4PROP_T prop;
- struct _SMB_ACE4_INT_T *next;
-} SMB_ACE4_INT_T;
+ struct SMB4ACE_T *next;
+};
#define SMB_ACL4_INT_MAGIC 0x29A3E792
struct SMB4ACL_T
@@ -51,8 +51,8 @@ struct SMB4ACL_T
uint32_t magic;
uint16_t controlflags;
uint32_t naces;
- SMB_ACE4_INT_T *first;
- SMB_ACE4_INT_T *last;
+ struct SMB4ACE_T *first;
+ struct SMB4ACE_T *last;
};
enum smbacl4_mode_enum {e_simple=0, e_special=1};
@@ -190,9 +190,9 @@ static struct SMB4ACL_T *get_validated_aclint(struct SMB4ACL_T *theacl)
return aclint;
}
-static SMB_ACE4_INT_T *get_validated_aceint(struct SMB4ACE_T *ace)
+static struct SMB4ACE_T *get_validated_aceint(struct SMB4ACE_T *ace)
{
- SMB_ACE4_INT_T *aceint = (SMB_ACE4_INT_T *)ace;
+ struct SMB4ACE_T *aceint = (struct SMB4ACE_T *)ace;
if (ace==NULL)
{
DEBUG(2, ("ace is NULL\n"));
@@ -227,10 +227,10 @@ struct SMB4ACL_T *smb_create_smb4acl(TALLOC_CTX *mem_ctx)
struct SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *theacl, SMB_ACE4PROP_T *prop)
{
struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
- SMB_ACE4_INT_T *ace;
+ struct SMB4ACE_T *ace;
- ace = (SMB_ACE4_INT_T *)TALLOC_ZERO_SIZE(
- theacl, sizeof(SMB_ACE4_INT_T));
+ ace = (struct SMB4ACE_T *)TALLOC_ZERO_SIZE(
+ theacl, sizeof(struct SMB4ACE_T));
if (ace==NULL)
{
DEBUG(0, ("TALLOC_SIZE failed\n"));
@@ -256,7 +256,7 @@ struct SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *theacl, SMB_ACE4PROP_T *prop)
SMB_ACE4PROP_T *smb_get_ace4(struct SMB4ACE_T *ace)
{
- SMB_ACE4_INT_T *aceint = get_validated_aceint(ace);
+ struct SMB4ACE_T *aceint = get_validated_aceint(ace);
if (aceint==NULL)
return NULL;
@@ -265,7 +265,7 @@ SMB_ACE4PROP_T *smb_get_ace4(struct SMB4ACE_T *ace)
struct SMB4ACE_T *smb_next_ace4(struct SMB4ACE_T *ace)
{
- SMB_ACE4_INT_T *aceint = get_validated_aceint(ace);
+ struct SMB4ACE_T *aceint = get_validated_aceint(ace);
if (aceint==NULL)
return NULL;
@@ -355,7 +355,7 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx,
)
{
struct SMB4ACL_T *aclint = (struct SMB4ACL_T *)theacl;
- SMB_ACE4_INT_T *aceint;
+ struct SMB4ACE_T *aceint;
struct security_ace *nt_ace_list = NULL;
int good_aces = 0;
@@ -377,7 +377,7 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx,
for (aceint=aclint->first;
aceint!=NULL;
- aceint=(SMB_ACE4_INT_T *)aceint->next) {
+ aceint=(struct SMB4ACE_T *)aceint->next) {
uint32_t mask;
struct dom_sid sid;
SMB_ACE4PROP_T *ace = &aceint->prop;
@@ -634,13 +634,13 @@ NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn,
static void smbacl4_dump_nfs4acl(int level, struct SMB4ACL_T *theacl)
{
struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
- SMB_ACE4_INT_T *aceint;
+ struct SMB4ACE_T *aceint;
DEBUG(level, ("NFS4ACL: size=%d\n", aclint->naces));
for (aceint = aclint->first;
aceint!=NULL;
- aceint=(SMB_ACE4_INT_T *)aceint->next) {
+ aceint=(struct SMB4ACE_T *)aceint->next) {
SMB_ACE4PROP_T *ace = &aceint->prop;
DEBUG(level, ("\tACE: type=%d, flags=0x%x, fflags=0x%x, "
@@ -662,10 +662,10 @@ static SMB_ACE4PROP_T *smbacl4_find_equal_special(
SMB_ACE4PROP_T *aceNew)
{
struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
- SMB_ACE4_INT_T *aceint;
+ struct SMB4ACE_T *aceint;
for (aceint = aclint->first; aceint != NULL;
- aceint=(SMB_ACE4_INT_T *)aceint->next) {
+ aceint=(struct SMB4ACE_T *)aceint->next) {
SMB_ACE4PROP_T *ace = &aceint->prop;
DEBUG(10,("ace type:0x%x flags:0x%x aceFlags:0x%x "
@@ -834,9 +834,9 @@ static int smbacl4_substitute_special(
)
{
struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
- SMB_ACE4_INT_T *aceint;
+ struct SMB4ACE_T *aceint;
- for(aceint = aclint->first; aceint!=NULL; aceint=(SMB_ACE4_INT_T *)aceint->next) {
+ for(aceint = aclint->first; aceint!=NULL; aceint=(struct SMB4ACE_T *)aceint->next) {
SMB_ACE4PROP_T *ace = &aceint->prop;
DEBUG(10,("ace type: %d, iflags: %x, flags: %x, "
@@ -870,9 +870,9 @@ static int smbacl4_substitute_simple(
)
{
struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
- SMB_ACE4_INT_T *aceint;
+ struct SMB4ACE_T *aceint;
- for(aceint = aclint->first; aceint!=NULL; aceint=(SMB_ACE4_INT_T *)aceint->next) {
+ for(aceint = aclint->first; aceint!=NULL; aceint=(struct SMB4ACE_T *)aceint->next) {
SMB_ACE4PROP_T *ace = &aceint->prop;
DEBUG(10,("ace type: %d, iflags: %x, flags: %x, "
--
1.9.1
From e37ad494bb901fc47c921ea68eccb713d51716d2 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 13:12:46 +0200
Subject: [PATCH 09/18] nfs4acls: Remove get_validated_aclint
With the anonymous struct SMB4ACL_T we can rely on the compiler
to warn us
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 108 ++++++++++++++++----------------------------
1 file changed, 39 insertions(+), 69 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index 8e625d9..8742f03 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -45,10 +45,8 @@ struct SMB4ACE_T
struct SMB4ACE_T *next;
};
-#define SMB_ACL4_INT_MAGIC 0x29A3E792
struct SMB4ACL_T
{
- uint32_t magic;
uint16_t controlflags;
uint32_t naces;
struct SMB4ACE_T *first;
@@ -172,24 +170,6 @@ static uint32_t map_windows_ace_flags_to_nfs4_ace_flags(uint32_t win_ace_flags)
return nfs4_ace_flags;
}
-static struct SMB4ACL_T *get_validated_aclint(struct SMB4ACL_T *theacl)
-{
- struct SMB4ACL_T *aclint = (struct SMB4ACL_T *)theacl;
- if (theacl==NULL)
- {
- DEBUG(2, ("acl is NULL\n"));
- errno = EINVAL;
- return NULL;
- }
- if (aclint->magic!=SMB_ACL4_INT_MAGIC)
- {
- DEBUG(2, ("aclint bad magic 0x%x\n", aclint->magic));
- errno = EINVAL;
- return NULL;
- }
- return aclint;
-}
-
static struct SMB4ACE_T *get_validated_aceint(struct SMB4ACE_T *ace)
{
struct SMB4ACE_T *aceint = (struct SMB4ACE_T *)ace;
@@ -218,19 +198,17 @@ struct SMB4ACL_T *smb_create_smb4acl(TALLOC_CTX *mem_ctx)
errno = ENOMEM;
return NULL;
}
- theacl->magic = SMB_ACL4_INT_MAGIC;
theacl->controlflags = SEC_DESC_SELF_RELATIVE;
/* theacl->first, last = NULL not needed */
return (struct SMB4ACL_T *)theacl;
}
-struct SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *theacl, SMB_ACE4PROP_T *prop)
+struct SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *acl, SMB_ACE4PROP_T *prop)
{
- struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
struct SMB4ACE_T *ace;
ace = (struct SMB4ACE_T *)TALLOC_ZERO_SIZE(
- theacl, sizeof(struct SMB4ACE_T));
+ acl, sizeof(struct SMB4ACE_T));
if (ace==NULL)
{
DEBUG(0, ("TALLOC_SIZE failed\n"));
@@ -241,15 +219,15 @@ struct SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *theacl, SMB_ACE4PROP_T *prop)
/* ace->next = NULL not needed */
memcpy(&ace->prop, prop, sizeof(SMB_ACE4PROP_T));
- if (aclint->first==NULL)
+ if (acl->first==NULL)
{
- aclint->first = ace;
- aclint->last = ace;
+ acl->first = ace;
+ acl->last = ace;
} else {
- aclint->last->next = (void *)ace;
- aclint->last = ace;
+ acl->last->next = (void *)ace;
+ acl->last = ace;
}
- aclint->naces++;
+ acl->naces++;
return (struct SMB4ACE_T *)ace;
}
@@ -272,40 +250,40 @@ struct SMB4ACE_T *smb_next_ace4(struct SMB4ACE_T *ace)
return (struct SMB4ACE_T *)aceint->next;
}
-struct SMB4ACE_T *smb_first_ace4(struct SMB4ACL_T *theacl)
+struct SMB4ACE_T *smb_first_ace4(struct SMB4ACL_T *acl)
{
- struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
- if (aclint==NULL)
+ if (acl == NULL) {
return NULL;
+ }
- return (struct SMB4ACE_T *)aclint->first;
+ return acl->first;
}
-uint32_t smb_get_naces(struct SMB4ACL_T *theacl)
+uint32_t smb_get_naces(struct SMB4ACL_T *acl)
{
- struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
- if (aclint==NULL)
+ if (acl == NULL) {
return 0;
+ }
- return aclint->naces;
+ return acl->naces;
}
-uint16_t smbacl4_get_controlflags(struct SMB4ACL_T *theacl)
+uint16_t smbacl4_get_controlflags(struct SMB4ACL_T *acl)
{
- struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
- if (aclint==NULL)
+ if (acl == NULL) {
return 0;
+ }
- return aclint->controlflags;
+ return acl->controlflags;
}
-bool smbacl4_set_controlflags(struct SMB4ACL_T *theacl, uint16_t controlflags)
+bool smbacl4_set_controlflags(struct SMB4ACL_T *acl, uint16_t controlflags)
{
- struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
- if (aclint==NULL)
+ if (acl == NULL) {
return false;
+ }
- aclint->controlflags = controlflags;
+ acl->controlflags = controlflags;
return true;
}
@@ -346,7 +324,7 @@ static int smbacl4_fGetFileOwner(files_struct *fsp, SMB_STRUCT_STAT *psbuf)
static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx,
smbacl4_vfs_params *params,
- struct SMB4ACL_T *theacl, /* in */
+ struct SMB4ACL_T *acl, /* in */
struct dom_sid *psid_owner, /* in */
struct dom_sid *psid_group, /* in */
bool is_directory, /* in */
@@ -354,28 +332,22 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx,
int *pgood_aces /* out */
)
{
- struct SMB4ACL_T *aclint = (struct SMB4ACL_T *)theacl;
struct SMB4ACE_T *aceint;
struct security_ace *nt_ace_list = NULL;
int good_aces = 0;
DEBUG(10, ("%s entered\n", __func__));
- aclint = get_validated_aclint(theacl);
- /* We do not check for theacl being NULL here
- because this is already checked in smb_get_nt_acl_nfs4().
- We reserve twice the number of input aces because one nfs4
- ace might result in 2 nt aces.*/
nt_ace_list = (struct security_ace *)TALLOC_ZERO_SIZE(
- mem_ctx, 2 * aclint->naces * sizeof(struct security_ace));
+ mem_ctx, 2 * acl->naces * sizeof(struct security_ace));
if (nt_ace_list==NULL)
{
- DEBUG(10, ("talloc error with %d aces", aclint->naces));
+ DEBUG(10, ("talloc error with %d aces", acl->naces));
errno = ENOMEM;
return false;
}
- for (aceint=aclint->first;
+ for (aceint=acl->first;
aceint!=NULL;
aceint=(struct SMB4ACE_T *)aceint->next) {
uint32_t mask;
@@ -631,14 +603,13 @@ NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn,
mem_ctx, ppdesc, theacl);
}
-static void smbacl4_dump_nfs4acl(int level, struct SMB4ACL_T *theacl)
+static void smbacl4_dump_nfs4acl(int level, struct SMB4ACL_T *acl)
{
- struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
struct SMB4ACE_T *aceint;
- DEBUG(level, ("NFS4ACL: size=%d\n", aclint->naces));
+ DEBUG(level, ("NFS4ACL: size=%d\n", acl->naces));
- for (aceint = aclint->first;
+ for (aceint = acl->first;
aceint!=NULL;
aceint=(struct SMB4ACE_T *)aceint->next) {
SMB_ACE4PROP_T *ace = &aceint->prop;
@@ -658,13 +629,12 @@ static void smbacl4_dump_nfs4acl(int level, struct SMB4ACL_T *theacl)
* return ace if found matching; otherwise NULL
*/
static SMB_ACE4PROP_T *smbacl4_find_equal_special(
- struct SMB4ACL_T *theacl,
+ struct SMB4ACL_T *acl,
SMB_ACE4PROP_T *aceNew)
{
- struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
struct SMB4ACE_T *aceint;
- for (aceint = aclint->first; aceint != NULL;
+ for (aceint = acl->first; aceint != NULL;
aceint=(struct SMB4ACE_T *)aceint->next) {
SMB_ACE4PROP_T *ace = &aceint->prop;
@@ -828,15 +798,15 @@ static int smbacl4_MergeIgnoreReject(
}
static int smbacl4_substitute_special(
- struct SMB4ACL_T *theacl,
+ struct SMB4ACL_T *acl,
uid_t ownerUID,
gid_t ownerGID
)
{
- struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
struct SMB4ACE_T *aceint;
- for(aceint = aclint->first; aceint!=NULL; aceint=(struct SMB4ACE_T *)aceint->next) {
+ for(aceint = acl->first; aceint!=NULL;
+ aceint=(struct SMB4ACE_T *)aceint->next) {
SMB_ACE4PROP_T *ace = &aceint->prop;
DEBUG(10,("ace type: %d, iflags: %x, flags: %x, "
@@ -864,15 +834,15 @@ static int smbacl4_substitute_special(
}
static int smbacl4_substitute_simple(
- struct SMB4ACL_T *theacl,
+ struct SMB4ACL_T *acl,
uid_t ownerUID,
gid_t ownerGID
)
{
- struct SMB4ACL_T *aclint = get_validated_aclint(theacl);
struct SMB4ACE_T *aceint;
- for(aceint = aclint->first; aceint!=NULL; aceint=(struct SMB4ACE_T *)aceint->next) {
+ for(aceint = acl->first; aceint!=NULL;
+ aceint=(struct SMB4ACE_T *)aceint->next) {
SMB_ACE4PROP_T *ace = &aceint->prop;
DEBUG(10,("ace type: %d, iflags: %x, flags: %x, "
--
1.9.1
From e147beecd53959ac6c8802cfd855534a573ca635 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 13:12:46 +0200
Subject: [PATCH 10/18] nfs4acls: Remove get_validated_aceint
With the anonymous struct SMB4ACE_T we can rely on the compiler
to warn us
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 39 ++++++++-------------------------------
1 file changed, 8 insertions(+), 31 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index 8742f03..6987cff 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -37,10 +37,8 @@
extern const struct generic_mapping file_generic_mapping;
-#define SMB_ACE4_INT_MAGIC 0x76F8A967
struct SMB4ACE_T
{
- uint32_t magic;
SMB_ACE4PROP_T prop;
struct SMB4ACE_T *next;
};
@@ -170,24 +168,6 @@ static uint32_t map_windows_ace_flags_to_nfs4_ace_flags(uint32_t win_ace_flags)
return nfs4_ace_flags;
}
-static struct SMB4ACE_T *get_validated_aceint(struct SMB4ACE_T *ace)
-{
- struct SMB4ACE_T *aceint = (struct SMB4ACE_T *)ace;
- if (ace==NULL)
- {
- DEBUG(2, ("ace is NULL\n"));
- errno = EINVAL;
- return NULL;
- }
- if (aceint->magic!=SMB_ACE4_INT_MAGIC)
- {
- DEBUG(2, ("aceint bad magic 0x%x\n", aceint->magic));
- errno = EINVAL;
- return NULL;
- }
- return aceint;
-}
-
struct SMB4ACL_T *smb_create_smb4acl(TALLOC_CTX *mem_ctx)
{
struct SMB4ACL_T *theacl = (struct SMB4ACL_T *)TALLOC_ZERO_SIZE(
@@ -215,7 +195,6 @@ struct SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *acl, SMB_ACE4PROP_T *prop)
errno = ENOMEM;
return NULL;
}
- ace->magic = SMB_ACE4_INT_MAGIC;
/* ace->next = NULL not needed */
memcpy(&ace->prop, prop, sizeof(SMB_ACE4PROP_T));
@@ -234,20 +213,20 @@ struct SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *acl, SMB_ACE4PROP_T *prop)
SMB_ACE4PROP_T *smb_get_ace4(struct SMB4ACE_T *ace)
{
- struct SMB4ACE_T *aceint = get_validated_aceint(ace);
- if (aceint==NULL)
+ if (ace == NULL) {
return NULL;
+ }
- return &aceint->prop;
+ return &ace->prop;
}
struct SMB4ACE_T *smb_next_ace4(struct SMB4ACE_T *ace)
{
- struct SMB4ACE_T *aceint = get_validated_aceint(ace);
- if (aceint==NULL)
+ if (ace == NULL) {
return NULL;
+ }
- return (struct SMB4ACE_T *)aceint->next;
+ return ace->next;
}
struct SMB4ACE_T *smb_first_ace4(struct SMB4ACL_T *acl)
@@ -355,13 +334,11 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx,
SMB_ACE4PROP_T *ace = &aceint->prop;
uint32_t win_ace_flags;
- DEBUG(10, ("magic: 0x%x, type: %d, iflags: %x, flags: %x, "
+ DEBUG(10, ("type: %d, iflags: %x, flags: %x, "
"mask: %x, who: %d\n",
- aceint->magic, ace->aceType, ace->flags,
+ ace->aceType, ace->flags,
ace->aceFlags, ace->aceMask, ace->who.id));
- SMB_ASSERT(aceint->magic==SMB_ACE4_INT_MAGIC);
-
if (ace->flags & SMB_ACE4_ID_SPECIAL) {
switch (ace->who.special_id) {
case SMB_ACE4_WHO_OWNER:
--
1.9.1
From 23c51a9aa88dbcc2e8228fa2d2428c0bfc4310e1 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 12 Aug 2015 07:31:01 +0200
Subject: [PATCH 11/18] nfs4acls: Use talloc_zero()
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index 6987cff..2473c44 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -170,8 +170,9 @@ static uint32_t map_windows_ace_flags_to_nfs4_ace_flags(uint32_t win_ace_flags)
struct SMB4ACL_T *smb_create_smb4acl(TALLOC_CTX *mem_ctx)
{
- struct SMB4ACL_T *theacl = (struct SMB4ACL_T *)TALLOC_ZERO_SIZE(
- mem_ctx, sizeof(struct SMB4ACL_T));
+ struct SMB4ACL_T *theacl;
+
+ theacl = talloc_zero(mem_ctx, struct SMB4ACL_T);
if (theacl==NULL)
{
DEBUG(0, ("TALLOC_SIZE failed\n"));
--
1.9.1
From 8267972ccc927714d402ce08218f02eb8c460a25 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 13:33:40 +0200
Subject: [PATCH 12/18] nfs4acls: Use talloc_zero()
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index 2473c44..2cf0ebe 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -188,8 +188,7 @@ struct SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *acl, SMB_ACE4PROP_T *prop)
{
struct SMB4ACE_T *ace;
- ace = (struct SMB4ACE_T *)TALLOC_ZERO_SIZE(
- acl, sizeof(struct SMB4ACE_T));
+ ace = talloc_zero(acl, struct SMB4ACE_T);
if (ace==NULL)
{
DEBUG(0, ("TALLOC_SIZE failed\n"));
--
1.9.1
From 39d3487d71429f73ee52e35668eb06dcac418f68 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 13:34:35 +0200
Subject: [PATCH 13/18] nfs4acls: Use talloc_zero_array()
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index 2cf0ebe..fda4728 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -317,8 +317,8 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx,
DEBUG(10, ("%s entered\n", __func__));
- nt_ace_list = (struct security_ace *)TALLOC_ZERO_SIZE(
- mem_ctx, 2 * acl->naces * sizeof(struct security_ace));
+ nt_ace_list = talloc_zero_array(mem_ctx, struct security_ace,
+ 2 * acl->naces);
if (nt_ace_list==NULL)
{
DEBUG(10, ("talloc error with %d aces", acl->naces));
--
1.9.1
From 256d166d79f214e9ec8e58f49907fab935a72db6 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 13:36:45 +0200
Subject: [PATCH 14/18] nfs4acls: Use talloc_realloc()
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index fda4728..a680ad1 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -456,9 +456,9 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx,
}
}
- nt_ace_list = (struct security_ace *)
- TALLOC_REALLOC(mem_ctx, nt_ace_list,
- good_aces * sizeof(struct security_ace));
+ nt_ace_list = talloc_realloc(mem_ctx, nt_ace_list, struct security_ace,
+ good_aces);
+
/* returns a NULL ace list when good_aces is zero. */
if (good_aces && nt_ace_list == NULL) {
DEBUG(10, ("realloc error with %d aces", good_aces));
--
1.9.1
From 9a502ad08efc4f0d96c60ca5f746db69a2fc6fa7 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 13:37:42 +0200
Subject: [PATCH 15/18] nfs4acls: Remove a few unnecessary casts
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index a680ad1..80cd5c0 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -181,7 +181,7 @@ struct SMB4ACL_T *smb_create_smb4acl(TALLOC_CTX *mem_ctx)
}
theacl->controlflags = SEC_DESC_SELF_RELATIVE;
/* theacl->first, last = NULL not needed */
- return (struct SMB4ACL_T *)theacl;
+ return theacl;
}
struct SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *acl, SMB_ACE4PROP_T *prop)
@@ -203,12 +203,12 @@ struct SMB4ACE_T *smb_add_ace4(struct SMB4ACL_T *acl, SMB_ACE4PROP_T *prop)
acl->first = ace;
acl->last = ace;
} else {
- acl->last->next = (void *)ace;
+ acl->last->next = ace;
acl->last = ace;
}
acl->naces++;
- return (struct SMB4ACE_T *)ace;
+ return ace;
}
SMB_ACE4PROP_T *smb_get_ace4(struct SMB4ACE_T *ace)
@@ -326,9 +326,7 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx,
return false;
}
- for (aceint=acl->first;
- aceint!=NULL;
- aceint=(struct SMB4ACE_T *)aceint->next) {
+ for (aceint = acl->first; aceint != NULL; aceint = aceint->next) {
uint32_t mask;
struct dom_sid sid;
SMB_ACE4PROP_T *ace = &aceint->prop;
@@ -586,9 +584,7 @@ static void smbacl4_dump_nfs4acl(int level, struct SMB4ACL_T *acl)
DEBUG(level, ("NFS4ACL: size=%d\n", acl->naces));
- for (aceint = acl->first;
- aceint!=NULL;
- aceint=(struct SMB4ACE_T *)aceint->next) {
+ for (aceint = acl->first; aceint != NULL; aceint = aceint->next) {
SMB_ACE4PROP_T *ace = &aceint->prop;
DEBUG(level, ("\tACE: type=%d, flags=0x%x, fflags=0x%x, "
@@ -611,8 +607,7 @@ static SMB_ACE4PROP_T *smbacl4_find_equal_special(
{
struct SMB4ACE_T *aceint;
- for (aceint = acl->first; aceint != NULL;
- aceint=(struct SMB4ACE_T *)aceint->next) {
+ for (aceint = acl->first; aceint != NULL; aceint = aceint->next) {
SMB_ACE4PROP_T *ace = &aceint->prop;
DEBUG(10,("ace type:0x%x flags:0x%x aceFlags:0x%x "
@@ -782,8 +777,7 @@ static int smbacl4_substitute_special(
{
struct SMB4ACE_T *aceint;
- for(aceint = acl->first; aceint!=NULL;
- aceint=(struct SMB4ACE_T *)aceint->next) {
+ for (aceint = acl->first; aceint != NULL; aceint = aceint->next) {
SMB_ACE4PROP_T *ace = &aceint->prop;
DEBUG(10,("ace type: %d, iflags: %x, flags: %x, "
@@ -818,8 +812,7 @@ static int smbacl4_substitute_simple(
{
struct SMB4ACE_T *aceint;
- for(aceint = acl->first; aceint!=NULL;
- aceint=(struct SMB4ACE_T *)aceint->next) {
+ for (aceint = acl->first; aceint != NULL; aceint = aceint->next) {
SMB_ACE4PROP_T *ace = &aceint->prop;
DEBUG(10,("ace type: %d, iflags: %x, flags: %x, "
--
1.9.1
From 9614bc150f88f303768d0b57b19aef297c8333b8 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 14:13:43 +0200
Subject: [PATCH 16/18] nfs4acls: Introduce a helper variable
... triggered by removing a "==false" condition
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index 80cd5c0..7968048 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -483,6 +483,7 @@ static NTSTATUS smb_get_nt_acl_nfs4_common(const SMB_STRUCT_STAT *sbuf,
struct security_ace *nt_ace_list = NULL;
struct security_acl *psa = NULL;
TALLOC_CTX *frame = talloc_stackframe();
+ bool ok;
if (theacl==NULL) {
TALLOC_FREE(frame);
@@ -494,9 +495,10 @@ static NTSTATUS smb_get_nt_acl_nfs4_common(const SMB_STRUCT_STAT *sbuf,
uid_to_sid(&sid_owner, sbuf->st_ex_uid);
gid_to_sid(&sid_group, sbuf->st_ex_gid);
- if (smbacl4_nfs42win(mem_ctx, params, theacl, &sid_owner, &sid_group,
- S_ISDIR(sbuf->st_ex_mode),
- &nt_ace_list, &good_aces)==false) {
+ ok = smbacl4_nfs42win(mem_ctx, params, theacl, &sid_owner, &sid_group,
+ S_ISDIR(sbuf->st_ex_mode),
+ &nt_ace_list, &good_aces);
+ if (!ok) {
DEBUG(8,("smbacl4_nfs42win failed\n"));
TALLOC_FREE(frame);
return map_nt_error_from_unix(errno);
--
1.9.1
From 5a9ede0a348527f22eb68cf78e0f0a5ad8e83c95 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 14:16:04 +0200
Subject: [PATCH 17/18] nfs4acls: Fix a small memleak
We don't need the nt_ace_list beyond this function, make_sec_acl makes
a copy and make_sec_desc makes another one
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index 7968048..b3034f9 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -495,7 +495,7 @@ static NTSTATUS smb_get_nt_acl_nfs4_common(const SMB_STRUCT_STAT *sbuf,
uid_to_sid(&sid_owner, sbuf->st_ex_uid);
gid_to_sid(&sid_group, sbuf->st_ex_gid);
- ok = smbacl4_nfs42win(mem_ctx, params, theacl, &sid_owner, &sid_group,
+ ok = smbacl4_nfs42win(frame, params, theacl, &sid_owner, &sid_group,
S_ISDIR(sbuf->st_ex_mode),
&nt_ace_list, &good_aces);
if (!ok) {
--
1.9.1
From ff9e2c2fc7e1a181610e00ed3b33ec9732a99226 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Aug 2015 14:20:07 +0200
Subject: [PATCH 18/18] nfs4acls: Remove type_name param from
smbacl4_get_vfs_params
It is kindof unexpected that we get params for something else but
"nfs4:"
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/nfs4_acls.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index b3034f9..26a98b7 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -65,7 +65,6 @@ typedef struct _smbacl4_vfs_params {
* Gather special parameters for NFS4 ACL handling
*/
static int smbacl4_get_vfs_params(
- const char *type_name,
struct connection_struct *conn,
smbacl4_vfs_params *params
)
@@ -86,21 +85,23 @@ static int smbacl4_get_vfs_params(
ZERO_STRUCTP(params);
- enumval = lp_parm_enum(SNUM(conn), type_name, "mode",
+ enumval = lp_parm_enum(SNUM(conn), SMBACL4_PARAM_TYPE_NAME, "mode",
enum_smbacl4_modes, e_simple);
if (enumval == -1) {
- DEBUG(10, ("value for %s:mode unknown\n", type_name));
+ DEBUG(10, ("value for %s:mode unknown\n",
+ SMBACL4_PARAM_TYPE_NAME));
return -1;
}
params->mode = (enum smbacl4_mode_enum)enumval;
- params->do_chown = lp_parm_bool(SNUM(conn), type_name,
+ params->do_chown = lp_parm_bool(SNUM(conn), SMBACL4_PARAM_TYPE_NAME,
"chown", true);
- enumval = lp_parm_enum(SNUM(conn), type_name, "acedup",
+ enumval = lp_parm_enum(SNUM(conn), SMBACL4_PARAM_TYPE_NAME, "acedup",
enum_smbacl4_acedups, e_dontcare);
if (enumval == -1) {
- DEBUG(10, ("value for %s:acedup unknown\n", type_name));
+ DEBUG(10, ("value for %s:acedup unknown\n",
+ SMBACL4_PARAM_TYPE_NAME));
return -1;
}
params->acedup = (enum smbacl4_acedup_enum)enumval;
@@ -547,7 +548,7 @@ NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp,
}
/* Special behaviours */
- if (smbacl4_get_vfs_params(SMBACL4_PARAM_TYPE_NAME, fsp->conn, ¶ms)) {
+ if (smbacl4_get_vfs_params(fsp->conn, ¶ms)) {
return NT_STATUS_NO_MEMORY;
}
@@ -572,7 +573,7 @@ NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn,
}
/* Special behaviours */
- if (smbacl4_get_vfs_params(SMBACL4_PARAM_TYPE_NAME, conn, ¶ms)) {
+ if (smbacl4_get_vfs_params(conn, ¶ms)) {
return NT_STATUS_NO_MEMORY;
}
@@ -929,8 +930,7 @@ NTSTATUS smb_set_nt_acl_nfs4(vfs_handle_struct *handle, files_struct *fsp,
}
/* Special behaviours */
- if (smbacl4_get_vfs_params(SMBACL4_PARAM_TYPE_NAME,
- fsp->conn, ¶ms)) {
+ if (smbacl4_get_vfs_params(fsp->conn, ¶ms)) {
TALLOC_FREE(frame);
return NT_STATUS_NO_MEMORY;
}
--
1.9.1
More information about the samba-technical
mailing list