mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
r6876: - fixed a memory leak in the cldap server
- keep the samdb open between requests
(This used to be commit ee75a8353b
)
This commit is contained in:
parent
b836187484
commit
13a3fdf933
@ -130,6 +130,7 @@ static void cldapd_task_init(struct task_server *task)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cldapd->task = task;
|
cldapd->task = task;
|
||||||
|
cldapd->samctx = NULL;
|
||||||
|
|
||||||
/* start listening on the configured network interfaces */
|
/* start listening on the configured network interfaces */
|
||||||
status = cldapd_startup_interfaces(cldapd);
|
status = cldapd_startup_interfaces(cldapd);
|
||||||
|
@ -27,5 +27,5 @@
|
|||||||
*/
|
*/
|
||||||
struct cldapd_server {
|
struct cldapd_server {
|
||||||
struct task_server *task;
|
struct task_server *task;
|
||||||
const char *dns_domain;
|
struct ldb_context *samctx;
|
||||||
};
|
};
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
/*
|
/*
|
||||||
fill in the cldap netlogon union for a given version
|
fill in the cldap netlogon union for a given version
|
||||||
*/
|
*/
|
||||||
static NTSTATUS cldapd_netlogon_fill(struct cldap_socket *cldap,
|
static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd,
|
||||||
TALLOC_CTX *mem_ctx,
|
TALLOC_CTX *mem_ctx,
|
||||||
const char *domain,
|
const char *domain,
|
||||||
const char *domain_guid,
|
const char *domain_guid,
|
||||||
@ -39,7 +39,6 @@ static NTSTATUS cldapd_netlogon_fill(struct cldap_socket *cldap,
|
|||||||
uint32_t version,
|
uint32_t version,
|
||||||
union nbt_cldap_netlogon *netlogon)
|
union nbt_cldap_netlogon *netlogon)
|
||||||
{
|
{
|
||||||
struct ldb_context *samctx;
|
|
||||||
const char *attrs[] = {"realm", "dnsDomain", "objectGUID", "name", NULL};
|
const char *attrs[] = {"realm", "dnsDomain", "objectGUID", "name", NULL};
|
||||||
struct ldb_message **res;
|
struct ldb_message **res;
|
||||||
int ret;
|
int ret;
|
||||||
@ -55,11 +54,13 @@ static NTSTATUS cldapd_netlogon_fill(struct cldap_socket *cldap,
|
|||||||
const char *site_name2;
|
const char *site_name2;
|
||||||
const char *pdc_ip;
|
const char *pdc_ip;
|
||||||
|
|
||||||
samctx = samdb_connect(mem_ctx);
|
if (cldapd->samctx == NULL) {
|
||||||
if (samctx == NULL) {
|
cldapd->samctx = samdb_connect(mem_ctx);
|
||||||
|
if (cldapd->samctx == NULL) {
|
||||||
DEBUG(2,("Unable to open sam in cldap netlogon reply\n"));
|
DEBUG(2,("Unable to open sam in cldap netlogon reply\n"));
|
||||||
return NT_STATUS_INTERNAL_DB_CORRUPTION;
|
return NT_STATUS_INTERNAL_DB_CORRUPTION;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* the domain has an optional trailing . */
|
/* the domain has an optional trailing . */
|
||||||
if (domain && domain[strlen(domain)-1] == '.') {
|
if (domain && domain[strlen(domain)-1] == '.') {
|
||||||
@ -67,7 +68,7 @@ static NTSTATUS cldapd_netlogon_fill(struct cldap_socket *cldap,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* try and find the domain */
|
/* try and find the domain */
|
||||||
ret = gendb_search(samctx, samctx, NULL, &res, attrs,
|
ret = gendb_search(cldapd->samctx, mem_ctx, NULL, &res, attrs,
|
||||||
"(&(objectClass=domainDNS)(|(dnsDomain=%s)(objectGUID=%s)))",
|
"(&(objectClass=domainDNS)(|(dnsDomain=%s)(objectGUID=%s)))",
|
||||||
domain?domain:"",
|
domain?domain:"",
|
||||||
domain_guid?domain_guid:"");
|
domain_guid?domain_guid:"");
|
||||||
@ -177,6 +178,7 @@ void cldapd_netlogon_request(struct cldap_socket *cldap,
|
|||||||
const char *filter,
|
const char *filter,
|
||||||
const char *src_address, int src_port)
|
const char *src_address, int src_port)
|
||||||
{
|
{
|
||||||
|
struct cldapd_server *cldapd = talloc_get_type(cldap->incoming.private, struct cldapd_server);
|
||||||
struct ldap_parse_tree *tree;
|
struct ldap_parse_tree *tree;
|
||||||
int i;
|
int i;
|
||||||
const char *domain = NULL;
|
const char *domain = NULL;
|
||||||
@ -191,7 +193,7 @@ void cldapd_netlogon_request(struct cldap_socket *cldap,
|
|||||||
|
|
||||||
TALLOC_CTX *tmp_ctx = talloc_new(cldap);
|
TALLOC_CTX *tmp_ctx = talloc_new(cldap);
|
||||||
|
|
||||||
DEBUG(0,("cldap filter='%s'\n", filter));
|
DEBUG(5,("cldap filter='%s'\n", filter));
|
||||||
|
|
||||||
tree = ldap_parse_filter_string(tmp_ctx, filter);
|
tree = ldap_parse_filter_string(tmp_ctx, filter);
|
||||||
if (tree == NULL) goto failed;
|
if (tree == NULL) goto failed;
|
||||||
@ -249,10 +251,10 @@ void cldapd_netlogon_request(struct cldap_socket *cldap,
|
|||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(0,("cldap netlogon query domain=%s host=%s user=%s version=%d guid=%s\n",
|
DEBUG(5,("cldap netlogon query domain=%s host=%s user=%s version=%d guid=%s\n",
|
||||||
domain, host, user, version, domain_guid));
|
domain, host, user, version, domain_guid));
|
||||||
|
|
||||||
status = cldapd_netlogon_fill(cldap, tmp_ctx, domain, domain_guid,
|
status = cldapd_netlogon_fill(cldapd, tmp_ctx, domain, domain_guid,
|
||||||
user, src_address,
|
user, src_address,
|
||||||
version, &netlogon);
|
version, &netlogon);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user