summaryrefslogtreecommitdiff
path: root/source/nmbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-04-30 13:28:41 +0000
committerJeremy Allison <jra@samba.org>2002-04-30 13:28:41 +0000
commitd04b55f2186fb8af998cf61c576771a5f72f4892 (patch)
tree9ff8c3a7cf34cefc0ee9a550a3bb1236a9e77595 /source/nmbd
parent73267ca42d9eddabb71b31b4c5068ebbe7bc9f7c (diff)
downloadsamba-d04b55f2186fb8af998cf61c576771a5f72f4892.tar.gz
Start of merge to 2_2_RELEASE branch for release.
Jeremy.
Diffstat (limited to 'source/nmbd')
-rw-r--r--source/nmbd/nmbd.c87
-rw-r--r--source/nmbd/nmbd_become_dmb.c8
-rw-r--r--source/nmbd/nmbd_browsesync.c5
-rw-r--r--source/nmbd/nmbd_logonnames.c1
-rw-r--r--source/nmbd/nmbd_mynames.c39
-rw-r--r--source/nmbd/nmbd_namequery.c6
-rw-r--r--source/nmbd/nmbd_responserecordsdb.c2
-rw-r--r--source/nmbd/nmbd_subnetdb.c11
-rw-r--r--source/nmbd/nmbd_synclists.c6
-rw-r--r--source/nmbd/nmbd_winsserver.c4
-rw-r--r--source/nmbd/nmbd_workgroupdb.c3
11 files changed, 103 insertions, 69 deletions
diff --git a/source/nmbd/nmbd.c b/source/nmbd/nmbd.c
index fa4e1c4cfd9..52f9d6d9f03 100644
--- a/source/nmbd/nmbd.c
+++ b/source/nmbd/nmbd.c
@@ -50,55 +50,52 @@ BOOL found_lm_clients = False;
time_t StartupTime = 0;
-extern struct in_addr ipzero;
-
/**************************************************************************** **
- Catch a sigterm.
+ Handle a SIGTERM in band.
**************************************************************************** */
-static void sig_term(int sig)
+static void terminate(void)
{
- BlockSignals(True,SIGTERM);
-
- DEBUG(0,("Got SIGTERM: going down...\n"));
-
- /* Write out wins.dat file if samba is a WINS server */
- wins_write_database(False);
-
- /* Remove all SELF registered names. */
- release_my_names();
-
- /* Announce all server entries as 0 time-to-live, 0 type. */
- announce_my_servers_removed();
+ DEBUG(0,("Got SIGTERM: going down...\n"));
+
+ /* Write out wins.dat file if samba is a WINS server */
+ wins_write_database(False);
- /* If there was an async dns child - kill it. */
- kill_async_dns_child();
+ /* Remove all SELF registered names. */
+ release_my_names();
- exit(0);
+ /* Announce all server entries as 0 time-to-live, 0 type. */
+ announce_my_servers_removed();
-} /* sig_term */
+ /* If there was an async dns child - kill it. */
+ kill_async_dns_child();
+
+ exit(0);
+}
/**************************************************************************** **
- Catch a sighup.
+ Catch a SIGTERM signal.
**************************************************************************** */
-static VOLATILE sig_atomic_t reload_after_sighup = False;
+static VOLATILE sig_atomic_t got_sig_term;
-static void sig_hup(int sig)
+static void sig_term(int sig)
{
- BlockSignals( True, SIGHUP );
-
- DEBUG( 0, ( "Got SIGHUP dumping debug info.\n" ) );
-
- write_browse_list( 0, True );
-
- dump_all_namelists();
+ got_sig_term = 1;
+ sys_select_signal();
+}
- reload_after_sighup = True;
+/**************************************************************************** **
+ Catch a SIGHUP signal.
+ **************************************************************************** */
- BlockSignals(False,SIGHUP);
+static VOLATILE sig_atomic_t reload_after_sighup;
-} /* sig_hup */
+static void sig_hup(int sig)
+{
+ reload_after_sighup = 1;
+ sys_select_signal();
+}
#if DUMP_CORE
/**************************************************************************** **
@@ -337,6 +334,15 @@ static void process(void)
return;
/*
+ * Handle termination inband.
+ */
+
+ if (got_sig_term) {
+ got_sig_term = 0;
+ terminate();
+ }
+
+ /*
* Process all incoming packets
* read above. This calls the success and
* failure functions registered when response
@@ -493,11 +499,14 @@ static void process(void)
*/
if(reload_after_sighup) {
- reload_nmbd_services( True );
- reopen_logs();
- if(reload_interfaces(0))
- return;
- reload_after_sighup = False;
+ DEBUG( 0, ( "Got SIGHUP dumping debug info.\n" ) );
+ write_browse_list( 0, True );
+ dump_all_namelists();
+ reload_nmbd_services( True );
+ reopen_logs();
+ if(reload_interfaces(0))
+ return;
+ reload_after_sighup = 0;
}
/* check for new network interfaces */
@@ -662,6 +671,7 @@ static void usage(char *pname)
extern FILE *dbf;
extern char *optarg;
extern BOOL append_log;
+ extern BOOL AllowDebugChange;
BOOL opt_interactive = False;
pstring logfile;
@@ -754,6 +764,7 @@ static void usage(char *pname)
break;
case 'd':
DEBUGLEVEL = atoi(optarg);
+ AllowDebugChange = False;
break;
case 'p':
global_nmb_port = atoi(optarg);
diff --git a/source/nmbd/nmbd_become_dmb.c b/source/nmbd/nmbd_become_dmb.c
index 6825643c85a..7af896e3e03 100644
--- a/source/nmbd/nmbd_become_dmb.c
+++ b/source/nmbd/nmbd_become_dmb.c
@@ -27,7 +27,6 @@
extern pstring global_myname;
extern fstring global_myworkgroup;
extern char **my_netbios_names;
-extern struct in_addr ipzero;
extern struct in_addr allones_ip;
extern uint16 samba_nb_type; /* Samba's NetBIOS type. */
@@ -214,7 +213,7 @@ static void become_domain_master_query_success(struct subnet_record *subrec,
/* BUG note. Samba 1.9.16p11 servers seem to return the broadcast
address or zero ip for this query. Pretend this is ok. */
- if(ismyip(ip) || ip_equal(allones_ip, ip) || ip_equal(ipzero, ip))
+ if(ismyip(ip) || ip_equal(allones_ip, ip) || is_zero_ip(ip))
{
if( DEBUGLVL( 3 ) )
{
@@ -231,12 +230,13 @@ static void become_domain_master_query_success(struct subnet_record *subrec,
else
{
if( DEBUGLVL( 0 ) )
- {
+ {
dbgtext( "become_domain_master_query_success:\n" );
dbgtext( "There is already a domain master browser at " );
dbgtext( "IP %s for workgroup %s ", inet_ntoa(ip), nmbname->name );
dbgtext( "registered on subnet %s.\n", subrec->subnet_name );
- }
+ }
+ become_domain_master_stage1(subrec, nmbname->name);
}
}
diff --git a/source/nmbd/nmbd_browsesync.c b/source/nmbd/nmbd_browsesync.c
index d472b6ff284..40e04e7ecb7 100644
--- a/source/nmbd/nmbd_browsesync.c
+++ b/source/nmbd/nmbd_browsesync.c
@@ -25,7 +25,6 @@
#include "includes.h"
#include "smb.h"
-extern struct in_addr ipzero;
extern pstring global_myname;
extern fstring global_myworkgroup;
@@ -308,7 +307,7 @@ static void find_domain_master_name_query_success(struct subnet_record *subrec,
/* First check if we already have a dmb for this workgroup. */
- if(!ip_equal(work->dmb_addr, ipzero) && ip_equal(work->dmb_addr, answer_ip))
+ if(!is_zero_ip(work->dmb_addr) && ip_equal(work->dmb_addr, answer_ip))
{
/* Do the local master browser announcement to the domain
master browser name and IP. */
@@ -319,7 +318,7 @@ static void find_domain_master_name_query_success(struct subnet_record *subrec,
return;
}
else
- putip((char *)&work->dmb_addr, &ipzero);
+ zero_ip(&work->dmb_addr);
/* Now initiate the node status request. */
make_nmb_name(&nmbname,"*",0x0);
diff --git a/source/nmbd/nmbd_logonnames.c b/source/nmbd/nmbd_logonnames.c
index 4f48b21b7fd..52340f1f310 100644
--- a/source/nmbd/nmbd_logonnames.c
+++ b/source/nmbd/nmbd_logonnames.c
@@ -27,7 +27,6 @@
extern pstring global_myname;
extern fstring global_myworkgroup;
extern char **my_netbios_names;
-extern struct in_addr ipzero;
extern struct in_addr allones_ip;
extern uint16 samba_nb_type; /* Samba's NetBIOS type. */
diff --git a/source/nmbd/nmbd_mynames.c b/source/nmbd/nmbd_mynames.c
index b1b3f48b62a..07745e793a1 100644
--- a/source/nmbd/nmbd_mynames.c
+++ b/source/nmbd/nmbd_mynames.c
@@ -80,6 +80,35 @@ Exiting.\n", global_myworkgroup, subrec->subnet_name));
initiate_myworkgroup_startup(subrec, work);
}
+/*******************************************************************
+ Utility function to add a name to the unicast subnet, or add in
+ our IP address if it already exists.
+******************************************************************/
+
+static void insert_refresh_name_into_unicast( struct subnet_record *subrec,
+ struct nmb_name *nmbname, uint16 nb_type )
+{
+ struct name_record *namerec;
+
+ if (!we_are_a_wins_client()) {
+ insert_permanent_name_into_unicast(subrec, nmbname, nb_type);
+ return;
+ }
+
+ if((namerec = find_name_on_subnet(unicast_subnet, nmbname, FIND_SELF_NAME)) == NULL)
+ {
+ /* The name needs to be created on the unicast subnet. */
+ (void)add_name_to_subnet( unicast_subnet, nmbname->name,
+ nmbname->name_type, nb_type,
+ MIN(lp_max_ttl(), MAX_REFRESH_TIME), SELF_NAME, 1, &subrec->myip);
+ }
+ else
+ {
+ /* The name already exists on the unicast subnet. Add our local
+ IP for the given broadcast subnet to the name. */
+ add_ip_to_name_record( namerec, subrec->myip);
+ }
+}
/****************************************************************************
Add my workgroup and my given names to the subnet lists.
@@ -115,13 +144,13 @@ BOOL register_my_workgroup_and_names(void)
struct nmb_name nmbname;
make_nmb_name(&nmbname, my_netbios_names[i],0x20);
- insert_permanent_name_into_unicast(subrec, &nmbname, samba_nb_type);
+ insert_refresh_name_into_unicast(subrec, &nmbname, samba_nb_type);
make_nmb_name(&nmbname, my_netbios_names[i],0x3);
- insert_permanent_name_into_unicast(subrec, &nmbname, samba_nb_type);
+ insert_refresh_name_into_unicast(subrec, &nmbname, samba_nb_type);
make_nmb_name(&nmbname, my_netbios_names[i],0x0);
- insert_permanent_name_into_unicast(subrec, &nmbname, samba_nb_type);
+ insert_refresh_name_into_unicast(subrec, &nmbname, samba_nb_type);
}
}
@@ -138,10 +167,10 @@ BOOL register_my_workgroup_and_names(void)
struct nmb_name nmbname;
make_nmb_name(&nmbname, global_myworkgroup, 0x0);
- insert_permanent_name_into_unicast(subrec, &nmbname, samba_nb_type|NB_GROUP);
+ insert_refresh_name_into_unicast(subrec, &nmbname, samba_nb_type|NB_GROUP);
make_nmb_name(&nmbname, global_myworkgroup, 0x1e);
- insert_permanent_name_into_unicast(subrec, &nmbname, samba_nb_type|NB_GROUP);
+ insert_refresh_name_into_unicast(subrec, &nmbname, samba_nb_type|NB_GROUP);
}
/*
diff --git a/source/nmbd/nmbd_namequery.c b/source/nmbd/nmbd_namequery.c
index 1f0895ee37f..9d2a7a48958 100644
--- a/source/nmbd/nmbd_namequery.c
+++ b/source/nmbd/nmbd_namequery.c
@@ -24,8 +24,6 @@
#include "includes.h"
-extern struct in_addr ipzero;
-
/****************************************************************************
Deal with a response packet when querying a name.
****************************************************************************/
@@ -38,7 +36,9 @@ static void query_name_response( struct subnet_record *subrec,
BOOL success = False;
struct nmb_name *question_name =
&rrec->packet->packet.nmb.question.question_name;
- struct in_addr answer_ip = ipzero;
+ struct in_addr answer_ip;
+
+ zero_ip(&answer_ip);
/* Ensure we don't retry the query but leave the response record cleanup
to the timeout code. We may get more answer responses in which case
diff --git a/source/nmbd/nmbd_responserecordsdb.c b/source/nmbd/nmbd_responserecordsdb.c
index b24c85a9d81..63601ff26c4 100644
--- a/source/nmbd/nmbd_responserecordsdb.c
+++ b/source/nmbd/nmbd_responserecordsdb.c
@@ -26,8 +26,6 @@
extern int ClientNMB;
-extern struct in_addr ipzero;
-
int num_response_packets = 0;
/***************************************************************************
diff --git a/source/nmbd/nmbd_subnetdb.c b/source/nmbd/nmbd_subnetdb.c
index 9030e42b298..0067d89f669 100644
--- a/source/nmbd/nmbd_subnetdb.c
+++ b/source/nmbd/nmbd_subnetdb.c
@@ -33,7 +33,6 @@ extern int global_nmb_port;
extern fstring myworkgroup;
extern char **my_netbios_names;
-extern struct in_addr ipzero;
/* This is the broadcast subnets database. */
struct subnet_record *subnetlist = NULL;
@@ -232,7 +231,7 @@ BOOL create_subnets(void)
{
int num_interfaces = iface_count();
int i;
- struct in_addr unicast_ip;
+ struct in_addr unicast_ip, ipzero;
extern struct in_addr loopback_ip;
if(num_interfaces == 0)
@@ -280,7 +279,7 @@ BOOL create_subnets(void)
struct in_addr real_wins_ip;
real_wins_ip = wins_srv_ip();
- if (!zero_ip(real_wins_ip))
+ if (!is_zero_ip(real_wins_ip))
{
unicast_ip = real_wins_ip;
}
@@ -302,7 +301,7 @@ BOOL create_subnets(void)
{
/* We should not be using a WINS server at all. Set the
ip address of the subnet to be zero. */
- unicast_ip = ipzero;
+ zero_ip(&unicast_ip);
}
/*
@@ -315,6 +314,8 @@ BOOL create_subnets(void)
unicast_subnet = make_subnet( "UNICAST_SUBNET", UNICAST_SUBNET,
unicast_ip, unicast_ip, unicast_ip);
+ zero_ip(&ipzero);
+
remote_broadcast_subnet = make_subnet( "REMOTE_BROADCAST_SUBNET",
REMOTE_BROADCAST_SUBNET,
ipzero, ipzero, ipzero);
@@ -347,7 +348,7 @@ BOOL we_are_a_wins_client(void)
static int cache_we_are_a_wins_client = -1;
if(cache_we_are_a_wins_client == -1)
- cache_we_are_a_wins_client = (ip_equal(ipzero, unicast_subnet->myip) ?
+ cache_we_are_a_wins_client = (is_zero_ip(unicast_subnet->myip) ?
False : True);
return cache_we_are_a_wins_client;
diff --git a/source/nmbd/nmbd_synclists.c b/source/nmbd/nmbd_synclists.c
index 1132d9a5147..c8dac82aa15 100644
--- a/source/nmbd/nmbd_synclists.c
+++ b/source/nmbd/nmbd_synclists.c
@@ -101,7 +101,7 @@ static void sync_child(char *name, int nm_type,
/* All the cli_XX functions take UNIX character set. */
fstrcpy(unix_workgroup, cli.server_domain?cli.server_domain:workgroup);
- dos_to_unix(unix_workgroup, True);
+ dos_to_unix(unix_workgroup);
/* Fetch a workgroup list. */
cli_NetServerEnum(&cli, unix_workgroup,
@@ -111,7 +111,7 @@ static void sync_child(char *name, int nm_type,
/* Now fetch a server list. */
if (servers) {
fstrcpy(unix_workgroup, workgroup);
- dos_to_unix(unix_workgroup, True);
+ dos_to_unix(unix_workgroup);
cli_NetServerEnum(&cli, unix_workgroup,
local?SV_TYPE_LOCAL_LIST_ONLY:SV_TYPE_ALL,
callback, NULL);
@@ -260,7 +260,7 @@ static void complete_sync(struct sync_record *s)
ptr = line;
/* The line is written in UNIX character set. Convert to DOS codepage. */
- unix_to_dos(line,True);
+ unix_to_dos(line);
if (!next_token(&ptr,server,NULL,sizeof(server)) ||
!next_token(&ptr,type_str,NULL, sizeof(type_str)) ||
diff --git a/source/nmbd/nmbd_winsserver.c b/source/nmbd/nmbd_winsserver.c
index 04f7ae33bbc..45385fc4e00 100644
--- a/source/nmbd/nmbd_winsserver.c
+++ b/source/nmbd/nmbd_winsserver.c
@@ -26,12 +26,10 @@
#define WINS_LIST "wins.dat"
#define WINS_VERSION 1
-extern struct in_addr ipzero;
-
-
/****************************************************************************
possibly call the WINS hook external program when a WINS change is made
*****************************************************************************/
+
static void wins_hook(char *operation, struct name_record *namerec, int ttl)
{
pstring command;
diff --git a/source/nmbd/nmbd_workgroupdb.c b/source/nmbd/nmbd_workgroupdb.c
index baa40dc1f9e..1dddc2cd18c 100644
--- a/source/nmbd/nmbd_workgroupdb.c
+++ b/source/nmbd/nmbd_workgroupdb.c
@@ -31,7 +31,6 @@ extern pstring global_myname;
extern fstring global_myworkgroup;
extern char **my_netbios_names;
extern uint16 samba_nb_type;
-extern struct in_addr ipzero;
int workgroup_count = 0; /* unique index key: one for each workgroup */
@@ -101,7 +100,7 @@ static struct work_record *create_workgroup(const char *name, int ttl)
/* No known domain master browser as yet. */
*work->dmb_name.name = '\0';
- putip((char *)&work->dmb_addr, &ipzero);
+ zero_ip(&work->dmb_addr);
/* WfWg uses 01040b01 */
/* Win95 uses 01041501 */