summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-01-07 18:44:52 +0100
committerVolker Lendecke <vl@samba.org>2009-01-08 22:29:54 +0100
commit84292022bf801112d2cb7f0f8512cf00079def20 (patch)
tree465b8f7c2f51769cf4a15d2b82e2ba4465bdfe40
parent825500f5dafb848b95f5a5ea6595cc24f377bc3a (diff)
downloadsamba-84292022bf801112d2cb7f0f8512cf00079def20.tar.gz
samba-84292022bf801112d2cb7f0f8512cf00079def20.tar.bz2
samba-84292022bf801112d2cb7f0f8512cf00079def20.zip
Now that all policy_handle free_fn's are just TALLOC_FREE, dump free_fn
-rw-r--r--source3/include/ntdomain.h1
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/rpc_server/srv_eventlog_nt.c10
-rw-r--r--source3/rpc_server/srv_lsa_hnd.c22
-rw-r--r--source3/rpc_server/srv_lsa_nt.c25
-rw-r--r--source3/rpc_server/srv_samr_nt.c50
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c9
-rw-r--r--source3/rpc_server/srv_svcctl_nt.c13
-rw-r--r--source3/rpc_server/srv_winreg_nt.c20
9 files changed, 51 insertions, 101 deletions
diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h
index bffa158fea..3f501550da 100644
--- a/source3/include/ntdomain.h
+++ b/source3/include/ntdomain.h
@@ -123,7 +123,6 @@ struct policy {
POLICY_HND pol_hnd;
void *data_ptr;
- void (*free_fn)(void *);
};
struct handle_list {
diff --git a/source3/include/proto.h b/source3/include/proto.h
index afc207b6f6..96b2e26d30 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -6188,7 +6188,7 @@ NTSTATUS _eventlog_read_eventlog( pipes_struct * p,
/* The following definitions come from rpc_server/srv_lsa_hnd.c */
bool init_pipe_handle_list(pipes_struct *p, const char *pipe_name);
-bool create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *), void *data_ptr);
+bool create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void *data_ptr);
bool find_policy_by_hnd(pipes_struct *p, POLICY_HND *hnd, void **data_p);
bool close_policy_hnd(pipes_struct *p, POLICY_HND *hnd);
void close_policy_by_pipe(pipes_struct *p);
diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c
index 7b7f381d91..145b4600f9 100644
--- a/source3/rpc_server/srv_eventlog_nt.c
+++ b/source3/rpc_server/srv_eventlog_nt.c
@@ -45,11 +45,6 @@ static int eventlog_info_destructor(EVENTLOG_INFO *elog)
return 0;
}
-static void free_eventlog_info( void *ptr )
-{
- TALLOC_FREE(ptr);
-}
-
/********************************************************************
********************************************************************/
@@ -238,9 +233,8 @@ static NTSTATUS elog_open( pipes_struct * p, const char *logname, POLICY_HND *hn
/* create the policy handle */
- if ( !create_policy_hnd
- ( p, hnd, free_eventlog_info, ( void * ) elog ) ) {
- free_eventlog_info( elog );
+ if ( !create_policy_hnd( p, hnd, elog ) ) {
+ TALLOC_FREE(elog);
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c
index a00e097596..5f7c8d9f1a 100644
--- a/source3/rpc_server/srv_lsa_hnd.c
+++ b/source3/rpc_server/srv_lsa_hnd.c
@@ -103,9 +103,13 @@ bool init_pipe_handle_list(pipes_struct *p, const char *pipe_name)
/****************************************************************************
find first available policy slot. creates a policy handle for you.
+
+ If "data_ptr" is given, this must be a talloc'ed object, create_policy_hnd
+ talloc_moves this into the handle. If the policy_hnd is closed,
+ data_ptr is TALLOC_FREE()'ed
****************************************************************************/
-bool create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *), void *data_ptr)
+bool create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void *data_ptr)
{
static uint32 pol_hnd_low = 0;
static uint32 pol_hnd_high = 0;
@@ -119,16 +123,15 @@ bool create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *)
return False;
}
- pol = SMB_MALLOC_P(struct policy);
+ pol = TALLOC_ZERO_P(NULL, struct policy);
if (!pol) {
DEBUG(0,("create_policy_hnd: ERROR: out of memory!\n"));
return False;
}
- ZERO_STRUCTP(pol);
-
- pol->data_ptr = data_ptr;
- pol->free_fn = free_fn;
+ if (data_ptr != NULL) {
+ pol->data_ptr = talloc_move(pol, &data_ptr);
+ }
pol_hnd_low++;
if (pol_hnd_low == 0)
@@ -211,16 +214,11 @@ bool close_policy_hnd(pipes_struct *p, POLICY_HND *hnd)
DEBUG(3,("Closed policy\n"));
- if (pol->free_fn && pol->data_ptr)
- (*pol->free_fn)(pol->data_ptr);
-
p->pipe_handles->count--;
DLIST_REMOVE(p->pipe_handles->Policy, pol);
- ZERO_STRUCTP(pol);
-
- SAFE_FREE(pol);
+ TALLOC_FREE(pol);
return True;
}
diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c
index 0db739dff2..ed54c3a86e 100644
--- a/source3/rpc_server/srv_lsa_nt.c
+++ b/source3/rpc_server/srv_lsa_nt.c
@@ -96,15 +96,6 @@ static int init_lsa_ref_domain_list(TALLOC_CTX *mem_ctx,
}
-/*******************************************************************
- Function to free the per handle data.
- ********************************************************************/
-
-static void free_lsa_info(void *ptr)
-{
- TALLOC_FREE(ptr);
-}
-
/***************************************************************************
initialize a lsa_DomainInfo structure.
***************************************************************************/
@@ -398,7 +389,7 @@ NTSTATUS _lsa_OpenPolicy2(pipes_struct *p,
acc_granted = LSA_POLICY_ALL_ACCESS;
/* associate the domain SID with the (unique) handle. */
- info = TALLOC_ZERO_P(NULL, struct lsa_info);
+ info = TALLOC_ZERO_P(p->mem_ctx, struct lsa_info);
if (info == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -407,7 +398,7 @@ NTSTATUS _lsa_OpenPolicy2(pipes_struct *p,
info->access = acc_granted;
/* set up the LSA QUERY INFO response */
- if (!create_policy_hnd(p, r->out.handle, free_lsa_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.handle, info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
return NT_STATUS_OK;
@@ -447,7 +438,7 @@ NTSTATUS _lsa_OpenPolicy(pipes_struct *p,
}
/* associate the domain SID with the (unique) handle. */
- info = TALLOC_ZERO_P(NULL, struct lsa_info);
+ info = TALLOC_ZERO_P(p->mem_ctx, struct lsa_info);
if (info == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -456,7 +447,7 @@ NTSTATUS _lsa_OpenPolicy(pipes_struct *p,
info->access = acc_granted;
/* set up the LSA QUERY INFO response */
- if (!create_policy_hnd(p, r->out.handle, free_lsa_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.handle, info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
return NT_STATUS_OK;
@@ -1555,7 +1546,7 @@ NTSTATUS _lsa_CreateAccount(pipes_struct *p,
/* associate the user/group SID with the (unique) handle. */
- info = TALLOC_ZERO_P(NULL, struct lsa_info);
+ info = TALLOC_ZERO_P(p->mem_ctx, struct lsa_info);
if (info == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -1564,7 +1555,7 @@ NTSTATUS _lsa_CreateAccount(pipes_struct *p,
info->access = r->in.access_mask;
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, r->out.acct_handle, free_lsa_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.acct_handle, info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
return privilege_create_account( &info->sid );
@@ -1600,7 +1591,7 @@ NTSTATUS _lsa_OpenAccount(pipes_struct *p,
return NT_STATUS_ACCESS_DENIED;
#endif
/* associate the user/group SID with the (unique) handle. */
- info = TALLOC_ZERO_P(NULL, struct lsa_info);
+ info = TALLOC_ZERO_P(p->mem_ctx, struct lsa_info);
if (info == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -1609,7 +1600,7 @@ NTSTATUS _lsa_OpenAccount(pipes_struct *p,
info->access = r->in.access_mask;
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, r->out.acct_handle, free_lsa_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.acct_handle, info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
return NT_STATUS_OK;
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c
index 8ab4715a51..9984bf0cfc 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -358,7 +358,8 @@ static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid)
static int samr_info_destructor(struct samr_info *info);
-static struct samr_info *get_samr_info_by_sid(DOM_SID *psid)
+static struct samr_info *get_samr_info_by_sid(TALLOC_CTX *mem_ctx,
+ DOM_SID *psid)
{
struct samr_info *info;
fstring sid_str;
@@ -369,7 +370,7 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid)
fstrcpy(sid_str,"(NULL)");
}
- if ((info = TALLOC_ZERO_P(NULL, struct samr_info)) == NULL) {
+ if ((info = TALLOC_ZERO_P(mem_ctx, struct samr_info)) == NULL) {
return NULL;
}
talloc_set_destructor(info, samr_info_destructor);
@@ -444,15 +445,6 @@ static int samr_info_destructor(struct samr_info *info)
}
/*******************************************************************
- Function to free the per handle data.
- ********************************************************************/
-
-static void free_samr_info(void *ptr)
-{
- TALLOC_FREE(ptr);
-}
-
-/*******************************************************************
Idle event handler. Throw away the disp info cache.
********************************************************************/
@@ -653,12 +645,12 @@ NTSTATUS _samr_OpenDomain(pipes_struct *p,
}
/* associate the domain SID with the (unique) handle. */
- if ((info = get_samr_info_by_sid(r->in.sid))==NULL)
+ if ((info = get_samr_info_by_sid(p->mem_ctx, r->in.sid))==NULL)
return NT_STATUS_NO_MEMORY;
info->acc_granted = acc_granted;
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, r->out.domain_handle, free_samr_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.domain_handle, info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
DEBUG(5,("_samr_OpenDomain: %d\n", __LINE__));
@@ -2196,12 +2188,12 @@ NTSTATUS _samr_OpenUser(pipes_struct *p,
TALLOC_FREE(sampass);
/* associate the user's SID and access bits with the new handle. */
- if ((info = get_samr_info_by_sid(&sid)) == NULL)
+ if ((info = get_samr_info_by_sid(p->mem_ctx, &sid)) == NULL)
return NT_STATUS_NO_MEMORY;
info->acc_granted = acc_granted;
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, user_pol, free_samr_info, (void *)info))
+ if (!create_policy_hnd(p, user_pol, info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
return NT_STATUS_OK;
@@ -3161,7 +3153,7 @@ NTSTATUS _samr_CreateUser2(pipes_struct *p,
}
/* associate the user's SID with the new handle. */
- if ((info = get_samr_info_by_sid(&sid)) == NULL) {
+ if ((info = get_samr_info_by_sid(p->mem_ctx, &sid)) == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -3170,7 +3162,7 @@ NTSTATUS _samr_CreateUser2(pipes_struct *p,
info->acc_granted = acc_granted;
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, user_pol, free_samr_info, (void *)info)) {
+ if (!create_policy_hnd(p, user_pol, info)) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
@@ -3222,7 +3214,7 @@ NTSTATUS _samr_Connect(pipes_struct *p,
/* set up the SAMR connect_anon response */
/* associate the user's SID with the new handle. */
- if ((info = get_samr_info_by_sid(NULL)) == NULL)
+ if ((info = get_samr_info_by_sid(p->mem_ctx, NULL)) == NULL)
return NT_STATUS_NO_MEMORY;
/* don't give away the farm but this is probably ok. The SAMR_ACCESS_ENUM_DOMAINS
@@ -3235,7 +3227,7 @@ NTSTATUS _samr_Connect(pipes_struct *p,
info->acc_granted = des_access & (SAMR_ACCESS_ENUM_DOMAINS|SAMR_ACCESS_OPEN_DOMAIN);
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, r->out.connect_handle, free_samr_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.connect_handle, info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
return NT_STATUS_OK;
@@ -3289,14 +3281,14 @@ NTSTATUS _samr_Connect2(pipes_struct *p,
return nt_status;
/* associate the user's SID and access granted with the new handle. */
- if ((info = get_samr_info_by_sid(NULL)) == NULL)
+ if ((info = get_samr_info_by_sid(p->mem_ctx, NULL)) == NULL)
return NT_STATUS_NO_MEMORY;
info->acc_granted = acc_granted;
info->status = r->in.access_mask; /* this looks so wrong... - gd */
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, r->out.connect_handle, free_samr_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.connect_handle, info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
DEBUG(5,("%s: %d\n", fn, __LINE__));
@@ -3526,13 +3518,13 @@ NTSTATUS _samr_OpenAlias(pipes_struct *p,
}
/* associate the alias SID with the new handle. */
- if ((info = get_samr_info_by_sid(&sid)) == NULL)
+ if ((info = get_samr_info_by_sid(p->mem_ctx, &sid)) == NULL)
return NT_STATUS_NO_MEMORY;
info->acc_granted = acc_granted;
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, alias_pol, free_samr_info, (void *)info))
+ if (!create_policy_hnd(p, alias_pol, info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
return NT_STATUS_OK;
@@ -4947,7 +4939,7 @@ NTSTATUS _samr_CreateDomainGroup(pipes_struct *p,
sid_compose(&info_sid, get_global_sam_sid(), *r->out.rid);
- if ((info = get_samr_info_by_sid(&info_sid)) == NULL)
+ if ((info = get_samr_info_by_sid(p->mem_ctx, &info_sid)) == NULL)
return NT_STATUS_NO_MEMORY;
/* they created it; let the user do what he wants with it */
@@ -4955,7 +4947,7 @@ NTSTATUS _samr_CreateDomainGroup(pipes_struct *p,
info->acc_granted = GENERIC_RIGHTS_GROUP_ALL_ACCESS;
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, r->out.group_handle, free_samr_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.group_handle, info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
force_flush_samr_cache(disp_info);
@@ -5039,7 +5031,7 @@ NTSTATUS _samr_CreateDomAlias(pipes_struct *p,
return NT_STATUS_ACCESS_DENIED;
}
- if ((info = get_samr_info_by_sid(&info_sid)) == NULL)
+ if ((info = get_samr_info_by_sid(p->mem_ctx, &info_sid)) == NULL)
return NT_STATUS_NO_MEMORY;
/* they created it; let the user do what he wants with it */
@@ -5047,7 +5039,7 @@ NTSTATUS _samr_CreateDomAlias(pipes_struct *p,
info->acc_granted = GENERIC_RIGHTS_ALIAS_ALL_ACCESS;
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, r->out.alias_handle, free_samr_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.alias_handle, info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
force_flush_samr_cache(disp_info);
@@ -5418,7 +5410,7 @@ NTSTATUS _samr_OpenGroup(pipes_struct *p,
sid_append_rid(&info_sid, r->in.rid);
sid_to_fstring(sid_string, &info_sid);
- if ((info = get_samr_info_by_sid(&info_sid)) == NULL)
+ if ((info = get_samr_info_by_sid(p->mem_ctx, &info_sid)) == NULL)
return NT_STATUS_NO_MEMORY;
info->acc_granted = acc_granted;
@@ -5433,7 +5425,7 @@ NTSTATUS _samr_OpenGroup(pipes_struct *p,
return NT_STATUS_NO_SUCH_GROUP;
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, r->out.group_handle, free_samr_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.group_handle, info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
return NT_STATUS_OK;
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 5e2cc05056..123cbf9335 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -227,11 +227,6 @@ static int printer_entry_destructor(Printer_entry *Printer)
return 0;
}
-static void free_printer_entry(void *Printer)
-{
- TALLOC_FREE(Printer);
-}
-
/****************************************************************************
Functions to duplicate a SPOOL_NOTIFY_OPTION struct stored in Printer_entry.
****************************************************************************/
@@ -597,8 +592,8 @@ static bool open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint3
}
talloc_set_destructor(new_printer, printer_entry_destructor);
- if (!create_policy_hnd(p, hnd, free_printer_entry, new_printer)) {
- SAFE_FREE(new_printer);
+ if (!create_policy_hnd(p, hnd, new_printer)) {
+ TALLOC_FREE(new_printer);
return False;
}
diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c
index 56cbc815a3..16d409db74 100644
--- a/source3/rpc_server/srv_svcctl_nt.c
+++ b/source3/rpc_server/srv_svcctl_nt.c
@@ -167,15 +167,6 @@ static SEC_DESC* construct_scm_sd( TALLOC_CTX *ctx )
}
/******************************************************************
- free() function for REGISTRY_KEY
- *****************************************************************/
-
-static void free_service_handle_info(void *ptr)
-{
- TALLOC_FREE( ptr );
-}
-
-/******************************************************************
Find a registry key handle and return a SERVICE_INFO
*****************************************************************/
@@ -244,14 +235,14 @@ static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, u
/* store the SERVICE_INFO and create an open handle */
- if ( !create_policy_hnd( p, handle, free_service_handle_info, info ) ) {
+ if ( !create_policy_hnd( p, handle, info ) ) {
result = WERR_ACCESS_DENIED;
goto done;
}
done:
if ( !W_ERROR_IS_OK(result) )
- free_service_handle_info( info );
+ TALLOC_FREE(info);
return result;
}
diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c
index 1131033b04..8092601202 100644
--- a/source3/rpc_server/srv_winreg_nt.c
+++ b/source3/rpc_server/srv_winreg_nt.c
@@ -26,16 +26,6 @@
#define DBGC_CLASS DBGC_RPC_SRV
/******************************************************************
- free() function for struct registry_key
- *****************************************************************/
-
-static void free_regkey(void *ptr)
-{
- struct registry_key *key = (struct registry_key *)ptr;
- TALLOC_FREE(key);
-}
-
-/******************************************************************
Find a registry key handle and return a struct registry_key *
*****************************************************************/
@@ -69,19 +59,19 @@ static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd,
struct registry_key *key;
if (parent == NULL) {
- result = reg_openhive(NULL, subkeyname, access_desired,
+ result = reg_openhive(p->mem_ctx, subkeyname, access_desired,
p->server_info->ptok, &key);
}
else {
- result = reg_openkey(NULL, parent, subkeyname, access_desired,
- &key);
+ result = reg_openkey(p->mem_ctx, parent, subkeyname,
+ access_desired, &key);
}
if ( !W_ERROR_IS_OK(result) ) {
return result;
}
- if ( !create_policy_hnd( p, hnd, free_regkey, key ) ) {
+ if ( !create_policy_hnd( p, hnd, key ) ) {
return WERR_BADFILE;
}
@@ -755,7 +745,7 @@ WERROR _winreg_CreateKey( pipes_struct *p, struct winreg_CreateKey *r)
return result;
}
- if (!create_policy_hnd(p, r->out.new_handle, free_regkey, new_key)) {
+ if (!create_policy_hnd(p, r->out.new_handle, new_key)) {
TALLOC_FREE(new_key);
return WERR_BADFILE;
}