From 04cfbc7854bb793481e9050264a1f0cac1c6198a Mon Sep 17 00:00:00 2001
From: John Terpstra
Table of Contents
Table of Contents
Definition of NetBIOS Protocol and Name Resolution Modes
Luke Leighton
Dan Shearer
Chris Hertel
Steve French
Simo Sorce
Andrew Bartlett
Tim Potter
Martin Pool
David Chappell <David.Chappell@mail.trincoll.edu>
Chris Hertel
Andrew Tridgell
Andrew Tridgell
Finding useful information on windows
Jelmer R. Vernooij <jelmer@samba.org>
Andrew Tridgell <tridge@samba.org>
Luke Leighton <lkcl@switchboard.net>
Paul Ashton <paul@argo.demon.co.uk>
Duncan Stansfield <duncans@sco.com>
Gerald Carter
Gerald Carter
Andrew Bartlett
LanMan and NT Password Encryption
Jeremy Allison <samba@samba.org>
Jelmer Vernooij <jelmer@samba.org>
Anthony Liguori <aliguor@us.ibm.com>
Jelmer Vernooij <jelmer@samba.org>
Alexander Bokovoy <ab@samba.org>
Stefan Metzmacher <metze@metzemix.de>
Jelmer Vernooij
Jelmer R. Vernooij <jelmer@samba.org>
Table of Contents
+
Definition of NetBIOS Protocol and Name Resolution Modes
Luke Leighton
Dan Shearer
Chris Hertel
Steve French
Simo Sorce
Andrew Bartlett
Tim Potter
Martin Pool
David Chappell <David.Chappell@mail.trincoll.edu>
Chris Hertel
Andrew Tridgell
Andrew Tridgell
Finding useful information on windows
Jelmer R. Vernooij <jelmer@samba.org>
Andrew Tridgell <tridge@samba.org>
Luke Leighton <lkcl@switchboard.net>
Paul Ashton <paul@argo.demon.co.uk>
Duncan Stansfield <duncans@sco.com>
Gerald Carter
Gerald Carter
Andrew Bartlett
LanMan and NT Password Encryption
Jeremy Allison <samba@samba.org>
Jelmer Vernooij <jelmer@samba.org>
Anthony Liguori <aliguor@us.ibm.com>
Jelmer Vernooij <jelmer@samba.org>
Alexander Bokovoy <ab@samba.org>
Stefan Metzmacher <metze@metzemix.de>
Jelmer Vernooij
Jelmer R. Vernooij <jelmer@samba.org>
Table of Contents
NetBIOS runs over the following tranports: TCP/IP; NetBEUI and IPX/SPX. Samba only uses NetBIOS over TCP/IP. For details on the TCP/IP NetBIOS Session Service NetBIOS Datagram Service, and NetBIOS Names, see @@ -75,7 +75,7 @@ NetBIOS names are either UNIQUE or GROUP. Only one application can claim a UNIQUE NetBIOS name on a network.
There are two kinds of NetBIOS Name resolution: Broadcast and Point-to-Point. -
Clients can claim names, and therefore offer services on successfully claimed names, on their broadcast-isolated subnet. One way to get NetBIOS services (such as browsing: see ftp.microsoft.com/drg/developr/CIFS/browdiff.txt; and @@ -87,7 +87,7 @@ find that some of your hosts spend 95 percent of their time dealing with broadcast traffic. [If you have IPX/SPX on your LAN or WAN, you will find that this is already happening: a packet analyzer will show, roughly every twelve minutes, great swathes of broadcast traffic!]. -
rfc1001.txt describes, amongst other things, the implementation and use of, a 'NetBIOS Name Service'. NT/AS offers 'Windows Internet Name Service' which is fully rfc1001/2 compliant, but has had to take specific action @@ -128,7 +128,7 @@ WINS Clients therefore claim names from the WINS server. If the WINS server allows them to register a name, the client's NetBIOS session service can then offer services on this name. Other WINS clients will then contact the WINS server to resolve a NetBIOS name. -
This document gives a general overview of how Samba works internally. The Samba Team has tried to come up with a model which is the best possible compromise between elegance, portability, security @@ -139,7 +139,7 @@ It also tries to answer some of the frequently asked questions such as:
Is Samba secure when running on Unix? The xyz platform? What about the root priveliges issue? -
Pros and cons of multithreading in various parts of Samba
Why not have a separate process for name resolution, WINS, and browsing?
People sometimes tout threads as a uniformly good thing. They are very nice in their place but are quite inappropriate for smbd. nmbd is another matter, and multi-threading it would be very nice. @@ -156,7 +156,7 @@ smbd multi-threaded. Multi-threading would actually make Samba much slower, less scalable, less portable and much less robust. The fact that we use a separate process for each connection is one of Samba's biggest advantages. -
A few problems that would arise from a threaded smbd are:
It's not only to create threads instead of processes, but you @@ -181,7 +181,7 @@ A few problems that would arise from a threaded smbd are:
we couldn't use the system locking calls as the locking context of fcntl() is a process, not a thread. -
This would be ideal, but gets sunk by portability requirements.
Andrew tried to write a test threads library for nmbd that used only @@ -208,7 +208,7 @@ packet that arrives. Having a pool of processes is possible but is nasty to program cleanly due to the enormous amount of shared data (in complex structures) between the processes. We can't rely on each platform having a shared memory system. -
Originally Andrew used recursion to simulate a multi-threaded environment, which use the stack enormously and made for really confusing debugging sessions. Luke Leighton rewrote it to use a @@ -225,11 +225,11 @@ a single process.
Then Jeremy rewrote nmbd. The packet data in nmbd isn't what's on the wire. It's a nice format that is very amenable to processing but still -keeps the idea of a distinct packet. See "struct packet_struct" in +keeps the idea of a distinct packet. See "struct packet_struct" in nameserv.h. It has all the detail but none of the on-the-wire mess. This makes it ideal for using in disk or memory-based databases for browsing and WINS support. -
Table of Contents
Table of Contents
The syntax of a debugging log file is represented as:
>debugfile< :== { >debugmsg< } @@ -282,16 +282,16 @@ by a newline. Note that in the above example the function names are not listed on the header line. That's because the example above was generated on an SGI Indy, and the SGI compiler doesn't support the __FUNCTION__ macro. -
Use of the DEBUG() macro is unchanged. DEBUG() takes two parameters. The first is the message level, the second is the body of a function call to the Debug1() function.
That's confusing.
Here's an example which may help a bit. If you would write
-printf( "This is a %s message.\n", "debug" ); +printf( "This is a %s message.\n", "debug" );
to send the output to stdout, then you would write
-DEBUG( 0, ( "This is a %s message.\n", "debug" ) ); +DEBUG( 0, ( "This is a %s message.\n", "debug" ) );
to send the output to the debug file. All of the normal printf() formatting escapes work. @@ -316,12 +316,12 @@ DEBUG() is called, the new input is simply appended. DEBUG() has been used to write partial lines. Here's a simple (dumb) example of the kind of thing I'm talking about:
- DEBUG( 0, ("The test returned " ) ); + DEBUG( 0, ("The test returned " ) ); if( test() ) - DEBUG(0, ("True") ); + DEBUG(0, ("True") ); else - DEBUG(0, ("False") ); - DEBUG(0, (".\n") ); + DEBUG(0, ("False") ); + DEBUG(0, (".\n") );
Without the format buffer, the output (assuming test() returned true) would look like this: @@ -333,35 +333,35 @@ would look like this: [1998/07/30 16:00:51, 0] file.c:function(261) .
Which isn't much use. The format buffer kludge fixes this problem. -
In addition to the kludgey solution to the broken line problem described above, there is a clean solution. The DEBUGADD() macro never generates a header. It will append new text to the current debug message even if the format buffer is empty. The syntax of the DEBUGADD() macro is the same as that of the DEBUG() macro.
- DEBUG( 0, ("This is the first line.\n" ) ); - DEBUGADD( 0, ("This is the second line.\nThis is the third line.\n" ) ); + DEBUG( 0, ("This is the first line.\n" ) ); + DEBUGADD( 0, ("This is the second line.\nThis is the third line.\n" ) );
Produces
[1998/07/30 16:00:51, 0] file.c:function(512) This is the first line. This is the second line. This is the third line. -
One of the problems with the DEBUG() macro was that DEBUG() lines tended to get a bit long. Consider this example from nmbd_sendannounce.c:
- DEBUG(3,("send_local_master_announcement: type %x for name %s on subnet %s for workgroup %s\n", + DEBUG(3,("send_local_master_announcement: type %x for name %s on subnet %s for workgroup %s\n", type, global_myname, subrec->subnet_name, work->work_group));
One solution to this is to break it down using DEBUG() and DEBUGADD(), as follows:
- DEBUG( 3, ( "send_local_master_announcement: " ) ); - DEBUGADD( 3, ( "type %x for name %s ", type, global_myname ) ); - DEBUGADD( 3, ( "on subnet %s ", subrec->subnet_name ) ); - DEBUGADD( 3, ( "for workgroup %s\n", work->work_group ) ); + DEBUG( 3, ( "send_local_master_announcement: " ) ); + DEBUGADD( 3, ( "type %x for name %s ", type, global_myname ) ); + DEBUGADD( 3, ( "on subnet %s ", subrec->subnet_name ) ); + DEBUGADD( 3, ( "for workgroup %s\n", work->work_group ) );
A similar, but arguably nicer approach is to use the DEBUGLVL() macro. This macro returns True if the message level is less than or equal to @@ -369,10 +369,10 @@ the global DEBUGLEVEL value, so:
if( DEBUGLVL( 3 ) ) { - dbgtext( "send_local_master_announcement: " ); - dbgtext( "type %x for name %s ", type, global_myname ); - dbgtext( "on subnet %s ", subrec->subnet_name ); - dbgtext( "for workgroup %s\n", work->work_group ); + dbgtext( "send_local_master_announcement: " ); + dbgtext( "type %x for name %s ", type, global_myname ); + dbgtext( "on subnet %s ", subrec->subnet_name ); + dbgtext( "for workgroup %s\n", work->work_group ); }
(The dbgtext() function is explained below.)
There are a few advantages to this scheme:
The test is performed only once. @@ -382,7 +382,7 @@ within the DEBUGLVL() block.
Processing that is only relevant to debug output can be contained within the DEBUGLVL() block. -
This function prints debug message text to the debug file (and possibly to syslog) via the format buffer. The function uses a variable argument list just like printf() or Debug1(). The @@ -391,7 +391,7 @@ and then passed to format_debug_text(). If you use DEBUGLVL() you will probably print the body of the message using dbgtext(). -
This is the function that writes a debug message header. Headers are not processed via the format buffer. Also note that if the format buffer is not empty, a call to dbghdr() will not @@ -399,7 +399,7 @@ produce any output. See the comments in dbghdr() for more info.
It is not likely that this function will be called directly. It is used by DEBUG() and DEBUGADD(). -
This is a static function in debug.c. It stores the output text for the body of the message in a buffer until it encounters a newline. When the newline character is found, the buffer is @@ -481,7 +481,7 @@ Here are some other suggestions: reason: consistency
don't explicitly extern functions (they are autogenerated by - "make proto" into proto.h) + "make proto" into proto.h) reason: consistency
use endian safe macros when unpacking SMBs (see byteorder.h and @@ -550,7 +550,7 @@ The suggestions above are simply that, suggestions, but the information may help in reducing the routine rework done on new code. The preceeding list is expected to change routinely as new support routines and macros are added. -
Table of Contents
Table of Contents
This section describes character set handling in Samba, as implemented in Samba 3.0 and above
@@ -560,12 +560,12 @@ strings to/from DOS codepages. The problem is that there was no way of telling if a particular char* is in dos codepage or unix codepage. This led to a nightmare of code that tried to cope with particular cases without handlingt the general case. -
The new system works like this:
- all char* strings inside Samba are "unix" strings. These are - multi-byte strings that are in the charset defined by the "unix - charset" option in smb.conf. + all char* strings inside Samba are "unix" strings. These are + multi-byte strings that are in the charset defined by the "unix + charset" option in smb.conf.
there is no single fixed character set for unix strings, but any character set that is used does need the following properties: @@ -618,32 +618,32 @@ The new system works like this: like strchr_m(). I know this is very slow, and we will eventually speed it up but right now we want this stuff correct not fast.
- all lp_ functions now return unix strings. The magic "DOS" flag on + all lp_ functions now return unix strings. The magic "DOS" flag on parameters is gone.
all vfs functions take unix strings. Don't convert when passing to them -
This section describes the macros defined in byteorder.h. These macros are used extensively in the Samba code. -
+
returns the value of the unsigned short (16 bit) little-endian integer at offset pos within buffer buf. An integer of this type is sometimes - refered to as "USHORT". -
returns the value of the unsigned 32 bit little-endian integer at offset -pos within buffer buf.
returns the value of the signed short (16 bit) little-endian integer at -offset pos within buffer buf.
returns the value of the signed 32 bit little-endian integer at offset pos -within buffer buf.
sets the unsigned short (16 bit) little-endian integer at offset pos within -buffer buf to value val.
sets the unsigned 32 bit little-endian integer at offset pos within buffer -buf to the value val.
sets the short (16 bit) signed little-endian integer at offset pos within -buffer buf to the value val.
sets the signed 32 bit little-endian integer at offset pos withing buffer -buf to the value val.
returns the value of the unsigned short (16 bit) big-endian integer at -offset pos within buffer buf.
returns the value of the unsigned 32 bit big-endian integer at offset -pos within buffer buf.
sets the value of the unsigned short (16 bit) big-endian integer at + refered to as "USHORT". +
returns the value of the unsigned 32 bit little-endian integer at offset +pos within buffer buf.
returns the value of the signed short (16 bit) little-endian integer at +offset pos within buffer buf.
returns the value of the signed 32 bit little-endian integer at offset pos +within buffer buf.
sets the unsigned short (16 bit) little-endian integer at offset pos within +buffer buf to value val.
sets the unsigned 32 bit little-endian integer at offset pos within buffer +buf to the value val.
sets the short (16 bit) signed little-endian integer at offset pos within +buffer buf to the value val.
sets the signed 32 bit little-endian integer at offset pos withing buffer +buf to the value val.
returns the value of the unsigned short (16 bit) big-endian integer at +offset pos within buffer buf.
returns the value of the unsigned 32 bit big-endian integer at offset +pos within buffer buf.
sets the value of the unsigned short (16 bit) big-endian integer at offset pos within buffer buf to value val. -refered to as "USHORT".
This section describes the functions need to make a LAN Manager RPC call. This information had been obtained by examining the Samba code and the LAN Manager 2.0 API documentation. It should not be considered entirely @@ -656,7 +656,7 @@ call_api(int prcnt, int drcnt, int mprcnt, int mdrcnt,
This function is defined in client.c. It uses an SMB transaction to call a remote api. -
The parameters are as follows:
+
The parameters are as follows:
prcnt: the number of bytes of parameters begin sent.
drcnt: the number of bytes of data begin sent. @@ -689,8 +689,8 @@ in the manual, not the data which is actually passed. An ASCIIZ string describing the data structure which ought to be returned.
Any parameters which appear in the function call, as defined in the LAN -Manager API documentation, after the "Server" and up to and including the -"uLevel" parameters. +Manager API documentation, after the "Server" and up to and including the +"uLevel" parameters.
An unsigned 16 bit integer which gives the size in bytes of the buffer we will use to receive the returned array of data structures. Presumably this @@ -701,7 +701,7 @@ substructures apply, this string is of zero length.
The code in client.c always calls call_api() with no data. It is unclear when a non-zero length data buffer would be sent. -
The returned parameters (pointed to by rparam), in their order of appearance are:
An unsigned 16 bit integer which contains the API function's return code. @@ -718,9 +718,9 @@ It is also possible that this may sometimes be the number of bytes returned.
When call_api() returns, rparam points to the returned parameters. The first if these is the result code. It will be zero if the API call -suceeded. This value by be read with "SVAL(rparam,0)". +suceeded. This value by be read with "SVAL(rparam,0)".
-The second parameter may be read as "SVAL(rparam,2)". It is a 16 bit offset +The second parameter may be read as "SVAL(rparam,2)". It is a 16 bit offset which indicates what the base address of the returned data buffer was when it was built on the server. It should be used to correct pointer before use. @@ -729,10 +729,10 @@ The returned data buffer contains the array of returned data structures. Note that all pointers must be adjusted before use. The function fix_char_ptr() in client.c can be used for this purpose.
-The third parameter (which may be read as "SVAL(rparam,4)") has something to +The third parameter (which may be read as "SVAL(rparam,4)") has something to do with indicating the amount of data returned or possibly the amount of data which can be returned if enough buffer space is allowed. -
Table of Contents
Table of Contents
Basically, the file is processed on a line by line basis. There are four types of lines that are recognized by the lexical analyzer (params.c): @@ -782,7 +782,7 @@ ignores them. The latter two line types are scanned for These are the only tokens passed to the parameter loader (loadparm.c). Parameter names and values are divided from one another by an equal sign: '='. -
+
Whitespace is defined as all characters recognized by the isspace() function (see ctype(3C)) except for the newline character ('\n') The newline is excluded because it identifies the end of the line. @@ -797,7 +797,7 @@ the exception of carriage return characters ('\r'), all of which are removed.
Leading and trailing whitespace is removed from names and values. -
Long section header and parameter lines may be extended across multiple lines by use of the backslash character ('\\'). Line continuation is ignored for blank and comment lines. @@ -820,7 +820,7 @@ line, plus the four preceeding the word 'with' in the second line. Line continuation characters are ignored on blank lines and at the end of comments. They are *only* recognized within section and parameter lines. -
The syntax of the smb.conf file is as follows:
<file> :== { <section> } EOF <section> :== <section header> { <parameter line> } <section header> :== '[' NAME ']' @@ -863,12 +863,12 @@ terminating character, and the rest of the line is ignored. The lines A parameter line is divided into a NAME and a VALUE. The *first* equal sign on the line separates the NAME from the VALUE. The VALUE is terminated by a newline character (NL = '\n'). -
Table of Contents
Table of Contents
This is a short document that describes some of the issues that confront a SMB implementation on unix, and how Samba copes with them. They may help people who are looking at unix<->PC @@ -876,7 +876,7 @@ interoperability.
It was written to help out a person who was writing a paper on unix to PC connectivity. -
The SMB protocol has only a loose username concept. Early SMB protocols (such as CORE and COREPLUS) have no username concept at all. Even in later protocols clients often attempt operations @@ -887,20 +887,20 @@ Unix security is based around username/password pairs. A unix box should not allow clients to do any substantive operation without some sort of validation.
-The problem mostly manifests itself when the unix server is in "share -level" security mode. This is the default mode as the alternative -"user level" security mode usually forces a client to connect to the +The problem mostly manifests itself when the unix server is in "share +level" security mode. This is the default mode as the alternative +"user level" security mode usually forces a client to connect to the server as the same user for each connected share, which is inconvenient in many sites.
-In "share level" security the client normally gives a username in the -"session setup" protocol, but does not supply an accompanying -password. The client then connects to resources using the "tree -connect" protocol, and supplies a password. The problem is that the +In "share level" security the client normally gives a username in the +"session setup" protocol, but does not supply an accompanying +password. The client then connects to resources using the "tree +connect" protocol, and supplies a password. The problem is that the user on the PC types the username and the password in different contexts, unaware that they need to go together to give access to the server. The username is normally the one the user typed in when they -"logged onto" the PC (this assumes Windows for Workgroups). The +"logged onto" the PC (this assumes Windows for Workgroups). The password is the one they chose when connecting to the disk or printer.
The user often chooses a totally different username for their login as @@ -913,9 +913,9 @@ in the vast majority of cases. The methods include username maps, the service%user syntax, the saving of session setup usernames for later validation and the derivation of the username from the service name (either directly or via the user= option). -
-The commonly used SMB protocols have no way of saying "you can't do -that because you don't own the file". They have, in fact, no concept +
+The commonly used SMB protocols have no way of saying "you can't do +that because you don't own the file". They have, in fact, no concept of file ownership at all.
This brings up all sorts of interesting problems. For example, when @@ -925,13 +925,13 @@ receive the wrong date. This is because the utime() call under unix only succeeds for the owner of the file, or root, even if the file is world writeable. For security reasons Samba does all file operations as the validated user, not root, so the utime() fails. This can stuff -up shared development diectories as programs like "make" will not get +up shared development diectories as programs like "make" will not get file time comparisons right.
There are several possible solutions to this problem, including username mapping, and forcing a specific username for particular shares. -
Many SMB clients uppercase passwords before sending them. I have no idea why they do this. Interestingly WfWg uppercases the password only if the server is running a protocol greater than COREPLUS, so @@ -940,20 +940,20 @@ obviously it isn't just the data entry routines that are to blame. Unix passwords are case sensitive. So if users use mixed case passwords they are in trouble.
-Samba can try to cope with this by either using the "password level" +Samba can try to cope with this by either using the "password level" option which causes Samba to try the offered password with up to the -specified number of case changes, or by using the "password server" +specified number of case changes, or by using the "password server" option which allows Samba to do its validation via another machine (typically a WinNT server).
Samba supports the password encryption method used by SMB clients. Note that the use of password encryption in Microsoft -networking leads to password hashes that are "plain text equivalent". +networking leads to password hashes that are "plain text equivalent". This means that it is *VERY* important to ensure that the Samba smbpasswd file containing these password hashes is only readable by the root user. See the documentation ENCRYPTION.txt for more details. -
Since samba 2.2, samba supports other types of locking as well. This section is outdated.
@@ -978,14 +978,14 @@ a unix environment because few unix programs use byte range locking. The stress of huge numbers of lock requests from dos/windows clients can kill the daemon on some systems.
-The second major problem is the "opportunistic locking" requested by +The second major problem is the "opportunistic locking" requested by some clients. If a client requests opportunistic locking then it is asking the server to notify it if anyone else tries to do something on the same file, at which time the client will say if it is willing to give up its lock. Unix has no simple way of implementing opportunistic locking, and currently Samba has no support for it. -
+When a SMB client opens a file it asks for a particular "deny mode" to be placed on the file. These modes (DENY_NONE, DENY_READ, DENY_WRITE, DENY_ALL, DENY_FCB and DENY_DOS) specify what actions should be allowed by anyone else who tries to use the file at the same time. If @@ -998,7 +998,7 @@ directory or a shared memory implementation. The lock file method is clumsy and consumes processing and file resources, the shared memory implementation is vastly prefered and is turned on by default for those systems that support it. -
A SMB session can run with several uids on the one socket. This happens when a user connects to two shares with different usernames. To cope with this the unix server needs to switch uids @@ -1006,11 +1006,11 @@ within the one process. On some unixes (such as SCO) this is not possible. This means that on those unixes the client is restricted to a single uid.
-Note that you can also get the "trapdoor uid" message for other +Note that you can also get the "trapdoor uid" message for other reasons. Please see the FAQ for details. -
-There is a convention that clients on sockets use high "unprivilaged" -port numbers (>1000) and connect to servers on low "privilaged" port +
+There is a convention that clients on sockets use high "unprivilaged" +port numbers (>1000) and connect to servers on low "privilaged" port numbers. This is enforced in Unix as non-root users can't open a socket for listening on port numbers less than 1000.
@@ -1031,13 +1031,13 @@ to any of these OSes unless they are running as root. The answer comes back, but it goes to port 137 which the unix user can't listen on. Interestingly WinNT3.1 got this right - it sends node status responses back to the source port in the request. -
+There are many "protocol levels" in the SMB protocol. It seems that each time new functionality was added to a Microsoft operating system, they added the equivalent functions in a new protocol level of the SMB -protocol to "externalise" the new capabilities. +protocol to "externalise" the new capabilities.
-This means the protocol is very "rich", offering many ways of doing +This means the protocol is very "rich", offering many ways of doing each file operation. This means SMB servers need to be complex and large. It also means it is very difficult to make them bug free. It is not just Samba that suffers from this problem, other servers such as @@ -1045,19 +1045,19 @@ WinNT don't support every variation of every call and it has almost certainly been a headache for MS developers to support the myriad of SMB calls that are available.
-There are about 65 "top level" operations in the SMB protocol (things +There are about 65 "top level" operations in the SMB protocol (things like SMBread and SMBwrite). Some of these include hundreds of sub-functions (SMBtrans has at least 120 sub-functions, like DosPrintQAdd and NetSessionEnum). All of them take several options that can change the way they work. Many take dozens of possible -"information levels" that change the structures that need to be -returned. Samba supports all but 2 of the "top level" functions. It +"information levels" that change the structures that need to be +returned. Samba supports all but 2 of the "top level" functions. It supports only 8 (so far) of the SMBtrans sub-functions. Even NT doesn't support them all.
-Samba currently supports up to the "NT LM 0.12" protocol, which is the +Samba currently supports up to the "NT LM 0.12" protocol, which is the one preferred by Win95 and WinNT3.5. Luckily this protocol level has a -"capabilities" field which specifies which super-duper new-fangled +"capabilities" field which specifies which super-duper new-fangled options the server suports. This helps to make the implementation of this protocol level much easier.
@@ -1102,13 +1102,13 @@ You'll notice that it produces a LOT of output. It is showing you the arguments to every system call that the program makes and the result. Very little happens in a program without a system call so you get lots of output. You'll also find that it produces a lot of -"preamble" stuff showing the loading of shared libraries etc. Ignore +"preamble" stuff showing the loading of shared libraries etc. Ignore this (unless its going wrong!)
For example, the only line that really matters in the strace echo hello output is:
-write(1, "hello\n", 6) = 6 +write(1, "hello\n", 6) = 6
all the rest is just setting up to run the program.
Ok, now you're familiar with strace. To use it on Samba you need to strace the running smbd daemon. The way I tend ot use it is to first @@ -1118,10 +1118,10 @@ find which process ID that client is attached to, then as root I do stderr output from this command to a file for later perusal. For example, if I'm using a csh style shell:
strace -f -p 3872 >& strace.out
or with a sh style shell:
strace -f -p 3872 > strace.out 2>&1
-Note the "-f" option. This is only available on some systems, and +Note the "-f" option. This is only available on some systems, and allows you to trace not just the current process, but any children it forks. This is great for finding printing problems caused by the -"print command" being wrong. +"print command" being wrong.
Once you are attached you then can do whatever it is on the client that is causing problems and you will capture all the system calls @@ -1132,20 +1132,20 @@ output for strings that I know will appear when the problem happens. For example, if I am having touble with permissions on a file I would search for that files name in the strace output and look at the surrounding lines. Another trick is to match up file descriptor -numbers and "follow" what happens to an open file until it is closed. +numbers and "follow" what happens to an open file until it is closed.
Beyond this you will have to use your initiative. To give you an idea of what you are looking for here is a piece of strace output that shows that /dev/null is not world writeable, which causes printing to fail with Samba:
-[pid 28268] open("/dev/null", O_RDWR) = -1 EACCES (Permission denied) -[pid 28268] open("/dev/null", O_WRONLY) = -1 EACCES (Permission denied) +[pid 28268] open("/dev/null", O_RDWR) = -1 EACCES (Permission denied) +[pid 28268] open("/dev/null", O_WRONLY) = -1 EACCES (Permission denied)
The process is trying to first open /dev/null read-write then read-only. Both fail. This means /dev/null has incorrect permissions. -
Table of Contents
Table of Contents
Table of Contents
Table of Contents
This document contains information to provide an NT workstation with login services, without the need for an NT server. It is the sgml version of http://mailhost.cb1.com/~lkcl/cifsntdomain.txt, controlled by Luke.
@@ -1178,7 +1178,7 @@ NT workstation, and enabling full debugging in NETLOGON. This is achieved by setting the following REG_SZ registry key to 0x1ffffff:
HKLM\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters
Incorrect direct editing of the registry can cause your machine to fail. Then again, so can incorrect implementation of this -protocol. See "Liability:" above.
+protocol. See "Liability:" above.
Bear in mind that each packet over-the-wire will have its origin in an API call. Therefore, there are likely to be structures, enumerations and defines that are usefully documented elsewhere. @@ -1191,12 +1191,12 @@ Failure to return this error code will make the workstation report that it is already a member of the domain.
the cryptographic side of the NetrServerPasswordSet command, which would allow the workstation to change its password. This password is used to generate the long-term session key. [It is possible to reject this -command, and keep the default workstation password].
cket Traces from Netmonitor (Service Pack 1 and above) |
ul Ashton and Luke Leighton's other "NT Domain" doc. |
FS documentation - cifs6.txt |
FS documentation - cifsrap2.txt |
Paul Ashton: loads of work with Net Monitor; understanding the NT authentication system; reference implementation of the NT domain support on which this document is originally based. |
Duncan Stansfield: low-level analysis of MSRPC Pipes. |
Linus Nordberg: producing c-code from Paul's crypto spec. |
Windows Sourcer development team |
-In the SMB Transact pipes, some "Structures", described here, appear to be +command, and keep the default workstation password].
cket Traces from Netmonitor (Service Pack 1 and above) |
ul Ashton and Luke Leighton's other "NT Domain" doc. |
FS documentation - cifs6.txt |
FS documentation - cifsrap2.txt |
Paul Ashton: loads of work with Net Monitor; understanding the NT authentication system; reference implementation of the NT domain support on which this document is originally based. |
Duncan Stansfield: low-level analysis of MSRPC Pipes. |
Linus Nordberg: producing c-code from Paul's crypto spec. |
Windows Sourcer development team |
+In the SMB Transact pipes, some "Structures", described here, appear to be 4-byte aligned with the SMB header, at their start. Exactly which -"Structures" need aligning is not precisely known or documented. +"Structures" need aligning is not precisely known or documented.
-In the UDP NTLOGON Mailslots, some "Structures", described here, appear to be +In the UDP NTLOGON Mailslots, some "Structures", described here, appear to be 2-byte aligned with the start of the mailslot, at their start.
Domain SID is of the format S-revision-version-auth1-auth2...authN. @@ -1219,15 +1219,15 @@ into or taken out of the SMB data stream. if the count is non-zero, then the pointer is also non-zero. immediately following the pointer is the count again, followed by an array of container sub-structures. the count appears a third time after the last sub-structure. -
command number in the msrpc packet header
0x00
0x02
0x0B
0x0C
UTIME is 32 bits, indicating time in seconds since 01jan1970. documented in cifs6.txt (section 3.5 page, page 30).
num of sub-authorities in domain SID
SID revision number
num of sub-authorities in domain SID
6 bytes for domain SID - Identifier Authority.
domain SID sub-authorities
Note: the domain SID is documented elsewhere. -
length of unicode string
max length of unicode string
4 - undocumented.
unicode string header
undocumented buffer pointer
length of unicode string
null-terminated string of unicode characters.
padding to get unicode string 4-byte aligned with the start of the SMB header.
max length of unicode string
0 - undocumented
length of unicode string
string of uncode characters
0x18 - length (in bytes) including the length field.
0 - root directory (pointer)
0 - object name (pointer)
0 - attributes (undocumented)
0 - security descriptior (pointer)
0 - security quality of service
5 - SID type
0 - undocumented
domain SID unicode string header
domain SID unicode string
Note: there is a conflict between the unicode string header and the unicode string itself as to which to use to indicate string length. this will need to be resolved.
Note: the SID type indicates, for example, an alias; a well-known group etc. this is documented somewhere.
5 - well-known SID. 1 - user SID (see ShowACLs)
5 - undocumented
domain RID
0 - domain index out of above reference domains
Note: logon server name starts with two '\' characters and is upper case.
Note: account name is the logon client name from the LSA Request Challenge, with a $ on the end of it, in upper case.
undocumented buffer pointer
logon server unicode string
account name unicode string
sec_chan - security channel type
logon client machine unicode string
Note: logon server name starts with two '\' characters and is upper case.
undocumented buffer pointer
logon server unicode string
undocumented buffer pointer
logon client machine unicode string
Note: whenever this structure appears in a request, you must take a copy of the client-calculated credentials received, because they will beused in subsequent credential checks. the presumed intention is to - maintain an authenticated request/response trail.
client and server names
???? padding, for 4-byte alignment with SMB header.
pointer to client credentials.
client-calculated credentials + client time
Note: whenever this structure appears in a request, you must take a copy of the client-calculated credentials received, because they will be used in subsequent credential checks. the presumed intention is to maintain an authenticated request/response trail.
logon account info
client-calculated credentials + client time
ptr_id_info_1
domain name unicode header
param control
logon ID
user name unicode header
workgroup name unicode header
arc4 LM OWF Password
arc4 NT OWF Password
domain name unicode string
user name unicode string
workstation name unicode string
Note: presumably, the return credentials is supposedly for the server to verify that the credential chain hasn't been compromised.
client identification/authentication info
pointer to return credentials.
return credentials - ignored.
logon level
switch value
+
command number in the msrpc packet header
0x00
0x02
0x0B
0x0C
UTIME is 32 bits, indicating time in seconds since 01jan1970. documented in cifs6.txt (section 3.5 page, page 30).
num of sub-authorities in domain SID
SID revision number
num of sub-authorities in domain SID
6 bytes for domain SID - Identifier Authority.
domain SID sub-authorities
Note: the domain SID is documented elsewhere. +
length of unicode string
max length of unicode string
4 - undocumented.
unicode string header
undocumented buffer pointer
length of unicode string
null-terminated string of unicode characters.
padding to get unicode string 4-byte aligned with the start of the SMB header.
max length of unicode string
0 - undocumented
length of unicode string
string of uncode characters
0x18 - length (in bytes) including the length field.
0 - root directory (pointer)
0 - object name (pointer)
0 - attributes (undocumented)
0 - security descriptior (pointer)
0 - security quality of service
5 - SID type
0 - undocumented
domain SID unicode string header
domain SID unicode string
Note: there is a conflict between the unicode string header and the unicode string itself as to which to use to indicate string length. this will need to be resolved.
Note: the SID type indicates, for example, an alias; a well-known group etc. this is documented somewhere.
5 - well-known SID. 1 - user SID (see ShowACLs)
5 - undocumented
domain RID
0 - domain index out of above reference domains
Note: logon server name starts with two '\' characters and is upper case.
Note: account name is the logon client name from the LSA Request Challenge, with a $ on the end of it, in upper case.
undocumented buffer pointer
logon server unicode string
account name unicode string
sec_chan - security channel type
logon client machine unicode string
Note: logon server name starts with two '\' characters and is upper case.
undocumented buffer pointer
logon server unicode string
undocumented buffer pointer
logon client machine unicode string
Note: whenever this structure appears in a request, you must take a copy of the client-calculated credentials received, because they will beused in subsequent credential checks. the presumed intention is to + maintain an authenticated request/response trail.
client and server names
???? padding, for 4-byte alignment with SMB header.
pointer to client credentials.
client-calculated credentials + client time
Note: whenever this structure appears in a request, you must take a copy of the client-calculated credentials received, because they will be used in subsequent credential checks. the presumed intention is to maintain an authenticated request/response trail.
logon account info
client-calculated credentials + client time
ptr_id_info_1
domain name unicode header
param control
logon ID
user name unicode header
workgroup name unicode header
arc4 LM OWF Password
arc4 NT OWF Password
domain name unicode string
user name unicode string
workstation name unicode string
Note: presumably, the return credentials is supposedly for the server to verify that the credential chain hasn't been compromised.
client identification/authentication info
pointer to return credentials.
return credentials - ignored.
logon level
switch value
switch (switch_value) case 1: { ID_INFO_1 id_info_1; } -
undocumented buffer pointer.
num referenced domains?
undocumented domain name buffer pointer.
32 - max number of entries
4 - num referenced domains?
domain name unicode string header
referenced domain unicode string headers
domain name unicode string
referenced domain SIDs
??? padding to get 4-byte alignment with start of SMB header
domain name string length * 2
domain name string length * 2
undocumented domain name string buffer pointer
undocumented domain SID string buffer pointer
domain name (unicode string)
domain SID
Note: it would be nice to know what the 16 byte user session key is for.
logon time
logoff time
kickoff time
password last set time
password can change time
password must change time
username unicode string header
user's full name unicode string header
logon script unicode string header
profile path unicode string header
home directory unicode string header
home directory drive unicode string header
logon count
bad password count
User ID
Group ID
num groups
undocumented buffer pointer to groups.
user flags
user session key
logon server unicode string header
logon domain unicode string header
undocumented logon domain id pointer
40 undocumented padding bytes. future expansion?
0 - num_other_sids?
NULL - undocumented pointer to other domain SIDs.
username unicode string
user's full name unicode string
logon script unicode string
profile path unicode string
home directory unicode string
home directory drive unicode string
num groups
group info
logon server unicode string
logon domain unicode string
domain SID
other domain SIDs?
Note: see cifsrap2.txt section5, page 10.
0 for shi1_type indicates a Disk. |
1 for shi1_type indicates a Print Queue. |
2 for shi1_type indicates a Device. |
3 for shi1_type indicates an IPC pipe. |
0x8000 0000 (top bit set in shi1_type) indicates a hidden share. |
shi1_netname - pointer to net name
shi1_type - type of share. 0 - undocumented.
shi1_remark - pointer to comment.
shi1_netname - unicode string of net name
shi1_remark - unicode string of comment.
share container with 0 entries:
0 - EntriesRead
0 - Buffer
share container with > 0 entries:
EntriesRead
non-zero - Buffer
EntriesRead
share entry pointers
share entry strings
padding to get unicode string 4-byte aligned with start of the SMB header.
EntriesRead
0 - padding
Note: see cifs6.txt section 6.4 - the fields described therein will be of assistance here. for example, the type listed below is the same as fServerType, which is described in 6.4.1.
0x00000001 All workstations
0x00000002 All servers
0x00000004 Any server running with SQL server
0x00000008 Primary domain controller
0x00000010 Backup domain controller
0x00000020 Server running the timesource service
0x00000040 Apple File Protocol servers
0x00000080 Novell servers
0x00000100 Domain Member
0x00000200 Server sharing print queue
0x00000400 Server running dialin service.
0x00000800 Xenix server
0x00001000 NT server
0x00002000 Server running Windows for
0x00008000 Windows NT non DC server
0x00010000 Server that can run the browser service
0x00020000 Backup browser server
0x00040000 Master browser server
0x00080000 Domain Master Browser server
0x40000000 Enumerate only entries marked "local"
0x80000000 Enumerate Domains. The pszServer and pszDomain parameters must be NULL.
500 - platform_id
pointer to name
5 - major version
4 - minor version
type (SV_TYPE_... bit field)
pointer to comment
sv101_name - unicode string of server name
sv_101_comment - unicode string of server comment.
padding to get unicode string 4-byte aligned with start of the SMB header.
For details on the SMB Transact Named Pipe, see cifs6.txt
undocumented buffer pointer.
num referenced domains?
undocumented domain name buffer pointer.
32 - max number of entries
4 - num referenced domains?
domain name unicode string header
referenced domain unicode string headers
domain name unicode string
referenced domain SIDs
??? padding to get 4-byte alignment with start of SMB header
domain name string length * 2
domain name string length * 2
undocumented domain name string buffer pointer
undocumented domain SID string buffer pointer
domain name (unicode string)
domain SID
Note: it would be nice to know what the 16 byte user session key is for.
logon time
logoff time
kickoff time
password last set time
password can change time
password must change time
username unicode string header
user's full name unicode string header
logon script unicode string header
profile path unicode string header
home directory unicode string header
home directory drive unicode string header
logon count
bad password count
User ID
Group ID
num groups
undocumented buffer pointer to groups.
user flags
user session key
logon server unicode string header
logon domain unicode string header
undocumented logon domain id pointer
40 undocumented padding bytes. future expansion?
0 - num_other_sids?
NULL - undocumented pointer to other domain SIDs.
username unicode string
user's full name unicode string
logon script unicode string
profile path unicode string
home directory unicode string
home directory drive unicode string
num groups
group info
logon server unicode string
logon domain unicode string
domain SID
other domain SIDs?
Note: see cifsrap2.txt section5, page 10.
0 for shi1_type indicates a Disk. |
1 for shi1_type indicates a Print Queue. |
2 for shi1_type indicates a Device. |
3 for shi1_type indicates an IPC pipe. |
0x8000 0000 (top bit set in shi1_type) indicates a hidden share. |
shi1_netname - pointer to net name
shi1_type - type of share. 0 - undocumented.
shi1_remark - pointer to comment.
shi1_netname - unicode string of net name
shi1_remark - unicode string of comment.
share container with 0 entries:
0 - EntriesRead
0 - Buffer
share container with > 0 entries:
EntriesRead
non-zero - Buffer
EntriesRead
share entry pointers
share entry strings
padding to get unicode string 4-byte aligned with start of the SMB header.
EntriesRead
0 - padding
Note: see cifs6.txt section 6.4 - the fields described therein will be of assistance here. for example, the type listed below is the same as fServerType, which is described in 6.4.1.
0x00000001 All workstations
0x00000002 All servers
0x00000004 Any server running with SQL server
0x00000008 Primary domain controller
0x00000010 Backup domain controller
0x00000020 Server running the timesource service
0x00000040 Apple File Protocol servers
0x00000080 Novell servers
0x00000100 Domain Member
0x00000200 Server sharing print queue
0x00000400 Server running dialin service.
0x00000800 Xenix server
0x00001000 NT server
0x00002000 Server running Windows for
0x00008000 Windows NT non DC server
0x00010000 Server that can run the browser service
0x00020000 Backup browser server
0x00040000 Master browser server
0x00080000 Domain Master Browser server
0x40000000 Enumerate only entries marked "local"
0x80000000 Enumerate Domains. The pszServer and pszDomain parameters must be NULL.
500 - platform_id
pointer to name
5 - major version
4 - minor version
type (SV_TYPE_... bit field)
pointer to comment
sv101_name - unicode string of server name
sv_101_comment - unicode string of server comment.
padding to get unicode string 4-byte aligned with start of the SMB header.
For details on the SMB Transact Named Pipe, see cifs6.txt
The MSRPC is conducted over an SMB Transact Pipe with a name of \PIPE\. You must first obtain a 16 bit file handle, by sending a SMBopenX with the pipe name \PIPE\srvsvc for @@ -1266,21 +1266,21 @@ To be resolved: lkcl/01nov97 there appear to be two additional bytes after the null-terminated \PIPE\ name for the RPC pipe. Values seen so far are listed below:
initial SMBopenX request: RPC API command 0x26 params: - "\\PIPE\\lsarpc" 0x65 0x63; 0x72 0x70; 0x44 0x65; - "\\PIPE\\srvsvc" 0x73 0x76; 0x4E 0x00; 0x5C 0x43; -
[section to be rewritten, following receipt of work by Duncan Stansfield]
Interesting note: if you set packed data representation to 0x0100 0000 -then all 4-byte and 2-byte word ordering is turned around!
The start of each of the NTLSA and NETLOGON named pipes begins with:
offset: 00
Variable type: UINT8
Variable data: 5 - RPC major version
offset: 01
Variable type: UINT8
Variable data: 0 - RPC minor version
offset: 02
Variable type: UINT8
Variable data: 2 - RPC response packet
offset: 03
Variable type: UINT8
Variable data: 3 - (FirstFrag bit-wise or with LastFrag)
offset: 04
Variable type: UINT32
Variable data: 0x1000 0000 - packed data representation
offset: 08
Variable type: UINT16
Variable data: fragment length - data size (bytes) inc header and tail.
offset: 0A
Variable type: UINT16
Variable data: 0 - authentication length
offset: 0C
Variable type: UINT32
Variable data: call identifier. matches 12th UINT32 of incoming RPC data.
offset: 10
Variable type: UINT32
Variable data: allocation hint - data size (bytes) minus header and tail.
offset: 14
Variable type: UINT16
Variable data: 0 - presentation context identifier
offset: 16
Variable type: UINT8
Variable data: 0 - cancel count
offset: 17
Variable type: UINT8
Variable data: in replies: 0 - reserved; in requests: opnum - see #defines.
offset: 18
Variable type: ......
Variable data: start of data (goes on for allocation_hint bytes)
reply same as request (0x05)
reply same as request (0x00)
one of the MSRPC_Type enums
reply same as request (0x00 for Bind, 0x03 for Request)
reply same as request (0x00000010)
the length of the data section of the SMB trans packet
call identifier. (e.g. 0x00149594)
the remainder of the packet depending on the "type"
the interfaces are numbered. as yet I haven't seen more than one interface used on the same pipe name srvsvc
+ "\\PIPE\\lsarpc" 0x65 0x63; 0x72 0x70; 0x44 0x65; + "\\PIPE\\srvsvc" 0x73 0x76; 0x4E 0x00; 0x5C 0x43; +
[section to be rewritten, following receipt of work by Duncan Stansfield]
Interesting note: if you set packed data representation to 0x0100 0000 +then all 4-byte and 2-byte word ordering is turned around!
The start of each of the NTLSA and NETLOGON named pipes begins with:
offset: 00
Variable type: UINT8
Variable data: 5 - RPC major version
offset: 01
Variable type: UINT8
Variable data: 0 - RPC minor version
offset: 02
Variable type: UINT8
Variable data: 2 - RPC response packet
offset: 03
Variable type: UINT8
Variable data: 3 - (FirstFrag bit-wise or with LastFrag)
offset: 04
Variable type: UINT32
Variable data: 0x1000 0000 - packed data representation
offset: 08
Variable type: UINT16
Variable data: fragment length - data size (bytes) inc header and tail.
offset: 0A
Variable type: UINT16
Variable data: 0 - authentication length
offset: 0C
Variable type: UINT32
Variable data: call identifier. matches 12th UINT32 of incoming RPC data.
offset: 10
Variable type: UINT32
Variable data: allocation hint - data size (bytes) minus header and tail.
offset: 14
Variable type: UINT16
Variable data: 0 - presentation context identifier
offset: 16
Variable type: UINT8
Variable data: 0 - cancel count
offset: 17
Variable type: UINT8
Variable data: in replies: 0 - reserved; in requests: opnum - see #defines.
offset: 18
Variable type: ......
Variable data: start of data (goes on for allocation_hint bytes)
reply same as request (0x05)
reply same as request (0x00)
one of the MSRPC_Type enums
reply same as request (0x00 for Bind, 0x03 for Request)
reply same as request (0x00000010)
the length of the data section of the SMB trans packet
call identifier. (e.g. 0x00149594)
the remainder of the packet depending on the "type"
the interfaces are numbered. as yet I haven't seen more than one interface used on the same pipe name srvsvc
abstract (0x4B324FC8, 0x01D31670, 0x475A7812, 0x88E16EBF, 0x00000003) transfer (0x8A885D04, 0x11C91CEB, 0x0008E89F, 0x6048102B, 0x00000002) -
the remainder of the packet after the header if "type" was Bind in the response header, "type" should be BindAck
maximum transmission fragment size (0x1630)
max receive fragment size (0x1630)
associated group id (0x0)
the number of elements (0x1)
presentation context identifier (0x0)
the number of syntaxes (has always been 1?)(0x1)
4-byte alignment padding, against SMB header
num and vers. of interface client is using
num and vers. of interface to use for replies
length of the string including null terminator
the string above in single byte, null terminated form
the response to place after the header in the reply packet
same as request
same as request
zero
the address string, as described earlier
4-byte alignment padding, against SMB header
the number of results (0x01)
4-byte alignment padding, against SMB header
result (0x00 = accept)
reason (0x00 = no reason specified)
the transfer syntax from the request
the remainder of the packet after the header for every other other request
the size of the stub data in bytes
presentation context identifier (0x0)
operation number (0x15)
a packet dependent on the pipe name (probably the interface) and the op number)
The end of each of the NTLSA and NETLOGON named pipes ends with:
end of data
return code
the remainder of the packet after the header if "type" was Bind in the response header, "type" should be BindAck
maximum transmission fragment size (0x1630)
max receive fragment size (0x1630)
associated group id (0x0)
the number of elements (0x1)
presentation context identifier (0x0)
the number of syntaxes (has always been 1?)(0x1)
4-byte alignment padding, against SMB header
num and vers. of interface client is using
num and vers. of interface to use for replies
length of the string including null terminator
the string above in single byte, null terminated form
the response to place after the header in the reply packet
same as request
same as request
zero
the address string, as described earlier
4-byte alignment padding, against SMB header
the number of results (0x01)
4-byte alignment padding, against SMB header
result (0x00 = accept)
reason (0x00 = no reason specified)
the transfer syntax from the request
the remainder of the packet after the header for every other other request
the size of the stub data in bytes
presentation context identifier (0x0)
operation number (0x15)
a packet dependent on the pipe name (probably the interface) and the op number)
The end of each of the NTLSA and NETLOGON named pipes ends with:
end of data
return code
RPC Binds are the process of associating an RPC pipe (e.g \PIPE\lsarpc) -with a "transfer syntax" (see RPC_Iface structure). The purpose for doing +with a "transfer syntax" (see RPC_Iface structure). The purpose for doing this is unknown.
Note: The RPC_ResBind SMB Transact request is sent with two uint16 setup parameters. The first is 0x0026; the second is the file handle returned by the SMBopenX Transact response.
Note: The RPC_ResBind members maxtsize, maxrsize and assocgid are the same in the response as the same members in the RPC_ReqBind. The RPC_ResBind member transfersyntax is the same in the response as the
Note: The RPC_ResBind response member secondaddr contains the name of what is presumed to be the service behind the RPC pipe. The - mapping identified so far is:
RPC_ResBind response:
"\\PIPE\\ntsvcs"
"\\PIPE\\lsass"
"\\PIPE\\lsass"
"\\PIPE\\wksvcs"
"\\PIPE\\NETLOGON"
Note: The RPC_Packet fraglength member in both the Bind Request and Bind Acknowledgment must contain the length of the entire RPC data, including the RPC_Packet header.
Request:
RPC_Packet |
RPC_ReqBind |
Response:
RPC_Packet |
RPC_ResBind |
The sequence of actions taken on this pipe are:
Establish a connection to the IPC$ share (SMBtconX). use encrypted passwords. |
Open an RPC Pipe with the name "\\PIPE\\lsarpc". Store the file handle. |
Using the file handle, send a Set Named Pipe Handle state to 0x4300. |
Send an LSA Open Policy request. Store the Policy Handle. |
Using the Policy Handle, send LSA Query Info Policy requests, etc. |
Using the Policy Handle, send an LSA Close. |
Close the IPC$ share. |
Defines for this pipe, identifying the query are:
0x2c
0x07
0x0d
0xff
0xfe
0xfd
0x00
Note: The policy handle can be anything you like.
buffer pointer
server name - unicode string starting with two '\'s
object attributes
1 - desired access
Note: The info class in response must be the same as that in the request.
undocumented buffer pointer
info class (same as info class in request).
+ mapping identified so far is:
- initial SMBopenX request:
RPC_ResBind response:
- "\\PIPE\\srvsvc"
"\\PIPE\\ntsvcs"
- "\\PIPE\\samr"
"\\PIPE\\lsass"
- "\\PIPE\\lsarpc"
"\\PIPE\\lsass"
- "\\PIPE\\wkssvc"
"\\PIPE\\wksvcs"
- "\\PIPE\\NETLOGON"
"\\PIPE\\NETLOGON"
Note: The RPC_Packet fraglength member in both the Bind Request and Bind Acknowledgment must contain the length of the entire RPC data, including the RPC_Packet header.
Request:
RPC_Packet |
RPC_ReqBind |
Response:
RPC_Packet |
RPC_ResBind |
The sequence of actions taken on this pipe are:
Establish a connection to the IPC$ share (SMBtconX). use encrypted passwords. |
Open an RPC Pipe with the name "\\PIPE\\lsarpc". Store the file handle. |
Using the file handle, send a Set Named Pipe Handle state to 0x4300. |
Send an LSA Open Policy request. Store the Policy Handle. |
Using the Policy Handle, send LSA Query Info Policy requests, etc. |
Using the Policy Handle, send an LSA Close. |
Close the IPC$ share. |
Defines for this pipe, identifying the query are:
0x2c
0x07
0x0d
0xff
0xfe
0xfd
0x00
Note: The policy handle can be anything you like.
buffer pointer
server name - unicode string starting with two '\'s
object attributes
1 - desired access
Note: The info class in response must be the same as that in the request.
Note: num_entries in response must be same as num_entries in request.
LSA policy handle
num_entries
undocumented domain SID buffer pointer
undocumented domain name buffer pointer
DOM_SID[num_entries] domain SIDs to be looked up.
completely undocumented 16 bytes.
Note: num_entries in response must be same as num_entries in request.
LSA policy handle
num_entries
num_entries
undocumented domain SID buffer pointer
undocumented domain name buffer pointer
names to be looked up.
undocumented bytes - falsely translated SID structure?
The sequence of actions taken on this pipe are:
tablish a connection to the IPC$ share (SMBtconX). use encrypted passwords. |
en an RPC Pipe with the name "\\PIPE\\NETLOGON". Store the file handle. |
ing the file handle, send a Set Named Pipe Handle state to 0x4300. |
eate Client Challenge. Send LSA Request Challenge. Store Server Challenge. |
lculate Session Key. Send an LSA Auth 2 Challenge. Store Auth2 Challenge. |
lc/Verify Client Creds. Send LSA Srv PW Set. Calc/Verify Server Creds. |
lc/Verify Client Creds. Send LSA SAM Logon . Calc/Verify Server Creds. |
lc/Verify Client Creds. Send LSA SAM Logoff. Calc/Verify Server Creds. |
ose the IPC$ share. |
Defines for this pipe, identifying the query are
0x04
0x06
0x02
0x03
0x0f
0x0e
Note: logon server name starts with two '\' characters and is upper case.
Note: logon client is the machine, not the user.
Note: the initial LanManager password hash, against which the challenge is issued, is the machine name itself (lower case). there will becalls issued (LSA Server Password Set) which will change this, later. refusing these calls allows you to always deal with the same password (i.e the LM# of the machine name in lower case).
undocumented buffer pointer
logon server unicode string
logon client unicode string
client challenge
Note: in between request and response, calculate the client credentials, and check them against the client-calculated credentials (this process uses the previously received client credentials).
Note: neg_flags in the response is the same as that in the request.
Note: you must take a copy of the client-calculated credentials received here, because they will be used in subsequent authentication packets.
client identification info
client-calculated credentials
padding to 4-byte align with start of SMB header.
neg_flags - negotiated flags (usual value is 0x0000 01ff)
Note: the new password is suspected to be a DES encryption using the old password to generate the key.
Note: in between request and response, calculate the client credentials, and check them against the client-calculated credentials (this process uses the previously received client credentials).
Note: the server credentials are constructed from the client-calculated credentials and the client time + 1 second.
Note: you must take a copy of the client-calculated credentials received here, because they will be used in subsequent authentication packets.
Note: num_entries in response must be same as num_entries in request.
LSA policy handle
num_entries
undocumented domain SID buffer pointer
undocumented domain name buffer pointer
DOM_SID[num_entries] domain SIDs to be looked up.
completely undocumented 16 bytes.
Note: num_entries in response must be same as num_entries in request.
LSA policy handle
num_entries
num_entries
undocumented domain SID buffer pointer
undocumented domain name buffer pointer
names to be looked up.
undocumented bytes - falsely translated SID structure?
The sequence of actions taken on this pipe are:
tablish a connection to the IPC$ share (SMBtconX). use encrypted passwords. |
en an RPC Pipe with the name "\\PIPE\\NETLOGON". Store the file handle. |
ing the file handle, send a Set Named Pipe Handle state to 0x4300. |
eate Client Challenge. Send LSA Request Challenge. Store Server Challenge. |
lculate Session Key. Send an LSA Auth 2 Challenge. Store Auth2 Challenge. |
lc/Verify Client Creds. Send LSA Srv PW Set. Calc/Verify Server Creds. |
lc/Verify Client Creds. Send LSA SAM Logon . Calc/Verify Server Creds. |
lc/Verify Client Creds. Send LSA SAM Logoff. Calc/Verify Server Creds. |
ose the IPC$ share. |
Defines for this pipe, identifying the query are
0x04
0x06
0x02
0x03
0x0f
0x0e
Note: logon server name starts with two '\' characters and is upper case.
Note: logon client is the machine, not the user.
Note: the initial LanManager password hash, against which the challenge is issued, is the machine name itself (lower case). there will becalls issued (LSA Server Password Set) which will change this, later. refusing these calls allows you to always deal with the same password (i.e the LM# of the machine name in lower case).
undocumented buffer pointer
logon server unicode string
logon client unicode string
client challenge
Note: in between request and response, calculate the client credentials, and check them against the client-calculated credentials (this process uses the previously received client credentials).
Note: neg_flags in the response is the same as that in the request.
Note: you must take a copy of the client-calculated credentials received here, because they will be used in subsequent authentication packets.
client identification info
client-calculated credentials
padding to 4-byte align with start of SMB header.
neg_flags - negotiated flags (usual value is 0x0000 01ff)
Note: the new password is suspected to be a DES encryption using the old password to generate the key.
Note: in between request and response, calculate the client credentials, and check them against the client-calculated credentials (this process uses the previously received client credentials).
Note: the server credentials are constructed from the client-calculated credentials and the client time + 1 second.
Note: you must take a copy of the client-calculated credentials received here, because they will be used in subsequent authentication packets.
Note: valid_user is True iff the username and password hash are valid for the requested domain. -
undocumented buffer pointer
server credentials. server time stamp appears to be ignored.
+
Note: presumably, the SAM_INFO structure is validated, and a (currently undocumented) error code returned if the Logoff is invalid. -
Note: mailslots will contain a response mailslot, to which the response should be sent. the target NetBIOS name is REQUEST_NAME<20>, where REQUEST_NAME is the name of the machine that sent the request. -
Note: NTversion, LMNTtoken, LM20token in response are the same as those given in the request.
0x0007 - Query for PDC
machine name
response mailslot
padding to 2-byte align with start of mailslot.
machine name
NTversion
LMNTtoken
LM20token
0x000A - Respose to Query for PDC
machine name (in uppercase)
padding to 2-byte align with start of mailslot.
machine name
domain name
NTversion (same as received in request)
LMNTtoken (same as received in request)
LM20token (same as received in request)
Note: machine name in response is preceded by two '\' characters.
Note: NTversion, LMNTtoken, LM20token in response are the same as those given in the request.
Note: user name in the response is presumably the same as that in the request.
0x0012 - SAM Logon
request count
machine name
user name
response mailslot
alloweable account
domain SID size
domain SID, of sid_size bytes.
???? padding to 4? 2? -byte align with start of mailslot.
NTversion
LMNTtoken
LM20token
Defines for this pipe, identifying the query are:
0x0f
0x15
Note: share level and switch value in the response are presumably the same as those in the request.
Note: cifsrap2.txt (section 5) may be of limited assistance here.
pointer (to server name?)
server name
padding to get unicode string 4-byte aligned with the start of the SMB header.
share level
switch value
pointer to SHARE_INFO_1_CTR
share info with 0 entries
preferred maximum length (0xffff ffff)
Intel byte ordered addition of corresponding 4 byte words in arrays A1 and A2
DES ECB encryption of 8 byte data D using 7 byte key K
Lan man hash
NT hash
md4(machine_password) == md4(lsadump $machine.acc) == +
Note: NTversion, LMNTtoken, LM20token in response are the same as those given in the request.
0x0007 - Query for PDC
machine name
response mailslot
padding to 2-byte align with start of mailslot.
machine name
NTversion
LMNTtoken
LM20token
0x000A - Respose to Query for PDC
machine name (in uppercase)
padding to 2-byte align with start of mailslot.
machine name
domain name
NTversion (same as received in request)
LMNTtoken (same as received in request)
LM20token (same as received in request)
Note: machine name in response is preceded by two '\' characters.
Note: NTversion, LMNTtoken, LM20token in response are the same as those given in the request.
Note: user name in the response is presumably the same as that in the request.
0x0012 - SAM Logon
request count
machine name
user name
response mailslot
alloweable account
domain SID size
domain SID, of sid_size bytes.
???? padding to 4? 2? -byte align with start of mailslot.
NTversion
LMNTtoken
LM20token
Defines for this pipe, identifying the query are:
0x0f
0x15
Note: share level and switch value in the response are presumably the same as those in the request.
Note: cifsrap2.txt (section 5) may be of limited assistance here.
pointer (to server name?)
server name
padding to get unicode string 4-byte aligned with the start of the SMB header.
share level
switch value
pointer to SHARE_INFO_1_CTR
share info with 0 entries
preferred maximum length (0xffff ffff)
Intel byte ordered addition of corresponding 4 byte words in arrays A1 and A2
DES ECB encryption of 8 byte data D using 7 byte key K
Lan man hash
NT hash
md4(machine_password) == md4(lsadump $machine.acc) == pwdump(machine$) (initially) == md4(lmowf(unicode(machine))) -
ARC4 encryption of data D of length Ld with key K of length Lk
subset of v from bytes m to n, optionally padded with zeroes to length l
E(K[7..7,7],E(K[0..6],D)) computes a credential
4 byte current time
8 byte client and server challenges Rc,Rs: 8 byte client and server credentials
+
ARC4 encryption of data D of length Ld with key K of length Lk
subset of v from bytes m to n, optionally padded with zeroes to length l
E(K[7..7,7],E(K[0..6],D)) computes a credential
4 byte current time
8 byte client and server challenges Rc,Rs: 8 byte client and server credentials
C->S ReqChal,Cc S->C Cs
@@ -1358,7 +1358,7 @@ S: Ts = Time() S->C Cred(Ks,Cred(Ks,Rc+Tc+1)),userinfo(logon script,UID,SIDs,etc) C: assert(Rs == Cred(Ks,Cred(Rc+Tc+1)) C: Rc = Cred(Ks,Rc+Tc+1) -
On first joining the domain the session key could be computed by anyone listening in on the network as the machine password has a well known value. Until the machine is rebooted it will use this session @@ -1379,30 +1379,30 @@ returned by the server. The password OWFs should NOT be sent over the network reversibly encrypted. They should be sent using ARC4(Ks,md4(owf)) with the server computing the same function using the owf values in the SAM. -
SIDs and RIDs are well documented elsewhere.
A SID is an NT Security ID (see DOM_SID structure). They are of the form:
revision-NN-SubAuth1-SubAuth2-SubAuth3... |
revision-0xNNNNNNNNNNNN-SubAuth1-SubAuth2-SubAuth3... |
currently, the SID revision is 1. The Sub-Authorities are known as Relative IDs (RIDs). -
S-1-0-0
S-1-1-0
S-1-2-0
S-1-3-0
S-1-3-1
S-1-3-2
S-1-3-3
S-1-4
+
S-1-0-0
S-1-1-0
S-1-2-0
S-1-3-0
S-1-3-1
S-1-3-2
S-1-3-3
S-1-4
A RID is a sub-authority value, as part of either a SID, or in the case of Group RIDs, part of the DOM_GID structure, in the USER_INFO_1 structure, in the LSA SAM Logon response. -
Groupname: DOMAIN_USER_RID_ADMIN
????: 0x0000
RID: 01F4
Groupname: DOMAIN_USER_RID_GUEST
????: 0x0000
RID: 01F5
Groupname: DOMAIN_GROUP_RID_ADMINS
????: 0x0000
RID: 0200
Groupname: DOMAIN_GROUP_RID_USERS
????: 0x0000
RID: 0201
Groupname: DOMAIN_GROUP_RID_GUESTS
????: 0x0000
RID: 0202
Groupname: DOMAIN_ALIAS_RID_ADMINS
????: 0x0000
RID: 0220
Groupname: DOMAIN_ALIAS_RID_USERS
????: 0x0000
RID: 0221
Groupname: DOMAIN_ALIAS_RID_GUESTS
????: 0x0000
RID: 0222
Groupname: DOMAIN_ALIAS_RID_POWER_USERS
????: 0x0000
RID: 0223
Groupname: DOMAIN_ALIAS_RID_ACCOUNT_OPS
????: 0x0000
RID: 0224
Groupname: DOMAIN_ALIAS_RID_SYSTEM_OPS
????: 0x0000
RID: 0225
Groupname: DOMAIN_ALIAS_RID_PRINT_OPS
????: 0x0000
RID: 0226
Groupname: DOMAIN_ALIAS_RID_BACKUP_OPS
????: 0x0000
RID: 0227
Groupname: DOMAIN_ALIAS_RID_REPLICATOR
????: 0x0000
RID: 0228
Table of Contents
Groupname: DOMAIN_USER_RID_ADMIN
????: 0x0000
RID: 01F4
Groupname: DOMAIN_USER_RID_GUEST
????: 0x0000
RID: 01F5
Groupname: DOMAIN_GROUP_RID_ADMINS
????: 0x0000
RID: 0200
Groupname: DOMAIN_GROUP_RID_USERS
????: 0x0000
RID: 0201
Groupname: DOMAIN_GROUP_RID_GUESTS
????: 0x0000
RID: 0202
Groupname: DOMAIN_ALIAS_RID_ADMINS
????: 0x0000
RID: 0220
Groupname: DOMAIN_ALIAS_RID_USERS
????: 0x0000
RID: 0221
Groupname: DOMAIN_ALIAS_RID_GUESTS
????: 0x0000
RID: 0222
Groupname: DOMAIN_ALIAS_RID_POWER_USERS
????: 0x0000
RID: 0223
Groupname: DOMAIN_ALIAS_RID_ACCOUNT_OPS
????: 0x0000
RID: 0224
Groupname: DOMAIN_ALIAS_RID_SYSTEM_OPS
????: 0x0000
RID: 0225
Groupname: DOMAIN_ALIAS_RID_PRINT_OPS
????: 0x0000
RID: 0226
Groupname: DOMAIN_ALIAS_RID_BACKUP_OPS
????: 0x0000
RID: 0227
Groupname: DOMAIN_ALIAS_RID_REPLICATOR
????: 0x0000
RID: 0228
Table of Contents
The purpose of this document is to provide some insight into Samba's printing functionality and also to describe the semantics of certain features of Windows client printing. -
Samba uses a table of function pointers to seven functions. The @@ -1413,10 +1413,10 @@ Currently there are only two printing back end implementations defined.
a generic set of functions for working with standard UNIX printing subsystems
a set of CUPS specific functions (this is only enabled if - the CUPS libraries were located at compile time).
-Samba provides periodic caching of the output from the "lpq command" +Samba provides periodic caching of the output from the "lpq command" for performance reasons. This cache time is configurable in seconds. Obviously the longer the cache time the less often smbd will be required to exec a copy of lpq. However, the accuracy of the print @@ -1436,7 +1436,7 @@ There are two ways in which a a print job can be entered into a print queue's TDB. The first is to submit the job from a Windows client which will insert the job information directly into the TDB. The second method is to have the print job picked up by executing the -"lpq command". +"lpq command".
/* included from printing.h */ struct printjob { @@ -1457,9 +1457,9 @@ struct printjob { };
The current manifestation of the printjob structure contains a field -for the UNIX job id returned from the "lpq command" and a Windows job +for the UNIX job id returned from the "lpq command" and a Windows job ID (32-bit bounded by PRINT_MAX_JOBID). When a print job is returned -by the "lpq command" that does not match an existing job in the queue's +by the "lpq command" that does not match an existing job in the queue's TDB, a 32-bit job ID above the <*vance doesn't know what word is missing here*> is generating by adding UNIX_JOB_START to the id reported by lpq.
@@ -1474,7 +1474,7 @@ steps ( refer to print.c:print_queue_update() ): stored in LOCK/printer_name. If so, then do not update the TDB.
Lock the mutex entry in the TDB and store our own pid. Check that this succeeded, else fail.
Store the updated time stamp for the new cache - listing
Retrieve the queue listing via "lpq command"
+ listing
Retrieve the queue listing via "lpq command"
foreach job in the queue { if the job is a UNIX job, create a new entry; @@ -1489,7 +1489,7 @@ steps ( refer to print.c:print_queue_update() ): }
Delete any jobs in the TDB that are not in the in the lpq listing
Store the print queue status in the TDB
update the cache time stamp again
Note that it is the contents of this TDB that is returned to Windows -clients and not the actual listing from the "lpq command". +clients and not the actual listing from the "lpq command".
The NT_DEVICEMODE stored as part of the printjob structure is used to store a pointer to a non-default DeviceMode associated with the print @@ -1502,11 +1502,11 @@ and the job has the printer's device mode associated with it by default. Only non-default Device Mode are stored with print jobs in the print queue TDB. Otherwise, the Device Mode is obtained from the printer object when the client issues a GetJob(level == 2) request. -
When working with Windows NT+ clients, it is possible for a @@ -1604,13 +1604,13 @@ handle for notification. Samba currently uses the snum of the printer for this which can break if the list of services has been modified since the notification handle was registered.
The size is either (a) the string length in UNICODE for strings, (b) the size in bytes of the security descriptor, or (c) 0 for -data values.
Table of Contents
Table of Contents
The current Samba codebase possesses the capability to use groups of WINS servers that share a common namespace for NetBIOS name registration and resolution. The formal parameter syntax is
WINS_SERVER_PARAM = SERVER [ SEPARATOR SERVER_LIST ] - WINS_SERVER_PARAM = "wins server" + WINS_SERVER_PARAM = "wins server" SERVER = ADDR[:TAG] ADDR = ip_addr | fqdn TAG = string @@ -1623,7 +1623,7 @@ A simple example of a valid wins server setting is wins server = 192.168.1.2 192.168.1.3
In the event that no TAG is defined in for a SERVER in the list, smbd assigns a default -TAG of "*". A TAG is used to group servers of a shared NetBIOS namespace together. Upon +TAG of "*". A TAG is used to group servers of a shared NetBIOS namespace together. Upon startup, nmbd will attempt to register the netbios name value with one server in each tagged group.
@@ -1634,7 +1634,7 @@ interface names in the tags is only by convention and is not a technical require wins server = 192.168.1.2:eth0 192.168.1.3:eth0 192.168.2.2:eth1
Using this configuration, nmbd would attempt to register the server's NetBIOS name -with one WINS server in each group. Because the "eth0" group has two servers, the +with one WINS server in each group. Because the "eth0" group has two servers, the second server would only be used when a registration (or resolution) request to the first server in that group timed out.
@@ -1646,7 +1646,7 @@ If a timeout occurs when querying a specific WINS server, that server is marked prevent further timeouts and the next server in the WINS group is contacted. Once marked as dead, Samba will not attempt to contact that server for name registration/resolution queries for a period of 10 minutes. -
Table of Contents
Table of Contents
One of the biggest problems with passdb is it's implementation of 'security'. Access control is on a 'are you root at the moment' basis, and it has no concept of NT ACLs. Things like ldapsam had to add 'magic' 'are you root' checks.
We took this very seriously when we started work, and the new structure @@ -1706,7 +1706,7 @@ actual data store (like the LDAP server).
Finally, we have generic get_sec_desc() and set_sec_desc() routines to allow external ACL manipulation. These do lookups based on SID. -
One of the primary tenants of the 'new SAM' is that it would not attempt to deal with 'what unix id for that'. This would be left to the 'SMS' (Sid Mapping System') or SID farm, and probably administered via @@ -1716,7 +1716,7 @@ Accounts not preexisting in unix would be served up via winbind.
This is an *optional* part, and my preferred end-game. We have a fare way to go before things like winbind up to it however. -
One of the things that the 'new SAM' work has tried to face is both compatibility with existing code, and a closer alignment to the SAMR interface. I consider SAMR to be a 'primary customer' to the this work, @@ -1741,11 +1741,11 @@ have *really* changed. 'conflicting' updates: Currently we don't deal with this (in passdb or the new sam stuff), but the design is sufficiently flexible to 'deny' a second update. I don't foresee locking records however. -
This is where smbd, samtest and whatever end-user replacement we have for pdbedit sits. They use only the SAM interface, and do not get 'special knowledge' of what is below them. -
This level 'owns' the various handle structures, the get/set routines on those structures and provides the public interface. The application layer may initialize a 'context' to be passed to all interface routines, @@ -1756,7 +1756,7 @@ abstraction to the modules below, and arrange for their initial loading.
We could possibly add ACL checking at this layer, to avoid discrepancies in implementation modules. -
These do not communicate with the application directly, only by setting values in the handles, and receiving requests from the interface. These modules are responsible for translating values from the handle's @@ -1764,13 +1764,13 @@ modules are responsible for translating values from the handle's to 'know' things like it's own domain SID, domain name, and any other state attached to the SAM. Simpler modules may call back to some helper routine. -
In order for there to be a smooth transition, kai is writing a module that reads existing passdb backends, and translates them into SAM replies. (Also pulling data from the account policy DB etc). We also intend to write a module that does the reverse - gives the SAM a passdb interface. -
This is the first of the SAM modules to be committed to the tree - mainly because I needed to coordinate work with metze (who authored most of it). This module aims to use Samba's libads code to provide an @@ -1782,7 +1782,7 @@ the construction of an Samba AD DC.
We also intend to construct a Samba 2.2/3.0 compatible ldap module, again using libads code. -
The 'new SAM' development effort also concerned itself with getting a sane implementation of memory management. It was decided that we would be (as much as possible) talloc based, using an 'internal talloc @@ -1811,7 +1811,7 @@ NT_USER_TOKEN *access_token, uint32 access_desired, const DOM_SID NTSTATUS sam_enum_accounts(const SAM_CONTEXT *context, const NT_USER_TOKEN *access_token, const DOM_SID *domainsid, uint16 acct_ctrl, int32 *account_count, SAM_ACCOUNT_ENUM **accounts) -
Testing is vital in any piece of software, and Samba is certainly no exception. In designing this new subsystem, we have taken care to ensure it is easily tested, independent of outside protocols. @@ -1840,13 +1840,13 @@ Because the 'new SAM' is NT ACL based, there will be a command to specify an arbitrary NT ACL, but for now it uses 'system' by default.
Table of Contents
19 Apr 1999
Table of Contents
With the development of LanManager and Windows NT compatible password encryption for Samba, it is now able to validate user connections in exactly the same way as a LanManager or Windows NT server.
This document describes how the SMB password encryption algorithm works and what issues there are in choosing whether you want to use it. You should read it carefully, especially - the part about security and the "PROS and CONS" section.
LanManager encryption is somewhat similar to UNIX + the part about security and the "PROS and CONS" section.
LanManager encryption is somewhat similar to UNIX password encryption. The server uses a file containing a hashed value of a user's password. This is created by taking the user's plaintext password, capitalising it, and either @@ -1854,7 +1854,7 @@ specify an arbitrary NT ACL, but for now it uses 'system' by default. This 14 byte value is used as two 56 bit DES keys to encrypt a 'magic' eight byte value, forming a 16 byte value which is stored by the server and client. Let this value be known as - the "hashed password".
Windows NT encryption is a higher quality mechanism, + the "hashed password".
Windows NT encryption is a higher quality mechanism, consisting of doing an MD4 hash on a Unicode version of the user's password. This also produces a 16 byte hash value that is non-reversible.
When a client (LanManager, Windows for WorkGroups, Windows @@ -1863,11 +1863,11 @@ specify an arbitrary NT ACL, but for now it uses 'system' by default. protocol that the client and server will use. In the reply to this request the Samba server generates and appends an 8 byte, random value - this is stored in the Samba server after the reply is sent - and is known as the "challenge". The challenge is different for + and is known as the "challenge". The challenge is different for every client connection.
The client then uses the hashed password (16 byte values described above), appended with 5 null bytes, as three 56 bit DES keys, each of which is used to encrypt the challenge 8 byte - value, forming a 24 byte value known as the "response".
In the SMB call SMBsessionsetupX (when user level security + value, forming a 24 byte value known as the "response".
In the SMB call SMBsessionsetupX (when user level security is selected) or the call SMBtconX (when share level security is selected), the 24 byte response is returned by the client to the Samba server. For Windows NT protocol levels the above calculation @@ -1883,7 +1883,7 @@ specify an arbitrary NT ACL, but for now it uses 'system' by default. know the correct password and is denied access.
Note that the Samba server never knows or stores the cleartext of the user's password - just the 16 byte hashed values derived from it. Also note that the cleartext password or 16 byte hashed values - are never transmitted over the network - thus increasing security.
In order for Samba to participate in the above protocol + are never transmitted over the network - thus increasing security.
In order for Samba to participate in the above protocol it must be able to look up the 16 byte hashed values given a user name. Unfortunately, as the UNIX password value is also a one way hash function (ie. it is impossible to retrieve the cleartext of the user's @@ -1924,7 +1924,7 @@ username:uid:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: to 32 ascii hexadecimal digits (0-9, A-F). These are an ascii representation of the 16 byte hashed value of a user's password.
To set a user to have no password (not recommended), edit the file using vi, and replace the first 11 characters with the ascii text - "NO PASSWORD" (minus the quotes).
For example, to clear the password for user bob, his smbpasswd file + "NO PASSWORD" (minus the quotes).
For example, to clear the password for user bob, his smbpasswd file entry would look like :
bob:100:NO PASSWORDXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: [U ]:LCT-00000000:Bob's full name:/bobhome:/bobshell @@ -1940,10 +1940,10 @@ bob:100:NO PASSWORDXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: to enable this on your server.Note : This file should be protected very carefully. Anyone with access to this file can (with enough knowledge of the protocols) gain access to your SMB server. The file is thus more - sensitive than a normal unix /etc/passwd file.
Table of Contents
Table of Contents
The new modules system has the following advantages:
Transparent loading of static and shared modules (no need -for a subsystem to know about modules) |
Simple selection between shared and static modules at configure time |
"preload modules" option for increasing performance for stable modules |
No nasty #define stuff anymore |
All backends are available as plugin now (including pdb_ldap and pdb_tdb) |
+for a subsystem to know about modules)
Some subsystems in samba use different backends. These backends can be either statically linked in to samba or available as a plugin. A subsystem should have a function that allows a module to register itself. For example, @@ -1953,7 +1953,7 @@ NTSTATUS smb_register_passdb(int version, const char *name, pdb_init_function in
This function will be called by the initialisation function of the module to register itself. -
+
The modules system compiles a list of initialisation functions for the static modules of each subsystem. This is a define. For example, it is here currently (from include/config.h): @@ -1963,7 +1963,7 @@ it is here currently (from include/config.h):
These functions should be called before the subsystem is used. That should be done when the subsystem is initialised or first used. -
If a subsystem needs a certain backend, it should check if it has already been registered. If the backend hasn't been registered already, the subsystem should call smb_probe_module(char *subsystem, char *backend). @@ -1973,7 +1973,7 @@ is a slash, smb_probe_module() tries to load the module from the absolute path specified in 'backend'.
After smb_probe_module() has been executed, the subsystem should check again if the module has been registered. -
Each module has an initialisation function. For modules that are included with samba this name is 'subsystem_backend_init'. For external modules (that will never be built-in, but only available as a module) this name is always 'init_module'. (In the case of modules included with samba, the configure system will add a #define subsystem_backend_init() init_module()). The prototype for these functions is: @@ -1984,11 +1984,11 @@ registration functions. The function should return NT_STATUS_OK on success and NT_STATUS_UNSUCCESSFUL or a more useful nt error code on failure.
For example, pdb_ldap_init() contains:
NTSTATUS pdb_ldap_init(void) { -smb_register_passdb(PASSDB_INTERFACE_VERSION, "ldapsam", pdb_init_ldapsam); -smb_register_passdb(PASSDB_INTERFACE_VERSION, "ldapsam_nua", pdb_init_ldapsam_nua); +smb_register_passdb(PASSDB_INTERFACE_VERSION, "ldapsam", pdb_init_ldapsam); +smb_register_passdb(PASSDB_INTERFACE_VERSION, "ldapsam_nua", pdb_init_ldapsam_nua); return NT_STATUS_OK; } -
+
Some macros in configure.in generate the various defines and substs that are necessary for the system to work correct. All modules that should be built by default have to be added to the variable 'default_modules'. @@ -2009,13 +2009,13 @@ Practically, this means all c files that contain static_init_
There currently also is a configure.in command called SMB_MODULE_PROVIVES(). This is used for modules that register multiple things. It should not -be used as probing will most likely disappear in the future.
Table of Contents
Table of Contents
This document describes how to make use the new RPC Pluggable Modules features of Samba 3.0. This architecture was added to increase the maintainability of Samba allowing RPC Pipes to be worked on separately from the main CVS branch. The RPM architecture will also allow third-party vendors to add functionality to Samba through plug-ins. -
When an RPC call is sent to smbd, smbd tries to load a shared library by the name librpc_<pipename>.so to handle the call if it doesn't know how to handle the call internally. For instance, LSA calls @@ -2032,7 +2032,7 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *s argument.
the Client name of the named pipe
the Server name of the named pipe
a list of api_structs that map RPC ordinal numbers to function calls
the number of api_structs contained in cmds
See rpc_server/srv_reg.c and rpc_server/srv_reg_nt.c for a small example of how to use this library. -
Table of Contents
Table of Contents
Each VFS operation has a vfs_op_type, a function pointer and a handle pointer in the struct vfs_ops and tree macros to make it easier to call the operations. (Take a look at include/vfs.h and include/vfs_macros.h.) @@ -2128,7 +2128,7 @@ DO NOT ACCESS conn->vfs.ops.* directly !!! (tofd), (fsp), (fromfd), (header), (offset), (count))) ... -
These values are used by the VFS subsystem when building the conn->vfs and conn->vfs_opaque structs for a connection with multiple VFS modules. Internally, Samba differentiates only opaque and transparent layers at this process. @@ -2157,7 +2157,7 @@ typedef enum _vfs_op_layer { SMB_VFS_LAYER_SCANNER /* - Checks data and possibly initiates additional */ /* file activity like logging to files _inside_ samba VFS */ } vfs_op_layer; -
As each Samba module a VFS module should have a
NTSTATUS vfs_example_init(void);
function if it's staticly linked to samba or
NTSTATUS init_module(void);
function if it's a shared module. @@ -2195,9 +2195,9 @@ static vfs_op_tuple example_op_tuples[] = { NTSTATUS init_module(void) { - return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "example", example_op_tuples); + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "example", example_op_tuples); } -
Each VFS function has as first parameter a pointer to the modules vfs_handle_struct. +
Each VFS function has as first parameter a pointer to the modules vfs_handle_struct.
typedef struct vfs_handle_struct { struct vfs_handle_struct *next, *prev; @@ -2207,7 +2207,7 @@ typedef struct vfs_handle_struct { void *data; void (*free_data)(void **data); } vfs_handle_struct; -
this is the module parameter specified in the vfs objects parameter.
e.g. for 'vfs objects = example:test' param would be "test".
This vfs_ops struct contains the information for calling the next module operations. +
this is the module parameter specified in the vfs objects parameter.
e.g. for 'vfs objects = example:test' param would be "test".
This vfs_ops struct contains the information for calling the next module operations. Use the SMB_VFS_NEXT_* macros to call a next module operations and don't access handle->vfs_next.ops.* directly!
This is a pointer back to the connection_struct to witch the handle belongs.
This is a pointer for holding module private data. You can alloc data with connection life time on the handle->conn->mem_ctx TALLOC_CTX. @@ -2217,14 +2217,14 @@ you can set this function pointer to NULL.
Some useful MAC
#define SMB_VFS_HANDLE_GET_DATA(handle, datap, type, ret) { \ if (!(handle)||((datap=(type *)(handle)->data)==NULL)) { \ - DEBUG(0,("%s() failed to get vfs_handle->data!\n",FUNCTION_MACRO)); \ + DEBUG(0,("%s() failed to get vfs_handle->data!\n",FUNCTION_MACRO)); \ ret; \ } \ } #define SMB_VFS_HANDLE_SET_DATA(handle, datap, free_fn, type, ret) { \ if (!(handle)) { \ - DEBUG(0,("%s() failed to set handle->data!\n",FUNCTION_MACRO)); \ + DEBUG(0,("%s() failed to set handle->data!\n",FUNCTION_MACRO)); \ ret; \ } else { \ if ((handle)->free_data) { \ @@ -2298,20 +2298,20 @@ you can set this function pointer to NULL.
Some useful MAC (handle)->vfs_next.handles.sendfile,\ (tofd), (fsp), (fromfd), (header), (offset), (count))) ... -
-Add "vfs_handle_struct *handle, " as first parameter to all vfs operation functions. +
+Add "vfs_handle_struct *handle, " as first parameter to all vfs operation functions. e.g. example_connect(connection_struct *conn, const char *service, const char *user); -> example_connect(vfs_handle_struct *handle, connection_struct *conn, const char *service, const char *user);
-Replace "default_vfs_ops." with "smb_vfs_next_". +Replace "default_vfs_ops." with "smb_vfs_next_". e.g. default_vfs_ops.connect(conn, service, user); -> smb_vfs_next_connect(conn, service, user);
-Uppercase all "smb_vfs_next_*" functions. +Uppercase all "smb_vfs_next_*" functions. e.g. smb_vfs_next_connect(conn, service, user); -> SMB_VFS_NEXT_CONNECT(conn, service, user);
-Add "handle, " as first parameter to all SMB_VFS_NEXT_*() calls. +Add "handle, " as first parameter to all SMB_VFS_NEXT_*() calls. e.g. SMB_VFS_NEXT_CONNECT(conn, service, user); -> SMB_VFS_NEXT_CONNECT(handle, conn, service, user);
@@ -2411,7 +2411,7 @@ e.g.
NTSTATUS init_module(void) { - return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,"example",example_op_tuples); + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,"example",example_op_tuples); }
@@ -2447,14 +2447,14 @@ static int example_connect(vfs_handle_struct *handle, /* alloc our private data */ data = (struct example_privates *)talloc_zero(conn->mem_ctx, sizeof(struct example_privates)); if (!data) { - DEBUG(0,("talloc_zero() failed\n")); + DEBUG(0,("talloc_zero() failed\n")); return -1; } /* init out private data */ - data->some_string = talloc_strdup(conn->mem_ctx,"test"); + data->some_string = talloc_strdup(conn->mem_ctx,"test"); if (!data->some_string) { - DEBUG(0,("talloc_strdup() failed\n")); + DEBUG(0,("talloc_strdup() failed\n")); return -1; } @@ -2480,7 +2480,7 @@ static int example_close(vfs_handle_struct *handle, files_struct *fsp, int fd) SMB_VFS_HANDLE_GET_DATA(handle, data, struct example_privates, return -1); /* do something here...*/ - DEBUG(0,("some_string: %s\n",data->some_string)); + DEBUG(0,("some_string: %s\n",data->some_string)); return SMB_VFS_NEXT_CLOSE(handle, fsp, fd); } @@ -2508,14 +2508,14 @@ static int example_connect(vfs_handle_struct *handle, /* alloc our private data */ data = (struct example_privates *)malloc(sizeof(struct example_privates)); if (!data) { - DEBUG(0,("malloc() failed\n")); + DEBUG(0,("malloc() failed\n")); return -1; } /* init out private data */ - data->some_string = strdup("test"); + data->some_string = strdup("test"); if (!data->some_string) { - DEBUG(0,("strdup() failed\n")); + DEBUG(0,("strdup() failed\n")); return -1; } @@ -2540,7 +2540,7 @@ static int example_close(vfs_handle_struct *handle, files_struct *fsp, int fd) SMB_VFS_HANDLE_GET_DATA(handle, data, struct example_privates, return -1); /* do something here...*/ - DEBUG(0,("some_string: %s\n",data->some_string)); + DEBUG(0,("some_string: %s\n",data->some_string)); return SMB_VFS_NEXT_CLOSE(handle, fsp, fd); } @@ -2561,7 +2561,7 @@ for your module.
Compiling & Testing...
./configure --enable-developer ... |
make |
Try to fix all compiler warnings |
make |
Testing, Testing, Testing ... |
-
Avoid writing functions like this:
@@ -2572,7 +2572,7 @@ static int example_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
Overload only the functions you really need to! -
If you want to just implement a better version of a default samba opaque function (e.g. like a disk_free() function for a special filesystem) @@ -2588,16 +2588,16 @@ e.g. for a readonly filesystem. static int example_rename(vfs_handle_struct *handle, connection_struct *conn, char *oldname, char *newname) { - DEBUG(10,("function rename() not allowed on vfs 'example'\n")); + DEBUG(10,("function rename() not allowed on vfs 'example'\n")); errno = ENOSYS; return -1; } -
Table of Contents
Table of Contents
Please, please update the version number in source/include/version.h to include the versioning of your package. This makes it easier to distinguish standard samba builds from custom-build samba builds (distributions often patch packages). For example, a good version would be:
Version 2.999+3.0.alpha21-5 for Debian -