1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

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@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Volker Lendecke 2015-08-11 12:35:20 +02:00
parent 9db523b169
commit f15ad38d14
6 changed files with 68 additions and 62 deletions

View File

@ -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;

View File

@ -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,

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -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();