From 7950c5e87082f4292780b0b1571c5111b291e39e Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Thu, 24 Jul 1997 20:39:30 +0000 Subject: nameserv.c: split add_domain_names() into three functions: add_domain_logon_names() - adds <1c> names on WINS and broadcast. add_domain_master_wins() - adds <1b> name only with WINS server add_domain_master_bcast() - adds <1b> names only by bcast. : made add_domain_names() add <1c> names, unconditionally, and add <1b> name with the WINS server if using a WINS server, or add <1b> name by broadcast if _not_ using a WINS server, but _not_ both. : removed the direct parameter from remove_name_entry() and add_my_name_entry(). nameelect.c: made become_domain_master(), on successful registration of the <1b> name with the WINS server, go ahead and register the <1b> names by broadcast. if the <1b> name is _not_ successfully registered with the WINS server, the broadcast registration of <1b> names will _not_ proceed. namedbsubnet.c: sorted out calls to add_my_name_entry() and remove_my_name() which no longer has a direct parameter. this is all added because... in order to fix a compatibility bug with 1.9.16p2->p11, jeremy had added a feature that got the <1b> broadcast registered names _directly_ into the nmbd netbios lists, undefended. the aim was to get round the aggressive netbios registration of <1b> names of 1.9.16p2->p11. however, because 1.9.16p2->p11 don't properly _provide_ netlogon services, it is better that an error message appears in 1.9.17 logs, and that administrators are made aware of the problems with 1.9.16p2->p11, and replace 1.9.16p2->p11 servers, rather than attempt to run 1.9.16 alonside 1.9.17. (these warning messages will need to be added...) in _addition_, they shouldn't _be_ getting two samba servers to provide domain logon / domain master services for the same workgroup in the same WINS scope! lkcl (This used to be commit 5a668ff7ba83433b5eaa9f7d03a42573ee26caf9) --- source3/nameelect.c | 140 +++++++++++++++++++++++++++------------------------- 1 file changed, 73 insertions(+), 67 deletions(-) (limited to 'source3/nameelect.c') diff --git a/source3/nameelect.c b/source3/nameelect.c index 2b4ebf091cc..295fcd73335 100644 --- a/source3/nameelect.c +++ b/source3/nameelect.c @@ -349,7 +349,7 @@ void become_local_master(struct subnet_record *d, struct work_record *work) 0,lp_serverstring(),True); /* add special browser name */ - add_my_name_entry(d,MSBROWSE,0x01,nb_type|NB_ACTIVE|NB_GROUP,False); + add_my_name_entry(d,MSBROWSE,0x01,nb_type|NB_ACTIVE|NB_GROUP); /* DON'T do anything else after calling add_my_name_entry() */ break; @@ -365,7 +365,7 @@ void become_local_master(struct subnet_record *d, struct work_record *work) 0,myname,True); /* add master name */ - add_my_name_entry(d,work->work_group,0x1d,nb_type|NB_ACTIVE,False); + add_my_name_entry(d,work->work_group,0x1d,nb_type|NB_ACTIVE); /* DON'T do anything else after calling add_my_name_entry() */ break; @@ -444,74 +444,80 @@ on subnet %s\n", work->work_group, inet_ntoa(d->bcast_ip))); ******************************************************************/ void become_domain_master(struct subnet_record *d, struct work_record *work) { - /* domain type must be limited to domain enum + server type. it must - not have SV_TYPE_SERVER or anything else with SERVER in it, else - clients get confused and start thinking this entry is a server - not a workgroup - */ + /* domain type must be limited to domain enum + server type. it must + not have SV_TYPE_SERVER or anything else with SERVER in it, else + clients get confused and start thinking this entry is a server + not a workgroup + */ - if (!work || !d) return; - - if (!lp_domain_master()) - { - DEBUG(0,("Samba not configured as a domain master browser.\n")); - return; - } + if (!work || !d) return; - DEBUG(2,("Becoming domain master for %s %s (currently at stage %d)\n", + if (!lp_domain_master()) + { + DEBUG(0,("Samba not configured as a domain master browser.\n")); + return; + } + + DEBUG(2,("Becoming domain master for %s %s (currently at stage %d)\n", work->work_group,inet_ntoa(d->bcast_ip),work->dom_state)); - - switch (work->dom_state) - { - case DOMAIN_NONE: /* while we were nothing but a server... */ - { - DEBUG(3,("become_domain_master: go to first stage: register <1b> name\n")); - work->dom_state = DOMAIN_WAIT; - - /* Registering the DOMAIN<1b> name is very tricky. We need to - do this on all our subnets, but don't want to bradcast it - on locally connected subnets (WinNT doesn't do this). Also, - previous versions of Samba screw up royally when we do this. - We need to register it immediatly on our local subnet, but - also actually check with the WINS server if it exists. If the name - has already been claimed by someone else in the WINS server - then we need to back out all our local registrations and - fail. Thus we only directly enter the name on local subnets, - on the WINS subnet we actually check... - */ - /* XXXX the 0x1b is domain master browser name */ - if(d == wins_subnet) - add_my_name_entry(d, work->work_group,0x1b,nb_type|NB_ACTIVE,False); - else - add_my_name_entry(d, work->work_group,0x1b,nb_type|NB_ACTIVE,True); - /* DON'T do anything else after calling add_my_name_entry() */ - break; - } + switch (work->dom_state) + { + case DOMAIN_NONE: /* while we were nothing but a server... */ + { + DEBUG(3,("become_domain_master: go to first stage: register <1b> name\n")); + work->dom_state = DOMAIN_WAIT; + + /* Registering the DOMAIN<1b> name is very tricky. We need to + do this on all our subnets, but don't want to bradcast it + on locally connected subnets (WinNT doesn't do this). Also, + previous versions of Samba screw up royally when we do this. + We need to register it immediatly on our local subnet, but + also actually check with the WINS server if it exists. If the name + has already been claimed by someone else in the WINS server + then we need to back out all our local registrations and + fail. Thus we only directly enter the name on local subnets, + on the WINS subnet we actually check... + */ + /* XXXX the 0x1b is domain master browser name */ + add_my_name_entry(d, work->work_group,0x1b,nb_type|NB_ACTIVE); + + /* DON'T do anything else after calling add_my_name_entry() */ + break; + } - case DOMAIN_WAIT: - { - work->dom_state = DOMAIN_MST; /* ... become domain master */ - DEBUG(3,("become_domain_master: first stage - register as domain member\n")); - - /* update our server status */ - work->ServerType |= SV_TYPE_NT|SV_TYPE_DOMAIN_MASTER; - add_server_entry(d,work,myname,work->ServerType|SV_TYPE_LOCAL_LIST_ONLY, - 0, lp_serverstring(),True); + case DOMAIN_WAIT: + { + work->dom_state = DOMAIN_MST; /* ... become domain master */ + DEBUG(3,("become_domain_master: first stage - register as domain member\n")); - DEBUG(0,("Samba is now a domain master browser for workgroup %s on subnet %s\n", - work->work_group, inet_ntoa(d->bcast_ip))); + /* update our server status */ + work->ServerType |= SV_TYPE_NT|SV_TYPE_DOMAIN_MASTER; + add_server_entry(d,work,myname,work->ServerType|SV_TYPE_LOCAL_LIST_ONLY, + 0, lp_serverstring(),True); - break; - } + DEBUG(0,("Samba is now a domain master browser for workgroup %s on subnet %s\n", + work->work_group, inet_ntoa(d->bcast_ip))); - case DOMAIN_MST: - { - /* don't have to do anything: just report success */ - DEBUG(3,("domain second stage: there isn't one!\n")); - break; - } - } + if (d == wins_subnet) + { + /* ok! we successfully registered by unicast with the + WINS server. we now expect to become the domain + master on the local subnets. if this fails, it's + probably a 1.9.16p2 to 1.9.16p11 server's fault + */ + add_domain_master_bcast(); + } + break; + } + + case DOMAIN_MST: + { + /* don't have to do anything: just report success */ + DEBUG(3,("domain second stage: there isn't one!\n")); + break; + } + } } @@ -539,7 +545,7 @@ void become_logon_server(struct subnet_record *d, struct work_record *work) work->log_state = LOGON_WAIT; /* XXXX the 0x1c is apparently something to do with domain logons */ - add_my_name_entry(d, myworkgroup,0x1c,nb_type|NB_ACTIVE|NB_GROUP,False); + add_my_name_entry(d, myworkgroup,0x1c,nb_type|NB_ACTIVE|NB_GROUP); /* DON'T do anything else after calling add_my_name_entry() */ break; @@ -598,8 +604,8 @@ void unbecome_local_master(struct subnet_record *d, struct work_record *work, /* announce ourselves as no longer active as a master browser. */ announce_server(d, work, work->work_group, myname, 0, 0); - remove_name_entry(d,MSBROWSE ,0x01,False); - remove_name_entry(d,work->work_group,0x1d,False); + remove_name_entry(d,MSBROWSE ,0x01); + remove_name_entry(d,work->work_group,0x1d); } } @@ -635,7 +641,7 @@ void unbecome_domain_master(struct subnet_record *d, struct work_record *work, announce_server(d, work, work->work_group, myname, 0, 0); /* Remove the name entry without any NetBIOS traffic as that's how it was registered. */ - remove_name_entry(d,work->work_group,0x1b,True); + remove_name_entry(d,work->work_group,0x1b); } } } @@ -665,7 +671,7 @@ void unbecome_logon_server(struct subnet_record *d, struct work_record *work, /* announce ourselves as no longer active as a master browser. */ announce_server(d, work, work->work_group, myname, 0, 0); - remove_name_entry(d,work->work_group,0x1c,False); + remove_name_entry(d,work->work_group,0x1c); } } -- cgit