summaryrefslogtreecommitdiff
path: root/source3/nmbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-11-12 23:15:52 +0000
committerJeremy Allison <jra@samba.org>2002-11-12 23:15:52 +0000
commit250c9801197ea1c949bd94c1c891f81ab118b130 (patch)
tree3a0ec79c71a010961d78726e223a70e1bc75c73f /source3/nmbd
parent477025a6f628fd1a8d3bfacd30726e7a41819e50 (diff)
downloadsamba-250c9801197ea1c949bd94c1c891f81ab118b130.tar.gz
samba-250c9801197ea1c949bd94c1c891f81ab118b130.tar.bz2
samba-250c9801197ea1c949bd94c1c891f81ab118b130.zip
Removed global_myworkgroup, global_myname, global_myscope. Added liberal
dashes of const. This is a rather large check-in, some things may break. It does compile though :-). Jeremy. (This used to be commit 82b8f749a36b42e22186297482aad2abb04fab8a)
Diffstat (limited to 'source3/nmbd')
-rw-r--r--source3/nmbd/nmbd.c102
-rw-r--r--source3/nmbd/nmbd_become_dmb.c25
-rw-r--r--source3/nmbd/nmbd_become_lmb.c32
-rw-r--r--source3/nmbd/nmbd_browsesync.c17
-rw-r--r--source3/nmbd/nmbd_elections.c23
-rw-r--r--source3/nmbd/nmbd_incomingdgrams.c30
-rw-r--r--source3/nmbd/nmbd_incomingrequests.c15
-rw-r--r--source3/nmbd/nmbd_logonnames.c19
-rw-r--r--source3/nmbd/nmbd_mynames.c27
-rw-r--r--source3/nmbd/nmbd_namelistdb.c4
-rw-r--r--source3/nmbd/nmbd_nameregister.c6
-rw-r--r--source3/nmbd/nmbd_packets.c14
-rw-r--r--source3/nmbd/nmbd_processlogon.c22
-rw-r--r--source3/nmbd/nmbd_sendannounce.c66
-rw-r--r--source3/nmbd/nmbd_serverlistdb.c31
-rw-r--r--source3/nmbd/nmbd_subnetdb.c3
-rw-r--r--source3/nmbd/nmbd_synclists.c2
-rw-r--r--source3/nmbd/nmbd_workgroupdb.c15
18 files changed, 158 insertions, 295 deletions
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 50730d40f3..5987d70a45 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -27,10 +27,6 @@ int ClientNMB = -1;
int ClientDGRAM = -1;
int global_nmb_port = -1;
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-extern char **my_netbios_names;
-
extern BOOL global_in_nmbd;
/* are we running as a daemon ? */
@@ -565,98 +561,6 @@ static BOOL open_sockets(BOOL isdaemon, int port)
}
/**************************************************************************** **
- Initialise connect, service and file structs.
- **************************************************************************** */
-
-static BOOL init_structs(void)
-{
- extern fstring local_machine;
- char *p, **ptr;
- int namecount;
- int n;
- int nodup;
- char *nbname;
-
- if (! *global_myname)
- {
- fstrcpy( global_myname, myhostname() );
- p = strchr_m( global_myname, '.' );
- if (p)
- *p = 0;
- }
- strupper( global_myname );
-
- /* Add any NETBIOS name aliases. Ensure that the first entry
- is equal to global_myname.
- */
- /* Work out the max number of netbios aliases that we have */
- ptr = lp_netbios_aliases();
- namecount = 0;
- if (ptr)
- for( ; *ptr; namecount++,ptr++ )
- ;
- if ( *global_myname )
- namecount++;
-
- /* Allocate space for the netbios aliases */
- my_netbios_names = (char **)malloc( sizeof(char *) * (namecount+1) );
- if( NULL == my_netbios_names )
- {
- DEBUG( 0, ( "init_structs: malloc fail.\n" ) );
- return( False );
- }
-
- /* Use the global_myname string first */
- namecount=0;
- if ( *global_myname )
- my_netbios_names[namecount++] = global_myname;
-
- ptr = lp_netbios_aliases();
- if (ptr)
- {
- while ( *ptr )
- {
- nbname = strdup(*ptr);
- if (nbname == NULL)
- {
- DEBUG(0,("init_structs: malloc fail when allocating names.\n"));
- return False;
- }
- strupper( nbname );
- /* Look for duplicates */
- nodup=1;
- for( n=0; n<namecount; n++ )
- {
- if( 0 == strcmp( nbname, my_netbios_names[n] ) )
- nodup=0;
- }
- if (nodup)
- my_netbios_names[namecount++] = nbname;
- else
- SAFE_FREE(nbname);
-
- ptr++;
- }
- }
-
- /* Terminate name list */
- my_netbios_names[namecount++] = NULL;
-
- fstrcpy( local_machine, global_myname );
- trim_string( local_machine, " ", " " );
- p = strchr_m( local_machine, ' ' );
- if (p)
- *p = 0;
- strlower( local_machine );
-
- DEBUG( 5, ("Netbios name list:-\n") );
- for( n=0; my_netbios_names[n]; n++ )
- DEBUGADD( 5, ( "my_netbios_names[%d]=\"%s\"\n", n, my_netbios_names[n] ) );
-
- return( True );
-}
-
-/**************************************************************************** **
main program
**************************************************************************** */
int main(int argc, const char *argv[])
@@ -727,14 +631,12 @@ static BOOL init_structs(void)
if ( !reload_nmbd_services(False) )
return(-1);
- if(!init_structs())
+ if(!init_names())
return -1;
reload_nmbd_services( True );
- fstrcpy( global_myworkgroup, lp_workgroup() );
-
- if (strequal(global_myworkgroup,"*"))
+ if (strequal(lp_workgroup(),"*"))
{
DEBUG(0,("ERROR: a workgroup name of * is no longer supported\n"));
exit(1);
diff --git a/source3/nmbd/nmbd_become_dmb.c b/source3/nmbd/nmbd_become_dmb.c
index ccc1f7e8ad..6b92f4c3c0 100644
--- a/source3/nmbd/nmbd_become_dmb.c
+++ b/source3/nmbd/nmbd_become_dmb.c
@@ -23,14 +23,11 @@
#include "includes.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-extern char **my_netbios_names;
extern struct in_addr allones_ip;
extern uint16 samba_nb_type; /* Samba's NetBIOS type. */
-static void become_domain_master_browser_bcast(char *);
+static void become_domain_master_browser_bcast(const char *);
/****************************************************************************
Fail to become a Domain Master Browser on a subnet.
@@ -53,11 +50,11 @@ workgroup %s on subnet %s\n", fail_name->name, subrec->subnet_name));
/* Set the state back to DOMAIN_NONE. */
work->dom_state = DOMAIN_NONE;
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, global_myname())) == NULL)
{
DEBUG(0,("become_domain_master_fail: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, work->work_group, subrec->subnet_name));
+ global_myname(), work->work_group, subrec->subnet_name));
return;
}
@@ -92,11 +89,11 @@ workgroup %s on subnet %s\n", registered_name->name, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, global_myname())) == NULL)
{
DEBUG(0,("become_domain_master_stage2: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, registered_name->name, subrec->subnet_name));
+ global_myname(), registered_name->name, subrec->subnet_name));
work->dom_state = DOMAIN_NONE;
return;
}
@@ -112,7 +109,7 @@ in workgroup %s on subnet %s\n",
if( DEBUGLVL( 0 ) )
{
- dbgtext( "*****\n\nSamba server %s ", global_myname );
+ dbgtext( "*****\n\nSamba server %s ", global_myname() );
dbgtext( "is now a domain master browser for " );
dbgtext( "workgroup %s ", work->work_group );
dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name );
@@ -128,7 +125,7 @@ in workgroup %s on subnet %s\n",
will stop us syncing with ourself if we are also
a local master browser. */
- make_nmb_name(&nmbname, global_myname, 0x20);
+ make_nmb_name(&nmbname, global_myname(), 0x20);
work->dmb_name = nmbname;
/* Pick the first interface ip address as the domain master browser ip. */
@@ -266,7 +263,7 @@ querying WINS server for name %s.\n",
Attempt to become a domain master browser on all broadcast subnets.
****************************************************************************/
-static void become_domain_master_browser_bcast(char *workgroup_name)
+static void become_domain_master_browser_bcast(const char *workgroup_name)
{
struct subnet_record *subrec;
@@ -315,7 +312,7 @@ for domain master browser on workgroup %s\n", subrec->subnet_name, workgroup_nam
Attempt to become a domain master browser by registering with WINS.
****************************************************************************/
-static void become_domain_master_browser_wins(char *workgroup_name)
+static void become_domain_master_browser_wins(const char *workgroup_name)
{
struct work_record *work;
@@ -391,9 +388,9 @@ void add_domain_names(time_t t)
1.9.16p2 to 1.9.16p11 - due to a bug in namelogon.c,
cannot provide domain master / domain logon services.
*/
- become_domain_master_browser_wins(global_myworkgroup);
+ become_domain_master_browser_wins(lp_workgroup());
}
else
- become_domain_master_browser_bcast(global_myworkgroup);
+ become_domain_master_browser_bcast(lp_workgroup());
}
}
diff --git a/source3/nmbd/nmbd_become_lmb.c b/source3/nmbd/nmbd_become_lmb.c
index 3e0884567e..7b8ba14bb5 100644
--- a/source3/nmbd/nmbd_become_lmb.c
+++ b/source3/nmbd/nmbd_become_lmb.c
@@ -23,8 +23,6 @@
#include "includes.h"
-extern pstring global_myname;
-
extern uint16 samba_nb_type; /* Samba's NetBIOS name type. */
/*******************************************************************
@@ -89,11 +87,11 @@ subnet %s.\n", workgroup_name, subrec->subnet_name ));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, global_myname())) == NULL)
{
DEBUG(0,("reset_workgroup_state: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, work->work_group, subrec->subnet_name));
+ global_myname(), work->work_group, subrec->subnet_name));
work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
return;
}
@@ -153,7 +151,7 @@ static void unbecome_local_master_success(struct subnet_record *subrec,
if( DEBUGLVL( 0 ) )
{
dbgtext( "*****\n\n" );
- dbgtext( "Samba name server %s ", global_myname );
+ dbgtext( "Samba name server %s ", global_myname() );
dbgtext( "has stopped being a local master browser " );
dbgtext( "for workgroup %s ", released_name->name );
dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name );
@@ -188,7 +186,7 @@ Removing from namelist anyway.\n", nmb_namestr(fail_name)));
if( DEBUGLVL( 0 ) )
{
dbgtext( "*****\n\n" );
- dbgtext( "Samba name server %s ", global_myname );
+ dbgtext( "Samba name server %s ", global_myname() );
dbgtext( "has stopped being a local master browser " );
dbgtext( "for workgroup %s ", fail_name->name );
dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name );
@@ -285,11 +283,11 @@ void unbecome_local_master_browser(struct subnet_record *subrec, struct work_rec
DEBUG(2,("unbecome_local_master_browser: unbecoming local master for workgroup %s \
on subnet %s\n",work->work_group, subrec->subnet_name));
- if(find_server_in_workgroup( work, global_myname) == NULL)
+ if(find_server_in_workgroup( work, global_myname()) == NULL)
{
DEBUG(0,("unbecome_local_master_browser: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, work->work_group, subrec->subnet_name));
+ global_myname(), work->work_group, subrec->subnet_name));
work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
return;
}
@@ -346,11 +344,11 @@ workgroup %s on subnet %s\n", registered_name->name, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, global_myname())) == NULL)
{
DEBUG(0,("become_local_master_stage2: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, registered_name->name, subrec->subnet_name));
+ global_myname(), registered_name->name, subrec->subnet_name));
work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
return;
}
@@ -368,7 +366,7 @@ on subnet %s\n", work->work_group, subrec->subnet_name));
subrec->work_changed = True;
/* Add this name to the workgroup as local master browser. */
- set_workgroup_local_master_browser_name( work, global_myname);
+ set_workgroup_local_master_browser_name( work, global_myname());
/* Count the number of servers we have on our list. If it's
less than 10 (just a heuristic) request the servers
@@ -403,7 +401,7 @@ on subnet %s\n", work->work_group, subrec->subnet_name));
if( DEBUGLVL( 0 ) )
{
dbgtext( "*****\n\n" );
- dbgtext( "Samba name server %s ", global_myname );
+ dbgtext( "Samba name server %s ", global_myname() );
dbgtext( "is now a local master browser " );
dbgtext( "for workgroup %s ", work->work_group );
dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name );
@@ -493,11 +491,11 @@ workgroup %s on subnet %s\n", work_name, subrec->subnet_name));
return;
}
- if(find_server_in_workgroup(work, global_myname) == NULL)
+ if(find_server_in_workgroup(work, global_myname()) == NULL)
{
DEBUG(0,("become_local_master_fail1: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, work->work_group, subrec->subnet_name));
+ global_myname(), work->work_group, subrec->subnet_name));
return;
}
@@ -536,11 +534,11 @@ void become_local_master_browser(struct subnet_record *subrec, struct work_recor
return;
}
- if(find_server_in_workgroup( work, global_myname) == NULL)
+ if(find_server_in_workgroup( work, global_myname()) == NULL)
{
DEBUG(0,("become_local_master_browser: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, work->work_group, subrec->subnet_name));
+ global_myname(), work->work_group, subrec->subnet_name));
return;
}
@@ -583,7 +581,7 @@ in workgroup %s on subnet %s\n",
as the workgroup name.
****************************************************************/
-void set_workgroup_local_master_browser_name( struct work_record *work, char *newname)
+void set_workgroup_local_master_browser_name( struct work_record *work, const char *newname)
{
DEBUG(5,("set_workgroup_local_master_browser_name: setting local master name to '%s' \
for workgroup %s.\n", newname, work->work_group ));
diff --git a/source3/nmbd/nmbd_browsesync.c b/source3/nmbd/nmbd_browsesync.c
index 5dcc8cce19..3a20f07b05 100644
--- a/source3/nmbd/nmbd_browsesync.c
+++ b/source3/nmbd/nmbd_browsesync.c
@@ -24,9 +24,6 @@
#include "includes.h"
#include "smb.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-
/* This is our local master browser list database. */
extern ubi_dlList lmb_browserlist[];
@@ -129,7 +126,7 @@ static void announce_local_master_browser_to_domain_master_browser( struct work_
SCVAL(p,0,ANN_MasterAnnouncement);
p++;
- StrnCpy(p,global_myname,15);
+ StrnCpy(p,global_myname(),15);
strupper(p);
p = skip_string(p,1);
@@ -142,7 +139,7 @@ static void announce_local_master_browser_to_domain_master_browser( struct work_
}
send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
- global_myname, 0x0, work->dmb_name.name, 0x0,
+ global_myname(), 0x0, work->dmb_name.name, 0x0,
work->dmb_addr, FIRST_SUBNET->myip, DGRAM_PORT);
}
@@ -611,12 +608,12 @@ void collect_all_workgroup_names_from_wins_server(time_t t)
return;
/* Check to see if we are a domain master browser on the unicast subnet. */
- if((work = find_workgroup_on_subnet( unicast_subnet, global_myworkgroup)) == NULL)
+ if((work = find_workgroup_on_subnet( unicast_subnet, lp_workgroup())) == NULL)
{
if( DEBUGLVL( 0 ) )
{
dbgtext( "collect_all_workgroup_names_from_wins_server:\n" );
- dbgtext( "Cannot find my workgroup %s ", global_myworkgroup );
+ dbgtext( "Cannot find my workgroup %s ", lp_workgroup() );
dbgtext( "on subnet %s.\n", unicast_subnet->subnet_name );
}
return;
@@ -660,7 +657,7 @@ void sync_all_dmbs(time_t t)
/* Check to see if we are a domain master browser on the
unicast subnet. */
- work = find_workgroup_on_subnet(unicast_subnet, global_myworkgroup);
+ work = find_workgroup_on_subnet(unicast_subnet, lp_workgroup());
if (!work) return;
if (!AM_DOMAIN_MASTER_BROWSER(work))
@@ -671,14 +668,14 @@ void sync_all_dmbs(time_t t)
/* count how many syncs we might need to do */
for (work=unicast_subnet->workgrouplist; work; work = work->next) {
- if (strcmp(global_myworkgroup, work->work_group)) {
+ if (strcmp(lp_workgroup(), work->work_group)) {
count++;
}
}
/* sync with a probability of 1/count */
for (work=unicast_subnet->workgrouplist; work; work = work->next) {
- if (strcmp(global_myworkgroup, work->work_group)) {
+ if (strcmp(lp_workgroup(), work->work_group)) {
if (((unsigned)sys_random()) % count != 0) continue;
lastrun = t;
diff --git a/source3/nmbd/nmbd_elections.c b/source3/nmbd/nmbd_elections.c
index acff7a72e8..976abbed25 100644
--- a/source3/nmbd/nmbd_elections.c
+++ b/source3/nmbd/nmbd_elections.c
@@ -23,17 +23,14 @@
#include "includes.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-
/* Election parameters. */
extern time_t StartupTime;
/****************************************************************************
Send an election datagram packet.
**************************************************************************/
-static void send_election_dgram(struct subnet_record *subrec, char *workgroup_name,
- uint32 criterion, int timeup,char *server_name)
+static void send_election_dgram(struct subnet_record *subrec, const char *workgroup_name,
+ uint32 criterion, int timeup,const char *server_name)
{
pstring outbuf;
char *p;
@@ -55,7 +52,7 @@ static void send_election_dgram(struct subnet_record *subrec, char *workgroup_na
p = skip_string(p,1);
send_mailslot(False, BROWSE_MAILSLOT, outbuf, PTR_DIFF(p,outbuf),
- global_myname, 0,
+ global_myname(), 0,
workgroup_name, 0x1e,
subrec->bcast_ip, subrec->myip, DGRAM_PORT);
}
@@ -92,7 +89,7 @@ static void check_for_master_browser_fail( struct subnet_record *subrec,
return;
}
- if (strequal(work->work_group, global_myworkgroup))
+ if (strequal(work->work_group, lp_workgroup()))
{
if (lp_local_master())
@@ -128,7 +125,7 @@ void check_master_browser_exists(time_t t)
{
static time_t lastrun=0;
struct subnet_record *subrec;
- char *workgroup_name = global_myworkgroup;
+ const char *workgroup_name = lp_workgroup();
if (!lastrun)
lastrun = t;
@@ -198,7 +195,7 @@ yet registered on subnet %s\n", nmb_namestr(&nmbname), subrec->subnet_name ));
}
send_election_dgram(subrec, work->work_group, work->ElectionCriterion,
- t - StartupTime, global_myname);
+ t - StartupTime, global_myname());
if (work->ElectionCount++ >= 4)
{
@@ -238,7 +235,7 @@ static BOOL win_election(struct work_record *work, int version,
version, ELECTION_VERSION,
criterion, mycriterion,
timeup, mytimeup,
- server_name, global_myname));
+ server_name, global_myname()));
if (version > ELECTION_VERSION)
return(False);
@@ -255,7 +252,7 @@ static BOOL win_election(struct work_record *work, int version,
if (timeup < mytimeup)
return(True);
- if (strcasecmp(global_myname, server_name) > 0)
+ if (strcasecmp(global_myname(), server_name) > 0)
return(False);
return(True);
@@ -290,7 +287,7 @@ void process_election(struct subnet_record *subrec, struct packet_struct *p, cha
goto done;
}
- if (!strequal(work->work_group, global_myworkgroup))
+ if (!strequal(work->work_group, lp_workgroup()))
{
DEBUG(3,("process_election: ignoring election request for workgroup %s on subnet %s as this \
is not my workgroup.\n", work->work_group, subrec->subnet_name ));
@@ -396,7 +393,7 @@ void nmbd_message_election(int msg_type, pid_t src, void *buf, size_t len)
for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec)) {
struct work_record *work;
for (work = subrec->workgrouplist; work; work = work->next) {
- if (strequal(work->work_group, global_myworkgroup)) {
+ if (strequal(work->work_group, lp_workgroup())) {
work->needelection = True;
work->ElectionCount=0;
work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
diff --git a/source3/nmbd/nmbd_incomingdgrams.c b/source3/nmbd/nmbd_incomingdgrams.c
index 261200b4c5..cd6954fc62 100644
--- a/source3/nmbd/nmbd_incomingdgrams.c
+++ b/source3/nmbd/nmbd_incomingdgrams.c
@@ -23,8 +23,6 @@
#include "includes.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
extern BOOL found_lm_clients;
#if 0
@@ -104,7 +102,7 @@ void process_host_announce(struct subnet_record *subrec, struct packet_struct *p
char *comment = buf+31;
struct work_record *work;
struct server_record *servrec;
- char *work_name;
+ const char *work_name;
char *source_name = dgram->source_name.name;
START_PROFILE(host_announce);
@@ -141,8 +139,8 @@ void process_host_announce(struct subnet_record *subrec, struct packet_struct *p
* to be our primary workgroup name.
*/
- if(strequal(work_name, global_myname))
- work_name = global_myworkgroup;
+ if(strequal(work_name, global_myname()))
+ work_name = lp_workgroup();
/*
* We are being very agressive here in adding a workgroup
@@ -396,10 +394,10 @@ master - ignoring master announce.\n"));
goto done;
}
- if((work = find_workgroup_on_subnet(subrec, global_myworkgroup)) == NULL)
+ if((work = find_workgroup_on_subnet(subrec, lp_workgroup())) == NULL)
{
DEBUG(0,("process_master_browser_announce: Cannot find workgroup %s on subnet %s\n",
- global_myworkgroup, subrec->subnet_name));
+ lp_workgroup(), subrec->subnet_name));
goto done;
}
@@ -439,7 +437,7 @@ void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct
char *announce_name = buf+9;
struct work_record *work;
struct server_record *servrec;
- char *work_name;
+ const char *work_name;
char *source_name = dgram->source_name.name;
pstring comment;
char *s = buf+9;
@@ -489,8 +487,8 @@ originate from OS/2 Warp client. Ignoring packet.\n"));
* not needed in the LanMan announce code, but it won't hurt.
*/
- if(strequal(work_name, global_myname))
- work_name = global_myworkgroup;
+ if(strequal(work_name, global_myname()))
+ work_name = lp_workgroup();
/*
* We are being very agressive here in adding a workgroup
@@ -580,7 +578,7 @@ static void send_backup_list_response(struct subnet_record *subrec,
/* We always return at least one name - our own. */
count = 1;
- StrnCpy(p,global_myname,15);
+ StrnCpy(p,global_myname(),15);
strupper(p);
p = skip_string(p,1);
@@ -605,7 +603,7 @@ static void send_backup_list_response(struct subnet_record *subrec,
if(count >= (unsigned int)max_number_requested)
break;
- if(strnequal(servrec->serv.name, global_myname,15))
+ if(strnequal(servrec->serv.name, global_myname(),15))
continue;
if(!(servrec->serv.type & SV_TYPE_BACKUP_BROWSER))
@@ -629,7 +627,7 @@ static void send_backup_list_response(struct subnet_record *subrec,
send_mailslot(True, BROWSE_MAILSLOT,
outbuf,PTR_DIFF(p,outbuf),
- global_myname, 0,
+ global_myname(), 0,
send_to_name->name,0,
sendto_ip, subrec->myip, port);
}
@@ -664,7 +662,7 @@ void process_get_backup_list_request(struct subnet_record *subrec,
for the requested workgroup. That means it must be our
workgroup. */
- if(strequal(workgroup_name, global_myworkgroup) == False)
+ if(strequal(workgroup_name, lp_workgroup()) == False)
{
DEBUG(7,("process_get_backup_list_request: Ignoring announce request for workgroup %s.\n",
workgroup_name));
@@ -801,7 +799,7 @@ void process_announce_request(struct subnet_record *subrec, struct packet_struct
nmb_namestr(&dgram->dest_name)));
/* We only send announcement requests on our workgroup. */
- if(strequal(workgroup_name, global_myworkgroup) == False)
+ if(strequal(workgroup_name, lp_workgroup()) == False)
{
DEBUG(7,("process_announce_request: Ignoring announce request for workgroup %s.\n",
workgroup_name));
@@ -840,7 +838,7 @@ void process_lm_announce_request(struct subnet_record *subrec, struct packet_str
nmb_namestr(&dgram->dest_name)));
/* We only send announcement requests on our workgroup. */
- if(strequal(workgroup_name, global_myworkgroup) == False)
+ if(strequal(workgroup_name, lp_workgroup()) == False)
{
DEBUG(7,("process_lm_announce_request: Ignoring announce request for workgroup %s.\n",
workgroup_name));
diff --git a/source3/nmbd/nmbd_incomingrequests.c b/source3/nmbd/nmbd_incomingrequests.c
index 834f237a2c..a8168566f1 100644
--- a/source3/nmbd/nmbd_incomingrequests.c
+++ b/source3/nmbd/nmbd_incomingrequests.c
@@ -27,8 +27,6 @@
#include "includes.h"
-extern fstring global_myworkgroup;
-
/****************************************************************************
Send a name release response.
**************************************************************************/
@@ -100,7 +98,7 @@ subnet %s from owner IP %s\n",
* names and *don't set the group bit* !!!!!
*/
- if( !group && !ismyip(owner_ip) && strequal(question->name, global_myworkgroup) &&
+ if( !group && !ismyip(owner_ip) && strequal(question->name, lp_workgroup()) &&
((question->name_type == 0x0) || (question->name_type == 0x1e)))
{
DEBUG(6,("process_name_release_request: FTP OnNet bug workaround. Ignoring \
@@ -292,20 +290,19 @@ We put our own names first, then in alphabetical order.
static int status_compare(char *n1,char *n2)
{
- extern pstring global_myname;
int l1,l2,l3;
/* It's a bit tricky because the names are space padded */
for (l1=0;l1<15 && n1[l1] && n1[l1] != ' ';l1++) ;
for (l2=0;l2<15 && n2[l2] && n2[l2] != ' ';l2++) ;
- l3 = strlen(global_myname);
+ l3 = strlen(global_myname());
- if ((l1==l3) && strncmp(n1,global_myname,l3) == 0 &&
- (l2!=l3 || strncmp(n2,global_myname,l3) != 0))
+ if ((l1==l3) && strncmp(n1,global_myname(),l3) == 0 &&
+ (l2!=l3 || strncmp(n2,global_myname(),l3) != 0))
return -1;
- if ((l2==l3) && strncmp(n2,global_myname,l3) == 0 &&
- (l1!=l3 || strncmp(n1,global_myname,l3) != 0))
+ if ((l2==l3) && strncmp(n2,global_myname(),l3) == 0 &&
+ (l1!=l3 || strncmp(n1,global_myname(),l3) != 0))
return 1;
return memcmp(n1,n2,18);
diff --git a/source3/nmbd/nmbd_logonnames.c b/source3/nmbd/nmbd_logonnames.c
index 28e0e8a02b..b73586aa45 100644
--- a/source3/nmbd/nmbd_logonnames.c
+++ b/source3/nmbd/nmbd_logonnames.c
@@ -23,9 +23,6 @@
#include "includes.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-extern char **my_netbios_names;
extern struct in_addr allones_ip;
extern uint16 samba_nb_type; /* Samba's NetBIOS type. */
@@ -47,11 +44,11 @@ workgroup %s on subnet %s\n", fail_name->name, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ 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));
+ global_myname(), fail_name->name, subrec->subnet_name));
work->log_state = LOGON_NONE;
return;
}
@@ -87,11 +84,11 @@ workgroup %s on subnet %s\n", registered_name->name, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ 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));
+ global_myname(), registered_name->name, subrec->subnet_name));
work->log_state = LOGON_NONE;
return;
}
@@ -115,7 +112,7 @@ in workgroup %s on subnet %s\n",
*/
{
struct nmb_name nmbname;
- make_nmb_name(&nmbname,global_myworkgroup,0x1c);
+ make_nmb_name(&nmbname,lp_workgroup(),0x1c);
insert_permanent_name_into_unicast(subrec, &nmbname, 0x1c);
}
@@ -152,12 +149,12 @@ void add_logon_names(void)
for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec))
{
- struct work_record *work = find_workgroup_on_subnet(subrec, global_myworkgroup);
+ 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,global_myworkgroup,0x1c);
+ make_nmb_name(&nmbname,lp_workgroup(),0x1c);
if (find_name_on_subnet(subrec, &nmbname, FIND_SELF_NAME) == NULL)
{
@@ -165,7 +162,7 @@ void add_logon_names(void)
{
dbgtext( "add_domain_logon_names:\n" );
dbgtext( "Attempting to become logon server " );
- dbgtext( "for workgroup %s ", global_myworkgroup );
+ dbgtext( "for workgroup %s ", lp_workgroup() );
dbgtext( "on subnet %s\n", subrec->subnet_name );
}
become_logon_server(subrec, work);
diff --git a/source3/nmbd/nmbd_mynames.c b/source3/nmbd/nmbd_mynames.c
index ba7d509a77..dd66821839 100644
--- a/source3/nmbd/nmbd_mynames.c
+++ b/source3/nmbd/nmbd_mynames.c
@@ -23,9 +23,6 @@
#include "includes.h"
-extern char **my_netbios_names;
-extern fstring global_myworkgroup;
-
extern uint16 samba_nb_type; /* Samba's NetBIOS type. */
/****************************************************************************
@@ -51,10 +48,10 @@ void register_my_workgroup_one_subnet(struct subnet_record *subrec)
struct work_record *work;
/* Create the workgroup on the subnet. */
- if((work = create_workgroup_on_subnet(subrec, global_myworkgroup,
+ if((work = create_workgroup_on_subnet(subrec, lp_workgroup(),
PERMANENT_TTL)) == NULL) {
DEBUG(0,("register_my_workgroup_and_names: Failed to create my workgroup %s on subnet %s. \
-Exiting.\n", global_myworkgroup, subrec->subnet_name));
+Exiting.\n", lp_workgroup(), subrec->subnet_name));
return;
}
@@ -63,14 +60,14 @@ Exiting.\n", global_myworkgroup, subrec->subnet_name));
add_samba_names_to_subnet(subrec);
/* Register all our names including aliases. */
- for (i=0; my_netbios_names[i]; i++) {
- register_name(subrec, my_netbios_names[i],0x20,samba_nb_type,
+ for (i=0; my_netbios_names(i); i++) {
+ register_name(subrec, my_netbios_names(i),0x20,samba_nb_type,
NULL,
my_name_register_failed, NULL);
- register_name(subrec, my_netbios_names[i],0x03,samba_nb_type,
+ register_name(subrec, my_netbios_names(i),0x03,samba_nb_type,
NULL,
my_name_register_failed, NULL);
- register_name(subrec, my_netbios_names[i],0x00,samba_nb_type,
+ register_name(subrec, my_netbios_names(i),0x00,samba_nb_type,
NULL,
my_name_register_failed, NULL);
}
@@ -133,7 +130,7 @@ BOOL register_my_workgroup_and_names(void)
add_samba_names_to_subnet(unicast_subnet);
- for (i=0; my_netbios_names[i]; i++)
+ for (i=0; my_netbios_names(i); i++)
{
for(subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec))
{
@@ -142,13 +139,13 @@ BOOL register_my_workgroup_and_names(void)
*/
struct nmb_name nmbname;
- make_nmb_name(&nmbname, my_netbios_names[i],0x20);
+ make_nmb_name(&nmbname, my_netbios_names(i),0x20);
insert_refresh_name_into_unicast(subrec, &nmbname, samba_nb_type);
- make_nmb_name(&nmbname, my_netbios_names[i],0x3);
+ make_nmb_name(&nmbname, my_netbios_names(i),0x3);
insert_refresh_name_into_unicast(subrec, &nmbname, samba_nb_type);
- make_nmb_name(&nmbname, my_netbios_names[i],0x0);
+ make_nmb_name(&nmbname, my_netbios_names(i),0x0);
insert_refresh_name_into_unicast(subrec, &nmbname, samba_nb_type);
}
}
@@ -165,10 +162,10 @@ BOOL register_my_workgroup_and_names(void)
*/
struct nmb_name nmbname;
- make_nmb_name(&nmbname, global_myworkgroup, 0x0);
+ make_nmb_name(&nmbname, lp_workgroup(), 0x0);
insert_refresh_name_into_unicast(subrec, &nmbname, samba_nb_type|NB_GROUP);
- make_nmb_name(&nmbname, global_myworkgroup, 0x1e);
+ make_nmb_name(&nmbname, lp_workgroup(), 0x1e);
insert_refresh_name_into_unicast(subrec, &nmbname, samba_nb_type|NB_GROUP);
}
diff --git a/source3/nmbd/nmbd_namelistdb.c b/source3/nmbd/nmbd_namelistdb.c
index bca79ef0c8..7ff2d4171e 100644
--- a/source3/nmbd/nmbd_namelistdb.c
+++ b/source3/nmbd/nmbd_namelistdb.c
@@ -23,8 +23,6 @@
#include "includes.h"
-extern char **my_netbios_names;
-
uint16 samba_nb_type = 0; /* samba's NetBIOS name type */
@@ -215,7 +213,7 @@ struct name_record *add_name_to_subnet( struct subnet_record *subrec,
namerec->data.wins_flags = WINS_ACTIVE;
/* If it's our primary name, flag it as so. */
- if( strequal( my_netbios_names[0], name ) )
+ if( strequal( my_netbios_names(0), name ) )
namerec->data.nb_flags |= NB_PERM;
/* Copy the IPs. */
diff --git a/source3/nmbd/nmbd_nameregister.c b/source3/nmbd/nmbd_nameregister.c
index b6d3c20d99..7bf2584053 100644
--- a/source3/nmbd/nmbd_nameregister.c
+++ b/source3/nmbd/nmbd_nameregister.c
@@ -23,8 +23,6 @@
#include "includes.h"
-extern fstring global_myworkgroup;
-
/* forward declarations */
static void wins_next_registration(struct response_record *rrec);
@@ -87,7 +85,7 @@ static void register_name_response(struct subnet_record *subrec,
*/
#if 1 /* OLD_SAMBA_SERVER_HACK */
- if((nmb->header.rcode == ACT_ERR) && strequal(global_myworkgroup, answer_name->name) &&
+ if((nmb->header.rcode == ACT_ERR) && strequal(lp_workgroup(), answer_name->name) &&
(answer_name->name_type == 0x1b)) {
/* Pretend we did not get this. */
rrec->num_msgs--;
@@ -463,7 +461,7 @@ static void multihomed_register_name(struct nmb_name *nmbname, uint16 nb_flags,
Try and register one of our names.
****************************************************************************/
void register_name(struct subnet_record *subrec,
- char *name, int type, uint16 nb_flags,
+ const char *name, int type, uint16 nb_flags,
register_name_success_function success_fn,
register_name_fail_function fail_fn,
struct userdata_struct *userdata)
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index d252b98ed6..894f6bb7d6 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -1080,15 +1080,14 @@ static void process_browse_packet(struct packet_struct *p, char *buf,int len)
struct dgram_packet *dgram = &p->packet.dgram;
int command = CVAL(buf,0);
struct subnet_record *subrec = find_subnet_for_dgram_browse_packet(p);
- extern pstring global_scope;
/* Drop the packet if it's a different NetBIOS scope, or
the source is from one of our names. */
- if (!strequal(dgram->dest_name.scope, global_scope))
+ if (!strequal(dgram->dest_name.scope, global_scope()))
{
DEBUG(7,("process_browse_packet: Discarding datagram from IP %s. Scope (%s) \
-mismatch with our scope (%s).\n", inet_ntoa(p->ip), dgram->dest_name.scope, global_scope));
+mismatch with our scope (%s).\n", inet_ntoa(p->ip), dgram->dest_name.scope, global_scope()));
return;
}
@@ -1193,15 +1192,14 @@ static void process_lanman_packet(struct packet_struct *p, char *buf,int len)
struct dgram_packet *dgram = &p->packet.dgram;
int command = SVAL(buf,0);
struct subnet_record *subrec = find_subnet_for_dgram_browse_packet(p);
- extern pstring global_scope;
/* Drop the packet if it's a different NetBIOS scope, or
the source is from one of our names. */
- if (!strequal(dgram->dest_name.scope, global_scope))
+ if (!strequal(dgram->dest_name.scope, global_scope()))
{
DEBUG(7,("process_lanman_packet: Discarding datagram from IP %s. Scope (%s) \
-mismatch with our scope (%s).\n", inet_ntoa(p->ip), dgram->dest_name.scope, global_scope));
+mismatch with our scope (%s).\n", inet_ntoa(p->ip), dgram->dest_name.scope, global_scope()));
return;
}
@@ -1932,8 +1930,8 @@ BOOL listen_for_packets(BOOL run_election)
Construct and send a netbios DGRAM.
**************************************************************************/
BOOL send_mailslot(BOOL unique, char *mailslot,char *buf,int len,
- char *srcname, int src_type,
- char *dstname, int dest_type,
+ const char *srcname, int src_type,
+ const char *dstname, int dest_type,
struct in_addr dest_ip,struct in_addr src_ip,
int dest_port)
{
diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c
index b65cebe203..6f2517f39f 100644
--- a/source3/nmbd/nmbd_processlogon.c
+++ b/source3/nmbd/nmbd_processlogon.c
@@ -27,9 +27,6 @@
#include "includes.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-
struct sam_database_info {
uint32 index;
uint32 serial_lo, serial_hi;
@@ -93,8 +90,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
return;
}
- pstrcpy(my_name, global_myname);
- strupper(my_name);
+ pstrcpy(my_name, global_myname());
code = SVAL(buf,0);
DEBUG(1,("process_logon_packet: Logon from %s: code = 0x%x\n", inet_ntoa(p->ip), code));
@@ -131,7 +127,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
send_mailslot(True, getdc,
outbuf,PTR_DIFF(q,outbuf),
- global_myname, 0x0,
+ global_myname(), 0x0,
machine,
dgram->source_name.name_type,
p->ip, *iface_ip(p->ip), p->port);
@@ -198,7 +194,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
q = ALIGN2(q, outbuf);
q += dos_PutUniCode(q, my_name, sizeof(pstring), True); /* PDC name */
- q += dos_PutUniCode(q, global_myworkgroup,sizeof(pstring), True); /* Domain name*/
+ q += dos_PutUniCode(q, lp_workgroup(),sizeof(pstring), True); /* Domain name*/
SIVAL(q, 0, 1); /* our nt version */
SSVAL(q, 4, 0xffff); /* our lmnttoken */
SSVAL(q, 6, 0xffff); /* our lm20token */
@@ -209,7 +205,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
DEBUG(3,("process_logon_packet: GETDC request from %s at IP %s, \
reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
- machine,inet_ntoa(p->ip), reply_name, global_myworkgroup,
+ machine,inet_ntoa(p->ip), reply_name, lp_workgroup(),
QUERYFORPDC_R, (uint32)ntversion, (uint32)lmnttoken,
(uint32)lm20token ));
@@ -217,7 +213,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
send_mailslot(True, getdc,
outbuf,PTR_DIFF(q,outbuf),
- global_myname, 0x0,
+ global_myname(), 0x0,
dgram->source_name.name,
dgram->source_name.name_type,
p->ip, *iface_ip(p->ip), p->port);
@@ -280,7 +276,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
fstrcpy(reply_name+2,my_name);
DEBUG(3,("process_logon_packet: SAMLOGON request from %s(%s) for %s, returning logon svr %s domain %s code %x token=%x\n",
- asccomp,inet_ntoa(p->ip), ascuser, reply_name, global_myworkgroup,
+ asccomp,inet_ntoa(p->ip), ascuser, reply_name, lp_workgroup(),
SAMLOGON_R ,lmnttoken));
/* Construct reply. */
@@ -299,7 +295,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
q += dos_PutUniCode(q, reply_name,sizeof(pstring), True);
q += dos_PutUniCode(q, ascuser, sizeof(pstring), True);
- q += dos_PutUniCode(q, global_myworkgroup,sizeof(pstring), True);
+ q += dos_PutUniCode(q, lp_workgroup(),sizeof(pstring), True);
}
#ifdef HAVE_ADS
else {
@@ -345,7 +341,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
q += 2; /* it must follow the domain name. */
/* Push dns host name */
- size = push_ascii(&q[1], global_myname, -1, 0);
+ size = push_ascii(&q[1], global_myname(), -1, 0);
SCVAL(q, 0, size);
q += (size + 1);
SSVAL(q, 0, 0x18c0); /* not sure what this is for, but */
@@ -397,7 +393,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
send_mailslot(True, getdc,
outbuf,PTR_DIFF(q,outbuf),
- global_myname, 0x0,
+ global_myname(), 0x0,
dgram->source_name.name,
dgram->source_name.name_type,
p->ip, *iface_ip(p->ip), p->port);
diff --git a/source3/nmbd/nmbd_sendannounce.c b/source3/nmbd/nmbd_sendannounce.c
index d4a7070042..de05ee973c 100644
--- a/source3/nmbd/nmbd_sendannounce.c
+++ b/source3/nmbd/nmbd_sendannounce.c
@@ -26,9 +26,6 @@
#include "includes.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-extern char **my_netbios_names;
extern int updatecount;
extern BOOL found_lm_clients;
@@ -52,7 +49,7 @@ void send_browser_reset(int reset_type, char *to_name, int to_type, struct in_ad
p++;
send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
- global_myname, 0x0, to_name, to_type, to_ip,
+ global_myname(), 0x0, to_name, to_type, to_ip,
FIRST_SUBNET->myip, DGRAM_PORT);
}
@@ -78,10 +75,10 @@ to subnet %s\n", work->work_group, subrec->subnet_name));
SCVAL(p,0,work->token); /* (local) Unique workgroup token id. */
p++;
- p += push_string(NULL, p+1, global_myname, 15, STR_ASCII|STR_UPPER|STR_TERMINATE);
+ p += push_string(NULL, p+1, global_myname(), 15, STR_ASCII|STR_UPPER|STR_TERMINATE);
send_mailslot(False, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
- global_myname, 0x0, work->work_group,0x1e, subrec->bcast_ip,
+ global_myname(), 0x0, work->work_group,0x1e, subrec->bcast_ip,
subrec->myip, DGRAM_PORT);
}
@@ -90,9 +87,9 @@ to subnet %s\n", work->work_group, subrec->subnet_name));
**************************************************************************/
static void send_announcement(struct subnet_record *subrec, int announce_type,
- char *from_name, char *to_name, int to_type, struct in_addr to_ip,
+ const char *from_name, const char *to_name, int to_type, struct in_addr to_ip,
time_t announce_interval,
- char *server_name, int server_type, char *server_comment)
+ const char *server_name, int server_type, const char *server_comment)
{
pstring outbuf;
char *p;
@@ -168,14 +165,14 @@ static void send_local_master_announcement(struct subnet_record *subrec, struct
uint32 type = servrec->serv.type & ~SV_TYPE_LOCAL_LIST_ONLY;
DEBUG(3,("send_local_master_announcement: type %x for name %s on subnet %s for workgroup %s\n",
- type, global_myname, subrec->subnet_name, work->work_group));
+ type, global_myname(), subrec->subnet_name, work->work_group));
send_announcement(subrec, ANN_LocalMasterAnnouncement,
- global_myname, /* From nbt name. */
+ global_myname(), /* From nbt name. */
work->work_group, 0x1e, /* To nbt name. */
subrec->bcast_ip, /* To ip. */
work->announce_interval, /* Time until next announce. */
- global_myname, /* Name to announce. */
+ global_myname(), /* Name to announce. */
type, /* Type field. */
servrec->serv.comment);
}
@@ -190,13 +187,13 @@ static void send_workgroup_announcement(struct subnet_record *subrec, struct wor
subrec->subnet_name, work->work_group));
send_announcement(subrec, ANN_DomainAnnouncement,
- global_myname, /* From nbt name. */
+ global_myname(), /* From nbt name. */
MSBROWSE, 0x1, /* To nbt name. */
subrec->bcast_ip, /* To ip. */
work->announce_interval, /* Time until next announce. */
work->work_group, /* Name to announce. */
SV_TYPE_DOMAIN_ENUM|SV_TYPE_NT, /* workgroup announce flags. */
- global_myname); /* From name as comment. */
+ global_myname()); /* From name as comment. */
}
/****************************************************************************
@@ -255,7 +252,7 @@ static void announce_server(struct subnet_record *subrec, struct work_record *wo
/* Only do domain announcements if we are a master and it's
our primary name we're being asked to announce. */
- if (AM_LOCAL_MASTER_BROWSER(work) && strequal(global_myname,servrec->serv.name))
+ if (AM_LOCAL_MASTER_BROWSER(work) && strequal(global_myname(),servrec->serv.name))
{
send_local_master_announcement(subrec, work, servrec);
send_workgroup_announcement(subrec, work);
@@ -277,7 +274,7 @@ void announce_my_server_names(time_t t)
for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec))
{
- struct work_record *work = find_workgroup_on_subnet(subrec, global_myworkgroup);
+ struct work_record *work = find_workgroup_on_subnet(subrec, lp_workgroup());
if(work)
{
@@ -341,7 +338,7 @@ void announce_my_lm_server_names(time_t t)
for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec))
{
- struct work_record *work = find_workgroup_on_subnet(subrec, global_myworkgroup);
+ struct work_record *work = find_workgroup_on_subnet(subrec, lp_workgroup());
if(work)
{
@@ -483,7 +480,8 @@ void announce_my_servers_removed(void)
void announce_remote(time_t t)
{
- char *s,*ptr;
+ char *s;
+ const char *ptr;
static time_t last_time = 0;
pstring s2;
struct in_addr addr;
@@ -505,14 +503,17 @@ void announce_remote(time_t t)
{
/* The entries are of the form a.b.c.d/WORKGROUP with
WORKGROUP being optional */
- char *wgroup;
+ const char *wgroup;
+ char *pwgroup;
int i;
- wgroup = strchr_m(s2,'/');
- if (wgroup)
- *wgroup++ = 0;
- if (!wgroup || !*wgroup)
- wgroup = global_myworkgroup;
+ pwgroup = strchr_m(s2,'/');
+ if (pwgroup)
+ *pwgroup++ = 0;
+ if (!pwgroup || !*pwgroup)
+ wgroup = lp_workgroup();
+ else
+ wgroup = pwgroup;
addr = *interpret_addr2(s2);
@@ -520,9 +521,9 @@ void announce_remote(time_t t)
/* Give the ip address as the address of our first
broadcast subnet. */
- for(i=0; my_netbios_names[i]; i++)
+ for(i=0; my_netbios_names(i); i++)
{
- char *name = my_netbios_names[i];
+ const char *name = my_netbios_names(i);
DEBUG(5,("announce_remote: Doing remote announce for server %s to IP %s.\n",
name, inet_ntoa(addr) ));
@@ -546,7 +547,8 @@ void announce_remote(time_t t)
void browse_sync_remote(time_t t)
{
- char *s,*ptr;
+ char *s;
+ const char *ptr;
static time_t last_time = 0;
pstring s2;
struct in_addr addr;
@@ -568,17 +570,17 @@ void browse_sync_remote(time_t t)
* for our workgroup on the firsst subnet.
*/
- if((work = find_workgroup_on_subnet(FIRST_SUBNET, global_myworkgroup)) == NULL)
+ if((work = find_workgroup_on_subnet(FIRST_SUBNET, lp_workgroup())) == NULL)
{
DEBUG(0,("browse_sync_remote: Cannot find workgroup %s on subnet %s\n",
- global_myworkgroup, FIRST_SUBNET->subnet_name ));
+ lp_workgroup(), FIRST_SUBNET->subnet_name ));
return;
}
if(!AM_LOCAL_MASTER_BROWSER(work))
{
DEBUG(5,("browse_sync_remote: We can only do this if we are a local master browser \
-for workgroup %s on subnet %s.\n", global_myworkgroup, FIRST_SUBNET->subnet_name ));
+for workgroup %s on subnet %s.\n", lp_workgroup(), FIRST_SUBNET->subnet_name ));
return;
}
@@ -587,7 +589,7 @@ for workgroup %s on subnet %s.\n", global_myworkgroup, FIRST_SUBNET->subnet_name
SCVAL(p,0,ANN_MasterAnnouncement);
p++;
- StrnCpy(p,global_myname,15);
+ StrnCpy(p,global_myname(),15);
strupper(p);
p = skip_string(p,1);
@@ -597,9 +599,9 @@ for workgroup %s on subnet %s.\n", global_myworkgroup, FIRST_SUBNET->subnet_name
addr = *interpret_addr2(s2);
DEBUG(5,("announce_remote: Doing remote browse sync announce for server %s to IP %s.\n",
- global_myname, inet_ntoa(addr) ));
+ global_myname(), inet_ntoa(addr) ));
send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
- global_myname, 0x0, "*", 0x0, addr, FIRST_SUBNET->myip, DGRAM_PORT);
+ global_myname(), 0x0, "*", 0x0, addr, FIRST_SUBNET->myip, DGRAM_PORT);
}
}
diff --git a/source3/nmbd/nmbd_serverlistdb.c b/source3/nmbd/nmbd_serverlistdb.c
index a315d80afe..2fee239b2d 100644
--- a/source3/nmbd/nmbd_serverlistdb.c
+++ b/source3/nmbd/nmbd_serverlistdb.c
@@ -26,9 +26,6 @@
extern int ClientNMB;
-extern fstring global_myworkgroup;
-extern char **my_netbios_names;
-
int updatecount = 0;
/*******************************************************************
@@ -91,7 +88,7 @@ static void add_server_to_workgroup(struct work_record *work,
Find a server in a server list.
**************************************************************************/
-struct server_record *find_server_in_workgroup(struct work_record *work, char *name)
+struct server_record *find_server_in_workgroup(struct work_record *work, const char *name)
{
struct server_record *ret;
@@ -128,8 +125,8 @@ void remove_server_from_workgroup(struct work_record *work, struct server_record
****************************************************************************/
struct server_record *create_server_on_workgroup(struct work_record *work,
- char *name,int servertype,
- int ttl,char *comment)
+ const char *name,int servertype,
+ int ttl, const char *comment)
{
struct server_record *servrec;
@@ -256,7 +253,7 @@ static uint32 write_this_server_name( struct subnet_record *subrec,
/*******************************************************************
Decide if we should write out a workgroup record for this workgroup.
- We return zero if we should not. Don't write out global_myworkgroup (we've
+ We return zero if we should not. Don't write out lp_workgroup() (we've
already done it) and also don't write out a second workgroup record
on the unicast subnet that we've already written out on one of the
broadcast subnets.
@@ -267,7 +264,7 @@ static uint32 write_this_workgroup_name( struct subnet_record *subrec,
{
struct subnet_record *ssub;
- if(strequal(global_myworkgroup, work->work_group))
+ if(strequal(lp_workgroup(), work->work_group))
return 0;
/* This is a workgroup we have seen on a broadcast subnet. All
@@ -295,8 +292,8 @@ static uint32 write_this_workgroup_name( struct subnet_record *subrec,
Write out the browse.dat file.
******************************************************************/
-void write_browse_list_entry(XFILE *fp, fstring name, uint32 rec_type,
- fstring local_master_browser_name, fstring description)
+void write_browse_list_entry(XFILE *fp, const char *name, uint32 rec_type,
+ const char *local_master_browser_name, const char *description)
{
fstring tmp;
@@ -368,10 +365,10 @@ void write_browse_list(time_t t, BOOL force_write)
* subnet.
*/
- if((work = find_workgroup_on_subnet(FIRST_SUBNET, global_myworkgroup)) == NULL)
+ if((work = find_workgroup_on_subnet(FIRST_SUBNET, lp_workgroup())) == NULL)
{
DEBUG(0,("write_browse_list: Fatal error - cannot find my workgroup %s\n",
- global_myworkgroup));
+ lp_workgroup()));
x_fclose(fp);
return;
}
@@ -388,22 +385,22 @@ void write_browse_list(time_t t, BOOL force_write)
* once.
*/
- for (i=0; my_netbios_names[i]; i++)
+ for (i=0; my_netbios_names(i); i++)
{
stype = 0;
for (subrec = FIRST_SUBNET; subrec ; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec))
{
- if((work = find_workgroup_on_subnet( subrec, global_myworkgroup )) == NULL)
+ if((work = find_workgroup_on_subnet( subrec, lp_workgroup() )) == NULL)
continue;
- if((servrec = find_server_in_workgroup( work, my_netbios_names[i])) == NULL)
+ if((servrec = find_server_in_workgroup( work, my_netbios_names(i))) == NULL)
continue;
stype |= servrec->serv.type;
}
/* Output server details, plus what workgroup they're in. */
- write_browse_list_entry(fp, my_netbios_names[i], stype,
- string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), global_myworkgroup);
+ write_browse_list_entry(fp, my_netbios_names(i), stype,
+ string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), lp_workgroup());
}
for (subrec = FIRST_SUBNET; subrec ; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec))
diff --git a/source3/nmbd/nmbd_subnetdb.c b/source3/nmbd/nmbd_subnetdb.c
index e68fc1589c..3ca33c4e53 100644
--- a/source3/nmbd/nmbd_subnetdb.c
+++ b/source3/nmbd/nmbd_subnetdb.c
@@ -30,9 +30,6 @@ extern int ClientNMB;
extern int ClientDGRAM;
extern int global_nmb_port;
-extern fstring myworkgroup;
-extern char **my_netbios_names;
-
/* This is the broadcast subnets database. */
struct subnet_record *subnetlist = NULL;
diff --git a/source3/nmbd/nmbd_synclists.c b/source3/nmbd/nmbd_synclists.c
index 24adf4e69f..30c7d579f1 100644
--- a/source3/nmbd/nmbd_synclists.c
+++ b/source3/nmbd/nmbd_synclists.c
@@ -247,7 +247,7 @@ static void complete_sync(struct sync_record *s)
unsigned type;
pstring comment;
pstring line;
- char *ptr;
+ const char *ptr;
int count=0;
f = x_fopen(s->fname,O_RDONLY, 0);
diff --git a/source3/nmbd/nmbd_workgroupdb.c b/source3/nmbd/nmbd_workgroupdb.c
index d1cfc24a31..f2dc80dfe5 100644
--- a/source3/nmbd/nmbd_workgroupdb.c
+++ b/source3/nmbd/nmbd_workgroupdb.c
@@ -26,9 +26,6 @@
extern int ClientNMB;
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-extern char **my_netbios_names;
extern uint16 samba_nb_type;
int workgroup_count = 0; /* unique index key: one for each workgroup */
@@ -226,7 +223,7 @@ void initiate_myworkgroup_startup(struct subnet_record *subrec, struct work_reco
{
int i;
- if(!strequal(global_myworkgroup, work->work_group))
+ if(!strequal(lp_workgroup(), work->work_group))
return;
/* If this is a broadcast subnet then start elections on it
@@ -244,21 +241,21 @@ workgroup %s on subnet %s\n", work->work_group, subrec->subnet_name));
/* Register the WORKGROUP<0> and WORKGROUP<1e> names on the network. */
- register_name(subrec,global_myworkgroup,0x0,samba_nb_type|NB_GROUP,
+ register_name(subrec,lp_workgroup(),0x0,samba_nb_type|NB_GROUP,
NULL,
fail_register,NULL);
- register_name(subrec,global_myworkgroup,0x1e,samba_nb_type|NB_GROUP,
+ register_name(subrec,lp_workgroup(),0x1e,samba_nb_type|NB_GROUP,
NULL,
fail_register,NULL);
- for( i = 0; my_netbios_names[i]; i++)
+ for( i = 0; my_netbios_names(i); i++)
{
- char *name = my_netbios_names[i];
+ const char *name = my_netbios_names(i);
int stype = lp_default_server_announce() | (lp_local_master() ?
SV_TYPE_POTENTIAL_BROWSER : 0 );
- if(!strequal(global_myname, name))
+ if(!strequal(global_myname(), name))
stype &= ~(SV_TYPE_MASTER_BROWSER|SV_TYPE_POTENTIAL_BROWSER|
SV_TYPE_DOMAIN_MASTER|SV_TYPE_DOMAIN_MEMBER);