From f4192476dc914f9b75c66c09249b58f0143e0ecc Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 13 Apr 2000 02:58:29 +0000 Subject: [PATCH] - got fed up of vuser_db spewing 150 lines of trash, made it possible to increase log levels for parse info. *whew*, now i can actually _read_ log.smb. - codepage koi8-r not KOI-R - fixup of util_sock.c from yesterday, all very painful. took out "min read length" from read_pipe because NT5 expects it to be ignored. stupid. i mean, what's the damn point of putting something in a protocol if it's never used, man? - disabled SChannel because it's still not quite complete (the sequence counfounders are wrong, except i'd never seen anything other than sequence 1-request or sequence 2-request). - all the rest is getting UDP 138 SAMLOGON and GETDC working. again. --- source/Makefile.in | 2 +- source/include/byteorder.h | 30 +++++----- source/lib/util_sock.c | 110 ++++++++++++++++++------------------- source/lib/vuser_db.c | 4 +- source/libsmb/nmblib.c | 2 +- source/netlogond/srv_netlogon_nt.c | 7 ++- source/nmbd/nmbd_processlogon.c | 26 ++++----- source/param/loadparm.c | 2 +- source/rpc_parse/parse_prs.c | 31 ++--------- source/smbd/pipes.c | 2 +- 10 files changed, 97 insertions(+), 119 deletions(-) diff --git a/source/Makefile.in b/source/Makefile.in index ae18fc61364..c76992cf812 100644 --- a/source/Makefile.in +++ b/source/Makefile.in @@ -78,7 +78,7 @@ LOCKDIR = @lockdir@ CODEPAGEDIR = $(LIBDIR)/codepages # The current codepage definition list. -CODEPAGELIST= 437 737 775 850 852 861 932 866 949 950 936 1251 ISO8859-1 ISO8859-2 ISO8859-5 ISO8859-7 KOI-R +CODEPAGELIST= 437 737 775 850 852 861 932 866 949 950 936 1251 ISO8859-1 ISO8859-2 ISO8859-5 ISO8859-7 koi8-r # where you are going to have the smbrun binary. This defaults to the # install directory. This binary is needed for correct printing diff --git a/source/include/byteorder.h b/source/include/byteorder.h index b270627b7f5..b36649989eb 100644 --- a/source/include/byteorder.h +++ b/source/include/byteorder.h @@ -237,41 +237,41 @@ it also defines lots of intermediate macros, just ignore those :-) #define DBG_RW_PCVAL(charmode,string,depth,base,read,inbuf,outbuf,len) \ { RW_PCVAL(read,inbuf,outbuf,len) \ - DEBUG(5,("%s%04x %s: ", \ + DEBUG(5+depth,("%s%04x %s: ", \ tab_depth(depth), base,string)); \ - if (charmode) print_asc(5, (unsigned char*)(outbuf), (len)); else \ - { uint32 idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%02x ", (outbuf)[idx])); } } \ - DEBUG(5,("\n")); } + if (charmode) print_asc(depth+5, (unsigned char*)(outbuf), (len)); else \ + { uint32 idx; for (idx = 0; idx < len; idx++) { DEBUG(5+depth,("%02x ", (outbuf)[idx])); } } \ + DEBUG(5+depth,("\n")); } #define DBG_RW_PSVAL(charmode,string,depth,base,read,big_endian,inbuf,outbuf,len) \ { RW_PSVAL(read,big_endian,inbuf,outbuf,len) \ - DEBUG(5,("%s%04x %s: ", \ + DEBUG(5+depth,("%s%04x %s: ", \ tab_depth(depth), base,string)); \ - if (charmode) print_asc(5, (unsigned char*)(outbuf), 2*(len)); else \ - { uint32 idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%04x ", (outbuf)[idx])); } } \ - DEBUG(5,("\n")); } + if (charmode) print_asc(depth+5, (unsigned char*)(outbuf), 2*(len)); else \ + { uint32 idx; for (idx = 0; idx < len; idx++) { DEBUG(5+depth,("%04x ", (outbuf)[idx])); } } \ + DEBUG(5+depth,("\n")); } #define DBG_RW_PIVAL(charmode,string,depth,base,read,big_endian,inbuf,outbuf,len) \ { RW_PIVAL(read,big_endian,inbuf,outbuf,len) \ - DEBUG(5,("%s%04x %s: ", \ + DEBUG(5+depth,("%s%04x %s: ", \ tab_depth(depth), base,string)); \ - if (charmode) print_asc(5, (unsigned char*)(outbuf), 4*(len)); else \ - { uint32 idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%08x ", (outbuf)[idx])); } } \ - DEBUG(5,("\n")); } + if (charmode) print_asc(depth+5, (unsigned char*)(outbuf), 4*(len)); else \ + { uint32 idx; for (idx = 0; idx < len; idx++) { DEBUG(5+depth,("%08x ", (outbuf)[idx])); } } \ + DEBUG(5+depth,("\n")); } #define DBG_RW_CVAL(string,depth,base,read,inbuf,outbuf) \ { RW_CVAL(read,inbuf,outbuf,0) \ - DEBUG(5,("%s%04x %s: %02x\n", \ + DEBUG(5+depth,("%s%04x %s: %02x\n", \ tab_depth(depth), base, string, outbuf)); } #define DBG_RW_SVAL(string,depth,base,read,big_endian,inbuf,outbuf) \ { RW_SVAL(read,big_endian,inbuf,outbuf,0) \ - DEBUG(5,("%s%04x %s: %04x\n", \ + DEBUG(5+depth,("%s%04x %s: %04x\n", \ tab_depth(depth), base, string, outbuf)); } #define DBG_RW_IVAL(string,depth,base,read,big_endian,inbuf,outbuf) \ { RW_IVAL(read,big_endian,inbuf,outbuf,0) \ - DEBUG(5,("%s%04x %s: %08x\n", \ + DEBUG(5+depth,("%s%04x %s: %08x\n", \ tab_depth(depth), base, string, outbuf)); } /* Alignment macros. */ diff --git a/source/lib/util_sock.c b/source/lib/util_sock.c index b9f6dbc6648..3a789ed533a 100644 --- a/source/lib/util_sock.c +++ b/source/lib/util_sock.c @@ -305,6 +305,8 @@ ssize_t read_socket_with_timeout(int fd, char *buf, size_t mincnt, if (maxcnt <= 0) return (0); + smb_read_error = 0; + /* Blocking read */ if (time_out <= 0) { @@ -329,11 +331,22 @@ ssize_t read_socket_with_timeout(int fd, char *buf, size_t mincnt, readret = read(fd, buf + nread, maxcnt - nread); #endif /* WITH_SSL */ - if (readret <= 0) + if (readret == 0) { - return readret; + DEBUG(5, + ("read_socket_with_timeout: blocking read. EOF from client.\n")); + smb_read_error = READ_EOF; + return -1; } + if (readret == -1) + { + DEBUG(0, + ("read_socket_with_timeout: read error = %s.\n", + strerror(errno))); + smb_read_error = READ_ERROR; + return -1; + } nread += readret; } return ((ssize_t) nread); @@ -350,9 +363,23 @@ ssize_t read_socket_with_timeout(int fd, char *buf, size_t mincnt, int selrtn = read_data_outstanding(fd, time_out); /* Check if error */ - if (selrtn <= 0) + if (selrtn == -1) { - return selrtn; + /* something is wrong. Maybe the socket is dead? */ + DEBUG(0, + ("read_socket_with_timeout: timeout read. select error = %s.\n", + strerror(errno))); + smb_read_error = READ_ERROR; + return -1; + } + + /* Did we timeout ? */ + if (selrtn == 0) + { + DEBUG(10, + ("read_socket_with_timeout: timeout read. select timed out.\n")); + smb_read_error = READ_TIMEOUT; + return -1; } #ifdef WITH_SSL @@ -368,9 +395,23 @@ ssize_t read_socket_with_timeout(int fd, char *buf, size_t mincnt, readret = read(fd, buf + nread, maxcnt - nread); #endif /* WITH_SSL */ - if (readret <= 0) + if (readret == 0) { - return readret; + /* we got EOF on the file descriptor */ + DEBUG(5, + ("read_socket_with_timeout: timeout read. EOF from client.\n")); + smb_read_error = READ_EOF; + return -1; + } + + if (readret == -1) + { + /* the descriptor is probably dead */ + DEBUG(0, + ("read_socket_with_timeout: timeout read. read error = %s.\n", + strerror(errno))); + smb_read_error = READ_ERROR; + return -1; } nread += readret; } @@ -380,7 +421,7 @@ ssize_t read_socket_with_timeout(int fd, char *buf, size_t mincnt, } /**************************************************************************** - Read data from a socket with a timout in msec. + Read data from a fd with a timout in msec. mincount = if timeout, minimum to read before returning maxcount = number to be read. time_out = timeout in milliseconds @@ -396,8 +437,6 @@ ssize_t read_with_timeout(int fd, char *buf, size_t mincnt, size_t maxcnt, if (maxcnt <= 0) return (0); - smb_read_error = 0; - /* Blocking read */ if (time_out <= 0) { @@ -422,17 +461,9 @@ ssize_t read_with_timeout(int fd, char *buf, size_t mincnt, size_t maxcnt, readret = read(fd, buf + nread, maxcnt - nread); #endif /* WITH_SSL */ - if (readret == 0) - { - smb_read_error = READ_EOF; - return -1; - } + if (readret <= 0) + return readret; - if (readret == -1) - { - smb_read_error = READ_ERROR; - return -1; - } nread += readret; } return ((ssize_t) nread); @@ -448,25 +479,8 @@ ssize_t read_with_timeout(int fd, char *buf, size_t mincnt, size_t maxcnt, { int selrtn = read_data_outstanding(fd, time_out); - /* Check if error */ - if (selrtn == -1) - { - /* something is wrong. Maybe the socket is dead? */ - DEBUG(0, - ("read_socket_with_timeout: timeout read. select error = %s.\n", - strerror(errno))); - smb_read_error = READ_ERROR; - return -1; - } - - /* Did we timeout ? */ - if (selrtn == 0) - { - DEBUG(10, - ("read_socket_with_timeout: timeout read. select timed out.\n")); - smb_read_error = READ_TIMEOUT; - return -1; - } + if (selrtn <= 0) + return selrtn; #ifdef WITH_SSL if (fd == sslFd) @@ -481,24 +495,8 @@ ssize_t read_with_timeout(int fd, char *buf, size_t mincnt, size_t maxcnt, readret = read(fd, buf + nread, maxcnt - nread); #endif /* WITH_SSL */ - if (readret == 0) - { - /* we got EOF on the file descriptor */ - DEBUG(5, - ("read_socket_with_timeout: timeout read. EOF from client.\n")); - smb_read_error = READ_EOF; - return -1; - } - - if (readret == -1) - { - /* the descriptor is probably dead */ - DEBUG(0, - ("read_socket_with_timeout: timeout read. read error = %s.\n", - strerror(errno))); - smb_read_error = READ_ERROR; - return -1; - } + if (readret <= 0) + return readret; nread += readret; } diff --git a/source/lib/vuser_db.c b/source/lib/vuser_db.c index 731387e82ad..f8d3ea5a83d 100644 --- a/source/lib/vuser_db.c +++ b/source/lib/vuser_db.c @@ -103,7 +103,7 @@ BOOL tdb_lookup_vuid( const vuser_key *uk, user_struct **usr) if (usr != NULL) { - if (!vuid_io_user_struct("usr", (*usr), &data, 0)) + if (!vuid_io_user_struct("usr", (*usr), &data, 100)) { prs_free_data(&key); prs_free_data(&data); @@ -138,7 +138,7 @@ BOOL tdb_store_vuid( const vuser_key *uk, user_struct *usr) prs_init(&data, 0, 4, False); if (!vuid_io_key("key", &k, &key, 0) || - !vuid_io_user_struct("usr", usr, &data, 0) || + !vuid_io_user_struct("usr", usr, &data, 100) || prs_tdb_store(tdb, TDB_REPLACE, &key, &data) != 0) { prs_free_data(&key); diff --git a/source/libsmb/nmblib.c b/source/libsmb/nmblib.c index c311a125a0e..318331cbbd6 100644 --- a/source/libsmb/nmblib.c +++ b/source/libsmb/nmblib.c @@ -800,7 +800,7 @@ static int build_dgram(char *buf,struct packet_struct *p) /* put in the header */ ubuf[0] = dgram->header.msg_type; - ubuf[1] = (((int)dgram->header.flags.node_type)<<2); + ubuf[1] = (((int)dgram->header.flags.node_type)<<2) + 0x10; if (dgram->header.flags.more) ubuf[1] |= 1; if (dgram->header.flags.first) ubuf[1] |= 2; RSSVAL(ubuf,2,dgram->header.dgm_id); diff --git a/source/netlogond/srv_netlogon_nt.c b/source/netlogond/srv_netlogon_nt.c index 16bf574d9b5..800e8d57360 100644 --- a/source/netlogond/srv_netlogon_nt.c +++ b/source/netlogond/srv_netlogon_nt.c @@ -1204,7 +1204,8 @@ uint32 _net_sam_logon(const UNISTR2 *uni_logon_srv, group_rid, num_gids, gids, 0x20, enc_user_sess_key, &uni_myname, &uni_sam_name, padding, - &global_sam_sid); break; + &global_sam_sid); + break; } case 3: { @@ -1228,7 +1229,9 @@ uint32 _net_sam_logon(const UNISTR2 *uni_logon_srv, gids, 0x20, enc_user_sess_key, &uni_myname, &uni_sam_name, padding, - &global_sam_sid, NULL); break;} + &global_sam_sid, NULL); + break; + } default: { status = NT_STATUS_INVALID_INFO_CLASS; diff --git a/source/nmbd/nmbd_processlogon.c b/source/nmbd/nmbd_processlogon.c index d29673cedf1..5951df05578 100644 --- a/source/nmbd/nmbd_processlogon.c +++ b/source/nmbd/nmbd_processlogon.c @@ -70,6 +70,8 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); code = SVAL(buf,0); DEBUG(1,("process_logon_packet: Logon from %s: code = %x\n", inet_ntoa(p->ip), code)); + dump_data(4, buf, len); + switch (code) { case 0: @@ -102,8 +104,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); send_mailslot(True, getdc, outbuf,PTR_DIFF(q,outbuf), - dgram->dest_name.name, - dgram->dest_name.name_type, + global_myname, 0x0, dgram->source_name.name, dgram->source_name.name_type, p->ip, *iface_ip(p->ip), p->port); @@ -176,7 +177,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, lp_workgroup(), + machine,inet_ntoa(p->ip), reply_name, global_myworkgroup, QUERYFORPDC_R, (uint32)ntversion, (uint32)lmnttoken, (uint32)lm20token )); @@ -184,10 +185,9 @@ 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), - dgram->dest_name.name, - dgram->dest_name.name_type, - dgram->source_name.name, - dgram->source_name.name_type, + global_myname, 0x0, + dgram->source_name.name, + dgram->source_name.name_type, p->ip, *iface_ip(p->ip), p->port); return; } @@ -258,9 +258,8 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", q += 2; q += dos_PutUniCode(q, reply_name,sizeof(pstring), True); - unistrcpy(q, uniuser); - q = skip_unibuf(q, PTR_DIFF(buf+len, q)); /* User name (workstation trust account) */ - q += dos_PutUniCode(q, lp_workgroup(),sizeof(pstring), True); + q += dos_PutUniCode(q, ascuser, sizeof(pstring), True); + q += dos_PutUniCode(q, global_myworkgroup,sizeof(pstring), True); /* tell the client what version we are */ SIVAL(q, 0, 1); /* our ntversion */ @@ -272,10 +271,9 @@ 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), - dgram->dest_name.name, - dgram->dest_name.name_type, - dgram->source_name.name, - dgram->source_name.name_type, + global_myname, 0x0, + dgram->source_name.name, + dgram->source_name.name_type, p->ip, *iface_ip(p->ip), p->port); break; } diff --git a/source/param/loadparm.c b/source/param/loadparm.c index 04be22024e6..44de275eeff 100644 --- a/source/param/loadparm.c +++ b/source/param/loadparm.c @@ -1128,7 +1128,7 @@ static void init_globals(void) /* NETLOGON Secure Channel */ Globals.bClientSChannel = False; - Globals.bServerSChannel = Auto; + Globals.bServerSChannel = False; /* NTLMv2 */ diff --git a/source/rpc_parse/parse_prs.c b/source/rpc_parse/parse_prs.c index d4b5a341fda..f642cacfb32 100644 --- a/source/rpc_parse/parse_prs.c +++ b/source/rpc_parse/parse_prs.c @@ -298,26 +298,6 @@ void prs_free_data(prs_struct *buf) buf->data_size = 0; } -static void *prs_realloc(void *p, size_t size) -{ - void *ret; - if (size == 0) - { - safe_free(p); - return NULL; - } - ret = (void *)malloc(size); - if (!ret) - return NULL; - if (p) - { - memcpy(ret, p, size); - memset(p, 0, 1); - } - safe_free(p); - return ret; -} - /******************************************************************* reallocate a memory buffer ********************************************************************/ @@ -685,9 +665,8 @@ BOOL _prs_uint8(char *name, prs_struct *ps, int depth, uint8 *data8) return False; } - DBG_RW_CVAL(name, depth, ps->offset, ps->io, q, *data8) - ps->offset += 1; - + DBG_RW_CVAL(name, depth, ps->offset, ps->io, q, *data8); + ps->offset += 1; return True; } @@ -1129,7 +1108,7 @@ BOOL _prs_string(char *name, prs_struct *ps, int depth, char *str, DEBUG(200, ("_prs_string: string %s len %d max %d\n", str, len, max_buf_size)); - DEBUG(10, + DEBUG(5+depth, ("%s%04x %s: ", tab_depth(depth), ps->offset, name != NULL ? name : "")); do @@ -1145,7 +1124,7 @@ BOOL _prs_string(char *name, prs_struct *ps, int depth, char *str, if (q == NULL) { ps->error = True; - DEBUG(10, ("%s\n", str)); + DEBUG(5+depth, ("%s\n", str)); prs_debug_out(ps, "_prs_string error", 5); return False; } @@ -1165,7 +1144,7 @@ BOOL _prs_string(char *name, prs_struct *ps, int depth, char *str, ps->offset += i + 1; - DEBUG(10, ("%s\n", str)); + DEBUG(5+depth, ("%s\n", str)); return True; } diff --git a/source/smbd/pipes.c b/source/smbd/pipes.c index bb412712344..f70ed77c3e9 100644 --- a/source/smbd/pipes.c +++ b/source/smbd/pipes.c @@ -239,7 +239,7 @@ int reply_pipe_read_and_X(char *inbuf, char *outbuf, int length, int bufsize) set_message(outbuf, 12, 0, True); data = smb_buf(outbuf); - nread = read_pipe(p, data, smb_mincnt, smb_maxcnt); + nread = read_pipe(p, data, 1, smb_maxcnt); if (nread < 0) return (UNIXERROR(ERRDOS, ERRnoaccess)); -- 2.11.4.GIT