mirror of
https://github.com/samba-team/samba.git
synced 2025-08-02 00:22:11 +03:00
r26402: Require a talloc context in libnetif.
(This used to be commit a35e51871b
)
This commit is contained in:
committed by
Stefan Metzmacher
parent
6f2252dace
commit
70f1f33af8
@ -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");
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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
|
||||
|
@ -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++;
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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";
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user