summaryrefslogtreecommitdiff
path: root/source3/modules/nfs4_acls.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-10-10 11:50:27 +1100
committerAndrew Bartlett <abartlet@samba.org>2012-10-11 12:25:11 +1100
commitc8ade07760ae0ccfdf2d875c9f3027926e62321b (patch)
treeabac36ce81b1e0737bfeb607699a41773beb958e /source3/modules/nfs4_acls.c
parent9158974540d0e311021f04789ed75ebda466c5b3 (diff)
downloadsamba-c8ade07760ae0ccfdf2d875c9f3027926e62321b.tar.gz
samba-c8ade07760ae0ccfdf2d875c9f3027926e62321b.tar.bz2
samba-c8ade07760ae0ccfdf2d875c9f3027926e62321b.zip
smbd: Add mem_ctx to {f,}get_nt_acl VFS call
This makes it clear which context the returned SD is allocated on, as a number of callers do not want it on talloc_tos(). As the ACL transformation allocates and then no longer needs a great deal of memory, a talloc_stackframe() call is used to contain the memory that is not returned further up the stack. Andrew Bartlett
Diffstat (limited to 'source3/modules/nfs4_acls.c')
-rw-r--r--source3/modules/nfs4_acls.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index 05f90f77df..48b045feb0 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -370,7 +370,7 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx, SMB4ACL_T *theacl, /* in */
}
static NTSTATUS smb_get_nt_acl_nfs4_common(const SMB_STRUCT_STAT *sbuf,
- uint32 security_info,
+ uint32 security_info, TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc, SMB4ACL_T *theacl)
{
int good_aces = 0;
@@ -378,7 +378,7 @@ static NTSTATUS smb_get_nt_acl_nfs4_common(const SMB_STRUCT_STAT *sbuf,
size_t sd_size = 0;
struct security_ace *nt_ace_list = NULL;
struct security_acl *psa = NULL;
- TALLOC_CTX *mem_ctx = talloc_tos();
+ TALLOC_CTX *frame = talloc_stackframe();
if (theacl==NULL || smb_get_naces(theacl)==0)
return NT_STATUS_ACCESS_DENIED; /* special because we
@@ -392,12 +392,14 @@ static NTSTATUS smb_get_nt_acl_nfs4_common(const SMB_STRUCT_STAT *sbuf,
S_ISDIR(sbuf->st_ex_mode),
&nt_ace_list, &good_aces)==False) {
DEBUG(8,("smbacl4_nfs42win failed\n"));
+ TALLOC_FREE(frame);
return map_nt_error_from_unix(errno);
}
- psa = make_sec_acl(mem_ctx, NT4_ACL_REVISION, good_aces, nt_ace_list);
+ psa = make_sec_acl(frame, NT4_ACL_REVISION, good_aces, nt_ace_list);
if (psa == NULL) {
DEBUG(2,("make_sec_acl failed\n"));
+ TALLOC_FREE(frame);
return NT_STATUS_NO_MEMORY;
}
@@ -409,6 +411,7 @@ static NTSTATUS smb_get_nt_acl_nfs4_common(const SMB_STRUCT_STAT *sbuf,
NULL, psa, &sd_size);
if (*ppdesc==NULL) {
DEBUG(2,("make_sec_desc failed\n"));
+ TALLOC_FREE(frame);
return NT_STATUS_NO_MEMORY;
}
@@ -416,11 +419,13 @@ static NTSTATUS smb_get_nt_acl_nfs4_common(const SMB_STRUCT_STAT *sbuf,
"sd_size %d\n",
(int)ndr_size_security_descriptor(*ppdesc, 0)));
+ TALLOC_FREE(frame);
return NT_STATUS_OK;
}
NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp,
uint32 security_info,
+ TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc,
SMB4ACL_T *theacl)
{
@@ -432,13 +437,15 @@ NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp,
return map_nt_error_from_unix(errno);
}
- return smb_get_nt_acl_nfs4_common(&sbuf, security_info, ppdesc,
+ return smb_get_nt_acl_nfs4_common(&sbuf, security_info,
+ mem_ctx, ppdesc,
theacl);
}
NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn,
const char *name,
uint32 security_info,
+ TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc,
SMB4ACL_T *theacl)
{
@@ -450,7 +457,8 @@ NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn,
return map_nt_error_from_unix(errno);
}
- return smb_get_nt_acl_nfs4_common(&sbuf, security_info, ppdesc,
+ return smb_get_nt_acl_nfs4_common(&sbuf, security_info,
+ mem_ctx, ppdesc,
theacl);
}