Changeset 988 for vendor/current/source4/nbt_server
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/source4/nbt_server
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/nbt_server/dgram/netlogon.c
r740 r988 29 29 #include "param/param.h" 30 30 #include "smbd/service_task.h" 31 #include " cldap_server/cldap_server.h"31 #include "dsdb/samdb/ldb_modules/util.h" 32 32 #include "libcli/security/security.h" 33 33 #include "nbt_server/dgram/proto.h" 34 #include "libds/common/roles.h" 34 35 35 36 /* … … 55 56 samctx = iface->nbtsrv->sam_ctx; 56 57 57 if (lpcfg_server_role(iface->nbtsrv->task->lp_ctx) != ROLE_ DOMAIN_CONTROLLER58 if (lpcfg_server_role(iface->nbtsrv->task->lp_ctx) != ROLE_ACTIVE_DIRECTORY_DC 58 59 || !samdb_is_pdc(samctx)) { 59 60 DEBUG(2, ("Not a PDC, so not processing LOGON_PRIMARY_QUERY\n")); … … 169 170 } 170 171 171 DEBUG( 2,("netlogon request to %s from %s:%d\n",172 DEBUG(5,("netlogon request to %s from %s:%d\n", 172 173 nbt_name_string(netlogon, name), src->addr, src->port)); 173 174 status = dgram_mailslot_netlogon_parse_request(dgmslot, netlogon, packet, netlogon); -
vendor/current/source4/nbt_server/interfaces.c
r740 r988 277 277 struct interface *ifaces) 278 278 { 279 int num_interfaces = iface_ count(ifaces);279 int num_interfaces = iface_list_count(ifaces); 280 280 int i; 281 281 TALLOC_CTX *tmp_ctx = talloc_new(nbtsrv); … … 287 287 const char *primary_address; 288 288 289 primary_address = iface_list_first_v4(ifaces); 290 289 291 /* the primary address is the address we will return 290 292 for non-WINS queries not made on a specific 291 293 interface */ 292 if (num_interfaces > 0) { 293 primary_address = iface_n_ip(ifaces, 0); 294 } else { 294 if (primary_address == NULL) { 295 295 primary_address = inet_ntoa(interpret_addr2( 296 lpcfg_netbios_name(lp_ctx))); 297 } 296 lpcfg_netbios_name(lp_ctx))); 297 } 298 298 299 primary_address = talloc_strdup(tmp_ctx, primary_address); 299 300 NT_STATUS_HAVE_NO_MEMORY(primary_address); … … 309 310 310 311 for (i=0; i<num_interfaces; i++) { 311 const char *bcast = iface_n_bcast(ifaces, i);312 const char *bcast; 312 313 const char *address, *netmask; 313 314 315 if (!iface_list_n_is_v4(ifaces, i)) { 316 /* v4 only for NBT protocol */ 317 continue; 318 } 319 320 bcast = iface_list_n_bcast(ifaces, i); 314 321 /* we can't assume every interface is broadcast capable */ 315 322 if (bcast == NULL) continue; 316 323 317 address = talloc_strdup(tmp_ctx, iface_ n_ip(ifaces, i));324 address = talloc_strdup(tmp_ctx, iface_list_n_ip(ifaces, i)); 318 325 bcast = talloc_strdup(tmp_ctx, bcast); 319 netmask = talloc_strdup(tmp_ctx, iface_ n_netmask(ifaces, i));326 netmask = talloc_strdup(tmp_ctx, iface_list_n_netmask(ifaces, i)); 320 327 321 328 status = nbtd_add_socket(nbtsrv, lp_ctx, … … 347 354 348 355 if (iface->ip_address) { 349 is_loopback = iface_ same_net(iface->ip_address, "127.0.0.1", "255.0.0.0");356 is_loopback = iface_list_same_net(iface->ip_address, "127.0.0.1", "255.0.0.0"); 350 357 ret = str_list_add(ret, iface->ip_address); 351 358 } … … 357 364 358 365 if (!is_loopback) { 359 if (iface_ same_net(iface2->ip_address, "127.0.0.1", "255.0.0.0")) {366 if (iface_list_same_net(iface2->ip_address, "127.0.0.1", "255.0.0.0")) { 360 367 continue; 361 368 } … … 381 388 /* try to find a exact match */ 382 389 for (cur=nbtd_server->interfaces;cur;cur=cur->next) { 383 if (iface_ same_net(address, cur->ip_address, cur->netmask)) {390 if (iface_list_same_net(address, cur->ip_address, cur->netmask)) { 384 391 DEBUG(10,("find interface for dst[%s] ip: %s/%s (iface[%p])\n", 385 392 address, cur->ip_address, cur->netmask, cur)); -
vendor/current/source4/nbt_server/nbt_server.c
r740 r988 31 31 #include "param/param.h" 32 32 33 NTSTATUS server_service_nbtd_init(void); 34 33 35 /* 34 36 startup the nbtd task … … 40 42 struct interface *ifaces; 41 43 42 load_interface s(task, lpcfg_interfaces(task->lp_ctx), &ifaces);44 load_interface_list(task, task->lp_ctx, &ifaces); 43 45 44 if (iface_ count(ifaces) == 0) {46 if (iface_list_count(ifaces) == 0) { 45 47 task_server_terminate(task, "nbtd: no network interfaces configured", false); 48 return; 49 } 50 51 if (lpcfg_disable_netbios(task->lp_ctx)) { 52 task_server_terminate(task, "nbtd: 'disable netbios = yes' set in smb.conf, shutting down nbt server", false); 46 53 return; 47 54 } -
vendor/current/source4/nbt_server/query.c
r740 r988 83 83 (packet->operation & NBT_FLAG_RECURSION_DESIRED) && 84 84 (iname->nb_flags & NBT_NM_GROUP) && 85 lpcfg_w ins_support(iface->nbtsrv->task->lp_ctx)) {85 lpcfg_we_are_a_wins_server(iface->nbtsrv->task->lp_ctx)) { 86 86 nbtd_winsserver_request(nbtsock, packet, src); 87 87 return; -
vendor/current/source4/nbt_server/register.c
r740 r988 31 31 #include "dsdb/samdb/samdb.h" 32 32 #include "param/param.h" 33 #include "libds/common/roles.h" 33 34 34 35 static void nbtd_start_refresh_timer(struct nbtd_iface_name *iname); … … 123 124 refresh_time = MIN(max_refresh_time, iname->ttl/2); 124 125 125 event_add_timed(iname->iface->nbtsrv->task->event_ctx,126 tevent_add_timer(iname->iface->nbtsrv->task->event_ctx, 126 127 iname, 127 128 timeval_add(&iname->registration_time, refresh_time, 0), … … 199 200 iname->wins_server = NULL; 200 201 201 DLIST_ADD_END(iface->names, iname , struct nbtd_iface_name *);202 DLIST_ADD_END(iface->names, iname); 202 203 203 204 if (nb_flags & NBT_NM_PERMANENT) { … … 290 291 } 291 292 292 if (lpcfg_server_role(nbtsrv->task->lp_ctx) == ROLE_ DOMAIN_CONTROLLER) {293 if (lpcfg_server_role(nbtsrv->task->lp_ctx) == ROLE_ACTIVE_DIRECTORY_DC) { 293 294 bool is_pdc = samdb_is_pdc(nbtsrv->sam_ctx); 294 295 if (is_pdc) { -
vendor/current/source4/nbt_server/wins/wins_dns_proxy.c
r414 r988 28 28 #include "smbd/service_task.h" 29 29 #include "libcli/resolve/resolve.h" 30 #include "lib/socket/socket.h" 30 31 31 32 struct wins_dns_proxy_state { … … 79 80 s->nbtsock = nbtsock; 80 81 s->packet = talloc_steal(s, packet); 81 s->src = s rc;82 if ( !talloc_reference(s, src)) {82 s->src = socket_address_copy(s, src); 83 if (s->src == NULL) { 83 84 goto failed; 84 85 } -
vendor/current/source4/nbt_server/wins/wins_ldb.c
r740 r988 93 93 if (!owner) { 94 94 struct interface *ifaces; 95 load_interface s(module, lpcfg_interfaces(lp_ctx), &ifaces);96 owner = iface_ n_ip(ifaces, 0);95 load_interface_list(module, lp_ctx, &ifaces); 96 owner = iface_list_first_v4(ifaces); 97 97 if (!owner) { 98 98 owner = "0.0.0.0"; -
vendor/current/source4/nbt_server/wins/winsclient.c
r740 r988 61 61 refresh_time = MIN(max_refresh_time, iname->ttl/2); 62 62 63 event_add_timed(iname->iface->nbtsrv->task->event_ctx,63 tevent_add_timer(iname->iface->nbtsrv->task->event_ctx, 64 64 iname, 65 65 timeval_add(&iname->registration_time, refresh_time, 0), … … 143 143 struct tevent_req *subreq; 144 144 struct nbtd_wins_refresh_state *state; 145 char **l; 145 146 146 147 state = talloc_zero(iname, struct nbtd_wins_refresh_state); … … 153 154 /* setup a wins name refresh request */ 154 155 state->io.in.name = iname->name; 155 state->io.in.wins_servers = (const char **)str_list_make_single(state, iname->wins_server); 156 l = str_list_make_single(state, iname->wins_server); 157 state->io.in.wins_servers = discard_const_p(const char *, l); 156 158 state->io.in.wins_port = lpcfg_nbt_port(iface->nbtsrv->task->lp_ctx); 157 159 state->io.in.addresses = nbtd_address_list(iface, state); … … 195 197 periodically */ 196 198 int wins_retry_time = lpcfg_parm_int(iname->iface->nbtsrv->task->lp_ctx, NULL, "nbtd", "wins_retry", 300); 197 event_add_timed(iname->iface->nbtsrv->task->event_ctx,199 tevent_add_timer(iname->iface->nbtsrv->task->event_ctx, 198 200 iname, 199 201 timeval_current_ofs(wins_retry_time, 0), -
vendor/current/source4/nbt_server/wins/winsdb.c
r740 r988 125 125 } 126 126 127 uint64_t winsdb_get_seqnumber(struct winsdb_handle *h)128 {129 int ret;130 struct ldb_context *ldb = h->ldb;131 struct ldb_dn *dn;132 struct ldb_result *res = NULL;133 TALLOC_CTX *tmp_ctx = talloc_new(ldb);134 uint64_t seqnumber = 0;135 136 dn = ldb_dn_new(tmp_ctx, ldb, "@BASEINFO");137 if (!dn) goto failed;138 139 /* find the record in the WINS database */140 ret = ldb_search(ldb, tmp_ctx, &res, dn, LDB_SCOPE_BASE, NULL, NULL);141 if (ret != LDB_SUCCESS) goto failed;142 if (res->count > 1) goto failed;143 144 if (res->count == 1) {145 seqnumber = ldb_msg_find_attr_as_uint64(res->msgs[0], "sequenceNumber", 0);146 }147 148 failed:149 talloc_free(tmp_ctx);150 return seqnumber;151 }152 153 127 /* 154 128 return a DN for a nbt_name … … 250 224 /* support old entries, with only the address */ 251 225 addr->address = (const char *)talloc_steal(addr, val->data); 252 addr->wins_owner = talloc_ reference(addr, rec->wins_owner);226 addr->wins_owner = talloc_strdup(addr, rec->wins_owner); 253 227 if (!addr->wins_owner) { 254 228 status = NT_STATUS_NO_MEMORY; … … 930 904 931 905 static bool winsdb_check_or_add_module_list(struct tevent_context *ev_ctx, 932 struct loadparm_context *lp_ctx, struct winsdb_handle *h) 906 struct loadparm_context *lp_ctx, struct winsdb_handle *h, 907 const char *wins_path) 933 908 { 934 909 int trans; … … 976 951 } 977 952 978 h->ldb = ldb_wrap_connect(h, ev_ctx, lp_ctx, lock_path(h, lp_ctx, lpcfg_wins_url(lp_ctx)),953 h->ldb = ldb_wrap_connect(h, ev_ctx, lp_ctx, wins_path, 979 954 NULL, NULL, flags); 980 955 if (!h->ldb) goto failed; … … 1004 979 bool ret; 1005 980 int ldb_err; 981 char *wins_path; 1006 982 1007 983 h = talloc_zero(mem_ctx, struct winsdb_handle); 1008 984 if (!h) return NULL; 1009 985 986 wins_path = lpcfg_state_path(h, lp_ctx, "wins.ldb"); 987 1010 988 if (lpcfg_parm_bool(lp_ctx, NULL,"winsdb", "nosync", false)) { 1011 989 flags |= LDB_FLG_NOSYNC; 1012 990 } 1013 991 1014 h->ldb = ldb_wrap_connect(h, ev_ctx, lp_ctx, lock_path(h, lp_ctx, lpcfg_wins_url(lp_ctx)),992 h->ldb = ldb_wrap_connect(h, ev_ctx, lp_ctx, wins_path, 1015 993 NULL, NULL, flags); 1016 994 if (!h->ldb) goto failed; 1017 995 1018 996 h->caller = caller; 1019 h->hook_script = lpcfg_wins_hook(lp_ctx );997 h->hook_script = lpcfg_wins_hook(lp_ctx, h); 1020 998 1021 999 h->local_owner = talloc_strdup(h, owner); … … 1023 1001 1024 1002 /* make sure the module list is available and used */ 1025 ret = winsdb_check_or_add_module_list(ev_ctx, lp_ctx, h );1003 ret = winsdb_check_or_add_module_list(ev_ctx, lp_ctx, h, wins_path); 1026 1004 if (!ret) goto failed; 1027 1005 -
vendor/current/source4/nbt_server/wins/winsserver.c
r740 r988 412 412 s->reg_address = packet->additional[0].rdata.netbios.addresses[0].ipaddr; 413 413 s->new_type = new_type; 414 s->src = s rc;415 if ( talloc_reference(s, src)== NULL) goto failed;414 s->src = socket_address_copy(s, src); 415 if (s->src == NULL) goto failed; 416 416 417 417 s->io.in.nbtd_server = iface->nbtsrv; … … 423 423 if (s->io.in.addresses == NULL) goto failed; 424 424 425 DLIST_ADD_END(iface->wack_queue, s , struct nbtd_wins_wack_state *);425 DLIST_ADD_END(iface->wack_queue, s); 426 426 427 427 talloc_set_destructor(s, nbtd_wins_wack_state_destructor); … … 680 680 /* 681 681 * choose a random address to be the first in the response to the client, 682 * prefer rthe addresses inside the nbtd:wins_randomize1Clist_mask netmask682 * prefer the addresses inside the nbtd:wins_randomize1Clist_mask netmask 683 683 */ 684 684 r = random(); … … 689 689 690 690 /* if the current one is in the same subnet, use it */ 691 same = iface_ same_net(addresses[idx], src->addr, mask);691 same = iface_list_same_net(addresses[idx], src->addr, mask); 692 692 if (same) { 693 693 sidx = idx; … … 1039 1039 const char *owner; 1040 1040 1041 if (!lpcfg_w ins_support(nbtsrv->task->lp_ctx)) {1041 if (!lpcfg_we_are_a_wins_server(nbtsrv->task->lp_ctx)) { 1042 1042 nbtsrv->winssrv = NULL; 1043 1043 return NT_STATUS_OK; … … 1058 1058 if (owner == NULL) { 1059 1059 struct interface *ifaces; 1060 load_interface s(nbtsrv->task, lpcfg_interfaces(nbtsrv->task->lp_ctx), &ifaces);1061 owner = iface_ n_ip(ifaces, 0);1060 load_interface_list(nbtsrv->task, nbtsrv->task->lp_ctx, &ifaces); 1061 owner = iface_list_first_v4(ifaces); 1062 1062 } 1063 1063 -
vendor/current/source4/nbt_server/wins/winswack.c
r740 r988 308 308 s->io.in.nbtd_server = nbtd_server; 309 309 s->io.in.nbt_port = lpcfg_nbt_port(nbtd_server->task->lp_ctx); 310 s->io.in.event_ctx = msg->ev;310 s->io.in.event_ctx = nbtd_server->task->event_ctx; 311 311 s->io.in.name = &req->in.name; 312 312 s->io.in.num_addresses = req->in.num_addrs; … … 367 367 368 368 s->io.in.nbtd_server = nbtd_server; 369 s->io.in.event_ctx = msg->ev;369 s->io.in.event_ctx = nbtd_server->task->event_ctx; 370 370 s->io.in.name = &req->in.name; 371 371 s->io.in.num_addresses = req->in.num_addrs; -
vendor/current/source4/nbt_server/wscript_build
r740 r988 4 4 source='wins/winsdb.c wins/wins_hook.c', 5 5 autoproto='wins/winsdb_proto.h', 6 public_deps='ldb ldbsamba' 6 public_deps='ldb ldbsamba', 7 enabled=bld.AD_DC_BUILD_IS_ENABLED() 7 8 ) 8 9 … … 15 16 deps='ldb netif samba-hostconfig samba-util', 16 17 internal_module=False, 18 enabled=bld.AD_DC_BUILD_IS_ENABLED() 17 19 ) 18 20 … … 21 23 source='wins/winsserver.c wins/winsclient.c wins/winswack.c wins/wins_dns_proxy.c', 22 24 autoproto='wins/winsserver_proto.h', 23 deps='cli-nbt WINSDB' 25 deps='cli-nbt WINSDB', 26 enabled=bld.AD_DC_BUILD_IS_ENABLED() 24 27 ) 25 28 … … 28 31 source='dgram/request.c dgram/netlogon.c dgram/browse.c', 29 32 autoproto='dgram/proto.h', 30 deps='LIBCLI_DGRAM CLDAPD' 33 deps='LIBCLI_DGRAM DSDB_MODULE_HELPERS', 34 enabled=bld.AD_DC_BUILD_IS_ENABLED() 31 35 ) 32 36 … … 35 39 source='interfaces.c register.c query.c nodestatus.c defense.c packet.c irpc.c', 36 40 autoproto='nbt_server_proto.h', 37 deps='cli-nbt NBTD_WINS NBTD_DGRAM' 41 deps='cli-nbt NBTD_WINS NBTD_DGRAM service', 42 enabled=bld.AD_DC_BUILD_IS_ENABLED() 38 43 ) 39 44 … … 45 50 deps='NBT_SERVER process_model', 46 51 internal_module=False, 52 enabled=bld.AD_DC_BUILD_IS_ENABLED() 47 53 ) 48 54
Note:
See TracChangeset
for help on using the changeset viewer.