summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1997-12-29 01:07:30 +0000
committerLuke Leighton <lkcl@samba.org>1997-12-29 01:07:30 +0000
commit2bcb4fa4ddb75627bd838e007692558067d9a9ba (patch)
tree5abed20c35dcf3a3189670028f229bb57ac79e71
parent499a2035514566f672bd52fae572cb1442e72a86 (diff)
downloadsamba-2bcb4fa4ddb75627bd838e007692558067d9a9ba.tar.gz
*** empty log message ***
-rw-r--r--source/nmbd/nmbd_browsesync.c20
-rw-r--r--source/nmbd/nmbd_processlogon.c438
-rw-r--r--source/nmbd/nmbd_winsserver.c18
3 files changed, 243 insertions, 233 deletions
diff --git a/source/nmbd/nmbd_browsesync.c b/source/nmbd/nmbd_browsesync.c
index cc81807de4f..d9fee447e1a 100644
--- a/source/nmbd/nmbd_browsesync.c
+++ b/source/nmbd/nmbd_browsesync.c
@@ -41,7 +41,8 @@ static struct subnet_record *call_subrec;
This is the NetServerEnum callback.
******************************************************************/
-static void callback(char *sname, uint32 stype, char *comment)
+static void callback(FILE *hnd, enum display_type display, enum action_type action,
+ char *sname, uint32 stype, char *comment)
{
struct work_record *work;
@@ -99,6 +100,7 @@ static void sync_browse_lists(struct subnet_record *subrec, struct work_record *
{
extern fstring local_machine;
static struct cli_state cli;
+ static int t_idx;
uint32 local_type = local ? SV_TYPE_LOCAL_LIST_ONLY : 0;
DEBUG(2,("%s: sync_browse_lists: Sync browse lists with server %s<%02x> at IP %s for workgroup %s\n",
@@ -119,7 +121,7 @@ Do not sync with ourselves.\n", work->work_group ));
return;
}
- if (!cli_session_request(&cli, name, nm_type, local_machine))
+ if (!cli_session_request(&cli, name, nm_type, local_machine, 0x0))
{
DEBUG(0,("sync_browse_lists: %s rejected the browse sync session\n",name));
cli_shutdown(&cli);
@@ -133,7 +135,7 @@ Do not sync with ourselves.\n", work->work_group ));
return;
}
- if (!cli_session_setup(&cli, "", "", 1, "", 0, work->work_group))
+ if (!cli_session_setup(&cli, "", "", 1, NULL, 0, work->work_group))
{
DEBUG(0,("sync_browse_lists: %s rejected the browse sync sessionsetup\n",
name));
@@ -141,7 +143,7 @@ Do not sync with ourselves.\n", work->work_group ));
return;
}
- if (!cli_send_tconX(&cli, "IPC$", "IPC", "", 1))
+ if (!cli_send_tconX(&cli, &t_idx, "IPC$", "IPC", "", 1))
{
DEBUG(0,("sync_browse_lists: %s refused browse sync IPC$ connect\n", name));
cli_shutdown(&cli);
@@ -152,13 +154,15 @@ Do not sync with ourselves.\n", work->work_group ));
call_subrec = subrec;
/* Fetch a workgroup list. */
- cli_NetServerEnum(&cli, work->work_group,
- local_type|SV_TYPE_DOMAIN_ENUM,
+ cli_NetServerEnum(&cli, t_idx,
+ NULL, DISPLAY_NONE, ACTION_ENUMERATE,
+ work->work_group, local_type|SV_TYPE_DOMAIN_ENUM,
callback);
/* Now fetch a server list. */
- cli_NetServerEnum(&cli, work->work_group,
- local?SV_TYPE_LOCAL_LIST_ONLY:SV_TYPE_ALL,
+ cli_NetServerEnum(&cli, t_idx,
+ NULL, DISPLAY_NONE, ACTION_ENUMERATE,
+ work->work_group, local?SV_TYPE_LOCAL_LIST_ONLY:SV_TYPE_ALL,
callback);
cli_shutdown(&cli);
diff --git a/source/nmbd/nmbd_processlogon.c b/source/nmbd/nmbd_processlogon.c
index cd2fbfd0a56..6d740efa261 100644
--- a/source/nmbd/nmbd_processlogon.c
+++ b/source/nmbd/nmbd_processlogon.c
@@ -3,8 +3,6 @@
Version 1.9.
NBT netbios routines and daemon - version 2
Copyright (C) Andrew Tridgell 1994-1997
- Copyright (C) Luke Kenneth Casson Leighton 1994-1997
- Copyright (C) Jeremy Allison 1994-1997
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
@@ -22,6 +20,9 @@
Revision History:
+ 14 jan 96: lkcl@pires.co.uk
+ added multiple workgroup domain master support
+
*/
#include "includes.h"
@@ -29,222 +30,227 @@
extern int DEBUGLEVEL;
extern pstring myname;
-extern fstring myworkgroup;
+
+extern pstring myworkgroup;
+
/****************************************************************************
-Process a domain logon packet
-**************************************************************************/
+ process a domain logon packet
-void process_logon_packet(struct packet_struct *p,char *buf,int len,
- char *mailslot)
+ **************************************************************************/
+void process_logon_packet(struct packet_struct *p,char *buf,int len)
{
- struct dgram_packet *dgram = &p->packet.dgram;
- pstring my_name;
- fstring reply_name;
- BOOL add_slashes = False;
- pstring outbuf;
- int code,reply_code;
- char unknown_byte = 0;
- uint16 request_count = 0;
- uint16 token = 0;
-
- uint32 ntversion;
- uint16 lmnttoken;
- uint16 lm20token;
- uint32 allowableaccount; /* Control bits, i.e. 0x80 == workstation trust a/c. */
- uint32 domainsidsize;
- uint16 requestcount;
- char *domainsid;
- char *getdc;
- char *uniuser; /* Unicode user name. */
- pstring ascuser;
- char *unicomp; /* Unicode computer name. */
- struct smb_passwd *smb_pass; /* To check if machine account exists */
-
- if (!lp_domain_logons())
- {
- DEBUG(3,("process_logon_packet: Logon packet received from IP %s and domain \
-logons are not enabled.\n", inet_ntoa(p->ip) ));
- return;
- }
-
- strcpy(my_name, myname);
- strupper(my_name);
-
- code = SVAL(buf,0);
- DEBUG(1,("process_logon_packet: Logon from %s: code = %x\n", inet_ntoa(p->ip), code));
-
- switch (code)
- {
- case 0:
- {
- char *q = buf + 2;
- char *machine = q;
- char *user = skip_string(machine,1);
-
- getdc = skip_string(user,1);
- q = skip_string(getdc,1);
- unknown_byte = CVAL(q,0);
- request_count = SVAL(q,1);
- token = SVAL(q,3);
-
- reply_code = 0x6;
- strcpy(reply_name,my_name);
- add_slashes = True;
-
- DEBUG(3,("process_logon_packet: Domain login request from %s at IP %s user=%s token=%x\n",
- machine,inet_ntoa(p->ip),user,token));
-
- q = outbuf;
- SSVAL(q, 0, 6); q += 2;
-
- strcpy(reply_name, "\\\\");
- strcat(reply_name, my_name);
- strcpy(q, reply_name); q = skip_string(q, 1); /* PDC name */
-
- SSVAL(q, 0, token); q += 2;
-
- dump_data(4, outbuf, PTR_DIFF(q, outbuf));
-
- send_mailslot(True, getdc,
- outbuf,PTR_DIFF(q,outbuf),
- dgram->dest_name.name,
- dgram->dest_name.name_type,
- dgram->source_name.name,
- dgram->source_name.name_type,
- p->ip, *iface_ip(p->ip));
- break;
- }
-
- case QUERYFORPDC:
- {
- char *q = buf + 2;
- char *machine = q;
-
- getdc = skip_string(machine,1);
- unicomp = skip_string(getdc,1);
-
- q = align2(unicomp, buf);
-
- q = skip_unicode_string(q, 1);
-
- ntversion = IVAL(q, 0); q += 4;
- lmnttoken = SVAL(q, 0); q += 2;
- lm20token = SVAL(q, 0); q += 2;
-
- /* Construct reply. */
-
- q = outbuf;
- SSVAL(q, 0, QUERYFORPDC_R); q += 2;
-
- strcpy(reply_name,my_name);
- strcpy(q, reply_name); q = skip_string(q, 1); /* PDC name */
-
- if (strcmp(mailslot, NT_LOGON_MAILSLOT)==0) {
- q = align2(q, buf);
-
- PutUniCode(q, my_name); /* PDC name */
- q = skip_unicode_string(q, 1);
- PutUniCode(q, myworkgroup); /* Domain name*/
- q = skip_unicode_string(q, 1);
-
- SIVAL(q, 0, ntversion); q += 4;
- SSVAL(q, 0, lmnttoken); q += 2;
- SSVAL(q, 0, lm20token); q += 2;
- }
-
- 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, lp_workgroup(),
- QUERYFORPDC_R, (uint32)ntversion, (uint32)lmnttoken,
- (uint32)lm20token ));
-
- dump_data(4, outbuf, PTR_DIFF(q, outbuf));
-
- send_mailslot(True, getdc,
- outbuf,PTR_DIFF(q,outbuf),
- dgram->dest_name.name,
- dgram->dest_name.name_type,
- dgram->source_name.name,
- dgram->source_name.name_type,
- p->ip, *iface_ip(p->ip));
- return;
- }
-
- case SAMLOGON:
- {
- char *q = buf + 2;
-
- requestcount = SVAL(q, 0); q += 2;
- unicomp = q;
- uniuser = skip_unicode_string(unicomp,1);
- getdc = skip_unicode_string(uniuser,1);
- q = skip_string(getdc,1);
- allowableaccount = IVAL(q, 0); q += 4;
- domainsidsize = IVAL(q, 0); q += 4;
- domainsid = q;
- q += domainsidsize + 3;
- ntversion = IVAL(q, 0); q += 4;
- lmnttoken = SVAL(q, 0); q += 2;
- lm20token = SVAL(q, 0); q += 2;
-
- DEBUG(3,("process_logon_packet: SAMLOGON sidsize %d ntv %d\n", domainsidsize, ntversion));
-
- /*
- * If MACHINE$ is in our password database then respond, else ignore.
- * Let's ignore the SID.
- */
-
- strcpy(ascuser, unistr(uniuser));
- DEBUG(3,("process_logon_packet: SAMLOGON user %s\n", ascuser));
-
- strcpy(reply_name,"\\\\"); /* Here it wants \\LOGONSERVER. */
- strcpy(reply_name+2,my_name);
-
- smb_pass = get_smbpwd_entry(ascuser, 0);
-
- if(!smb_pass)
- {
- DEBUG(3,("process_logon_packet: SAMLOGON request from %s(%s) for %s, not in password file\n",
- unistr(unicomp),inet_ntoa(p->ip), ascuser));
- return;
- }
- else
- {
- DEBUG(3,("process_logon_packet: SAMLOGON request from %s(%s) for %s, returning logon svr %s domain %s code %x token=%x\n",
- unistr(unicomp),inet_ntoa(p->ip), ascuser, reply_name, myworkgroup,
- SAMLOGON_R ,lmnttoken));
- }
-
- /* Construct reply. */
-
- q = outbuf;
- SSVAL(q, 0, SAMLOGON_R); q += 2;
-
- PutUniCode(q, reply_name); q = skip_unicode_string(q, 1);
- unistrcpy(q, uniuser); q = skip_unicode_string(q, 1); /* User name (workstation trust account) */
- PutUniCode(q, lp_workgroup()); q = skip_unicode_string(q, 1); /* Domain name. */
-
- SIVAL(q, 0, ntversion); q += 4;
- SSVAL(q, 0, lmnttoken); q += 2;
- SSVAL(q, 0, lm20token); q += 2;
-
- dump_data(4, outbuf, PTR_DIFF(q, outbuf));
-
- send_mailslot(True, getdc,
- outbuf,PTR_DIFF(q,outbuf),
- dgram->dest_name.name,
- dgram->dest_name.name_type,
- dgram->source_name.name,
- dgram->source_name.name_type,
- p->ip, *iface_ip(p->ip));
- break;
- }
-
- default:
- {
- DEBUG(3,("process_logon_packet: Unknown domain request %d\n",code));
- return;
- }
- }
+ struct dgram_packet *dgram = &p->packet.dgram;
+ pstring my_name;
+ pstring my_workgroup;
+ fstring reply_name;
+ BOOL add_slashes = False;
+ pstring outbuf;
+ int code,reply_code;
+ char unknown_byte = 0;
+ uint16 request_count = 0;
+ uint16 token = 0;
+
+ uint32 ntversion;
+ uint16 lmnttoken;
+ uint16 lm20token;
+ uint32 allowableaccount; /* Control bits, i.e. 0x80 == workstation trust a/c. */
+ uint32 domainsidsize;
+ uint16 requestcount;
+ char *domainsid;
+ char *getdc;
+ char *uniuser; /* Unicode user name. */
+ pstring ascuser;
+ char *unicomp; /* Unicode computer name. */
+ struct smb_passwd *smb_pass; /* To check if machine account exists */
+
+ if (!lp_domain_logons())
+ {
+ DEBUG(3,("process_logon_packet: Logon packet received from IP %s and domain \
+logons are not enabled.\n", inet_ntoa(p->ip)));
+ return;
+ }
+
+ strcpy(my_name, myname);
+ strupper(my_name);
+
+ strcpy(my_workgroup, myworkgroup);
+ strupper(my_workgroup);
+
+ code = SVAL(buf,0);
+ DEBUG(1,("process_logon_packet: Logon from %s: code = %x\n", inet_ntoa(p->ip), code));
+
+ switch (code)
+ {
+ case 0:
+ {
+ char *q = buf + 2;
+ char *machine = q;
+ char *user = skip_string(machine,1);
+
+ getdc = skip_string(user,1);
+ q = skip_string(getdc,1);
+ unknown_byte = CVAL(q,0);
+ request_count = SVAL(q,1);
+ token = SVAL(q,3);
+
+ reply_code = 0x6;
+ strcpy(reply_name,my_name);
+ add_slashes = True;
+
+ DEBUG(3,("process_logon_packet: Domain login request from %s at IP %s user=%s token=%x\n",
+ machine,inet_ntoa(p->ip),user,token));
+
+ q = outbuf;
+ SSVAL(q, 0, 6); q += 2;
+
+ strcpy(reply_name, "\\\\");
+ strcat(reply_name, my_name);
+ strcpy(q, reply_name); q = skip_string(q, 1); /* PDC name */
+
+ SSVAL(q, 0, token); q += 2;
+
+ dump_data(4, outbuf, PTR_DIFF(q, outbuf));
+
+ send_mailslot(True, getdc,
+ outbuf,PTR_DIFF(q,outbuf),
+ dgram->dest_name.name,
+ dgram->dest_name.name_type,
+ dgram->source_name.name,
+ dgram->source_name.name_type,
+ p->ip, *iface_ip(p->ip));
+ break;
+ }
+
+ case QUERYFORPDC:
+ {
+ char *q = buf + 2;
+ char *machine = q;
+
+ getdc = skip_string(machine,1);
+ unicomp = skip_string(getdc,1);
+
+ q = align2(unicomp, buf);
+
+ q = skip_unicode_string(q, 1);
+
+ ntversion = IVAL(q, 0); q += 4;
+ lmnttoken = SVAL(q, 0); q += 2;
+ lm20token = SVAL(q, 0); q += 2;
+
+ DEBUG(3,("process_logon_packet: GETDC request from %s at IP %s, \
+reporting %s domain %s ntversion=%x lm_nt=%x lm_20=%x\n",
+ machine,inet_ntoa(p->ip), reply_name, my_workgroup,
+ (uint32)ntversion, (uint32)lmnttoken,
+ (uint32)lm20token));
+
+ /* Construct reply. */
+
+ q = outbuf;
+ SSVAL(q, 0, QUERYFORPDC_R); q += 2;
+
+ strcpy(reply_name,my_name);
+ strcpy(q, reply_name); q = skip_string(q, 1); /* PDC name */
+
+ q = align2(q, buf);
+
+ PutUniCode(q, my_name); /* PDC name */
+ q = skip_unicode_string(q, 1);
+
+ PutUniCode(q, my_workgroup); /* Domain name. */
+ q = skip_unicode_string(q, 1);
+
+ SIVAL(q, 0, ntversion); q += 4;
+ SSVAL(q, 0, lmnttoken); q += 2;
+ SSVAL(q, 0, lm20token); q += 2;
+
+ dump_data(4, outbuf, PTR_DIFF(q, outbuf));
+
+ send_mailslot(True, getdc,
+ outbuf,PTR_DIFF(q,outbuf),
+ dgram->dest_name.name,
+ dgram->dest_name.name_type,
+ dgram->source_name.name,
+ dgram->source_name.name_type,
+ p->ip, *iface_ip(p->ip));
+ return;
+ }
+
+ case SAMLOGON:
+ {
+ char *q = buf + 2;
+
+ requestcount = SVAL(q, 0); q += 2;
+ unicomp = q;
+ uniuser = skip_unicode_string(unicomp,1);
+ getdc = skip_unicode_string(uniuser,1);
+ q = skip_string(getdc,1);
+ allowableaccount = IVAL(q, 0); q += 4;
+ domainsidsize = IVAL(q, 0); q += 4;
+ domainsid = q;
+ q += domainsidsize + 3;
+ ntversion = IVAL(q, 0); q += 4;
+ lmnttoken = SVAL(q, 0); q += 2;
+ lm20token = SVAL(q, 0); q += 2;
+
+ DEBUG(3,("process_logon_packet: SAMLOGON sidsize %d ntv %d\n", domainsidsize, ntversion));
+
+ /*
+ * If MACHINE$ is in our password database then respond, else ignore.
+ * Let's ignore the SID.
+ */
+
+ strcpy(ascuser, unistr(uniuser));
+ DEBUG(3,("process_logon_packet: SAMLOGON user %s\n", ascuser));
+
+ strcpy(reply_name,"\\\\"); /* Here it wants \\LOGONSERVER. */
+ strcpy(reply_name+2,my_name);
+
+ smb_pass = get_smbpwd_entry(ascuser, 0);
+
+ if(!smb_pass)
+ {
+ DEBUG(3,("process_logon_packet: SAMLOGON request from %s(%s) for %s, not in password file\n",
+ unistr(unicomp),inet_ntoa(p->ip), ascuser));
+ return;
+ }
+ else
+ {
+ DEBUG(3,("process_logon_packet: SAMLOGON request from %s(%s) for %s, returning logon svr %s domain %s code %x token=%x\n",
+ unistr(unicomp),inet_ntoa(p->ip), ascuser, reply_name, my_workgroup,
+ SAMLOGON_R ,lmnttoken));
+ }
+
+ /* Construct reply. */
+
+ q = outbuf;
+ SSVAL(q, 0, SAMLOGON_R); q += 2;
+
+ PutUniCode(q, reply_name); q = skip_unicode_string(q, 1);
+ unistrcpy(q, uniuser); q = skip_unicode_string(q, 1); /* User name (workstation trust account) */
+ PutUniCode(q, my_workgroup); q = skip_unicode_string(q, 1); /* Domain name. */
+
+ SIVAL(q, 0, ntversion); q += 4;
+ SSVAL(q, 0, lmnttoken); q += 2;
+ SSVAL(q, 0, lm20token); q += 2;
+
+ dump_data(4, outbuf, PTR_DIFF(q, outbuf));
+
+ send_mailslot(True, getdc,
+ outbuf,PTR_DIFF(q,outbuf),
+ dgram->dest_name.name,
+ dgram->dest_name.name_type,
+ dgram->source_name.name,
+ dgram->source_name.name_type,
+ p->ip, *iface_ip(p->ip));
+ break;
+ }
+
+ default:
+ {
+ DEBUG(3,("process_logon_packet: Unknown domain request %d\n", code));
+ return;
+ }
+ }
+
}
diff --git a/source/nmbd/nmbd_winsserver.c b/source/nmbd/nmbd_winsserver.c
index 725e6e3747a..bd8febd65d4 100644
--- a/source/nmbd/nmbd_winsserver.c
+++ b/source/nmbd/nmbd_winsserver.c
@@ -150,8 +150,8 @@ BOOL initialise_wins(void)
pstring name;
struct in_addr *ip_list;
int type = 0;
- int nb_flags;
- int ttl;
+ uint16 nb_flags;
+ time_t ttl;
enum name_source source;
char *ptr;
char *p;
@@ -262,8 +262,8 @@ BOOL initialise_wins(void)
}
/* Decode the netbios flags (hex) and the time-to-live (in seconds). */
- sscanf(nb_flags_str,"%x",&nb_flags);
- sscanf(ttl_str,"%d",&ttl);
+ sscanf(nb_flags_str,"%hx",&nb_flags);
+ sscanf(ttl_str,"%ld",&ttl);
/* add all entries that have 60 seconds or more to live */
if ((ttl - 60) > time_now || ttl == PERMANENT_TTL)
@@ -273,7 +273,7 @@ BOOL initialise_wins(void)
if(ttl != PERMANENT_TTL)
ttl -= time_now;
- DEBUG(4, ("initialise_wins: add name: %s#%02x ttl = %d first IP %s flags = %2x\n",
+ DEBUG(4, ("initialise_wins: add name: %s#%02x ttl = %ld first IP %s flags = %2hx\n",
name, type, ttl, inet_ntoa(ip_list[0]), nb_flags));
namerec = add_name_to_subnet(wins_server_subnet, name, type, nb_flags,
@@ -282,7 +282,7 @@ BOOL initialise_wins(void)
}
else
{
- DEBUG(4, ("initialise_wins: not adding name (ttl problem) %s#%02x ttl = %d first IP %s flags = %2x\n",
+ DEBUG(4, ("initialise_wins: not adding name (ttl problem) %s#%02x ttl = %ld first IP %s flags = %2hx\n",
name, type, ttl, inet_ntoa(ip_list[0]), nb_flags));
}
@@ -1549,9 +1549,9 @@ void wins_write_database(void)
if (namerec->source == REGISTER_NAME)
{
- fprintf(fp, "%s#%02x %d ",
- namerec->name.name,namerec->name.name_type, /* Ignore scope. */
- (int)namerec->death_time);
+ fprintf(fp, "%s#%02x %ld ",
+ namerec->name.name,namerec->name.name_type, /* Ignore scope. */
+ namerec->death_time);
for (i = 0; i < namerec->num_ips; i++)
fprintf(fp, "%s ", inet_ntoa(namerec->ip[i]));