summaryrefslogtreecommitdiff
path: root/source3/nmbd
diff options
context:
space:
mode:
authorSamba Release Account <samba-bugs@samba.org>1997-07-31 18:47:26 +0000
committerSamba Release Account <samba-bugs@samba.org>1997-07-31 18:47:26 +0000
commit363b9a2739e9e39d1f69625e6647c6c9047a901a (patch)
tree1fb3f2f19bbcd15922468bf125ba1314220cd915 /source3/nmbd
parentf2b7e75f0cbff28b082150ba5ec60617b92bd545 (diff)
downloadsamba-363b9a2739e9e39d1f69625e6647c6c9047a901a.tar.gz
samba-363b9a2739e9e39d1f69625e6647c6c9047a901a.tar.bz2
samba-363b9a2739e9e39d1f69625e6647c6c9047a901a.zip
loadparm.c: Added new netbios aliases parameter (code from Cisco)
nameannounce.c: Code to announce aliases as well as our own names. namedbsubnet.c: Code to add the aliases to the server list. nameserv.c: Code to defend our aliases on the namelist. namework.c: Code to check it's one of our aliases. nmbd.c: Code to initialise the aliases. proto.h: Fixup protos. util.c: Code to check it's one of our aliases. All above code based on code for 1.9.16p11 donated by Cisco from Ben Woodard <bwoodard@luthien.cisco.com> Jeremy (jallison@whistle.com) (This used to be commit a2ce1c0cb1331551ff728dcfe3260fab4cd827e5)
Diffstat (limited to 'source3/nmbd')
-rw-r--r--source3/nmbd/nmbd.c68
1 files changed, 64 insertions, 4 deletions
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 10701c24d4..925f975ffe 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -41,6 +41,7 @@ extern pstring myhostname;
static pstring host_file;
extern pstring myname;
extern fstring myworkgroup;
+extern char **my_netbios_names;
/* are we running as a daemon ? */
static BOOL is_daemon = False;
@@ -363,7 +364,11 @@ static BOOL open_sockets(BOOL isdaemon, int port)
static BOOL init_structs()
{
extern fstring local_machine;
- char *p;
+ char *p, *ptr;
+ int namecount;
+ int n;
+ int nodup;
+ pstring nbname;
if (! *myname) {
strcpy(myname,myhostname);
@@ -372,12 +377,62 @@ static BOOL init_structs()
}
strupper(myname);
+ /* Add any NETBIOS name aliases. Ensure that the first entry
+ is equal to myname. */
+ /* Work out the max number of netbios aliases that we have */
+ ptr=lp_netbios_aliases();
+ for (namecount=0; next_token(&ptr,nbname,NULL); namecount++)
+ ;
+ if (*myname)
+ namecount++;
+
+ /* Allocate space for the netbios aliases */
+ if((my_netbios_names=(char **)malloc(sizeof(char *)*(namecount+1))) == NULL)
+ {
+ DEBUG(0,("init_structs: malloc fail.\n"));
+ return False;
+ }
+
+ /* Use the myname string first */
+ namecount=0;
+ if (*myname)
+ my_netbios_names[namecount++] = myname;
+
+ ptr=lp_netbios_aliases();
+ while (next_token(&ptr,nbname,NULL)) {
+ strupper(nbname);
+ /* Look for duplicates */
+ nodup=1;
+ for(n=0; n<namecount; n++) {
+ if (strcmp(nbname, my_netbios_names[n])==0)
+ nodup=0;
+ }
+ if (nodup)
+ my_netbios_names[namecount++]=strdup(nbname);
+ }
+
+ /* Check the strdups succeeded. */
+ for(n = 0; n < namecount; n++)
+ if(my_netbios_names[n]==NULL)
+ {
+ DEBUG(0,("init_structs: malloc fail when allocating names.\n"));
+ return False;
+ }
+
+ /* Terminate name list */
+ my_netbios_names[namecount++]=NULL;
+
strcpy(local_machine,myname);
trim_string(local_machine," "," ");
p = strchr(local_machine,' ');
- if (p) *p = 0;
+ if (p)
+ *p = 0;
strlower(local_machine);
+ DEBUG(5, ("Netbios name list:-\n"));
+ for (n=0; my_netbios_names[n]; n++)
+ DEBUG(5, ("my_netbios_names[%d]=\"%s\"\n", n, my_netbios_names[n]));
+
return True;
}
@@ -493,14 +548,19 @@ static void usage(char *pname)
DEBUG(1,("%s netbios nameserver version %s started\n",timestring(),VERSION));
DEBUG(1,("Copyright Andrew Tridgell 1994-1997\n"));
- get_myname(myhostname,NULL);
+ if(!get_myname(myhostname,NULL))
+ {
+ DEBUG(0,("Unable to get my hostname - exiting.\n"));
+ return -1;
+ }
if (!reload_services(False))
return(-1);
codepage_initialise(lp_client_code_page());
- init_structs();
+ if(!init_structs())
+ return -1;
reload_services(True);