diff options
Diffstat (limited to 'source3/nmbd/nmbd_logonnames.c')
-rw-r--r-- | source3/nmbd/nmbd_logonnames.c | 195 |
1 files changed, 98 insertions, 97 deletions
diff --git a/source3/nmbd/nmbd_logonnames.c b/source3/nmbd/nmbd_logonnames.c index b73586aa45..f79fc56f7b 100644 --- a/source3/nmbd/nmbd_logonnames.c +++ b/source3/nmbd/nmbd_logonnames.c @@ -3,7 +3,7 @@ NBT netbios routines and daemon - version 2 Copyright (C) Andrew Tridgell 1994-1998 Copyright (C) Luke Kenneth Casson Leighton 1994-1998 - Copyright (C) Jeremy Allison 1994-1998 + Copyright (C) Jeremy Allison 1994-2003 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,38 +29,40 @@ extern uint16 samba_nb_type; /* Samba's NetBIOS type. */ /**************************************************************************** Fail to become a Logon server on a subnet. - ****************************************************************************/ +****************************************************************************/ + static void become_logon_server_fail(struct subnet_record *subrec, struct response_record *rrec, struct nmb_name *fail_name) { - struct work_record *work = find_workgroup_on_subnet(subrec, fail_name->name); - struct server_record *servrec; - - if(!work) - { - DEBUG(0,("become_logon_server_fail: Error - cannot find \ -workgroup %s on subnet %s\n", fail_name->name, subrec->subnet_name)); - return; - } - - if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) - { - DEBUG(0,("become_logon_server_fail: Error - cannot find server %s \ + nstring failname; + struct work_record *work; + struct server_record *servrec; + + pull_ascii_nstring(failname, fail_name->name); + work = find_workgroup_on_subnet(subrec, failname); + if(!work) { + DEBUG(0,("become_logon_server_fail: Error - cannot find \ +workgroup %s on subnet %s\n", failname, subrec->subnet_name)); + return; + } + + if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) { + DEBUG(0,("become_logon_server_fail: Error - cannot find server %s \ in workgroup %s on subnet %s\n", - global_myname(), fail_name->name, subrec->subnet_name)); - work->log_state = LOGON_NONE; - return; - } + global_myname(), failname, subrec->subnet_name)); + work->log_state = LOGON_NONE; + return; + } - /* Set the state back to LOGON_NONE. */ - work->log_state = LOGON_NONE; + /* Set the state back to LOGON_NONE. */ + work->log_state = LOGON_NONE; - servrec->serv.type &= ~SV_TYPE_DOMAIN_CTRL; + servrec->serv.type &= ~SV_TYPE_DOMAIN_CTRL; - DEBUG(0,("become_logon_server_fail: Failed to become a domain master for \ + DEBUG(0,("become_logon_server_fail: Failed to become a domain master for \ workgroup %s on subnet %s. Couldn't register name %s.\n", - work->work_group, subrec->subnet_name, nmb_namestr(fail_name))); + work->work_group, subrec->subnet_name, nmb_namestr(fail_name))); } @@ -74,49 +76,51 @@ static void become_logon_server_success(struct subnet_record *subrec, uint16 nb_flags, int ttl, struct in_addr registered_ip) { - struct work_record *work = find_workgroup_on_subnet( subrec, registered_name->name); - struct server_record *servrec; - - if(!work) - { - DEBUG(0,("become_logon_server_success: Error - cannot find \ -workgroup %s on subnet %s\n", registered_name->name, subrec->subnet_name)); - return; - } - - if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) - { - DEBUG(0,("become_logon_server_success: Error - cannot find server %s \ + nstring reg_name; + struct work_record *work; + struct server_record *servrec; + + pull_ascii_nstring(reg_name, registered_name->name); + work = find_workgroup_on_subnet( subrec, reg_name); + if(!work) { + DEBUG(0,("become_logon_server_success: Error - cannot find \ +workgroup %s on subnet %s\n", reg_name, subrec->subnet_name)); + return; + } + + if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) { + DEBUG(0,("become_logon_server_success: Error - cannot find server %s \ in workgroup %s on subnet %s\n", - global_myname(), registered_name->name, subrec->subnet_name)); - work->log_state = LOGON_NONE; - return; - } - - /* Set the state in the workgroup structure. */ - work->log_state = LOGON_SRV; /* Become domain master. */ - - /* Update our server status. */ - servrec->serv.type |= (SV_TYPE_NT|SV_TYPE_DOMAIN_MEMBER); - /* To allow Win95 policies to load we need to set type domain - controller. - */ - servrec->serv.type |= SV_TYPE_DOMAIN_CTRL; - - /* Tell the namelist writer to write out a change. */ - subrec->work_changed = True; - - /* - * Add the WORKGROUP<1C> name to the UNICAST subnet with the IP address - * for this subnet so we will respond to queries on this name. - */ - { - struct nmb_name nmbname; - make_nmb_name(&nmbname,lp_workgroup(),0x1c); - insert_permanent_name_into_unicast(subrec, &nmbname, 0x1c); - } - - DEBUG(0,("become_logon_server_success: Samba is now a logon server \ + global_myname(), reg_name, subrec->subnet_name)); + work->log_state = LOGON_NONE; + return; + } + + /* Set the state in the workgroup structure. */ + work->log_state = LOGON_SRV; /* Become domain master. */ + + /* Update our server status. */ + servrec->serv.type |= (SV_TYPE_NT|SV_TYPE_DOMAIN_MEMBER); + /* To allow Win95 policies to load we need to set type domain + controller. + */ + servrec->serv.type |= SV_TYPE_DOMAIN_CTRL; + + /* Tell the namelist writer to write out a change. */ + subrec->work_changed = True; + + /* + * Add the WORKGROUP<1C> name to the UNICAST subnet with the IP address + * for this subnet so we will respond to queries on this name. + */ + + { + struct nmb_name nmbname; + make_nmb_name(&nmbname,lp_workgroup(),0x1c); + insert_permanent_name_into_unicast(subrec, &nmbname, 0x1c); + } + + DEBUG(0,("become_logon_server_success: Samba is now a logon server \ for workgroup %s on subnet %s\n", work->work_group, subrec->subnet_name)); } @@ -128,45 +132,42 @@ for workgroup %s on subnet %s\n", work->work_group, subrec->subnet_name)); static void become_logon_server(struct subnet_record *subrec, struct work_record *work) { - DEBUG(2,("become_logon_server: Atempting to become logon server for workgroup %s \ + DEBUG(2,("become_logon_server: Atempting to become logon server for workgroup %s \ on subnet %s\n", work->work_group,subrec->subnet_name)); - DEBUG(3,("become_logon_server: go to first stage: register %s<1c> name\n", - work->work_group)); - work->log_state = LOGON_WAIT; + DEBUG(3,("become_logon_server: go to first stage: register %s<1c> name\n", + work->work_group)); + work->log_state = LOGON_WAIT; - register_name(subrec, work->work_group,0x1c,samba_nb_type|NB_GROUP, - become_logon_server_success, - become_logon_server_fail, NULL); + register_name(subrec, work->work_group,0x1c,samba_nb_type|NB_GROUP, + become_logon_server_success, + become_logon_server_fail, NULL); } /***************************************************************************** Add the internet group <1c> logon names by unicast and broadcast. ****************************************************************************/ + void add_logon_names(void) { - struct subnet_record *subrec; - - for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec)) - { - struct work_record *work = find_workgroup_on_subnet(subrec, lp_workgroup()); - - if (work && (work->log_state == LOGON_NONE)) - { - struct nmb_name nmbname; - make_nmb_name(&nmbname,lp_workgroup(),0x1c); - - if (find_name_on_subnet(subrec, &nmbname, FIND_SELF_NAME) == NULL) - { - if( DEBUGLVL( 0 ) ) - { - dbgtext( "add_domain_logon_names:\n" ); - dbgtext( "Attempting to become logon server " ); - dbgtext( "for workgroup %s ", lp_workgroup() ); - dbgtext( "on subnet %s\n", subrec->subnet_name ); - } - become_logon_server(subrec, work); - } - } - } + struct subnet_record *subrec; + + for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec)) { + struct work_record *work = find_workgroup_on_subnet(subrec, lp_workgroup()); + + if (work && (work->log_state == LOGON_NONE)) { + struct nmb_name nmbname; + make_nmb_name(&nmbname,lp_workgroup(),0x1c); + + if (find_name_on_subnet(subrec, &nmbname, FIND_SELF_NAME) == NULL) { + if( DEBUGLVL( 0 ) ) { + dbgtext( "add_domain_logon_names:\n" ); + dbgtext( "Attempting to become logon server " ); + dbgtext( "for workgroup %s ", lp_workgroup() ); + dbgtext( "on subnet %s\n", subrec->subnet_name ); + } + become_logon_server(subrec, work); + } + } + } } |