summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamba Release Account <samba-bugs@samba.org>1996-10-24 17:48:06 +0000
committerSamba Release Account <samba-bugs@samba.org>1996-10-24 17:48:06 +0000
commite010ad006ea1c4754f357951be648b8f45458613 (patch)
tree9d29249ef5dfec1e2884fc1438618800a4aca570
parent8a7c1bd3353c03ac7d3dec656772295a7d93b3f0 (diff)
downloadsamba-e010ad006ea1c4754f357951be648b8f45458613.tar.gz
samba-e010ad006ea1c4754f357951be648b8f45458613.tar.bz2
samba-e010ad006ea1c4754f357951be648b8f45458613.zip
dealing with name queries and dns lookups etc.
lkcl (This used to be commit 98cb371244fcb048ad13514140a4ea7243b2b039)
-rw-r--r--source3/include/proto.h8
-rw-r--r--source3/namedbname.c39
-rw-r--r--source3/nameservreply.c54
3 files changed, 48 insertions, 53 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 803ceba688..c2fab68429 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -353,9 +353,8 @@ struct name_record *add_netbios_entry(struct subnet_record *d,
int ttl, enum name_source source, struct in_addr ip,
BOOL new_only,BOOL wins);
void expire_names(time_t t);
-struct name_record *search_for_name(struct subnet_record **d,
- struct nmb_name *question,
- struct in_addr ip, int Time, int search);
+struct name_record *dns_name_search(struct nmb_name *question,
+ int Time, int search);
/*The following definitions come from namedbresp.c */
@@ -739,9 +738,6 @@ struct smb_passwd *get_smbpwnam(char *name);
/*The following definitions come from smbrun.c */
-/*The following definitions come from smbwizard.c */
-
-
/*The following definitions come from status.c */
void Ucrit_addUsername(pstring username);
diff --git a/source3/namedbname.c b/source3/namedbname.c
index d2ce9b1040..8bf6511737 100644
--- a/source3/namedbname.c
+++ b/source3/namedbname.c
@@ -512,24 +512,21 @@ void expire_names(time_t t)
/***************************************************************************
reply to a name query
****************************************************************************/
-struct name_record *search_for_name(struct subnet_record **d,
- struct nmb_name *question,
- struct in_addr ip, int Time, int search)
+struct name_record *dns_name_search(struct nmb_name *question,
+ int Time, int search)
{
+ struct subnet_record *d = find_subnet(ipgrp);
int name_type = question->name_type;
char *qname = question->name;
BOOL dns_type = (name_type == 0x20 || name_type == 0);
-
struct name_record *n;
+ if (d == NULL) return NULL;
+
DEBUG(3,("Search for %s from %s - ", namestr(question), inet_ntoa(ip)));
- /* first look up name in cache */
- n = find_name_search(d,question,search,ip);
-
- if (*d == NULL) return NULL;
-
- if (!n && (search & FIND_SELF)) {
+ if (!n && (search & FIND_SELF))
+ {
if (!lp_wins_proxy())
DEBUG(3,("wins proxy not enabled - failing lookup\n"));
else
@@ -541,7 +538,6 @@ struct name_record *search_for_name(struct subnet_record **d,
if (!n)
{
struct in_addr dns_ip;
- uint32 a;
/* only do DNS lookups if the query is for type 0x20 or type 0x0 */
if (!dns_type && name_type != 0x1b)
@@ -551,11 +547,9 @@ struct name_record *search_for_name(struct subnet_record **d,
}
/* look it up with DNS */
- a = interpret_addr(qname);
-
- putip((char *)&dns_ip,(char *)&a);
+ dns_ip.s_addr = interpret_addr(qname);
- if (!a)
+ if (dns_ip.s_addr)
{
/* no luck with DNS. We could possibly recurse here XXXX */
DEBUG(3,("no recursion.\n"));
@@ -573,21 +567,6 @@ struct name_record *search_for_name(struct subnet_record **d,
if (!n) return NULL;
}
- /* is our entry already dead? */
- if (n->death_time)
- {
- if (n->death_time < Time) return False;
- }
-
- /* it may have been an earlier failure */
- if (n->source == DNSFAIL)
- {
- DEBUG(3,("DNSFAIL\n"));
- return NULL;
- }
-
- DEBUG(3,("OK %s\n",inet_ntoa(n->ip_flgs[0].ip)));
-
return n;
}
diff --git a/source3/nameservreply.c b/source3/nameservreply.c
index 62b9ca0c49..407459b617 100644
--- a/source3/nameservreply.c
+++ b/source3/nameservreply.c
@@ -509,10 +509,6 @@ void reply_name_query(struct packet_struct *p)
int search = bcast ? FIND_LOCAL | FIND_WINS: FIND_WINS;
- if (!lp_wins_proxy()) {
- search |= FIND_SELF;
- }
-
if (search & FIND_LOCAL)
{
if (!(d = find_req_subnet(p->ip, bcast)))
@@ -547,13 +543,42 @@ void reply_name_query(struct packet_struct *p)
success = False;
}
- if (success && (n = search_for_name(&d,question,p->ip,p->timestamp, search)))
+ if (success)
+ {
+ /* look up the name in the cache */
+ n = find_name_search(&d, question, p->ip, search));
+
+ /* it is a name that already failed DNS lookup or it's expired */
+ if (n->source == DNSFAIL ||
+ (n->death_time && n->death_time < p->timestamp))
+ {
+ success = False;
+ }
+
+ /* do we want to do dns lookups? */
+ /* XXXX this DELAYS nmbd while it does a search. not a good idea
+ but there's no pleasant alternative. phil@hands.com suggested
+ making the name a full DNS name, which would succeed / fail
+ much quicker.
+ */
+ if (success && !n && (lp_wins_proxy() || !bcast))
+ {
+ n = dns_name_search(question, p->timestamp, search);
+ }
+ }
+
+ if (!n) success = False;
+
+ if (success)
{
- /* don't respond to broadcast queries unless the query is for
- a name we own or it is for a Primary Domain Controller name */
+ if (bcast && n->source != SELF && name_type != 0x1b)
+ {
+ /* don't respond to broadcast queries unless the query is for
+ a name we own or it is for a Primary Domain Controller name */
- if (bcast && n->source != SELF && name_type != 0x1b) {
- if (!lp_wins_proxy() || same_net(p->ip,n->ip_flgs[0].ip,*iface_nmask(p->ip))) {
+ if (!lp_wins_proxy() ||
+ same_net(p->ip,n->ip_flgs[0].ip,*iface_nmask(p->ip)))
+ {
/* never reply with a negative response to broadcast queries */
return;
}
@@ -573,12 +598,9 @@ void reply_name_query(struct packet_struct *p)
retip = n->ip_flgs[0].ip;
nb_flags = n->ip_flgs[0].nb_flags;
}
- else
- {
- if (bcast) return; /* never reply negative response to bcasts */
- success = False;
- }
-
+
+ if (!success && bcast) return; /* never reply negative response to bcasts */
+
/* if the IP is 0 then substitute my IP */
if (zero_ip(retip)) retip = *iface_ip(p->ip);
@@ -608,5 +630,3 @@ void reply_name_query(struct packet_struct *p)
ttl,
rdata, success ? 6 : 0);
}
-
-