--- source3/include/smb.h.orig 2016-09-06 10:49:56.660999798 +0800 +++ source3/include/smb.h 2016-09-06 10:50:20.317999897 +0800 @@ -533,7 +533,7 @@ /* Remote architectures we know about. */ enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, - RA_WIN2K, RA_WINXP, RA_WIN2K3, RA_VISTA, + RA_WIN2K, RA_WINXP, RA_WIN2K3, RA_VISTA, RA_WIN7, RA_WIN8, RA_WIN81, RA_WIN10, RA_SAMBA, RA_CIFSFS, RA_WINXP64, RA_OSX}; /* --- source3/lib/util.c.orig 2016-09-06 10:52:25.826000123 +0800 +++ source3/lib/util.c 2016-09-06 10:51:58.919998596 +0800 @@ -1273,6 +1273,18 @@ case RA_VISTA: remote_arch_str = "Vista"; break; + case RA_WIN7: + remote_arch_str = "Win7"; + break; + case RA_WIN8: + remote_arch_str = "Win8"; + break; + case RA_WIN81: + remote_arch_str = "Win8.1"; + break; + case RA_WIN10: + remote_arch_str = "Win10"; + break; case RA_SAMBA: remote_arch_str = "Samba"; break; --- libcli/smb/smb_constants.h.orig 2016-05-02 15:48:32.000000000 +0800 +++ libcli/smb/smb_constants.h 2016-09-06 12:40:28.743998120 +0800 @@ -316,7 +316,6 @@ #define FLAGS2_READ_PERMIT_EXECUTE 0x2000 #define FLAGS2_32_BIT_ERROR_CODES 0x4000 #define FLAGS2_UNICODE_STRINGS 0x8000 -#define FLAGS2_WIN2K_SIGNATURE 0xC852 /* Hack alert ! For now... JRA. */ /* FileAttributes (search attributes) field */ #define FILE_ATTRIBUTE_READONLY 0x0001L --- source3/smbd/negprot.c.orig 2016-03-30 18:19:32.000000000 +0800 +++ source3/smbd/negprot.c 2016-09-06 12:40:28.744998183 +0800 @@ -443,41 +443,67 @@ protocol [LANMAN1.0] protocol [LM1.2X002] protocol [LANMAN2.1] + +OSX: +protocol [NT LM 0.12] +protocol [SMB 2.002] +protocol [SMB 2.???] */ /* * Modified to recognize the architecture of the remote machine better. * * This appears to be the matrix of which protocol is used by which - * MS product. - Protocol WfWg Win95 WinNT Win2K OS/2 Vista - PC NETWORK PROGRAM 1.0 1 1 1 1 1 1 - XENIX CORE 2 2 - MICROSOFT NETWORKS 3.0 2 2 - DOS LM1.2X002 3 3 - MICROSOFT NETWORKS 1.03 3 - DOS LANMAN2.1 4 4 - LANMAN1.0 4 2 3 2 - Windows for Workgroups 3.1a 5 5 5 3 3 - LM1.2X002 6 4 4 4 - LANMAN2.1 7 5 5 5 - NT LM 0.12 6 8 6 6 - SMB 2.001 7 + * product. + Protocol WfWg Win95 WinNT Win2K OS/2 Vista OSX + PC NETWORK PROGRAM 1.0 1 1 1 1 1 1 + XENIX CORE 2 2 + MICROSOFT NETWORKS 3.0 2 2 + DOS LM1.2X002 3 3 + MICROSOFT NETWORKS 1.03 3 + DOS LANMAN2.1 4 4 + LANMAN1.0 4 2 3 2 + Windows for Workgroups 3.1a 5 5 5 3 3 + LM1.2X002 6 4 4 4 + LANMAN2.1 7 5 5 5 + NT LM 0.12 6 8 6 6 6 1 + SMB 2.001 7 + SMB 2.002 2 + SMB 2.??? 3 * * tim@fsg.com 09/29/95 * Win2K added by matty 17/7/99 */ -#define ARCH_WFWG 0x3 /* This is a fudge because WfWg is like Win95 */ -#define ARCH_WIN95 0x2 -#define ARCH_WINNT 0x4 -#define ARCH_WIN2K 0xC /* Win2K is like NT */ -#define ARCH_OS2 0x14 /* Again OS/2 is like NT */ -#define ARCH_SAMBA 0x20 -#define ARCH_CIFSFS 0x40 -#define ARCH_VISTA 0x8C /* Vista is like XP/2K */ - -#define ARCH_ALL 0x7F +#define PROT_PC_NETWORK_PROGRAM_1_0 0x0001 +#define PROT_XENIX_CORE 0x0002 +#define PROT_MICROSOFT_NETWORKS_3_0 0x0004 +#define PROT_DOS_LM1_2X002 0x0008 +#define PROT_MICROSOFT_NETWORKS_1_03 0x0010 +#define PROT_DOS_LANMAN2_1 0x0020 +#define PROT_LANMAN1_0 0x0040 +#define PROT_WFWG 0x0080 +#define PROT_LM1_2X002 0x0100 +#define PROT_LANMAN2_1 0x0200 +#define PROT_NT_LM_0_12 0x0400 +#define PROT_SMB_2_001 0x0800 +#define PROT_SMB_2_002 0x1000 +#define PROT_SMB_2_FF 0x2000 +#define PROT_SAMBA 0x4000 +#define PROT_POSIX_2 0x8000 + +#define ARCH_WFWG ( PROT_PC_NETWORK_PROGRAM_1_0 | PROT_MICROSOFT_NETWORKS_3_0 | \ + PROT_DOS_LM1_2X002 | PROT_DOS_LANMAN2_1 | PROT_WFWG ) +#define ARCH_WIN95 ( ARCH_WFWG | PROT_NT_LM_0_12 ) +#define ARCH_WINNT ( PROT_PC_NETWORK_PROGRAM_1_0 | PROT_XENIX_CORE | \ + PROT_MICROSOFT_NETWORKS_1_03 | PROT_LANMAN1_0 | PROT_WFWG | \ + PROT_LM1_2X002 | PROT_LANMAN2_1 | PROT_NT_LM_0_12 ) +#define ARCH_WIN2K ( ARCH_WINNT & ~(PROT_XENIX_CORE | PROT_MICROSOFT_NETWORKS_1_03) ) +#define ARCH_OS2 ( ARCH_WINNT & ~(PROT_MICROSOFT_NETWORKS_1_03 | PROT_WFWG) ) +#define ARCH_VISTA ( ARCH_WIN2K | PROT_SMB_2_001 ) +#define ARCH_SAMBA ( PROT_SAMBA ) +#define ARCH_CIFSFS ( PROT_POSIX_2 ) +#define ARCH_OSX ( PROT_NT_LM_0_12 | PROT_SMB_2_002 | PROT_SMB_2_FF ) /* List of supported protocols, most desired first */ static const struct { @@ -511,7 +537,7 @@ int chosen_level = -1; int protocol; const char *p; - int arch = ARCH_ALL; + int protocols = 0; int num_cliprotos; char **cliprotos; int i; @@ -580,41 +606,46 @@ } for (i=0; iflags2 == FLAGS2_WIN2K_SIGNATURE) - set_remote_arch(RA_WIN2K); - else - set_remote_arch(RA_WINNT); + set_remote_arch(RA_WINNT); break; case ARCH_WIN2K: - /* Vista may have been set in the negprot so don't - override it here */ - if ( get_remote_arch() != RA_VISTA ) - set_remote_arch(RA_WIN2K); + set_remote_arch(RA_WIN2K); break; case ARCH_VISTA: set_remote_arch(RA_VISTA); @@ -645,6 +670,9 @@ case ARCH_OS2: set_remote_arch(RA_OS2); break; + case ARCH_OSX: + set_remote_arch(RA_OSX); + break; default: set_remote_arch(RA_UNKNOWN); break; --- source3/smbd/smb2_negprot.c.orig 2016-03-30 18:19:32.000000000 +0800 +++ source3/smbd/smb2_negprot.c 2016-09-06 12:40:28.743998120 +0800 @@ -194,6 +194,8 @@ dialect_count, &dialect); + enum protocol_types protocol_max = protocol; + for (c=0; protocol == PROTOCOL_NONE && c < dialect_count; c++) { if (lp_server_max_protocol() < PROTOCOL_SMB2_10) { break; @@ -260,8 +260,24 @@ } } - if (get_remote_arch() != RA_SAMBA) { - set_remote_arch(RA_VISTA); + switch (get_remote_arch()) { + case RA_SAMBA: + case RA_CIFSFS: + case RA_OSX: + break; + default: + if (protocol_max < PROTOCOL_SMB2_10) { + set_remote_arch(RA_VISTA); + } else if (protocol_max < PROTOCOL_SMB2_22) { + set_remote_arch(RA_WIN7); + } else if (protocol_max < PROTOCOL_SMB3_02) { + set_remote_arch(RA_WIN8); + } else if (protocol_max < PROTOCOL_SMB3_10) { + set_remote_arch(RA_WIN81); + } else { + set_remote_arch(RA_WIN10); + } + break; } fstr_sprintf(remote_proto, "SMB%X_%02X",