summaryrefslogtreecommitdiff
path: root/source4/nbt_server/wins
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-12-06 16:54:34 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:48:25 +0100
commit2f5ca872a80ad872ab864061f0c6982d8605393f (patch)
tree061592e4ae1e79adc57cd5d99ff2fd6f3b8c2549 /source4/nbt_server/wins
parentfb29325f1d4feba6c3f52b690d3da5d492618c4f (diff)
downloadsamba-2f5ca872a80ad872ab864061f0c6982d8605393f.tar.gz
samba-2f5ca872a80ad872ab864061f0c6982d8605393f.tar.bz2
samba-2f5ca872a80ad872ab864061f0c6982d8605393f.zip
r26313: Fix more uses of static loadparm.
(This used to be commit 6fd0d9d3b75546d08c24c513e05b1843d5777608)
Diffstat (limited to 'source4/nbt_server/wins')
-rw-r--r--source4/nbt_server/wins/wins_hook.c9
-rw-r--r--source4/nbt_server/wins/winsclient.c6
-rw-r--r--source4/nbt_server/wins/winsdb.c24
-rw-r--r--source4/nbt_server/wins/winsdb.h3
-rw-r--r--source4/nbt_server/wins/winsserver.c31
5 files changed, 40 insertions, 33 deletions
diff --git a/source4/nbt_server/wins/wins_hook.c b/source4/nbt_server/wins/wins_hook.c
index 768f9477f6..ae832774a3 100644
--- a/source4/nbt_server/wins/wins_hook.c
+++ b/source4/nbt_server/wins/wins_hook.c
@@ -38,15 +38,14 @@ static const char *wins_hook_action_string(enum wins_hook_action action)
}
void wins_hook(struct winsdb_handle *h, const struct winsdb_record *rec,
- enum wins_hook_action action)
+ enum wins_hook_action action, const char *wins_hook_script)
{
- const char *script = lp_wins_hook(global_loadparm);
uint32_t i, length;
int child;
char *cmd = NULL;
TALLOC_CTX *tmp_mem = NULL;
- if (!script || !script[0]) return;
+ if (!wins_hook_script || !wins_hook_script[0]) return;
tmp_mem = talloc_new(h);
if (!tmp_mem) goto failed;
@@ -59,7 +58,7 @@ void wins_hook(struct winsdb_handle *h, const struct winsdb_record *rec,
cmd = talloc_asprintf(tmp_mem,
"%s %s %s %02x %ld",
- script,
+ wins_hook_script,
wins_hook_action_string(action),
rec->name->name,
rec->name->type,
@@ -92,5 +91,5 @@ void wins_hook(struct winsdb_handle *h, const struct winsdb_record *rec,
return;
failed:
talloc_free(tmp_mem);
- DEBUG(0,("FAILED: calling wins hook '%s'\n", script));
+ DEBUG(0,("FAILED: calling wins hook '%s'\n", wins_hook_script));
}
diff --git a/source4/nbt_server/wins/winsclient.c b/source4/nbt_server/wins/winsclient.c
index d1342c3766..046be28515 100644
--- a/source4/nbt_server/wins/winsclient.c
+++ b/source4/nbt_server/wins/winsclient.c
@@ -58,7 +58,7 @@ static void nbtd_wins_register_retry(struct event_context *ev, struct timed_even
static void nbtd_wins_start_refresh_timer(struct nbtd_iface_name *iname)
{
uint32_t refresh_time;
- uint32_t max_refresh_time = lp_parm_int(global_loadparm, NULL, "nbtd", "max_refresh_time", 7200);
+ uint32_t max_refresh_time = lp_parm_int(iname->iface->nbtsrv->task->lp_ctx, NULL, "nbtd", "max_refresh_time", 7200);
refresh_time = MIN(max_refresh_time, iname->ttl/2);
@@ -179,7 +179,7 @@ static void nbtd_wins_register_handler(struct composite_context *c)
if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
/* none of the WINS servers responded - try again
periodically */
- int wins_retry_time = lp_parm_int(global_loadparm, NULL, "nbtd", "wins_retry", 300);
+ int wins_retry_time = lp_parm_int(iname->iface->nbtsrv->task->lp_ctx, NULL, "nbtd", "wins_retry", 300);
event_add_timed(iname->iface->nbtsrv->task->event_ctx,
iname,
timeval_current_ofs(wins_retry_time, 0),
@@ -236,7 +236,7 @@ void nbtd_winsclient_register(struct nbtd_iface_name *iname)
/* setup a wins name register request */
io.in.name = iname->name;
- io.in.wins_servers = lp_wins_server_list(global_loadparm);
+ io.in.wins_servers = lp_wins_server_list(iname->iface->nbtsrv->task->lp_ctx);
io.in.addresses = nbtd_address_list(iface, iname);
io.in.nb_flags = iname->nb_flags;
io.in.ttl = iname->ttl;
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c
index 6ba0363824..438fb12b58 100644
--- a/source4/nbt_server/wins/winsdb.c
+++ b/source4/nbt_server/wins/winsdb.c
@@ -850,7 +850,7 @@ uint8_t winsdb_add(struct winsdb_handle *h, struct winsdb_record *rec, uint32_t
trans = ldb_transaction_commit(wins_db);
if (trans != LDB_SUCCESS) goto failed;
- wins_hook(h, rec, WINS_HOOK_ADD);
+ wins_hook(h, rec, WINS_HOOK_ADD, h->hook_script);
talloc_free(tmp_ctx);
return NBT_RCODE_OK;
@@ -899,7 +899,7 @@ uint8_t winsdb_modify(struct winsdb_handle *h, struct winsdb_record *rec, uint32
trans = ldb_transaction_commit(wins_db);
if (trans != LDB_SUCCESS) goto failed;
- wins_hook(h, rec, WINS_HOOK_MODIFY);
+ wins_hook(h, rec, WINS_HOOK_MODIFY, h->hook_script);
talloc_free(tmp_ctx);
return NBT_RCODE_OK;
@@ -934,7 +934,7 @@ uint8_t winsdb_delete(struct winsdb_handle *h, struct winsdb_record *rec)
trans = ldb_transaction_commit(wins_db);
if (trans != LDB_SUCCESS) goto failed;
- wins_hook(h, rec, WINS_HOOK_DELETE);
+ wins_hook(h, rec, WINS_HOOK_DELETE, h->hook_script);
talloc_free(tmp_ctx);
return NBT_RCODE_OK;
@@ -945,7 +945,7 @@ failed:
return NBT_RCODE_SVR;
}
-static bool winsdb_check_or_add_module_list(struct winsdb_handle *h)
+static bool winsdb_check_or_add_module_list(struct loadparm_context *lp_ctx, struct winsdb_handle *h)
{
int trans;
int ret;
@@ -988,11 +988,11 @@ static bool winsdb_check_or_add_module_list(struct winsdb_handle *h)
talloc_free(h->ldb);
h->ldb = NULL;
- if (lp_parm_bool(global_loadparm, NULL,"winsdb", "nosync", false)) {
+ if (lp_parm_bool(lp_ctx, NULL,"winsdb", "nosync", false)) {
flags |= LDB_FLG_NOSYNC;
}
- h->ldb = ldb_wrap_connect(h, global_loadparm, lock_path(h, global_loadparm, lp_wins_url(global_loadparm)),
+ h->ldb = ldb_wrap_connect(h, lp_ctx, lock_path(h, lp_ctx, lp_wins_url(lp_ctx)),
NULL, NULL, flags, NULL);
if (!h->ldb) goto failed;
@@ -1010,7 +1010,8 @@ failed:
return false;
}
-struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx, enum winsdb_handle_caller caller)
+struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
+ enum winsdb_handle_caller caller)
{
struct winsdb_handle *h = NULL;
const char *owner;
@@ -1021,17 +1022,18 @@ struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx, enum winsdb_handle_cal
h = talloc(mem_ctx, struct winsdb_handle);
if (!h) return NULL;
- if (lp_parm_bool(global_loadparm, NULL,"winsdb", "nosync", false)) {
+ if (lp_parm_bool(lp_ctx, NULL,"winsdb", "nosync", false)) {
flags |= LDB_FLG_NOSYNC;
}
- h->ldb = ldb_wrap_connect(h, global_loadparm, lock_path(h, global_loadparm, lp_wins_url(global_loadparm)),
+ h->ldb = ldb_wrap_connect(h, lp_ctx, lock_path(h, lp_ctx, lp_wins_url(lp_ctx)),
NULL, NULL, flags, NULL);
if (!h->ldb) goto failed;
h->caller = caller;
+ h->hook_script = lp_wins_hook(lp_ctx);
- owner = lp_parm_string(global_loadparm, NULL, "winsdb", "local_owner");
+ owner = lp_parm_string(lp_ctx, NULL, "winsdb", "local_owner");
if (!owner) {
owner = iface_n_ip(0);
}
@@ -1040,7 +1042,7 @@ struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx, enum winsdb_handle_cal
if (!h->local_owner) goto failed;
/* make sure the module list is available and used */
- ret = winsdb_check_or_add_module_list(h);
+ ret = winsdb_check_or_add_module_list(lp_ctx, h);
if (!ret) goto failed;
ldb_err = ldb_set_opaque(h->ldb, "winsdb_handle", h);
diff --git a/source4/nbt_server/wins/winsdb.h b/source4/nbt_server/wins/winsdb.h
index 27b745fadb..7c38a2b017 100644
--- a/source4/nbt_server/wins/winsdb.h
+++ b/source4/nbt_server/wins/winsdb.h
@@ -65,6 +65,9 @@ struct winsdb_handle {
/* local owner address */
const char *local_owner;
+
+ /* wins hook script */
+ const char *hook_script;
};
enum wins_hook_action {
diff --git a/source4/nbt_server/wins/winsserver.c b/source4/nbt_server/wins/winsserver.c
index bce80702df..98262a2f84 100644
--- a/source4/nbt_server/wins/winsserver.c
+++ b/source4/nbt_server/wins/winsserver.c
@@ -599,7 +599,8 @@ static int nbtd_wins_randomize1Clist_sort(void *p1,/* (const char **) */
return match_bits2 - match_bits1;
}
-static void nbtd_wins_randomize1Clist(const char **addresses, struct socket_address *src)
+static void nbtd_wins_randomize1Clist(struct loadparm_context *lp_ctx,
+ const char **addresses, struct socket_address *src)
{
const char *mask;
const char *tmp;
@@ -615,7 +616,7 @@ static void nbtd_wins_randomize1Clist(const char **addresses, struct socket_addr
ldb_qsort(addresses, num_addrs , sizeof(addresses[0]),
src, (ldb_qsort_cmp_fn_t)nbtd_wins_randomize1Clist_sort);
- mask = lp_parm_string(global_loadparm, NULL, "nbtd", "wins_randomize1Clist_mask");
+ mask = lp_parm_string(lp_ctx, NULL, "nbtd", "wins_randomize1Clist_mask");
if (!mask) {
mask = "255.255.255.0";
}
@@ -662,7 +663,8 @@ static void nbtd_wins_randomize1Clist(const char **addresses, struct socket_addr
/*
query a name
*/
-static void nbtd_winsserver_query(struct nbt_name_socket *nbtsock,
+static void nbtd_winsserver_query(struct loadparm_context *lp_ctx,
+ struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
struct socket_address *src)
{
@@ -692,7 +694,7 @@ static void nbtd_winsserver_query(struct nbt_name_socket *nbtsock,
* Value: 0 = deactivated, 1 = activated
*/
if (name->type == NBT_NAME_LOGON &&
- lp_parm_bool(global_loadparm, NULL, "nbtd", "wins_prepend1Bto1Cqueries", true)) {
+ lp_parm_bool(lp_ctx, NULL, "nbtd", "wins_prepend1Bto1Cqueries", true)) {
struct nbt_name name_1b;
name_1b = *name;
@@ -706,7 +708,7 @@ static void nbtd_winsserver_query(struct nbt_name_socket *nbtsock,
status = winsdb_lookup(winssrv->wins_db, name, packet, &rec);
if (!NT_STATUS_IS_OK(status)) {
- if (!lp_wins_dns_proxy(global_loadparm)) {
+ if (!lp_wins_dns_proxy(lp_ctx)) {
goto notfound;
}
@@ -788,8 +790,8 @@ static void nbtd_winsserver_query(struct nbt_name_socket *nbtsock,
* Value: 0 = deactivated, 1 = activated
*/
if (name->type == NBT_NAME_LOGON &&
- lp_parm_bool(global_loadparm, NULL, "nbtd", "wins_randomize1Clist", false)) {
- nbtd_wins_randomize1Clist(addresses, src);
+ lp_parm_bool(lp_ctx, NULL, "nbtd", "wins_randomize1Clist", false)) {
+ nbtd_wins_randomize1Clist(lp_ctx, addresses, src);
}
found:
@@ -933,7 +935,7 @@ void nbtd_winsserver_request(struct nbt_name_socket *nbtsock,
switch (packet->operation & NBT_OPCODE) {
case NBT_OPCODE_QUERY:
- nbtd_winsserver_query(nbtsock, packet, src);
+ nbtd_winsserver_query(iface->nbtsrv->task->lp_ctx, nbtsock, packet, src);
break;
case NBT_OPCODE_REGISTER:
@@ -957,7 +959,7 @@ NTSTATUS nbtd_winsserver_init(struct nbtd_server *nbtsrv)
{
uint32_t tmp;
- if (!lp_wins_support(global_loadparm)) {
+ if (!lp_wins_support(nbtsrv->task->lp_ctx)) {
nbtsrv->winssrv = NULL;
return NT_STATUS_OK;
}
@@ -965,14 +967,15 @@ NTSTATUS nbtd_winsserver_init(struct nbtd_server *nbtsrv)
nbtsrv->winssrv = talloc_zero(nbtsrv, struct wins_server);
NT_STATUS_HAVE_NO_MEMORY(nbtsrv->winssrv);
- nbtsrv->winssrv->config.max_renew_interval = lp_max_wins_ttl(global_loadparm);
- nbtsrv->winssrv->config.min_renew_interval = lp_min_wins_ttl(global_loadparm);
- tmp = lp_parm_int(global_loadparm, NULL, "wreplsrv", "tombstone_interval", 6*24*60*60);
+ nbtsrv->winssrv->config.max_renew_interval = lp_max_wins_ttl(nbtsrv->task->lp_ctx);
+ nbtsrv->winssrv->config.min_renew_interval = lp_min_wins_ttl(nbtsrv->task->lp_ctx);
+ tmp = lp_parm_int(nbtsrv->task->lp_ctx, NULL, "wreplsrv", "tombstone_interval", 6*24*60*60);
nbtsrv->winssrv->config.tombstone_interval = tmp;
- tmp = lp_parm_int(global_loadparm, NULL, "wreplsrv"," tombstone_timeout", 1*24*60*60);
+ tmp = lp_parm_int(nbtsrv->task->lp_ctx, NULL, "wreplsrv"," tombstone_timeout", 1*24*60*60);
nbtsrv->winssrv->config.tombstone_timeout = tmp;
- nbtsrv->winssrv->wins_db = winsdb_connect(nbtsrv->winssrv, WINSDB_HANDLE_CALLER_NBTD);
+ nbtsrv->winssrv->wins_db = winsdb_connect(nbtsrv->winssrv, nbtsrv->task->lp_ctx,
+ WINSDB_HANDLE_CALLER_NBTD);
if (!nbtsrv->winssrv->wins_db) {
return NT_STATUS_INTERNAL_DB_ERROR;
}