diff options
Diffstat (limited to 'source4')
26 files changed, 56 insertions, 42 deletions
diff --git a/source4/cldap_server/cldap_server.c b/source4/cldap_server/cldap_server.c index 8f6c9410f8..47597ff1db 100644 --- a/source4/cldap_server/cldap_server.c +++ b/source4/cldap_server/cldap_server.c @@ -159,7 +159,7 @@ static void cldapd_task_init(struct task_server *task) NTSTATUS status; struct interface *ifaces; - load_interfaces(lp_interfaces(task->lp_ctx), &ifaces); + load_interfaces(task, lp_interfaces(task->lp_ctx), &ifaces); if (iface_count(ifaces) == 0) { task_server_terminate(task, "cldapd: no network interfaces configured"); diff --git a/source4/cldap_server/netlogon.c b/source4/cldap_server/netlogon.c index 1c2b51aed7..b79d678e88 100644 --- a/source4/cldap_server/netlogon.c +++ b/source4/cldap_server/netlogon.c @@ -188,7 +188,7 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd, lp_workgroup(lp_ctx)); server_site = "Default-First-Site-Name"; client_site = "Default-First-Site-Name"; - load_interfaces(lp_interfaces(lp_ctx), &ifaces); + load_interfaces(mem_ctx, lp_interfaces(lp_ctx), &ifaces); pdc_ip = iface_best_ip(ifaces, src_address); ZERO_STRUCTP(netlogon); diff --git a/source4/heimdal_build/glue.c b/source4/heimdal_build/glue.c index 809b63f418..07062ae8bf 100644 --- a/source4/heimdal_build/glue.c +++ b/source4/heimdal_build/glue.c @@ -33,11 +33,12 @@ krb5_error_code KRB5_LIB_FUNCTION krb5_get_all_client_addrs(krb5_context context int i; struct interface *ifaces; - load_interfaces(lp_interfaces(global_loadparm), &ifaces); + load_interfaces(NULL, lp_interfaces(global_loadparm), &ifaces); res->len = iface_count(ifaces); res->val = malloc_array_p(HostAddress, res->len); if (res->val == NULL) { + talloc_free(ifaces); return ENOMEM; } for (i=0;i<res->len;i++) { @@ -46,11 +47,14 @@ krb5_error_code KRB5_LIB_FUNCTION krb5_get_all_client_addrs(krb5_context context res->val[i].address.length = 4; res->val[i].address.data = malloc(4); if (res->val[i].address.data == NULL) { + talloc_free(ifaces); return ENOMEM; } ((struct in_addr *)res->val[i].address.data)->s_addr = inet_addr(ip); } + talloc_free(ifaces); + return 0; } diff --git a/source4/kdc/kdc.c b/source4/kdc/kdc.c index 0301a4c264..5c8b2afe0f 100644 --- a/source4/kdc/kdc.c +++ b/source4/kdc/kdc.c @@ -574,7 +574,7 @@ static void kdc_task_init(struct task_server *task) break; } - load_interfaces(lp_interfaces(task->lp_ctx), &ifaces); + load_interfaces(task, lp_interfaces(task->lp_ctx), &ifaces); if (iface_count(ifaces) == 0) { task_server_terminate(task, "kdc: no network interfaces configured"); diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c index 9d3fa0ada4..f0b5e56205 100644 --- a/source4/ldap_server/ldap_server.c +++ b/source4/ldap_server/ldap_server.c @@ -550,7 +550,7 @@ static void ldapsrv_task_init(struct task_server *task) int num_interfaces; int i; - load_interfaces(lp_interfaces(task->lp_ctx), &ifaces); + load_interfaces(task, lp_interfaces(task->lp_ctx), &ifaces); num_interfaces = iface_count(ifaces); /* We have been given an interfaces line, and been diff --git a/source4/lib/socket/interface.c b/source4/lib/socket/interface.c index d21923d972..241fcbff5e 100644 --- a/source4/lib/socket/interface.c +++ b/source4/lib/socket/interface.c @@ -63,7 +63,7 @@ static struct interface *iface_find(struct interface *interfaces, /**************************************************************************** add an interface to the linked list of interfaces ****************************************************************************/ -static void add_interface(struct in_addr ip, struct in_addr nmask, struct interface **interfaces) +static void add_interface(TALLOC_CTX *mem_ctx, struct in_addr ip, struct in_addr nmask, struct interface **interfaces) { struct interface *iface; struct in_addr bcast; @@ -73,7 +73,7 @@ static void add_interface(struct in_addr ip, struct in_addr nmask, struct interf return; } - iface = talloc(*interfaces == NULL ? talloc_autofree_context() : *interfaces, struct interface); + iface = talloc(*interfaces == NULL ? mem_ctx : *interfaces, struct interface); if (iface == NULL) return; @@ -110,7 +110,8 @@ This handles the following different forms: 4) ip/mask 5) bcast/mask **/ -static void interpret_interface(const char *token, +static void interpret_interface(TALLOC_CTX *mem_ctx, + const char *token, struct iface_struct *probed_ifaces, int total_probed, struct interface **local_interfaces) @@ -125,7 +126,7 @@ static void interpret_interface(const char *token, /* first check if it is an interface name */ for (i=0;i<total_probed;i++) { if (gen_fnmatch(token, probed_ifaces[i].name) == 0) { - add_interface(probed_ifaces[i].ip, + add_interface(mem_ctx, probed_ifaces[i].ip, probed_ifaces[i].netmask, local_interfaces); added = 1; @@ -143,7 +144,7 @@ static void interpret_interface(const char *token, ip.s_addr = interpret_addr2(token).s_addr; for (i=0;i<total_probed;i++) { if (ip.s_addr == probed_ifaces[i].ip.s_addr) { - add_interface(probed_ifaces[i].ip, + add_interface(mem_ctx, probed_ifaces[i].ip, probed_ifaces[i].netmask, local_interfaces); return; @@ -169,7 +170,7 @@ static void interpret_interface(const char *token, ip.s_addr == MKNETADDR(ip.s_addr, nmask.s_addr)) { for (i=0;i<total_probed;i++) { if (same_net(ip, probed_ifaces[i].ip, nmask)) { - add_interface(probed_ifaces[i].ip, nmask, + add_interface(mem_ctx, probed_ifaces[i].ip, nmask, local_interfaces); return; } @@ -178,14 +179,14 @@ static void interpret_interface(const char *token, return; } - add_interface(ip, nmask, local_interfaces); + add_interface(mem_ctx, ip, nmask, local_interfaces); } /** load the list of network interfaces **/ -void load_interfaces(const char **interfaces, struct interface **local_interfaces) +void load_interfaces(TALLOC_CTX *mem_ctx, const char **interfaces, struct interface **local_interfaces) { const char **ptr = interfaces; int i; @@ -208,14 +209,14 @@ void load_interfaces(const char **interfaces, struct interface **local_interface } for (i=0;i<total_probed;i++) { if (ifaces[i].ip.s_addr != loopback_ip.s_addr) { - add_interface(ifaces[i].ip, + add_interface(mem_ctx, ifaces[i].ip, ifaces[i].netmask, local_interfaces); } } } while (ptr && *ptr) { - interpret_interface(*ptr, ifaces, total_probed, local_interfaces); + interpret_interface(mem_ctx, *ptr, ifaces, total_probed, local_interfaces); ptr++; } diff --git a/source4/lib/socket/testsuite.c b/source4/lib/socket/testsuite.c index a99ae078b5..6d4d81a884 100644 --- a/source4/lib/socket/testsuite.c +++ b/source4/lib/socket/testsuite.c @@ -42,7 +42,7 @@ static bool test_udp(struct torture_context *tctx) TALLOC_CTX *mem_ctx = tctx; struct interface *ifaces; - load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces); + load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces); status = socket_create("ip", SOCKET_TYPE_DGRAM, &sock1, 0); torture_assert_ntstatus_ok(tctx, status, "creating DGRAM IP socket 1"); @@ -135,7 +135,7 @@ static bool test_tcp(struct torture_context *tctx) torture_assert_ntstatus_ok(tctx, status, "creating IP stream socket 1"); talloc_steal(mem_ctx, sock2); - load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces); + load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces); localhost = socket_address_from_strings(sock1, sock1->backend_name, iface_best_ip(ifaces, "127.0.0.1"), 0); torture_assert(tctx, localhost, "Localhost not found"); diff --git a/source4/libcli/resolve/bcast.c b/source4/libcli/resolve/bcast.c index d1f3d65faf..1dd9328760 100644 --- a/source4/libcli/resolve/bcast.c +++ b/source4/libcli/resolve/bcast.c @@ -86,7 +86,7 @@ NTSTATUS resolve_name_bcast(struct nbt_name *name, bool resolve_context_add_bcast_method(struct resolve_context *ctx, struct loadparm_context *lp_ctx) { struct interface *ifaces; - load_interfaces(lp_interfaces(lp_ctx), &ifaces); + load_interfaces(ctx, lp_interfaces(lp_ctx), &ifaces); return resolve_context_add_method(ctx, resolve_name_bcast_send, resolve_name_bcast_recv, ifaces); } diff --git a/source4/libcli/resolve/nbtlist.c b/source4/libcli/resolve/nbtlist.c index 6c12fe706b..595743e693 100644 --- a/source4/libcli/resolve/nbtlist.c +++ b/source4/libcli/resolve/nbtlist.c @@ -76,7 +76,7 @@ static void nbtlist_handler(struct nbt_name_request *req) } /* favor a local address if possible */ - load_interfaces(lp_interfaces(global_loadparm), &ifaces); + load_interfaces(NULL, lp_interfaces(global_loadparm), &ifaces); state->reply_addr = NULL; for (i=0;i<q->out.num_addrs;i++) { if (iface_is_local(ifaces, q->out.reply_addrs[i])) { @@ -85,6 +85,7 @@ static void nbtlist_handler(struct nbt_name_request *req) break; } } + talloc_free(ifaces); if (state->reply_addr == NULL) { state->reply_addr = talloc_steal(state, diff --git a/source4/libcli/wrepl/winsrepl.c b/source4/libcli/wrepl/winsrepl.c index 15dc98f675..63b0a60f6c 100644 --- a/source4/libcli/wrepl/winsrepl.c +++ b/source4/libcli/wrepl/winsrepl.c @@ -334,7 +334,7 @@ struct composite_context *wrepl_connect_send(struct wrepl_socket *wrepl_socket, if (!our_ip) { struct interface *ifaces; - load_interfaces(lp_interfaces(global_loadparm), &ifaces); + load_interfaces(state, lp_interfaces(global_loadparm), &ifaces); our_ip = iface_best_ip(ifaces, peer_ip); } diff --git a/source4/nbt_server/nbt_server.c b/source4/nbt_server/nbt_server.c index 14b8d2461c..c7fb3b286a 100644 --- a/source4/nbt_server/nbt_server.c +++ b/source4/nbt_server/nbt_server.c @@ -39,7 +39,7 @@ static void nbtd_task_init(struct task_server *task) NTSTATUS status; struct interface *ifaces; - load_interfaces(lp_interfaces(task->lp_ctx), &ifaces); + load_interfaces(task, lp_interfaces(task->lp_ctx), &ifaces); if (iface_count(ifaces) == 0) { task_server_terminate(task, "nbtd: no network interfaces configured"); diff --git a/source4/nbt_server/wins/wins_ldb.c b/source4/nbt_server/wins/wins_ldb.c index 6fef218056..47aa415667 100644 --- a/source4/nbt_server/wins/wins_ldb.c +++ b/source4/nbt_server/wins/wins_ldb.c @@ -91,7 +91,7 @@ static int wins_ldb_init(struct ldb_module *ctx) owner = lp_parm_string(lp_ctx, NULL, "winsdb", "local_owner"); if (!owner) { struct interface *ifaces; - load_interfaces(lp_interfaces(lp_ctx), &ifaces); + load_interfaces(ctx, lp_interfaces(lp_ctx), &ifaces); owner = iface_n_ip(ifaces, 0); if (!owner) { owner = "0.0.0.0"; diff --git a/source4/nbt_server/wins/winsserver.c b/source4/nbt_server/wins/winsserver.c index e24ad85376..6219e6de68 100644 --- a/source4/nbt_server/wins/winsserver.c +++ b/source4/nbt_server/wins/winsserver.c @@ -980,7 +980,7 @@ NTSTATUS nbtd_winsserver_init(struct nbtd_server *nbtsrv) if (owner == NULL) { struct interface *ifaces; - load_interfaces(lp_interfaces(nbtsrv->task->lp_ctx), &ifaces); + load_interfaces(nbtsrv->task, lp_interfaces(nbtsrv->task->lp_ctx), &ifaces); owner = iface_n_ip(ifaces, 0); } diff --git a/source4/rpc_server/service_rpc.c b/source4/rpc_server/service_rpc.c index 363d5971c9..33a86851a8 100644 --- a/source4/rpc_server/service_rpc.c +++ b/source4/rpc_server/service_rpc.c @@ -374,14 +374,16 @@ static NTSTATUS dcesrv_add_ep_tcp(struct dcesrv_context *dce_ctx, struct event_context *event_ctx, const struct model_ops *model_ops) { NTSTATUS status; - struct interface *ifaces; - - load_interfaces(lp_interfaces(lp_ctx), &ifaces); /* Add TCP/IP sockets */ if (lp_interfaces(lp_ctx) && lp_bind_interfaces_only(lp_ctx)) { - int num_interfaces = iface_count(ifaces); + int num_interfaces; int i; + struct interface *ifaces; + + load_interfaces(dce_ctx, lp_interfaces(lp_ctx), &ifaces); + + num_interfaces = iface_count(ifaces); for(i = 0; i < num_interfaces; i++) { const char *address = iface_n_ip(ifaces, i); status = add_socket_rpc_tcp_iface(dce_ctx, e, event_ctx, model_ops, address); diff --git a/source4/scripting/ejs/smbcalls_sys.c b/source4/scripting/ejs/smbcalls_sys.c index cc1c3b4e32..72ddf90231 100644 --- a/source4/scripting/ejs/smbcalls_sys.c +++ b/source4/scripting/ejs/smbcalls_sys.c @@ -36,12 +36,14 @@ static int ejs_sys_interfaces(MprVarHandle eid, int argc, struct MprVar **argv) struct MprVar ret = mprArray("interfaces"); struct interface *ifaces; - load_interfaces(lp_interfaces(global_loadparm), &ifaces); + load_interfaces(NULL, lp_interfaces(global_loadparm), &ifaces); count = iface_count(ifaces); for (i=0;i<count;i++) { mprAddArray(&ret, i, mprString(iface_n_ip(ifaces, i))); } + + talloc_free(ifaces); mpr_Return(eid, ret); return 0; } diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c index 1dd022405a..bc17d100c5 100644 --- a/source4/smb_server/smb_server.c +++ b/source4/smb_server/smb_server.c @@ -222,7 +222,7 @@ static void smbsrv_task_init(struct task_server *task) int i; struct interface *ifaces; - load_interfaces(lp_interfaces(task->lp_ctx), &ifaces); + load_interfaces(task, lp_interfaces(task->lp_ctx), &ifaces); num_interfaces = iface_count(ifaces); diff --git a/source4/torture/nbt/dgram.c b/source4/torture/nbt/dgram.c index d8903eedac..0315989d66 100644 --- a/source4/torture/nbt/dgram.c +++ b/source4/torture/nbt/dgram.c @@ -89,7 +89,7 @@ static bool nbt_test_netlogon(struct torture_context *tctx) resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, event_context_find(tctx)), talloc_asprintf(tctx, "Failed to resolve %s", name.name)); - load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces); + load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces); myaddress = talloc_strdup(dgmsock, iface_best_ip(ifaces, address)); @@ -171,7 +171,7 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, event_context_find(tctx)), talloc_asprintf(tctx, "Failed to resolve %s", name.name)); - load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces); + load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces); myaddress = talloc_strdup(dgmsock, iface_best_ip(ifaces, address)); socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, @@ -283,7 +283,7 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, event_context_find(tctx)), talloc_asprintf(tctx, "Failed to resolve %s", name.name)); - load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces); + load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces); myaddress = talloc_strdup(dgmsock, iface_best_ip(ifaces, address)); socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, diff --git a/source4/torture/nbt/register.c b/source4/torture/nbt/register.c index 090027be2e..508c6b4840 100644 --- a/source4/torture/nbt/register.c +++ b/source4/torture/nbt/register.c @@ -54,7 +54,7 @@ static bool nbt_register_own(struct torture_context *tctx) if (!torture_nbt_get_name(tctx, &name, &address)) return false; - load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces); + load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces); myaddress = iface_best_ip(ifaces, address); @@ -123,7 +123,7 @@ static bool nbt_refresh_own(struct torture_context *tctx) if (!torture_nbt_get_name(tctx, &name, &address)) return false; - load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces); + load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces); myaddress = iface_best_ip(ifaces, address); diff --git a/source4/torture/nbt/wins.c b/source4/torture/nbt/wins.c index 0d895ddd0d..a236099a13 100644 --- a/source4/torture/nbt/wins.c +++ b/source4/torture/nbt/wins.c @@ -58,7 +58,7 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address struct socket_address *socket_address; struct interface *ifaces; - load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces); + load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces); myaddress = talloc_strdup(tctx, iface_best_ip(ifaces, address)); diff --git a/source4/torture/nbt/winsbench.c b/source4/torture/nbt/winsbench.c index 95241a1a12..db9371977e 100644 --- a/source4/torture/nbt/winsbench.c +++ b/source4/torture/nbt/winsbench.c @@ -245,7 +245,7 @@ static bool bench_wins(struct torture_context *tctx) state->registered = talloc_zero_array(state, bool, state->num_names); state->wins_server = address; state->wins_port = lp_nbt_port(tctx->lp_ctx); - load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces); + load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces); state->my_ip = talloc_strdup(tctx, iface_best_ip(ifaces, address)); state->ttl = timelimit; diff --git a/source4/torture/nbt/winsreplication.c b/source4/torture/nbt/winsreplication.c index b90daa98c4..d1c8e9a961 100644 --- a/source4/torture/nbt/winsreplication.c +++ b/source4/torture/nbt/winsreplication.c @@ -613,7 +613,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx( ctx->nbtsock = nbt_name_socket_init(ctx, NULL); if (!ctx->nbtsock) return NULL; - load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces); + load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces); ctx->myaddr = socket_address_from_strings(tctx, ctx->nbtsock->sock->backend_name, iface_best_ip(ifaces, address), 0); if (!ctx->myaddr) return NULL; diff --git a/source4/torture/rpc/spoolss_notify.c b/source4/torture/rpc/spoolss_notify.c index 48ddcb6a60..559c50df45 100644 --- a/source4/torture/rpc/spoolss_notify.c +++ b/source4/torture/rpc/spoolss_notify.c @@ -227,7 +227,7 @@ static bool test_RFFPCNEx(struct torture_context *tctx, lp_set_cmdline(tctx->lp_ctx, "dcerpc endpoint servers", "spoolss"); - load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces); + load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces); address = iface_n_ip(ifaces, 0); torture_comment(tctx, "Listening for callbacks on %s\n", address); status = smbsrv_add_socket(p->conn->event_ctx, tctx->lp_ctx, &single_ops, address); diff --git a/source4/utils/nmblookup.c b/source4/utils/nmblookup.c index 6c849fc0db..7eae9c7765 100644 --- a/source4/utils/nmblookup.c +++ b/source4/utils/nmblookup.c @@ -355,7 +355,7 @@ int main(int argc, const char *argv[]) exit(1); } - load_interfaces(lp_interfaces(cmdline_lp_ctx), &ifaces); + load_interfaces(NULL, lp_interfaces(cmdline_lp_ctx), &ifaces); while (poptPeekArg(pc)) { const char *name = poptGetArg(pc); @@ -363,6 +363,8 @@ int main(int argc, const char *argv[]) ret &= process_one(cmdline_lp_ctx, ifaces, name, lp_nbt_port(cmdline_lp_ctx)); } + talloc_free(ifaces); + poptFreeContext(pc); if (!ret) { diff --git a/source4/web_server/web_server.c b/source4/web_server/web_server.c index 0fdb0bfb4f..87cab2cc92 100644 --- a/source4/web_server/web_server.c +++ b/source4/web_server/web_server.c @@ -255,7 +255,7 @@ static void websrv_task_init(struct task_server *task) int i; struct interface *ifaces; - load_interfaces(lp_interfaces(task->lp_ctx), &ifaces); + load_interfaces(NULL, lp_interfaces(task->lp_ctx), &ifaces); num_interfaces = iface_count(ifaces); for(i = 0; i < num_interfaces; i++) { @@ -267,6 +267,8 @@ static void websrv_task_init(struct task_server *task) task); if (!NT_STATUS_IS_OK(status)) goto failed; } + + talloc_free(ifaces); } else { status = stream_setup_socket(task->event_ctx, model_ops, &web_stream_ops, diff --git a/source4/wrepl_server/wrepl_in_connection.c b/source4/wrepl_server/wrepl_in_connection.c index 74c524dc79..4d834a6a5a 100644 --- a/source4/wrepl_server/wrepl_in_connection.c +++ b/source4/wrepl_server/wrepl_in_connection.c @@ -280,7 +280,7 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service, struct loadpar int i; struct interface *ifaces; - load_interfaces(lp_interfaces(lp_ctx), &ifaces); + load_interfaces(task, lp_interfaces(lp_ctx), &ifaces); num_interfaces = iface_count(ifaces); diff --git a/source4/wrepl_server/wrepl_server.c b/source4/wrepl_server/wrepl_server.c index c8ad80351e..7d4be3e1b5 100644 --- a/source4/wrepl_server/wrepl_server.c +++ b/source4/wrepl_server/wrepl_server.c @@ -79,7 +79,7 @@ static NTSTATUS wreplsrv_open_winsdb(struct wreplsrv_service *service, if (owner == NULL) { struct interface *ifaces; - load_interfaces(lp_interfaces(lp_ctx), &ifaces); + load_interfaces(service, lp_interfaces(lp_ctx), &ifaces); owner = iface_n_ip(ifaces, 0); } |