summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/nbt_server/defense.c3
-rw-r--r--source4/nbt_server/nbt_server.h4
-rw-r--r--source4/nbt_server/winsserver.c6
-rw-r--r--source4/nbt_server/winswack.c16
-rw-r--r--source4/torture/nbt/wins.c13
-rw-r--r--source4/torture/nbt/winsbench.c2
6 files changed, 31 insertions, 13 deletions
diff --git a/source4/nbt_server/defense.c b/source4/nbt_server/defense.c
index c59877e4b7..8d71b31c65 100644
--- a/source4/nbt_server/defense.c
+++ b/source4/nbt_server/defense.c
@@ -56,7 +56,8 @@ void nbtd_request_defense(struct nbt_name_socket *nbtsock,
name = &packet->questions[0].name;
iname = nbtd_find_iname(iface, name, NBT_NM_ACTIVE);
- if (iname != NULL && !(iname->nb_flags & NBT_NM_GROUP)) {
+ if (iname != NULL &&
+ !IS_GROUP_NAME(name, iname->nb_flags)) {
DEBUG(2,("Defending name %s on %s against %s\n",
nbt_name_string(packet, name),
iface->bcast_address, src_address));
diff --git a/source4/nbt_server/nbt_server.h b/source4/nbt_server/nbt_server.h
index a698ebf1a0..6a7b14a546 100644
--- a/source4/nbt_server/nbt_server.h
+++ b/source4/nbt_server/nbt_server.h
@@ -79,3 +79,7 @@ struct nbtd_server {
return; \
} \
} while (0)
+
+/* this copes with the nasty hack that is the type 0x1c name */
+#define IS_GROUP_NAME(name, nb_flags) \
+ ((name)->type != NBT_NAME_LOGON && (nb_flags & NBT_NM_GROUP))
diff --git a/source4/nbt_server/winsserver.c b/source4/nbt_server/winsserver.c
index 45b147d86d..c1eed0b1fa 100644
--- a/source4/nbt_server/winsserver.c
+++ b/source4/nbt_server/winsserver.c
@@ -56,7 +56,7 @@ static uint8_t wins_register_new(struct nbt_name_socket *nbtsock,
rec.state = WINS_REC_ACTIVE;
rec.expire_time = time(NULL) + ttl;
rec.registered_by = src_address;
- if (nb_flags & NBT_NM_GROUP) {
+ if (IS_GROUP_NAME(name, nb_flags)) {
rec.addresses = str_list_make(packet, "255.255.255.255", NULL);
} else {
rec.addresses = str_list_make(packet, address, NULL);
@@ -145,7 +145,7 @@ static void nbtd_winsserver_register(struct nbt_name_socket *nbtsock,
/* if the registration is for a group, then just update the expiry time
and we are done */
- if (nb_flags & NBT_NM_GROUP) {
+ if (IS_GROUP_NAME(name, nb_flags)) {
wins_update_ttl(nbtsock, packet, rec, src_address, src_port);
goto done;
}
@@ -207,7 +207,7 @@ static void nbtd_winsserver_release(struct nbt_name_socket *nbtsock,
rec = winsdb_load(winssrv, name, packet);
if (rec == NULL ||
rec->state != WINS_REC_ACTIVE ||
- (rec->nb_flags & NBT_NM_GROUP)) {
+ IS_GROUP_NAME(name, rec->nb_flags)) {
goto done;
}
diff --git a/source4/nbt_server/winswack.c b/source4/nbt_server/winswack.c
index a15f0a7d06..190b1cdec7 100644
--- a/source4/nbt_server/winswack.c
+++ b/source4/nbt_server/winswack.c
@@ -173,11 +173,6 @@ void wins_register_wack(struct nbt_name_socket *nbtsock,
state->src_address = talloc_strdup(state, src_address);
if (state->src_address == NULL) goto failed;
- /* send a WACK to the client, specifying the maximum time it could
- take to check with the owner, plus some slack */
- ttl = 5 + 4 * str_list_length(rec->addresses);
- nbtd_wack_reply(nbtsock, packet, src_address, src_port, ttl);
-
/* setup a name query to the first address */
state->query.in.name = *rec->name;
state->query.in.dest_addr = state->owner_addresses[0];
@@ -186,6 +181,17 @@ void wins_register_wack(struct nbt_name_socket *nbtsock,
state->query.in.timeout = 1;
state->query.in.retries = 2;
+ /* the LOGON type is a nasty hack */
+ if (rec->name->type == NBT_NAME_LOGON) {
+ wins_wack_allow(state);
+ return;
+ }
+
+ /* send a WACK to the client, specifying the maximum time it could
+ take to check with the owner, plus some slack */
+ ttl = 5 + 4 * str_list_length(rec->addresses);
+ nbtd_wack_reply(nbtsock, packet, src_address, src_port, ttl);
+
req = nbt_name_query_send(nbtsock, &state->query);
if (req == NULL) goto failed;
diff --git a/source4/torture/nbt/wins.c b/source4/torture/nbt/wins.c
index 9258f3b517..3f8b361a93 100644
--- a/source4/torture/nbt/wins.c
+++ b/source4/torture/nbt/wins.c
@@ -111,7 +111,9 @@ static BOOL nbt_test_wins_name(TALLOC_CTX *mem_ctx, const char *address,
CHECK_STRING(io.out.wins_server, address);
CHECK_VALUE(io.out.rcode, 0);
- if (name->type != NBT_NAME_MASTER && nb_flags & NBT_NM_GROUP) {
+ if (name->type != NBT_NAME_MASTER &&
+ name->type != NBT_NAME_LOGON &&
+ (nb_flags & NBT_NM_GROUP)) {
printf("Try to register as non-group\n");
io.in.nb_flags &= ~NBT_NM_GROUP;
status = nbt_name_register_wins(nbtsock, mem_ctx, &io);
@@ -152,7 +154,8 @@ static BOOL nbt_test_wins_name(TALLOC_CTX *mem_ctx, const char *address,
CHECK_NAME(query.out.name, *name);
CHECK_VALUE(query.out.num_addrs, 1);
- if (nb_flags & NBT_NM_GROUP) {
+ if (name->type != NBT_NAME_LOGON &&
+ (nb_flags & NBT_NM_GROUP)) {
CHECK_STRING(query.out.reply_addrs[0], "255.255.255.255");
} else {
CHECK_STRING(query.out.reply_addrs[0], myaddress);
@@ -258,7 +261,8 @@ static BOOL nbt_test_wins_name(TALLOC_CTX *mem_ctx, const char *address,
printf("query the name to make sure its gone\n");
query.in.name = *name;
status = nbt_name_query(nbtsock, mem_ctx, &query);
- if (nb_flags & NBT_NM_GROUP) {
+ if (name->type != NBT_NAME_LOGON &&
+ (nb_flags & NBT_NM_GROUP)) {
if (!NT_STATUS_IS_OK(status)) {
printf("ERROR: Name query failed after group release - %s\n",
nt_errstr(status));
@@ -300,6 +304,9 @@ static BOOL nbt_test_wins(TALLOC_CTX *mem_ctx, const char *address)
ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H | NBT_NM_GROUP);
+ name.type = NBT_NAME_LOGON;
+ ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H | NBT_NM_GROUP);
+
name.scope = "example";
name.type = 0x72;
ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H);
diff --git a/source4/torture/nbt/winsbench.c b/source4/torture/nbt/winsbench.c
index 4c0934a0ed..f6a6283dd2 100644
--- a/source4/torture/nbt/winsbench.c
+++ b/source4/torture/nbt/winsbench.c
@@ -120,7 +120,7 @@ static void release_handler(struct nbt_name_request *req)
}
/*
- generate a registration
+ generate a name release
*/
static void generate_release(struct nbt_name_socket *nbtsock, struct wins_state *state, int idx)
{