[SCM] Samba Shared Repository - branch master updated -
84292022bf801112d2cb7f0f8512cf00079def20
Volker Lendecke
vlendec at samba.org
Thu Jan 8 21:30:38 GMT 2009
The branch, master has been updated
via 84292022bf801112d2cb7f0f8512cf00079def20 (commit)
via 825500f5dafb848b95f5a5ea6595cc24f377bc3a (commit)
via e94d7f53f9339b73ee5b20f5061b9b74f9866cee (commit)
via baa5c5eeb0c86ac9ae9edfd15da2621d2959938a (commit)
via 52b6756c4e5c0ab7cd74e23de36ac5df217d103b (commit)
via 5a4f71d40cbcfc67802fb2cbc45d8d74a9312342 (commit)
from 8cddcefb134ce33b853f45c7512aa78b5d720f23 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 84292022bf801112d2cb7f0f8512cf00079def20
Author: Volker Lendecke <vl at samba.org>
Date: Wed Jan 7 18:44:52 2009 +0100
Now that all policy_handle free_fn's are just TALLOC_FREE, dump free_fn
commit 825500f5dafb848b95f5a5ea6595cc24f377bc3a
Author: Volker Lendecke <vl at samba.org>
Date: Wed Jan 7 18:11:24 2009 +0100
Use TALLOC for struct lsa_info
commit e94d7f53f9339b73ee5b20f5061b9b74f9866cee
Author: Volker Lendecke <vl at samba.org>
Date: Wed Jan 7 18:06:21 2009 +0100
Make use of a talloc_destructor for free_printer_entry
commit baa5c5eeb0c86ac9ae9edfd15da2621d2959938a
Author: Volker Lendecke <vl at samba.org>
Date: Wed Jan 7 17:56:08 2009 +0100
Make use of a talloc_destructor for free_eventlog_info()
commit 52b6756c4e5c0ab7cd74e23de36ac5df217d103b
Author: Volker Lendecke <vl at samba.org>
Date: Wed Jan 7 17:48:10 2009 +0100
Make samr_info a talloc context of its own
commit 5a4f71d40cbcfc67802fb2cbc45d8d74a9312342
Author: Volker Lendecke <vl at samba.org>
Date: Wed Jan 7 17:36:54 2009 +0100
Simplify init_pipe_handle_list a bit
-----------------------------------------------------------------------
Summary of changes:
source3/include/nt_printing.h | 1 -
source3/include/ntdomain.h | 1 -
source3/include/proto.h | 2 +-
source3/rpc_server/srv_eventlog_nt.c | 19 ++++-----
source3/rpc_server/srv_lsa_hnd.c | 71 +++++++++++++++++-----------------
source3/rpc_server/srv_lsa_nt.c | 39 ++++++++-----------
source3/rpc_server/srv_samr_nt.c | 61 +++++++++++++----------------
source3/rpc_server/srv_spoolss_nt.c | 28 ++++---------
source3/rpc_server/srv_svcctl_nt.c | 13 +-----
source3/rpc_server/srv_winreg_nt.c | 20 ++-------
10 files changed, 104 insertions(+), 151 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/include/nt_printing.h b/source3/include/nt_printing.h
index 479404d..f515a40 100644
--- a/source3/include/nt_printing.h
+++ b/source3/include/nt_printing.h
@@ -452,7 +452,6 @@ typedef struct _Printer{
bool page_started;
uint32 jobid; /* jobid in printing backend */
int printer_type;
- TALLOC_CTX *ctx;
fstring servername;
fstring sharename;
uint32 type;
diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h
index bffa158..3f50155 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 afc207b..96b2e26 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 e5be325..145b460 100644
--- a/source3/rpc_server/srv_eventlog_nt.c
+++ b/source3/rpc_server/srv_eventlog_nt.c
@@ -37,14 +37,12 @@ typedef struct {
/********************************************************************
********************************************************************/
-static void free_eventlog_info( void *ptr )
+static int eventlog_info_destructor(EVENTLOG_INFO *elog)
{
- EVENTLOG_INFO *elog = (EVENTLOG_INFO *)ptr;
-
- if ( elog->etdb )
- elog_close_tdb( elog->etdb, False );
-
- TALLOC_FREE( elog );
+ if (elog->etdb) {
+ elog_close_tdb(elog->etdb, false);
+ }
+ return 0;
}
/********************************************************************
@@ -186,6 +184,7 @@ static NTSTATUS elog_open( pipes_struct * p, const char *logname, POLICY_HND *hn
if ( !(elog = TALLOC_ZERO_P( NULL, EVENTLOG_INFO )) )
return NT_STATUS_NO_MEMORY;
+ talloc_set_destructor(elog, eventlog_info_destructor);
elog->logname = talloc_strdup( elog, logname );
@@ -228,16 +227,14 @@ static NTSTATUS elog_open( pipes_struct * p, const char *logname, POLICY_HND *hn
/* now do the access check. Close the tdb if we fail here */
if ( !elog_check_access( elog, p->server_info->ptok ) ) {
- elog_close_tdb( elog->etdb, False );
TALLOC_FREE( elog );
return NT_STATUS_ACCESS_DENIED;
}
/* 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 839833c..5f7c8d9 100644
--- a/source3/rpc_server/srv_lsa_hnd.c
+++ b/source3/rpc_server/srv_lsa_hnd.c
@@ -46,35 +46,38 @@ static bool is_samr_lsa_pipe(const char *pipe_name)
bool init_pipe_handle_list(pipes_struct *p, const char *pipe_name)
{
- pipes_struct *plist = get_first_internal_pipe();
- struct handle_list *hl = NULL;
-
- for (plist = get_first_internal_pipe(); plist; plist = get_next_internal_pipe(plist)) {
- if (strequal( plist->name, pipe_name) ||
- (is_samr_lsa_pipe(plist->name) && is_samr_lsa_pipe(pipe_name))) {
- if (!plist->pipe_handles) {
- char *msg;
- if (asprintf(&msg, "init_pipe_handles: NULL "
- "pipe_handle pointer in pipe %s",
- pipe_name) != -1) {
- smb_panic(msg);
- } else {
- smb_panic("init_pipe_handle_list");
- }
- }
- hl = plist->pipe_handles;
+ pipes_struct *plist;
+ struct handle_list *hl;
+
+ for (plist = get_first_internal_pipe();
+ plist;
+ plist = get_next_internal_pipe(plist)) {
+ if (strequal(plist->name, pipe_name)) {
+ break;
+ }
+ if (is_samr_lsa_pipe(plist->name)
+ && is_samr_lsa_pipe(pipe_name)) {
+ /*
+ * samr and lsa share a handle space (same process
+ * under Windows?)
+ */
break;
}
}
- if (!hl) {
+ if (plist != NULL) {
+ hl = plist->pipe_handles;
+ if (hl == NULL) {
+ return false;
+ }
+ } else {
/*
- * No handle list for this pipe (first open of pipe).
- * Create list.
+ * First open, we have to create the handle list
*/
-
- if ((hl = SMB_MALLOC_P(struct handle_list)) == NULL)
- return False;
+ hl = SMB_MALLOC_P(struct handle_list);
+ if (hl == NULL) {
+ return false;
+ }
ZERO_STRUCTP(hl);
DEBUG(10,("init_pipe_handles: created handle list for pipe %s\n", pipe_name ));
@@ -100,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;
@@ -116,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)
@@ -208,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 3063427..ed54c3a 100644
--- a/source3/rpc_server/srv_lsa_nt.c
+++ b/source3/rpc_server/srv_lsa_nt.c
@@ -96,17 +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)
-{
- struct lsa_info *lsa = (struct lsa_info *)ptr;
-
- SAFE_FREE(lsa);
-}
-
/***************************************************************************
initialize a lsa_DomainInfo structure.
***************************************************************************/
@@ -400,15 +389,16 @@ NTSTATUS _lsa_OpenPolicy2(pipes_struct *p,
acc_granted = LSA_POLICY_ALL_ACCESS;
/* associate the domain SID with the (unique) handle. */
- if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
+ info = TALLOC_ZERO_P(p->mem_ctx, struct lsa_info);
+ if (info == NULL) {
return NT_STATUS_NO_MEMORY;
+ }
- ZERO_STRUCTP(info);
sid_copy(&info->sid,get_global_sam_sid());
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;
@@ -448,15 +438,16 @@ NTSTATUS _lsa_OpenPolicy(pipes_struct *p,
}
/* associate the domain SID with the (unique) handle. */
- if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
+ info = TALLOC_ZERO_P(p->mem_ctx, struct lsa_info);
+ if (info == NULL) {
return NT_STATUS_NO_MEMORY;
+ }
- ZERO_STRUCTP(info);
sid_copy(&info->sid,get_global_sam_sid());
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,15 +1546,16 @@ NTSTATUS _lsa_CreateAccount(pipes_struct *p,
/* associate the user/group SID with the (unique) handle. */
- if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
+ info = TALLOC_ZERO_P(p->mem_ctx, struct lsa_info);
+ if (info == NULL) {
return NT_STATUS_NO_MEMORY;
+ }
- ZERO_STRUCTP(info);
info->sid = *r->in.sid;
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 );
@@ -1599,15 +1591,16 @@ NTSTATUS _lsa_OpenAccount(pipes_struct *p,
return NT_STATUS_ACCESS_DENIED;
#endif
/* associate the user/group SID with the (unique) handle. */
- if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
+ info = TALLOC_ZERO_P(p->mem_ctx, struct lsa_info);
+ if (info == NULL) {
return NT_STATUS_NO_MEMORY;
+ }
- ZERO_STRUCTP(info);
info->sid = *r->in.sid;
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 afaf564..9984bf0 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -73,7 +73,6 @@ struct samr_info {
uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */
uint32 acc_granted;
DISP_INFO *disp_info;
- TALLOC_CTX *mem_ctx;
};
static const struct generic_mapping sam_generic_mapping = {
@@ -357,11 +356,13 @@ static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid)
Create a samr_info struct.
********************************************************************/
-static struct samr_info *get_samr_info_by_sid(DOM_SID *psid)
+static int samr_info_destructor(struct samr_info *info);
+
+static struct samr_info *get_samr_info_by_sid(TALLOC_CTX *mem_ctx,
+ DOM_SID *psid)
{
struct samr_info *info;
fstring sid_str;
- TALLOC_CTX *mem_ctx;
if (psid) {
sid_to_fstring(sid_str, psid);
@@ -369,10 +370,10 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid)
fstrcpy(sid_str,"(NULL)");
}
- mem_ctx = talloc_init("samr_info for domain sid %s", sid_str);
-
- if ((info = TALLOC_ZERO_P(mem_ctx, struct samr_info)) == NULL)
+ if ((info = TALLOC_ZERO_P(mem_ctx, struct samr_info)) == NULL) {
return NULL;
+ }
+ talloc_set_destructor(info, samr_info_destructor);
DEBUG(10,("get_samr_info_by_sid: created new info for sid %s\n", sid_str));
if (psid) {
@@ -382,7 +383,6 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid)
DEBUG(10,("get_samr_info_by_sid: created new info for NULL sid.\n"));
info->builtin_domain = False;
}
- info->mem_ctx = mem_ctx;
info->disp_info = get_samr_dispinfo_by_sid(psid);
@@ -433,22 +433,15 @@ static void free_samr_cache(DISP_INFO *disp_info)
unbecome_root();
}
-/*******************************************************************
- Function to free the per handle data.
- ********************************************************************/
-
-static void free_samr_info(void *ptr)
+static int samr_info_destructor(struct samr_info *info)
{
- struct samr_info *info=(struct samr_info *) ptr;
-
/* Only free the dispinfo cache if no one bothered to set up
a timeout. */
if (info->disp_info && info->disp_info->cache_timeout_event == NULL) {
free_samr_cache(info->disp_info);
}
-
- talloc_destroy(info->mem_ctx);
+ return 0;
}
/*******************************************************************
@@ -652,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__));
@@ -2195,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;
@@ -3160,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;
}
@@ -3169,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;
}
@@ -3221,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
@@ -3234,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;
@@ -3288,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__));
@@ -3525,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;
@@ -4946,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 */
@@ -4954,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;
--
Samba Shared Repository
More information about the samba-cvs
mailing list