trying to get HEAD building again. If you want the code
[kamenim/samba-autobuild/.git] / docs / docbook / projdoc / IntroSMB.xml
1 <chapter id="IntroSMB">
2 <chapterinfo>
3         &author.dlechnyr;
4         <pubdate>April 14, 2003</pubdate>
5 </chapterinfo>
6
7 <title>Introduction to Samba</title>
8
9 <para><quote>
10 "If you understand what you're doing, you're not learning anything." 
11 -- Anonymous
12 </quote></para>
13
14 <para>
15 Samba is a file and print server for Windows-based clients using TCP/IP as the underlying
16 transport protocol. In fact, it can support any SMB/CIFS-enabled client. One of Samba's big
17 strengths is that you can use it to blend your mix of Windows and Linux machines together
18 without requiring a separate Windows NT/2000/2003 Server.  Samba is actively being developed
19 by a global team of about 30 active programmers and was originally developed by Andrew Tridgell.
20 </para>
21
22 <sect1>
23 <title>Background</title>
24
25 <para>
26 Once long ago, there was a buzzword referred to as DCE/RPC. This stood for Distributed
27 Computing Environment/Remote Procedure Calls and conceptually was a good idea. It was
28 originally developed by Apollo/HP as NCA 1.0 (Network Computing Architecture) and only
29 ran over UDP. When there was a need to run it over TCP so that it would be compatible
30 with DECnet 3.0, it was redesigned, submitted to The Open Group, and officially became
31 known as DCE/RPC. Microsoft came along and decided, rather than pay $20 per seat to
32 license this technology, to reimplement DCE/RPC themselves as MSRPC. From this, the
33 concept continued in the form of SMB (Server Message Block, or the "what") using the
34 NetBIOS (Network Basic Input/Output System, or the "how") compatibility layer. You can
35 run SMB (i.e., transport) over several different protocols; many different implementations
36 arose as a result, including NBIPX (NetBIOS over IPX, NwLnkNb, or NWNBLink) and NBT
37 (NetBIOS over TCP/IP, or NetBT). As the years passed, NBT became the most common form
38 of implementation until the advance of "Direct-Hosted TCP" -- the Microsoft marketing
39 term for eliminating NetBIOS entirely and running SMB by itself across TCP port 445
40 only. As of yet, direct-hosted TCP has yet to catch on.
41 </para>
42
43 <para>
44 Perhaps the best summary of the origins of SMB are voiced in the 1997 article titled, CIFS:
45 Common Insecurities Fail Scrutiny:
46 </para>
47
48 <para><emphasis>
49 Several megabytes of NT-security archives, random whitepapers, RFCs, the CIFS spec, the Samba
50 stuff, a few MS knowledge-base articles, strings extracted from binaries, and packet dumps have
51 been dutifully waded through during the information-gathering stages of this project, and there
52 are *still* many missing pieces... While often tedious, at least the way has been generously
53 littered with occurrences of clapping hand to forehead and muttering 'crikey, what are they
54 thinking?
55 </emphasis></para>
56
57 </sect1>
58
59 <sect1>
60 <title>Terminology</title>
61
62 <itemizedlist>
63
64         <listitem><para>
65         SMB: Acronym for "Server Message Block". This is Microsoft's file and printer sharing protocol.
66         </para></listitem>
67
68         <listitem><para>
69         CIFS: Acronym for "Common Internet File System". Around 1996, Microsoft apparently
70         decided that SMB needed the word "Internet" in it, so they changed it to CIFS.  
71         </para></listitem>
72
73         <listitem><para>
74         Direct-Hosted: A method of providing file/printer sharing services over port 445/tcp
75         only using DNS for name resolution instead of WINS.
76         </para></listitem>
77
78         <listitem><para>
79         IPC: Acronym for "Inter-Process Communication". A method to communicate specific
80         information between programs.
81         </para></listitem>
82
83         <listitem><para>
84         Marshalling: - A method of serializing (i.e., sequential ordering of) variable data
85         suitable for transmission via a network connection or storing in a file. The source
86         data can be re-created using a similar process called unmarshalling.
87         </para></listitem> 
88
89         <listitem><para>
90         NetBIOS: Acronym for "Network Basic Input/Output System". This is not a protocol;
91         it is a method of communication across an existing protocol. This is a standard which
92         was originally developed for IBM by Sytek in 1983. To exaggerate the analogy a bit,
93         it can help to think of this in comparison your computer's BIOS -- it controls the
94         essential functions of your input/output hardware -- whereas NetBIOS controls the
95         essential functions of your input/output traffic via the network. Again, this is a bit
96         of an exaggeration but it should help that paradigm shift. What is important to realize
97         is that NetBIOS is a transport standard, not a protocol. Unfortunately, even technically
98         brilliant people tend to interchange NetBIOS with terms like NetBEUI without a second
99         thought; this will cause no end (and no doubt) of confusion.
100         </para></listitem>
101
102         <listitem><para>
103         NetBEUI: Acronym for the "NetBIOS Extended User Interface". Unlike NetBIOS, NetBEUI
104         is a protocol, not a standard. It is also not routable, so traffic on one side of a
105         router will be unable to communicate with the other side. Understanding NetBEUI is
106         not essential to deciphering SMB; however it helps to point out that it is not the
107         same as NetBIOS and to improve your score in trivia at parties. NetBEUI was originally
108         referred to by Microsoft as "NBF", or "The Windows NT NetBEUI Frame protocol driver".
109         It is not often heard from these days.
110         </para></listitem>
111
112         <listitem><para>
113         NBT: Acronym for "NetBIOS over TCP"; also known as "NetBT". Allows the continued use
114         of NetBIOS traffic proxied over TCP/IP. As a result, NetBIOS names are made 
115         to IP addresses and NetBIOS name types are conceptually equivalent to TCP/IP ports.
116         This is how file and printer sharing are accomplished in Windows 95/98/ME. They 
117         traditionally rely on three ports: NetBIOS Name Service (nbname) via UDP port 137, 
118         NetBIOS Datagram Service (nbdatagram) via UDP port 138, and NetBIOS Session Service 
119         (nbsession) via TCP port 139. All name resolution is done via WINS, NetBIOS broadcasts, 
120         and DNS. NetBIOS over TCP is documented in RFC 1001 (Concepts and methods) and RFC 1002 
121         (Detailed specifications).
122         </para></listitem>
123
124         <listitem><para>
125         W2K: Acronym for Windows 2000 Professional or Server
126         </para></listitem>
127
128         <listitem><para>
129         W3K: Acronym for Windows 2003 Server
130         </para></listitem>
131
132 </itemizedlist>
133
134 <para>If you plan on getting help, make sure to subscribe to the Samba Mailing List (available at 
135 <ulink url="http://www.samba.org/">http://www.samba.org</ulink>). 
136 </para>
137
138 </sect1>
139
140 <sect1>
141 <title>Related Projects</title>
142
143 <para>
144 There are currently two network filesystem client projects for Linux that are directly
145 related to Samba: SMBFS and CIFS VFS.  These are both available in the Linux kernel itself.
146 </para>
147
148 <itemizedlist>
149
150         <listitem><para>
151         SMBFS (Server Message Block File System) allows you to mount SMB shares (the protocol
152         that Microsoft Windows and OS/2 Lan Manager use to share files and printers 
153         over local networks) and access them just like any other Unix directory. This is useful 
154         if you just want to mount such filesystems without being a SMBFS server.
155         </para></listitem>
156
157         <listitem><para>
158         CIFS VFS (Common Internet File System Virtual File System) is the successor to SMBFS, and
159         is being actively developed for the upcoming version of the Linux kernel. The intent of this module
160         is to provide advanced network file system functionality including support for dfs (hierarchical
161         name space), secure per-user session establishment, safe distributed caching (oplock), 
162         optional packet signing, Unicode and other internationalization improvements, and optional 
163         Winbind (nsswitch) integration.
164         </para></listitem>
165  
166 </itemizedlist>
167
168 <para>
169 Again, it's important to note that these are implementations for client filesystems, and have
170 nothing to do with acting as a file and print server for SMB/CIFS clients.
171 </para>
172
173 <para>
174 There are other Open Source CIFS client implementations, such as the 
175 <ulink url="http://jcifs.samba.org/">jCIFS project</ulink>
176 which provides an SMB client toolkit written in Java.
177 </para>
178
179
180 </sect1>
181
182
183 <sect1>
184 <title>SMB Methodology</title>
185
186 <para>
187 Traditionally, SMB uses UDP port 137 (NetBIOS name service, or netbios-ns),
188 UDP port 138 (NetBIOS datagram service, or netbios-dgm), and TCP port 139 (NetBIOS
189 session service, or netbios-ssn). Anyone looking at their network with a good
190 packet sniffer will be amazed at the amount of traffic generated by just opening
191 up a single file. In general, SMB sessions are established in the following order:
192 </para>
193
194 <itemizedlist>
195         <listitem><para>
196         "TCP Connection" - establish 3-way handshake (connection) to port 139/tcp
197     or 445/tcp.
198         </para></listitem>
199
200         <listitem><para>
201         "NetBIOS Session Request" - using the following "Calling Names": The local
202     machine's NetBIOS name plus the 16th character 0x00; The server's NetBIOS
203     name plus the 16th character 0x20
204         </para></listitem>
205
206         <listitem><para>
207         "SMB Negotiate Protocol" - determine the protocol dialect to use, which will
208     be one of the following: PC Network Program 1.0 (Core) - share level security
209     mode only; Microsoft Networks 1.03 (Core Plus) - share level security
210     mode only; Lanman1.0 (LAN Manager 1.0) - uses Challenge/Response
211     Authentication; Lanman2.1 (LAN Manager 2.1) - uses Challenge/Response
212     Authentication; NT LM 0.12 (NT LM 0.12) - uses Challenge/Response
213     Authentication
214         </para></listitem>
215
216         <listitem><para>
217         SMB Session Startup. Passwords are encrypted (or not) according to one of
218     the following methods: Null (no encryption); Cleartext (no encryption); LM
219     and NTLM; NTLM; NTLMv2
220         </para></listitem>
221
222         <listitem><para>
223         SMB Tree Connect: Connect to a share name (e.g., \\servername\share); Connect
224     to a service type (e.g., IPC$ named pipe)
225         </para></listitem>
226
227 </itemizedlist>
228
229 <para>
230 A good way to examine this process in depth is to try out 
231 <ulink url="http://www.securityfriday.com/ToolDownload/SWB/swb_doc.html">SecurityFriday's SWB program</ulink>.
232 It allows you to walk through the establishment of a SMB/CIFS session step by step.
233 </para>
234
235 </sect1>
236
237 <sect1>
238 <title>Epilogue</title>
239
240 <para><quote>
241 What's fundamentally wrong is that nobody ever had any taste when they
242 did it. Microsoft has been very much into making the user interface look good,
243 but internally it's just a complete mess. And even people who program for Microsoft
244 and who have had years of experience, just don't know how it works internally.
245 Worse, nobody dares change it. Nobody dares to fix bugs because it's such a
246 mess that fixing one bug might just break a hundred programs that depend on
247 that bug. And Microsoft isn't interested in anyone fixing bugs -- they're interested
248 in making money. They don't have anybody who takes pride in Windows 95 as an
249 operating system.
250 </quote></para>
251
252 <para><quote>
253 People inside Microsoft know it's a bad operating system and they still
254 continue obviously working on it because they want to get the next version out
255 because they want to have all these new features to sell more copies of the
256 system.
257 </quote></para>
258
259 <para><quote>
260 The problem with that is that over time, when you have this kind of approach,
261 and because nobody understands it, because nobody REALLY fixes bugs (other than
262 when they're really obvious), the end result is really messy. You can't trust
263 it because under certain circumstances it just spontaneously reboots or just
264 halts in the middle of something that shouldn't be strange. Normally it works
265 fine and then once in a blue moon for some completely unknown reason, it's dead,
266 and nobody knows why. Not Microsoft, not the experienced user and certainly
267 not the completely clueless user who probably sits there shivering thinking
268 "What did I do wrong?" when they didn't do anything wrong at all.
269 </quote></para>
270
271 <para><quote>
272 That's what's really irritating to me."
273 </quote></para>
274
275 <para>-- 
276 <ulink url="http://hr.uoregon.edu/davidrl/boot.txt">Linus Torvalds, from an interview with BOOT Magazine, Sept 1998</ulink>
277 </para>
278
279 </sect1>
280
281 <sect1>
282 <title>Miscellaneous</title>
283
284 <!--FIXME: This really needs to go... -->
285
286 <para>
287 This chapter is Copyright 2003 David Lechnyr (david at lechnyr dot com).
288 Permission is granted to copy, distribute and/or modify this document under the terms
289 of the GNU Free Documentation License, Version 1.2 or any later version published by the Free
290 Software Foundation. A copy of the license is available at http://www.gnu.org/licenses/fdl.txt.
291 </para>
292
293 </sect1>
294 </chapter>