From cb6b82b5dc6ff89a0fe6ed4a1078fca1dfedb567 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 13 Aug 2003 03:57:48 +0000 Subject: Regenerate docs (This used to be commit 85414c8780cf57c396fea395918dfd161d67edb4) --- docs/htmldocs/Samba-Developers-Guide.html | 331 +++++++++++++++--------------- 1 file changed, 164 insertions(+), 167 deletions(-) (limited to 'docs/htmldocs/Samba-Developers-Guide.html') diff --git a/docs/htmldocs/Samba-Developers-Guide.html b/docs/htmldocs/Samba-Developers-Guide.html index 2edd2b5042..64c78025ed 100644 --- a/docs/htmldocs/Samba-Developers-Guide.html +++ b/docs/htmldocs/Samba-Developers-Guide.html @@ -12,10 +12,7 @@ Please send updates to Jelmer Vernooij. This documentation is distributed under the GNU General Public License (GPL) version 2. A copy of the license is included with the Samba source distribution. A copy can be found on-line at http://www.fsf.org/licenses/gpl.txt -">

SAMBA Developers Guide

SAMBA Team

Attributions.  - - -

Abstract

+">

SAMBA Developers Guide

Abstract

Last Update : Fri Jun 6 00:45:54 CEST 2003

This book is a collection of documents that might be useful for @@ -29,15 +26,15 @@ Please send updates to Jelmer Ve This documentation is distributed under the GNU General Public License (GPL) version 2. A copy of the license is included with the Samba source distribution. A copy can be found on-line at http://www.fsf.org/licenses/gpl.txt -


Table of Contents

1. Definition of NetBIOS Protocol and Name Resolution Modes
NETBIOS
BROADCAST NetBIOS
NBNS NetBIOS
2. Samba Architecture
Introduction
Multithreading and Samba
Threading smbd
Threading nmbd
nbmd Design
3. The samba DEBUG system
New Output Syntax
The DEBUG() Macro
The DEBUGADD() Macro
The DEBUGLVL() Macro
New Functions
dbgtext()
dbghdr()
format_debug_text()
4. Coding Suggestions
5. Samba Internals
Character Handling
The new functions
Macros in byteorder.h
CVAL(buf,pos)
PVAL(buf,pos)
SCVAL(buf,pos,val)
SVAL(buf,pos)
IVAL(buf,pos)
SVALS(buf,pos)
IVALS(buf,pos)
SSVAL(buf,pos,val)
SIVAL(buf,pos,val)
SSVALS(buf,pos,val)
SIVALS(buf,pos,val)
RSVAL(buf,pos)
RIVAL(buf,pos)
RSSVAL(buf,pos,val)
RSIVAL(buf,pos,val)
LAN Manager Samba API
Parameters
Return value
Code character table
6. The smb.conf file
Lexical Analysis
Handling of Whitespace
Handling of Line Continuation
Line Continuation Quirks
Syntax
About params.c
7. NetBIOS in a Unix World
Introduction
Usernames
File Ownership
Passwords
Locking
Deny Modes
Trapdoor UIDs
Port numbers
Protocol Complexity
8. Tracing samba system calls
9. Finding useful information on windows
Netlogon debugging output
10. NT Domain RPC's
Introduction
Sources
Credits
Notes and Structures
Notes
Enumerations
Structures
MSRPC over Transact Named Pipe
MSRPC Pipes
Header
Tail
RPC Bind / Bind Ack
NTLSA Transact Named Pipe
LSA Open Policy
LSA Query Info Policy
LSA Enumerate Trusted Domains
LSA Open Secret
LSA Close
LSA Lookup SIDS
LSA Lookup Names
NETLOGON rpc Transact Named Pipe
LSA Request Challenge
LSA Authenticate 2
LSA Server Password Set
LSA SAM Logon
LSA SAM Logoff
\\MAILSLOT\NET\NTLOGON
Query for PDC
SAM Logon
SRVSVC Transact Named Pipe
Net Share Enum
Net Server Get Info
Cryptographic side of NT Domain Authentication
Definitions
Protocol
Comments
SIDs and RIDs
Well-known SIDs
Well-known RIDS
11. Samba Printing Internals
Abstract
+


Table of Contents

Attributions
1. Definition of NetBIOS Protocol and Name Resolution Modes
NETBIOS
BROADCAST NetBIOS
NBNS NetBIOS
2. Samba Architecture
Introduction
Multithreading and Samba
Threading smbd
Threading nmbd
nbmd Design
3. The samba DEBUG system
New Output Syntax
The DEBUG() Macro
The DEBUGADD() Macro
The DEBUGLVL() Macro
New Functions
dbgtext()
dbghdr()
format_debug_text()
4. Coding Suggestions
5. Samba Internals
Character Handling
The new functions
Macros in byteorder.h
CVAL(buf,pos)
PVAL(buf,pos)
SCVAL(buf,pos,val)
SVAL(buf,pos)
IVAL(buf,pos)
SVALS(buf,pos)
IVALS(buf,pos)
SSVAL(buf,pos,val)
SIVAL(buf,pos,val)
SSVALS(buf,pos,val)
SIVALS(buf,pos,val)
RSVAL(buf,pos)
RIVAL(buf,pos)
RSSVAL(buf,pos,val)
RSIVAL(buf,pos,val)
LAN Manager Samba API
Parameters
Return value
Code character table
6. The smb.conf file
Lexical Analysis
Handling of Whitespace
Handling of Line Continuation
Line Continuation Quirks
Syntax
About params.c
7. NetBIOS in a Unix World
Introduction
Usernames
File Ownership
Passwords
Locking
Deny Modes
Trapdoor UIDs
Port numbers
Protocol Complexity
8. Tracing samba system calls
9. Finding useful information on windows
Netlogon debugging output
10. NT Domain RPC's
Introduction
Sources
Credits
Notes and Structures
Notes
Enumerations
Structures
MSRPC over Transact Named Pipe
MSRPC Pipes
Header
Tail
RPC Bind / Bind Ack
NTLSA Transact Named Pipe
LSA Open Policy
LSA Query Info Policy
LSA Enumerate Trusted Domains
LSA Open Secret
LSA Close
LSA Lookup SIDS
LSA Lookup Names
NETLOGON rpc Transact Named Pipe
LSA Request Challenge
LSA Authenticate 2
LSA Server Password Set
LSA SAM Logon
LSA SAM Logoff
\\MAILSLOT\NET\NTLOGON
Query for PDC
SAM Logon
SRVSVC Transact Named Pipe
Net Share Enum
Net Server Get Info
Cryptographic side of NT Domain Authentication
Definitions
Protocol
Comments
SIDs and RIDs
Well-known SIDs
Well-known RIDS
11. Samba Printing Internals
Abstract
Printing Interface to Various Back ends -
+
Print Queue TDB's -
+
ChangeID and Client Caching of Printer Information -
+
Windows NT/2K Printer Change Notify -
12. Samba WINS Internals
WINS Failover
13. The Upcoming SAM System
Security in the 'new SAM'
Standalone from UNIX
Handles and Races in the new SAM
Layers
Application
SAM Interface
SAM Modules
SAM Modules
Special Module: sam_passdb
sam_ads
Memory Management
Testing
14. LanMan and NT Password Encryption
Introduction
How does it work?
The smbpasswd file
15. Modules
Advantages
Loading modules
Static modules
Shared modules
Writing modules
Static/Shared selection in configure.in
16. RPC Pluggable Modules
About
General Overview
17. VFS Modules
The Samba (Posix) VFS layer
The general interface
Possible VFS operation layers
The Interaction between the Samba VFS subsystem and the modules
Initialization and registration
How the Modules handle per connection data
Upgrading to the New VFS Interface
Upgrading from 2.2.* and 3.0aplha modules
Some Notes
Implement TRANSPARENT functions
Implement OPAQUE functions
18. Notes to packagers
Versioning
Modules
19. Contributing code

Chapter 1. Definition of NetBIOS Protocol and Name Resolution Modes

Luke Leighton

12 June 1997

Attributions

Definition of NetBIOS Protocol and Name Resolution Modes

  • Luke Leighton

Samba Architecture

  • Dan Shearer

The samba DEBUG system

  • Chris Hertel

Coding Suggestions

  • Steve French

  • Simo Sorce

  • Andrew Bartlett

  • Tim Potter

  • Martin Pool

Samba Internals

The smb.conf file

  • Chris Hertel

NetBIOS in a Unix World

  • Andrew Tridgell

Tracing samba system calls

  • Andrew Tridgell

Finding useful information on windows

NT Domain RPC's

Samba Printing Internals

  • Gerald Carter

Samba WINS Internals

  • Gerald Carter

The Upcoming SAM System

  • Andrew Bartlett

LanMan and NT Password Encryption

Modules

RPC Pluggable Modules

VFS Modules

Notes to packagers

  • Jelmer Vernooij

Contributing code

Chapter 1. Definition of NetBIOS Protocol and Name Resolution Modes

Luke Leighton

12 June 1997

NETBIOS

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 @@ -78,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. -

BROADCAST NetBIOS

+

BROADCAST NetBIOS

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 @@ -90,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!]. -

NBNS NetBIOS

+

NBNS NetBIOS

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 @@ -131,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. -

Chapter 2. Samba Architecture

Dan Shearer

November 1997

Introduction

+

Chapter 2. Samba Architecture

Dan Shearer

November 1997

Introduction

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 @@ -142,7 +139,7 @@ It also tries to answer some of the frequently asked questions such as:

  1. Is Samba secure when running on Unix? The xyz platform? What about the root priveliges issue? -

  2. Pros and cons of multithreading in various parts of Samba

  3. Why not have a separate process for name resolution, WINS, and browsing?

Multithreading and Samba

+

  • Pros and cons of multithreading in various parts of Samba

  • Why not have a separate process for name resolution, WINS, and browsing?

  • Multithreading and Samba

    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. @@ -159,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. -

    Threading smbd

    +

    Threading smbd

    A few problems that would arise from a threaded smbd are:

    1. It's not only to create threads instead of processes, but you @@ -184,7 +181,7 @@ A few problems that would arise from a threaded smbd are:

    2. we couldn't use the system locking calls as the locking context of fcntl() is a process, not a thread. -

    Threading nmbd

    +

    Threading nmbd

    This would be ideal, but gets sunk by portability requirements.

    Andrew tried to write a test threads library for nmbd that used only @@ -211,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. -

    nbmd Design

    +

    nbmd Design

    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 @@ -232,7 +229,7 @@ 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. -

    Chapter 3. The samba DEBUG system

    Chris Hertel

    July 1998

    New Output Syntax

    +

    Chapter 3. The samba DEBUG system

    Chris Hertel

    July 1998

    New Output Syntax

    The syntax of a debugging log file is represented as:

       >debugfile< :== { >debugmsg< }
    @@ -285,7 +282,7 @@ 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.
    -

    The DEBUG() Macro

    +

    The DEBUG() 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. @@ -336,7 +333,7 @@ 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. -

    The DEBUGADD() Macro

    +

    The DEBUGADD() Macro

    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 @@ -385,7 +382,7 @@ within the DEBUGLVL() block.

  • Processing that is only relevant to debug output can be contained within the DEBUGLVL() block. -

  • New Functions

    dbgtext()

    +

    New Functions

    dbgtext()

    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 @@ -394,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(). -

    dbghdr()

    +

    dbghdr()

    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 @@ -402,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(). -

    format_debug_text()

    +

    format_debug_text()

    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 @@ -553,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. -

    Chapter 5. Samba Internals

    8 May 1996

    Character Handling

    +

    Chapter 5. Samba Internals

    8 May 1996

    Character Handling

    This section describes character set handling in Samba, as implemented in Samba 3.0 and above

    @@ -563,7 +560,7 @@ 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 functions

    +

    The new functions

    The new system works like this:

    1. all char* strings inside Samba are "unix" strings. These are @@ -625,41 +622,41 @@ The new system works like this: parameters is gone.

    2. all vfs functions take unix strings. Don't convert when passing to them -

    Macros in byteorder.h

    +

    Macros in byteorder.h

    This section describes the macros defined in byteorder.h. These macros are used extensively in the Samba code. -

    CVAL(buf,pos)

    +

    CVAL(buf,pos)

    returns the byte at offset pos within buffer buf as an unsigned character. -

    PVAL(buf,pos)

    returns the value of CVAL(buf,pos) cast to type unsigned integer.

    SCVAL(buf,pos,val)

    sets the byte at offset pos within buffer buf to value val.

    SVAL(buf,pos)

    +

    PVAL(buf,pos)

    returns the value of CVAL(buf,pos) cast to type unsigned integer.

    SCVAL(buf,pos,val)

    sets the byte at offset pos within buffer buf to value val.

    SVAL(buf,pos)

    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". -

    IVAL(buf,pos)

    returns the value of the unsigned 32 bit little-endian integer at offset -pos within buffer buf.

    SVALS(buf,pos)

    returns the value of the signed short (16 bit) little-endian integer at -offset pos within buffer buf.

    IVALS(buf,pos)

    returns the value of the signed 32 bit little-endian integer at offset pos -within buffer buf.

    SSVAL(buf,pos,val)

    sets the unsigned short (16 bit) little-endian integer at offset pos within -buffer buf to value val.

    SIVAL(buf,pos,val)

    sets the unsigned 32 bit little-endian integer at offset pos within buffer -buf to the value val.

    SSVALS(buf,pos,val)

    sets the short (16 bit) signed little-endian integer at offset pos within -buffer buf to the value val.

    SIVALS(buf,pos,val)

    sets the signed 32 bit little-endian integer at offset pos withing buffer -buf to the value val.

    RSVAL(buf,pos)

    returns the value of the unsigned short (16 bit) big-endian integer at -offset pos within buffer buf.

    RIVAL(buf,pos)

    returns the value of the unsigned 32 bit big-endian integer at offset -pos within buffer buf.

    RSSVAL(buf,pos,val)

    sets the value of the unsigned short (16 bit) big-endian integer at +

    IVAL(buf,pos)

    returns the value of the unsigned 32 bit little-endian integer at offset +pos within buffer buf.

    SVALS(buf,pos)

    returns the value of the signed short (16 bit) little-endian integer at +offset pos within buffer buf.

    IVALS(buf,pos)

    returns the value of the signed 32 bit little-endian integer at offset pos +within buffer buf.

    SSVAL(buf,pos,val)

    sets the unsigned short (16 bit) little-endian integer at offset pos within +buffer buf to value val.

    SIVAL(buf,pos,val)

    sets the unsigned 32 bit little-endian integer at offset pos within buffer +buf to the value val.

    SSVALS(buf,pos,val)

    sets the short (16 bit) signed little-endian integer at offset pos within +buffer buf to the value val.

    SIVALS(buf,pos,val)

    sets the signed 32 bit little-endian integer at offset pos withing buffer +buf to the value val.

    RSVAL(buf,pos)

    returns the value of the unsigned short (16 bit) big-endian integer at +offset pos within buffer buf.

    RIVAL(buf,pos)

    returns the value of the unsigned 32 bit big-endian integer at offset +pos within buffer buf.

    RSSVAL(buf,pos,val)

    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".

    RSIVAL(buf,pos,val)

    sets the value of the unsigned 32 bit big-endian integer at offset -pos within buffer buf to value val.

    LAN Manager Samba API

    +refered to as "USHORT".

    RSIVAL(buf,pos,val)

    sets the value of the unsigned 32 bit big-endian integer at offset +pos within buffer buf to value val.

    LAN Manager Samba API

    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 reliable. -

    -
    +

    +

     call_api(int prcnt, int drcnt, int mprcnt, int mdrcnt, 
     	char *param, char *data, char **rparam, char **rdata);
    -
    -

    +

    +

    This function is defined in client.c. It uses an SMB transaction to call a remote api. -

    Parameters

    The parameters are as follows:

    1. +

      Parameters

      The parameters are as follows:

      1. prcnt: the number of bytes of parameters begin sent.

      2. drcnt: the number of bytes of data begin sent. @@ -704,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. -

      Return value

      +

      Return value

      The returned parameters (pointed to by rparam), in their order of appearance are:

      1. An unsigned 16 bit integer which contains the API function's return code. @@ -735,7 +732,7 @@ 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 do with indicating the amount of data returned or possibly the amount of data which can be returned if enough buffer space is allowed. -

      Code character table

      +

    Code character table

    Certain data structures are described by means of ASCIIz strings containing code characters. These are the code characters:

    1. @@ -758,7 +755,7 @@ r pointer to returned data buffer??? L length in bytes of returned data buffer???

    2. h number of bytes of information available??? -

    Chapter 6. The smb.conf file

    Chris Hertel

    November 1997

    Lexical Analysis

    +

    Chapter 6. The smb.conf file

    Chris Hertel

    November 1997

    Lexical Analysis

    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): @@ -785,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: '='. -

    Handling of Whitespace

    +

    Handling of Whitespace

    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. @@ -800,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. -

  • Handling of Line Continuation

    +

    Handling of Line Continuation

    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. @@ -823,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. -

    Line Continuation Quirks

    Note the following example:

    +

    Line Continuation Quirks

    Note the following example:

     	param name = parameter value string \
         \
         with line continuation.
    @@ -847,7 +844,7 @@ terminating character, and the rest of the line is ignored.  The lines
     

    are read as

     	[section name]
         param name = value
    -

    Syntax

    The syntax of the smb.conf file is as follows:

    +

    Syntax

    The syntax of the smb.conf file is as follows:

       <file>            :==  { <section> } EOF
       <section>         :==  <section header> { <parameter line> }
       <section header>  :==  '[' NAME ']'
    @@ -866,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').
    -

    About params.c

    +

    About params.c

    The parsing of the config file is a bit unusual if you are used to lex, yacc, bison, etc. Both lexical analysis (scanning) and parsing are performed by params.c. Values are loaded via callbacks to loadparm.c. -

    Chapter 7. NetBIOS in a Unix World

    Andrew Tridgell

    April 1995

    Introduction

    +

    Chapter 7. NetBIOS in a Unix World

    Andrew Tridgell

    April 1995

    Introduction

    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 @@ -879,7 +876,7 @@ interoperability.

    It was written to help out a person who was writing a paper on unix to PC connectivity. -

    Usernames

    +

    Usernames

    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 @@ -916,7 +913,7 @@ 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). -

    File Ownership

    +

    File Ownership

    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. @@ -934,7 +931,7 @@ file time comparisons right. There are several possible solutions to this problem, including username mapping, and forcing a specific username for particular shares. -

    Passwords

    +

    Passwords

    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 @@ -956,7 +953,7 @@ 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. -

    Locking

    +

    Locking

    Since samba 2.2, samba supports other types of locking as well. This section is outdated.

    @@ -987,7 +984,7 @@ 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. -

    Deny Modes

    +

    Deny Modes

    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 @@ -1001,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. -

    Trapdoor UIDs

    +

    Trapdoor UIDs

    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 @@ -1011,7 +1008,7 @@ a single uid.

    Note that you can also get the "trapdoor uid" message for other reasons. Please see the FAQ for details. -

    Port numbers

    +

    Port numbers

    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 @@ -1034,7 +1031,7 @@ 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. -

    Protocol Complexity

    +

    Protocol Complexity

    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 @@ -1148,7 +1145,7 @@ causes printing to fail with Samba: The process is trying to first open /dev/null read-write then read-only. Both fail. This means /dev/null has incorrect permissions. -

    Chapter 9. Finding useful information on windows

    Jelmer R. Vernooij

    The Samba Team

    Andrew Tridgell

    Samba Team

    Table of Contents

    Netlogon debugging output

    Netlogon debugging output

    1. stop netlogon service on PDC

    2. rename original netlogon.dll to netlogon.dll.original

    3. copy checked version of netlogon.dll to system32 directory

    4. set HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters\DBFlag to 0x20000004

    5. start netlogon service on PDC

    Chapter 10. NT Domain RPC's

    Luke Leighton

    Duncan Stansfield

    01 November 97(version 0.0.24)

    Introduction

    +

    Chapter 9. Finding useful information on windows

    Jelmer R. Vernooij

    The Samba Team

    Andrew Tridgell

    Samba Team

    Table of Contents

    Netlogon debugging output

    Netlogon debugging output

    1. stop netlogon service on PDC

    2. rename original netlogon.dll to netlogon.dll.original

    3. copy checked version of netlogon.dll to system32 directory

    4. set HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters\DBFlag to 0x20000004

    5. start netlogon service on PDC

    Chapter 10. NT Domain RPC's

    Luke Leighton

    Duncan Stansfield

    01 November 97(version 0.0.24)

    Introduction

    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.

    @@ -1194,7 +1191,7 @@ 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].

  • Sources

    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

    Credits

    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

    Notes and Structures

    Notes

    1. +command, and keep the default workstation password].

    Sources

    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

    Credits

    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

    Notes and Structures

    Notes

    1. 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. @@ -1222,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. -

    Enumerations

    MSRPC Header type

    command number in the msrpc packet header

    MSRPC_Request:

    0x00

    MSRPC_Response:

    0x02

    MSRPC_Bind:

    0x0B

    MSRPC_BindAck:

    0x0C

    MSRPC Packet info

    The meaning of these flags is undocumented

    FirstFrag:

    0x01

    LastFrag:

    0x02

    NotaFrag:

    0x04

    RecRespond:

    0x08

    NoMultiplex:

    0x10

    NotForIdemp:

    0x20

    NotforBcast:

    0x40

    NoUuid:

    0x80

    Structures

    VOID *

    sizeof VOID* is 32 bits.

    char

    sizeof char is 8 bits.

    UTIME

    UTIME is 32 bits, indicating time in seconds since 01jan1970. documented in cifs6.txt (section 3.5 page, page 30).

    NTTIME

    NTTIME is 64 bits. documented in cifs6.txt (section 3.5 page, page 30).

    DOM_SID (domain SID structure)

    UINT32

    num of sub-authorities in domain SID

    UINT8

    SID revision number

    UINT8

    num of sub-authorities in domain SID

    UINT8[6]

    6 bytes for domain SID - Identifier Authority.

    UINT16[n_subauths]

    domain SID sub-authorities

    Note: the domain SID is documented elsewhere. -

    STR (string)

    STR (string) is a char[] : a null-terminated string of ascii characters.

    UNIHDR (unicode string header)

    UINT16

    length of unicode string

    UINT16

    max length of unicode string

    UINT32

    4 - undocumented.

    UNIHDR2 (unicode string header plus buffer pointer)

    UNIHDR

    unicode string header

    VOID*

    undocumented buffer pointer

    UNISTR (unicode string)

    UINT16[]

    null-terminated string of unicode characters.

    NAME (length-indicated unicode string)

    UINT32

    length of unicode string

    UINT16[]

    null-terminated string of unicode characters.

    UNISTR2 (aligned unicode string)

    UINT8[]

    padding to get unicode string 4-byte aligned with the start of the SMB header.

    UINT32

    max length of unicode string

    UINT32

    0 - undocumented

    UINT32

    length of unicode string

    UINT16[]

    string of uncode characters

    OBJ_ATTR (object attributes)

    UINT32

    0x18 - length (in bytes) including the length field.

    VOID*

    0 - root directory (pointer)

    VOID*

    0 - object name (pointer)

    UINT32

    0 - attributes (undocumented)

    VOID*

    0 - security descriptior (pointer)

    UINT32

    0 - security quality of service

    POL_HND (LSA policy handle)

    char[20]

    policy handle

    DOM_SID2 (domain SID structure, SIDS stored in unicode)

    UINT32

    5 - SID type

    UINT32

    0 - undocumented

    UNIHDR2

    domain SID unicode string header

    UNISTR

    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.

    DOM_RID (domain RID structure)

    UINT32

    5 - well-known SID. 1 - user SID (see ShowACLs)

    UINT32

    5 - undocumented

    UINT32

    domain RID

    UINT32

    0 - domain index out of above reference domains

    LOG_INFO (server, account, client structure)

    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.

    VOID*

    undocumented buffer pointer

    UNISTR2

    logon server unicode string

    UNISTR2

    account name unicode string

    UINT16

    sec_chan - security channel type

    UNISTR2

    logon client machine unicode string

    CLNT_SRV (server, client names structure)

    Note: logon server name starts with two '\' characters and is upper case.

    VOID*

    undocumented buffer pointer

    UNISTR2

    logon server unicode string

    VOID*

    undocumented buffer pointer

    UNISTR2

    logon client machine unicode string

    CREDS (credentials + time stamp)

    char[8]

    credentials

    UTIME

    time stamp

    CLNT_INFO2 (server, client structure, client credentials)

    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.

    CLNT_SRV

    client and server names

    UINT8[]

    ???? padding, for 4-byte alignment with SMB header.

    VOID*

    pointer to client credentials.

    CREDS

    client-calculated credentials + client time

    CLNT_INFO (server, account, client structure, client credentials)

    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.

    LOG_INFO

    logon account info

    CREDS

    client-calculated credentials + client time

    ID_INFO_1 (id info structure, auth level 1)

    VOID*

    ptr_id_info_1

    UNIHDR

    domain name unicode header

    UINT32

    param control

    UINT64

    logon ID

    UNIHDR

    user name unicode header

    UNIHDR

    workgroup name unicode header

    char[16]

    arc4 LM OWF Password

    char[16]

    arc4 NT OWF Password

    UNISTR2

    domain name unicode string

    UNISTR2

    user name unicode string

    UNISTR2

    workstation name unicode string

    SAM_INFO (sam logon/logoff id info structure)

    Note: presumably, the return credentials is supposedly for the server to verify that the credential chain hasn't been compromised.

    CLNT_INFO2

    client identification/authentication info

    VOID*

    pointer to return credentials.

    CRED

    return credentials - ignored.

    UINT16

    logon level

    UINT16

    switch value

    +

    Enumerations

    MSRPC Header type

    command number in the msrpc packet header

    MSRPC_Request:

    0x00

    MSRPC_Response:

    0x02

    MSRPC_Bind:

    0x0B

    MSRPC_BindAck:

    0x0C

    MSRPC Packet info

    The meaning of these flags is undocumented

    FirstFrag:

    0x01

    LastFrag:

    0x02

    NotaFrag:

    0x04

    RecRespond:

    0x08

    NoMultiplex:

    0x10

    NotForIdemp:

    0x20

    NotforBcast:

    0x40

    NoUuid:

    0x80

    Structures

    VOID *

    sizeof VOID* is 32 bits.

    char

    sizeof char is 8 bits.

    UTIME

    UTIME is 32 bits, indicating time in seconds since 01jan1970. documented in cifs6.txt (section 3.5 page, page 30).

    NTTIME

    NTTIME is 64 bits. documented in cifs6.txt (section 3.5 page, page 30).

    DOM_SID (domain SID structure)

    UINT32

    num of sub-authorities in domain SID

    UINT8

    SID revision number

    UINT8

    num of sub-authorities in domain SID

    UINT8[6]

    6 bytes for domain SID - Identifier Authority.

    UINT16[n_subauths]

    domain SID sub-authorities

    Note: the domain SID is documented elsewhere. +

    STR (string)

    STR (string) is a char[] : a null-terminated string of ascii characters.

    UNIHDR (unicode string header)

    UINT16

    length of unicode string

    UINT16

    max length of unicode string

    UINT32

    4 - undocumented.

    UNIHDR2 (unicode string header plus buffer pointer)

    UNIHDR

    unicode string header

    VOID*

    undocumented buffer pointer

    UNISTR (unicode string)

    UINT16[]

    null-terminated string of unicode characters.

    NAME (length-indicated unicode string)

    UINT32

    length of unicode string

    UINT16[]

    null-terminated string of unicode characters.

    UNISTR2 (aligned unicode string)

    UINT8[]

    padding to get unicode string 4-byte aligned with the start of the SMB header.

    UINT32

    max length of unicode string

    UINT32

    0 - undocumented

    UINT32

    length of unicode string

    UINT16[]

    string of uncode characters

    OBJ_ATTR (object attributes)

    UINT32

    0x18 - length (in bytes) including the length field.

    VOID*

    0 - root directory (pointer)

    VOID*

    0 - object name (pointer)

    UINT32

    0 - attributes (undocumented)

    VOID*

    0 - security descriptior (pointer)

    UINT32

    0 - security quality of service

    POL_HND (LSA policy handle)

    char[20]

    policy handle

    DOM_SID2 (domain SID structure, SIDS stored in unicode)

    UINT32

    5 - SID type

    UINT32

    0 - undocumented

    UNIHDR2

    domain SID unicode string header

    UNISTR

    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.

    DOM_RID (domain RID structure)

    UINT32

    5 - well-known SID. 1 - user SID (see ShowACLs)

    UINT32

    5 - undocumented

    UINT32

    domain RID

    UINT32

    0 - domain index out of above reference domains

    LOG_INFO (server, account, client structure)

    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.

    VOID*

    undocumented buffer pointer

    UNISTR2

    logon server unicode string

    UNISTR2

    account name unicode string

    UINT16

    sec_chan - security channel type

    UNISTR2

    logon client machine unicode string

    CLNT_SRV (server, client names structure)

    Note: logon server name starts with two '\' characters and is upper case.

    VOID*

    undocumented buffer pointer

    UNISTR2

    logon server unicode string

    VOID*

    undocumented buffer pointer

    UNISTR2

    logon client machine unicode string

    CREDS (credentials + time stamp)

    char[8]

    credentials

    UTIME

    time stamp

    CLNT_INFO2 (server, client structure, client credentials)

    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.

    CLNT_SRV

    client and server names

    UINT8[]

    ???? padding, for 4-byte alignment with SMB header.

    VOID*

    pointer to client credentials.

    CREDS

    client-calculated credentials + client time

    CLNT_INFO (server, account, client structure, client credentials)

    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.

    LOG_INFO

    logon account info

    CREDS

    client-calculated credentials + client time

    ID_INFO_1 (id info structure, auth level 1)

    VOID*

    ptr_id_info_1

    UNIHDR

    domain name unicode header

    UINT32

    param control

    UINT64

    logon ID

    UNIHDR

    user name unicode header

    UNIHDR

    workgroup name unicode header

    char[16]

    arc4 LM OWF Password

    char[16]

    arc4 NT OWF Password

    UNISTR2

    domain name unicode string

    UNISTR2

    user name unicode string

    UNISTR2

    workstation name unicode string

    SAM_INFO (sam logon/logoff id info structure)

    Note: presumably, the return credentials is supposedly for the server to verify that the credential chain hasn't been compromised.

    CLNT_INFO2

    client identification/authentication info

    VOID*

    pointer to return credentials.

    CRED

    return credentials - ignored.

    UINT16

    logon level

    UINT16

    switch value

             switch (switch_value)
             case 1:
             {
                 ID_INFO_1     id_info_1;
             }
    -

    GID (group id info)

    UINT32

    group id

    UINT32

    user attributes (only used by NT 3.1 and 3.51)

    DOM_REF (domain reference info)

    VOID*

    undocumented buffer pointer.

    UINT32

    num referenced domains?

    VOID*

    undocumented domain name buffer pointer.

    UINT32

    32 - max number of entries

    UINT32

    4 - num referenced domains?

    UNIHDR2

    domain name unicode string header

    UNIHDR2[num_ref_doms-1]

    referenced domain unicode string headers

    UNISTR

    domain name unicode string

    DOM_SID[num_ref_doms]

    referenced domain SIDs

    DOM_INFO (domain info, levels 3 and 5 are the same))

    UINT8[]

    ??? padding to get 4-byte alignment with start of SMB header

    UINT16

    domain name string length * 2

    UINT16

    domain name string length * 2

    VOID*

    undocumented domain name string buffer pointer

    VOID*

    undocumented domain SID string buffer pointer

    UNISTR2

    domain name (unicode string)

    DOM_SID

    domain SID

    USER_INFO (user logon info)

    Note: it would be nice to know what the 16 byte user session key is for.

    NTTIME

    logon time

    NTTIME

    logoff time

    NTTIME

    kickoff time

    NTTIME

    password last set time

    NTTIME

    password can change time

    NTTIME

    password must change time

    UNIHDR

    username unicode string header

    UNIHDR

    user's full name unicode string header

    UNIHDR

    logon script unicode string header

    UNIHDR

    profile path unicode string header

    UNIHDR

    home directory unicode string header

    UNIHDR

    home directory drive unicode string header

    UINT16

    logon count

    UINT16

    bad password count

    UINT32

    User ID

    UINT32

    Group ID

    UINT32

    num groups

    VOID*

    undocumented buffer pointer to groups.

    UINT32

    user flags

    char[16]

    user session key

    UNIHDR

    logon server unicode string header

    UNIHDR

    logon domain unicode string header

    VOID*

    undocumented logon domain id pointer

    char[40]

    40 undocumented padding bytes. future expansion?

    UINT32

    0 - num_other_sids?

    VOID*

    NULL - undocumented pointer to other domain SIDs.

    UNISTR2

    username unicode string

    UNISTR2

    user's full name unicode string

    UNISTR2

    logon script unicode string

    UNISTR2

    profile path unicode string

    UNISTR2

    home directory unicode string

    UNISTR2

    home directory drive unicode string

    UINT32

    num groups

    GID[num_groups]

    group info

    UNISTR2

    logon server unicode string

    UNISTR2

    logon domain unicode string

    DOM_SID

    domain SID

    DOM_SID[num_sids]

    other domain SIDs?

    SH_INFO_1_PTR (pointers to level 1 share info strings)

    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.
    VOID*

    shi1_netname - pointer to net name

    UINT32

    shi1_type - type of share. 0 - undocumented.

    VOID*

    shi1_remark - pointer to comment.

    SH_INFO_1_STR (level 1 share info strings)

    UNISTR2

    shi1_netname - unicode string of net name

    UNISTR2

    shi1_remark - unicode string of comment.

    SHARE_INFO_1_CTR

    share container with 0 entries:

    UINT32

    0 - EntriesRead

    UINT32

    0 - Buffer

    share container with > 0 entries:

    UINT32

    EntriesRead

    UINT32

    non-zero - Buffer

    UINT32

    EntriesRead

    SH_INFO_1_PTR[EntriesRead]

    share entry pointers

    SH_INFO_1_STR[EntriesRead]

    share entry strings

    UINT8[]

    padding to get unicode string 4-byte aligned with start of the SMB header.

    UINT32

    EntriesRead

    UINT32

    0 - padding

    SERVER_INFO_101

    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.

    SV_TYPE_WORKSTATION

    0x00000001 All workstations

    SV_TYPE_SERVER

    0x00000002 All servers

    SV_TYPE_SQLSERVER

    0x00000004 Any server running with SQL server

    SV_TYPE_DOMAIN_CTRL

    0x00000008 Primary domain controller

    SV_TYPE_DOMAIN_BAKCTRL

    0x00000010 Backup domain controller

    SV_TYPE_TIME_SOURCE

    0x00000020 Server running the timesource service

    SV_TYPE_AFP

    0x00000040 Apple File Protocol servers

    SV_TYPE_NOVELL

    0x00000080 Novell servers

    SV_TYPE_DOMAIN_MEMBER

    0x00000100 Domain Member

    SV_TYPE_PRINTQ_SERVER

    0x00000200 Server sharing print queue

    SV_TYPE_DIALIN_SERVER

    0x00000400 Server running dialin service.

    SV_TYPE_XENIX_SERVER

    0x00000800 Xenix server

    SV_TYPE_NT

    0x00001000 NT server

    SV_TYPE_WFW

    0x00002000 Server running Windows for

    SV_TYPE_SERVER_NT

    0x00008000 Windows NT non DC server

    SV_TYPE_POTENTIAL_BROWSER

    0x00010000 Server that can run the browser service

    SV_TYPE_BACKUP_BROWSER

    0x00020000 Backup browser server

    SV_TYPE_MASTER_BROWSER

    0x00040000 Master browser server

    SV_TYPE_DOMAIN_MASTER

    0x00080000 Domain Master Browser server

    SV_TYPE_LOCAL_LIST_ONLY

    0x40000000 Enumerate only entries marked "local"

    SV_TYPE_DOMAIN_ENUM

    0x80000000 Enumerate Domains. The pszServer and pszDomain parameters must be NULL.

    UINT32

    500 - platform_id

    VOID*

    pointer to name

    UINT32

    5 - major version

    UINT32

    4 - minor version

    UINT32

    type (SV_TYPE_... bit field)

    VOID*

    pointer to comment

    UNISTR2

    sv101_name - unicode string of server name

    UNISTR2

    sv_101_comment - unicode string of server comment.

    UINT8[]

    padding to get unicode string 4-byte aligned with start of the SMB header.

    MSRPC over Transact Named Pipe

    For details on the SMB Transact Named Pipe, see cifs6.txt

    MSRPC Pipes

    +

    GID (group id info)

    UINT32

    group id

    UINT32

    user attributes (only used by NT 3.1 and 3.51)

    DOM_REF (domain reference info)

    VOID*

    undocumented buffer pointer.

    UINT32

    num referenced domains?

    VOID*

    undocumented domain name buffer pointer.

    UINT32

    32 - max number of entries

    UINT32

    4 - num referenced domains?

    UNIHDR2

    domain name unicode string header

    UNIHDR2[num_ref_doms-1]

    referenced domain unicode string headers

    UNISTR

    domain name unicode string

    DOM_SID[num_ref_doms]

    referenced domain SIDs

    DOM_INFO (domain info, levels 3 and 5 are the same))

    UINT8[]

    ??? padding to get 4-byte alignment with start of SMB header

    UINT16

    domain name string length * 2

    UINT16

    domain name string length * 2

    VOID*

    undocumented domain name string buffer pointer

    VOID*

    undocumented domain SID string buffer pointer

    UNISTR2

    domain name (unicode string)

    DOM_SID

    domain SID

    USER_INFO (user logon info)

    Note: it would be nice to know what the 16 byte user session key is for.

    NTTIME

    logon time

    NTTIME

    logoff time

    NTTIME

    kickoff time

    NTTIME

    password last set time

    NTTIME

    password can change time

    NTTIME

    password must change time

    UNIHDR

    username unicode string header

    UNIHDR

    user's full name unicode string header

    UNIHDR

    logon script unicode string header

    UNIHDR

    profile path unicode string header

    UNIHDR

    home directory unicode string header

    UNIHDR

    home directory drive unicode string header

    UINT16

    logon count

    UINT16

    bad password count

    UINT32

    User ID

    UINT32

    Group ID

    UINT32

    num groups

    VOID*

    undocumented buffer pointer to groups.

    UINT32

    user flags

    char[16]

    user session key

    UNIHDR

    logon server unicode string header

    UNIHDR

    logon domain unicode string header

    VOID*

    undocumented logon domain id pointer

    char[40]

    40 undocumented padding bytes. future expansion?

    UINT32

    0 - num_other_sids?

    VOID*

    NULL - undocumented pointer to other domain SIDs.

    UNISTR2

    username unicode string

    UNISTR2

    user's full name unicode string

    UNISTR2

    logon script unicode string

    UNISTR2

    profile path unicode string

    UNISTR2

    home directory unicode string

    UNISTR2

    home directory drive unicode string

    UINT32

    num groups

    GID[num_groups]

    group info

    UNISTR2

    logon server unicode string

    UNISTR2

    logon domain unicode string

    DOM_SID

    domain SID

    DOM_SID[num_sids]

    other domain SIDs?

    SH_INFO_1_PTR (pointers to level 1 share info strings)

    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.
    VOID*

    shi1_netname - pointer to net name

    UINT32

    shi1_type - type of share. 0 - undocumented.

    VOID*

    shi1_remark - pointer to comment.

    SH_INFO_1_STR (level 1 share info strings)

    UNISTR2

    shi1_netname - unicode string of net name

    UNISTR2

    shi1_remark - unicode string of comment.

    SHARE_INFO_1_CTR

    share container with 0 entries:

    UINT32

    0 - EntriesRead

    UINT32

    0 - Buffer

    share container with > 0 entries:

    UINT32

    EntriesRead

    UINT32

    non-zero - Buffer

    UINT32

    EntriesRead

    SH_INFO_1_PTR[EntriesRead]

    share entry pointers

    SH_INFO_1_STR[EntriesRead]

    share entry strings

    UINT8[]

    padding to get unicode string 4-byte aligned with start of the SMB header.

    UINT32

    EntriesRead

    UINT32

    0 - padding

    SERVER_INFO_101

    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.

    SV_TYPE_WORKSTATION

    0x00000001 All workstations

    SV_TYPE_SERVER

    0x00000002 All servers

    SV_TYPE_SQLSERVER

    0x00000004 Any server running with SQL server

    SV_TYPE_DOMAIN_CTRL

    0x00000008 Primary domain controller

    SV_TYPE_DOMAIN_BAKCTRL

    0x00000010 Backup domain controller

    SV_TYPE_TIME_SOURCE

    0x00000020 Server running the timesource service

    SV_TYPE_AFP

    0x00000040 Apple File Protocol servers

    SV_TYPE_NOVELL

    0x00000080 Novell servers

    SV_TYPE_DOMAIN_MEMBER

    0x00000100 Domain Member

    SV_TYPE_PRINTQ_SERVER

    0x00000200 Server sharing print queue

    SV_TYPE_DIALIN_SERVER

    0x00000400 Server running dialin service.

    SV_TYPE_XENIX_SERVER

    0x00000800 Xenix server

    SV_TYPE_NT

    0x00001000 NT server

    SV_TYPE_WFW

    0x00002000 Server running Windows for

    SV_TYPE_SERVER_NT

    0x00008000 Windows NT non DC server

    SV_TYPE_POTENTIAL_BROWSER

    0x00010000 Server that can run the browser service

    SV_TYPE_BACKUP_BROWSER

    0x00020000 Backup browser server

    SV_TYPE_MASTER_BROWSER

    0x00040000 Master browser server

    SV_TYPE_DOMAIN_MASTER

    0x00080000 Domain Master Browser server

    SV_TYPE_LOCAL_LIST_ONLY

    0x40000000 Enumerate only entries marked "local"

    SV_TYPE_DOMAIN_ENUM

    0x80000000 Enumerate Domains. The pszServer and pszDomain parameters must be NULL.

    UINT32

    500 - platform_id

    VOID*

    pointer to name

    UINT32

    5 - major version

    UINT32

    4 - minor version

    UINT32

    type (SV_TYPE_... bit field)

    VOID*

    pointer to comment

    UNISTR2

    sv101_name - unicode string of server name

    UNISTR2

    sv_101_comment - unicode string of server comment.

    UINT8[]

    padding to get unicode string 4-byte aligned with start of the SMB header.

    MSRPC over Transact Named Pipe

    For details on the SMB Transact Named Pipe, see cifs6.txt

    MSRPC Pipes

    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 @@ -1271,11 +1268,11 @@ 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;
    -

    Header

    [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)

    RPC_Packet for request, response, bind and bind acknowledgement

    UINT8 versionmaj

    reply same as request (0x05)

    UINT8 versionmin

    reply same as request (0x00)

    UINT8 type

    one of the MSRPC_Type enums

    UINT8 flags

    reply same as request (0x00 for Bind, 0x03 for Request)

    UINT32 representation

    reply same as request (0x00000010)

    UINT16 fraglength

    the length of the data section of the SMB trans packet

    UINT16 authlength

    UINT32 callid

    call identifier. (e.g. 0x00149594)

    * stub USE TvPacket

    the remainder of the packet depending on the "type"

    Interface identification

    the interfaces are numbered. as yet I haven't seen more than one interface used on the same pipe name srvsvc

    +

    Header

    [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)

    RPC_Packet for request, response, bind and bind acknowledgement

    UINT8 versionmaj

    reply same as request (0x05)

    UINT8 versionmin

    reply same as request (0x00)

    UINT8 type

    one of the MSRPC_Type enums

    UINT8 flags

    reply same as request (0x00 for Bind, 0x03 for Request)

    UINT32 representation

    reply same as request (0x00000010)

    UINT16 fraglength

    the length of the data section of the SMB trans packet

    UINT16 authlength

    UINT32 callid

    call identifier. (e.g. 0x00149594)

    * stub USE TvPacket

    the remainder of the packet depending on the "type"

    Interface identification

    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)
    -

    RPC_Iface RW

    UINT8 byte[16]

    16 bytes of number

    UINT32 version

    the interface number

    RPC_ReqBind RW

    the remainder of the packet after the header if "type" was Bind in the response header, "type" should be BindAck

    UINT16 maxtsize

    maximum transmission fragment size (0x1630)

    UINT16 maxrsize

    max receive fragment size (0x1630)

    UINT32 assocgid

    associated group id (0x0)

    UINT32 numelements

    the number of elements (0x1)

    UINT16 contextid

    presentation context identifier (0x0)

    UINT8 numsyntaxes

    the number of syntaxes (has always been 1?)(0x1)

    UINT8[]

    4-byte alignment padding, against SMB header

    * abstractint USE RPC_Iface

    num and vers. of interface client is using

    * transferint USE RPC_Iface

    num and vers. of interface to use for replies

    RPC_Address RW

    UINT16 length

    length of the string including null terminator

    * port USE string

    the string above in single byte, null terminated form

    RPC_ResBind RW

    the response to place after the header in the reply packet

    UINT16 maxtsize

    same as request

    UINT16 maxrsize

    same as request

    UINT32 assocgid

    zero

    * secondaddr USE RPC_Address

    the address string, as described earlier

    UINT8[]

    4-byte alignment padding, against SMB header

    UINT8 numresults

    the number of results (0x01)

    UINT8[]

    4-byte alignment padding, against SMB header

    UINT16 result

    result (0x00 = accept)

    UINT16 reason

    reason (0x00 = no reason specified)

    * transfersyntax USE RPC_Iface

    the transfer syntax from the request

    RPC_ReqNorm RW

    the remainder of the packet after the header for every other other request

    UINT32 allochint

    the size of the stub data in bytes

    UINT16 prescontext

    presentation context identifier (0x0)

    UINT16 opnum

    operation number (0x15)

    * stub USE TvPacket

    a packet dependent on the pipe name (probably the interface) and the op number)

    RPC_ResNorm RW

    UINT32 allochint

    # size of the stub data in bytes

    UINT16 prescontext

    # presentation context identifier (same as request)

    UINT8 cancelcount

    # cancel count? (0x0)

    UINT8 reserved

    # 0 - one byte padding

    * stub USE TvPacket

    # the remainder of the reply

    Tail

    The end of each of the NTLSA and NETLOGON named pipes ends with:

    ......

    end of data

    UINT32

    return code

    RPC Bind / Bind Ack

    +

    RPC_Iface RW

    UINT8 byte[16]

    16 bytes of number

    UINT32 version

    the interface number

    RPC_ReqBind RW

    the remainder of the packet after the header if "type" was Bind in the response header, "type" should be BindAck

    UINT16 maxtsize

    maximum transmission fragment size (0x1630)

    UINT16 maxrsize

    max receive fragment size (0x1630)

    UINT32 assocgid

    associated group id (0x0)

    UINT32 numelements

    the number of elements (0x1)

    UINT16 contextid

    presentation context identifier (0x0)

    UINT8 numsyntaxes

    the number of syntaxes (has always been 1?)(0x1)

    UINT8[]

    4-byte alignment padding, against SMB header

    * abstractint USE RPC_Iface

    num and vers. of interface client is using

    * transferint USE RPC_Iface

    num and vers. of interface to use for replies

    RPC_Address RW

    UINT16 length

    length of the string including null terminator

    * port USE string

    the string above in single byte, null terminated form

    RPC_ResBind RW

    the response to place after the header in the reply packet

    UINT16 maxtsize

    same as request

    UINT16 maxrsize

    same as request

    UINT32 assocgid

    zero

    * secondaddr USE RPC_Address

    the address string, as described earlier

    UINT8[]

    4-byte alignment padding, against SMB header

    UINT8 numresults

    the number of results (0x01)

    UINT8[]

    4-byte alignment padding, against SMB header

    UINT16 result

    result (0x00 = accept)

    UINT16 reason

    reason (0x00 = no reason specified)

    * transfersyntax USE RPC_Iface

    the transfer syntax from the request

    RPC_ReqNorm RW

    the remainder of the packet after the header for every other other request

    UINT32 allochint

    the size of the stub data in bytes

    UINT16 prescontext

    presentation context identifier (0x0)

    UINT16 opnum

    operation number (0x15)

    * stub USE TvPacket

    a packet dependent on the pipe name (probably the interface) and the op number)

    RPC_ResNorm RW

    UINT32 allochint

    # size of the stub data in bytes

    UINT16 prescontext

    # presentation context identifier (same as request)

    UINT8 cancelcount

    # cancel count? (0x0)

    UINT8 reserved

    # 0 - one byte padding

    * stub USE TvPacket

    # the remainder of the reply

    Tail

    The end of each of the NTLSA and NETLOGON named pipes ends with:

    ......

    end of data

    UINT32

    return code

    RPC Bind / Bind Ack

    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 this is unknown. @@ -1283,7 +1280,7 @@ this is unknown. 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:

    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

    NTLSA Transact Named Pipe

    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:

    LSA Open Policy:

    0x2c

    LSA Query Info Policy:

    0x07

    LSA Enumerate Trusted Domains:

    0x0d

    LSA Open Secret:

    0xff

    LSA Lookup SIDs:

    0xfe

    LSA Lookup Names:

    0xfd

    LSA Close:

    0x00

    LSA Open Policy

    Note: The policy handle can be anything you like.

    Request

    VOID*

    buffer pointer

    UNISTR2

    server name - unicode string starting with two '\'s

    OBJ_ATTR

    object attributes

    UINT32

    1 - desired access

    Response

    POL_HND

    LSA policy handle

    return

    0 - indicates success

    LSA Query Info Policy

    Note: The info class in response must be the same as that in the request.

    Request

    POL_HND

    LSA policy handle

    UINT16

    info class (also a policy handle?)

    Response

    VOID*

    undocumented buffer pointer

    UINT16

    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

    NTLSA Transact Named Pipe

    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:

    LSA Open Policy:

    0x2c

    LSA Query Info Policy:

    0x07

    LSA Enumerate Trusted Domains:

    0x0d

    LSA Open Secret:

    0xff

    LSA Lookup SIDs:

    0xfe

    LSA Lookup Names:

    0xfd

    LSA Close:

    0x00

    LSA Open Policy

    Note: The policy handle can be anything you like.

    Request

    VOID*

    buffer pointer

    UNISTR2

    server name - unicode string starting with two '\'s

    OBJ_ATTR

    object attributes

    UINT32

    1 - desired access

    Response

    POL_HND

    LSA policy handle

    return

    0 - indicates success

    LSA Query Info Policy

    Note: The info class in response must be the same as that in the request.

    Request

    POL_HND

    LSA policy handle

    UINT16

    info class (also a policy handle?)

    Response

    VOID*

    undocumented buffer pointer

    UINT16

    info class (same as info class in request).

     switch (info class)
     case 3:
     case 5:
    @@ -1292,11 +1289,11 @@ DOM_INFO domain info, levels 3 and 5 (are the same).
     }
     
     return    0 - indicates success
    -

    LSA Enumerate Trusted Domains

    Request

    no extra data

    Response

    UINT32

    0 - enumeration context

    UINT32

    0 - entries read

    UINT32

    0 - trust information

    return

    0x8000 001a - "no trusted domains" success code

    LSA Open Secret

    Request

    no extra data

    Response

    UINT32

    0 - undocumented

    UINT32

    0 - undocumented

    UINT32

    0 - undocumented

    UINT32

    0 - undocumented

    UINT32

    0 - undocumented

    return 0x0C00 0034 - "no such secret" success code

    LSA Close

    Request

    POL_HND

    policy handle to be closed

    Response

    POL_HND

    0s - closed policy handle (all zeros)

    return 0 - indicates success

    LSA Lookup SIDS

    Note: num_entries in response must be same as num_entries in request.

    Request

    POL_HND

    LSA policy handle

    UINT32

    num_entries

    VOID*

    undocumented domain SID buffer pointer

    VOID*

    undocumented domain name buffer pointer

    VOID*[num_entries] undocumented domain SID pointers to be looked up. -

    DOM_SID[num_entries] domain SIDs to be looked up.

    char[16]

    completely undocumented 16 bytes.

    Response

    DOM_REF

    domain reference response

    UINT32

    num_entries (listed above)

    VOID*

    undocumented buffer pointer

    UINT32

    num_entries (listed above)

    DOM_SID2[num_entries]

    domain SIDs (from Request, listed above).

    UINT32

    num_entries (listed above)

    return 0 - indicates success

    LSA Lookup Names

    Note: num_entries in response must be same as num_entries in request.

    Request

    POL_HND

    LSA policy handle

    UINT32

    num_entries

    UINT32

    num_entries

    VOID*

    undocumented domain SID buffer pointer

    VOID*

    undocumented domain name buffer pointer

    NAME[num_entries]

    names to be looked up.

    char[]

    undocumented bytes - falsely translated SID structure?

    Response

    DOM_REF

    domain reference response

    UINT32

    num_entries (listed above)

    VOID*

    undocumented buffer pointer

    UINT32

    num_entries (listed above)

    DOM_RID[num_entries]

    domain SIDs (from Request, listed above).

    UINT32

    num_entries (listed above)

    return 0 - indicates success

    NETLOGON rpc Transact Named Pipe

    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

    LSA Request Challenge:

    0x04

    LSA Server Password Set:

    0x06

    LSA SAM Logon:

    0x02

    LSA SAM Logoff:

    0x03

    LSA Auth 2:

    0x0f

    LSA Logon Control:

    0x0e

    LSA Request Challenge

    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).

    Request

    VOID*

    undocumented buffer pointer

    UNISTR2

    logon server unicode string

    UNISTR2

    logon client unicode string

    char[8]

    client challenge

    Response

    char[8]

    server challenge

    return 0 - indicates success

    LSA Authenticate 2

    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.

    Request

    LOG_INFO

    client identification info

    char[8]

    client-calculated credentials

    UINT8[]

    padding to 4-byte align with start of SMB header.

    UINT32

    neg_flags - negotiated flags (usual value is 0x0000 01ff)

    Response

    char[8]

    server credentials.

    UINT32

    neg_flags - same as neg_flags in request.

    return 0 - indicates success. failure value unknown.

    LSA Server Password Set

    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.

    Request

    CLNT_INFO

    client identification/authentication info

    char[]

    new password - undocumented.

    Response

    CREDS

    server credentials. server time stamp appears to be ignored.

    return 0 - indicates success; 0xC000 006a indicates failure

    LSA SAM Logon

    +

    LSA Enumerate Trusted Domains

    Request

    no extra data

    Response

    UINT32

    0 - enumeration context

    UINT32

    0 - entries read

    UINT32

    0 - trust information

    return

    0x8000 001a - "no trusted domains" success code

    LSA Open Secret

    Request

    no extra data

    Response

    UINT32

    0 - undocumented

    UINT32

    0 - undocumented

    UINT32

    0 - undocumented

    UINT32

    0 - undocumented

    UINT32

    0 - undocumented

    return 0x0C00 0034 - "no such secret" success code

    LSA Close

    Request

    POL_HND

    policy handle to be closed

    Response

    POL_HND

    0s - closed policy handle (all zeros)

    return 0 - indicates success

    LSA Lookup SIDS

    Note: num_entries in response must be same as num_entries in request.

    Request

    POL_HND

    LSA policy handle

    UINT32

    num_entries

    VOID*

    undocumented domain SID buffer pointer

    VOID*

    undocumented domain name buffer pointer

    VOID*[num_entries] undocumented domain SID pointers to be looked up. +

    DOM_SID[num_entries] domain SIDs to be looked up.

    char[16]

    completely undocumented 16 bytes.

    Response

    DOM_REF

    domain reference response

    UINT32

    num_entries (listed above)

    VOID*

    undocumented buffer pointer

    UINT32

    num_entries (listed above)

    DOM_SID2[num_entries]

    domain SIDs (from Request, listed above).

    UINT32

    num_entries (listed above)

    return 0 - indicates success

    LSA Lookup Names

    Note: num_entries in response must be same as num_entries in request.

    Request

    POL_HND

    LSA policy handle

    UINT32

    num_entries

    UINT32

    num_entries

    VOID*

    undocumented domain SID buffer pointer

    VOID*

    undocumented domain name buffer pointer

    NAME[num_entries]

    names to be looked up.

    char[]

    undocumented bytes - falsely translated SID structure?

    Response

    DOM_REF

    domain reference response

    UINT32

    num_entries (listed above)

    VOID*

    undocumented buffer pointer

    UINT32

    num_entries (listed above)

    DOM_RID[num_entries]

    domain SIDs (from Request, listed above).

    UINT32

    num_entries (listed above)

    return 0 - indicates success

    NETLOGON rpc Transact Named Pipe

    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

    LSA Request Challenge:

    0x04

    LSA Server Password Set:

    0x06

    LSA SAM Logon:

    0x02

    LSA SAM Logoff:

    0x03

    LSA Auth 2:

    0x0f

    LSA Logon Control:

    0x0e

    LSA Request Challenge

    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).

    Request

    VOID*

    undocumented buffer pointer

    UNISTR2

    logon server unicode string

    UNISTR2

    logon client unicode string

    char[8]

    client challenge

    Response

    char[8]

    server challenge

    return 0 - indicates success

    LSA Authenticate 2

    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.

    Request

    LOG_INFO

    client identification info

    char[8]

    client-calculated credentials

    UINT8[]

    padding to 4-byte align with start of SMB header.

    UINT32

    neg_flags - negotiated flags (usual value is 0x0000 01ff)

    Response

    char[8]

    server credentials.

    UINT32

    neg_flags - same as neg_flags in request.

    return 0 - indicates success. failure value unknown.

    LSA Server Password Set

    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.

    Request

    CLNT_INFO

    client identification/authentication info

    char[]

    new password - undocumented.

    Response

    CREDS

    server credentials. server time stamp appears to be ignored.

    return 0 - indicates success; 0xC000 006a indicates failure

    LSA SAM Logon

    Note: valid_user is True iff the username and password hash are valid for the requested domain. -

    Request

    SAM_INFO

    sam_id structure

    Response

    VOID*

    undocumented buffer pointer

    CREDS

    server credentials. server time stamp appears to be ignored.

    +

    Request

    SAM_INFO

    sam_id structure

    Response

    VOID*

    undocumented buffer pointer

    CREDS

    server credentials. server time stamp appears to be ignored.

     if (valid_user)
     {
     	UINT16      3 - switch value indicating USER_INFO structure.
    @@ -1316,16 +1313,16 @@ else
     
         return    0xC000 0064 - NT_STATUS_NO_SUCH_USER.
     }
    -

    LSA SAM Logoff

    +

    LSA SAM Logoff

    Note: presumably, the SAM_INFO structure is validated, and a (currently undocumented) error code returned if the Logoff is invalid. -

    Request

    SAM_INFO

    sam_id structure

    Response

    VOID*

    undocumented buffer pointer

    CREDS

    server credentials. server time stamp appears to be ignored.

    return 0 - indicates success. undocumented failure indication.

    \\MAILSLOT\NET\NTLOGON

    +

    Request

    SAM_INFO

    sam_id structure

    Response

    VOID*

    undocumented buffer pointer

    CREDS

    server credentials. server time stamp appears to be ignored.

    return 0 - indicates success. undocumented failure indication.

    \\MAILSLOT\NET\NTLOGON

    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. -

    Query for PDC

    Note: NTversion, LMNTtoken, LM20token in response are the same as those given in the request.

    Request

    UINT16

    0x0007 - Query for PDC

    STR

    machine name

    STR

    response mailslot

    UINT8[]

    padding to 2-byte align with start of mailslot.

    UNISTR

    machine name

    UINT32

    NTversion

    UINT16

    LMNTtoken

    UINT16

    LM20token

    Response

    UINT16

    0x000A - Respose to Query for PDC

    STR

    machine name (in uppercase)

    UINT8[]

    padding to 2-byte align with start of mailslot.

    UNISTR

    machine name

    UNISTR

    domain name

    UINT32

    NTversion (same as received in request)

    UINT16

    LMNTtoken (same as received in request)

    UINT16

    LM20token (same as received in request)

    SAM Logon

    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.

    Request

    UINT16

    0x0012 - SAM Logon

    UINT16

    request count

    UNISTR

    machine name

    UNISTR

    user name

    STR

    response mailslot

    UINT32

    alloweable account

    UINT32

    domain SID size

    char[sid_size]

    domain SID, of sid_size bytes.

    UINT8[]

    ???? padding to 4? 2? -byte align with start of mailslot.

    UINT32

    NTversion

    UINT16

    LMNTtoken

    UINT16

    LM20token

    Response

    UINT16

    0x0013 - Response to SAM Logon

    UNISTR

    machine name

    UNISTR

    user name - workstation trust account

    UNISTR

    domain name

    UINT32

    NTversion

    UINT16

    LMNTtoken

    UINT16

    LM20token

    SRVSVC Transact Named Pipe

    Defines for this pipe, identifying the query are:

    Net Share Enum

    0x0f

    Net Server Get Info

    0x15

    Net Share Enum

    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.

    Request

    VOID*

    pointer (to server name?)

    UNISTR2

    server name

    UINT8[]

    padding to get unicode string 4-byte aligned with the start of the SMB header.

    UINT32

    share level

    UINT32

    switch value

    VOID*

    pointer to SHARE_INFO_1_CTR

    SHARE_INFO_1_CTR

    share info with 0 entries

    UINT32

    preferred maximum length (0xffff ffff)

    Response

    UINT32

    share level

    UINT32

    switch value

    VOID*

    pointer to SHARE_INFO_1_CTR

    SHARE_INFO_1_CTR

    share info (only added if share info ptr is non-zero)

    return 0 - indicates success

    Net Server Get Info

    Note: level is the same value as in the request.

    Request

    UNISTR2

    server name

    UINT32

    switch level

    Response

    UINT32

    switch level

    VOID*

    pointer to SERVER_INFO_101

    SERVER_INFO_101

    server info (only added if server info ptr is non-zero)

    return 0 - indicates success

    Cryptographic side of NT Domain Authentication

    Definitions

    Add(A1,A2)

    Intel byte ordered addition of corresponding 4 byte words in arrays A1 and A2

    E(K,D)

    DES ECB encryption of 8 byte data D using 7 byte key K

    lmowf()

    Lan man hash

    ntowf()

    NT hash

    PW

    md4(machine_password) == md4(lsadump $machine.acc) == +

    Query for PDC

    Note: NTversion, LMNTtoken, LM20token in response are the same as those given in the request.

    Request

    UINT16

    0x0007 - Query for PDC

    STR

    machine name

    STR

    response mailslot

    UINT8[]

    padding to 2-byte align with start of mailslot.

    UNISTR

    machine name

    UINT32

    NTversion

    UINT16

    LMNTtoken

    UINT16

    LM20token

    Response

    UINT16

    0x000A - Respose to Query for PDC

    STR

    machine name (in uppercase)

    UINT8[]

    padding to 2-byte align with start of mailslot.

    UNISTR

    machine name

    UNISTR

    domain name

    UINT32

    NTversion (same as received in request)

    UINT16

    LMNTtoken (same as received in request)

    UINT16

    LM20token (same as received in request)

    SAM Logon

    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.

    Request

    UINT16

    0x0012 - SAM Logon

    UINT16

    request count

    UNISTR

    machine name

    UNISTR

    user name

    STR

    response mailslot

    UINT32

    alloweable account

    UINT32

    domain SID size

    char[sid_size]

    domain SID, of sid_size bytes.

    UINT8[]

    ???? padding to 4? 2? -byte align with start of mailslot.

    UINT32

    NTversion

    UINT16

    LMNTtoken

    UINT16

    LM20token

    Response

    UINT16

    0x0013 - Response to SAM Logon

    UNISTR

    machine name

    UNISTR

    user name - workstation trust account

    UNISTR

    domain name

    UINT32

    NTversion

    UINT16

    LMNTtoken

    UINT16

    LM20token

    SRVSVC Transact Named Pipe

    Defines for this pipe, identifying the query are:

    Net Share Enum

    0x0f

    Net Server Get Info

    0x15

    Net Share Enum

    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.

    Request

    VOID*

    pointer (to server name?)

    UNISTR2

    server name

    UINT8[]

    padding to get unicode string 4-byte aligned with the start of the SMB header.

    UINT32

    share level

    UINT32

    switch value

    VOID*

    pointer to SHARE_INFO_1_CTR

    SHARE_INFO_1_CTR

    share info with 0 entries

    UINT32

    preferred maximum length (0xffff ffff)

    Response

    UINT32

    share level

    UINT32

    switch value

    VOID*

    pointer to SHARE_INFO_1_CTR

    SHARE_INFO_1_CTR

    share info (only added if share info ptr is non-zero)

    return 0 - indicates success

    Net Server Get Info

    Note: level is the same value as in the request.

    Request

    UNISTR2

    server name

    UINT32

    switch level

    Response

    UINT32

    switch level

    VOID*

    pointer to SERVER_INFO_101

    SERVER_INFO_101

    server info (only added if server info ptr is non-zero)

    return 0 - indicates success

    Cryptographic side of NT Domain Authentication

    Definitions

    Add(A1,A2)

    Intel byte ordered addition of corresponding 4 byte words in arrays A1 and A2

    E(K,D)

    DES ECB encryption of 8 byte data D using 7 byte key K

    lmowf()

    Lan man hash

    ntowf()

    NT hash

    PW

    md4(machine_password) == md4(lsadump $machine.acc) == pwdump(machine$) (initially) == md4(lmowf(unicode(machine))) -

    ARC4(K,Lk,D,Ld)

    ARC4 encryption of data D of length Ld with key K of length Lk

    v[m..n(,l)]

    subset of v from bytes m to n, optionally padded with zeroes to length l

    Cred(K,D)

    E(K[7..7,7],E(K[0..6],D)) computes a credential

    Time()

    4 byte current time

    Cc,Cs

    8 byte client and server challenges Rc,Rs: 8 byte client and server credentials

    Protocol

    +

    ARC4(K,Lk,D,Ld)

    ARC4 encryption of data D of length Ld with key K of length Lk

    v[m..n(,l)]

    subset of v from bytes m to n, optionally padded with zeroes to length l

    Cred(K,D)

    E(K[7..7,7],E(K[0..6],D)) computes a credential

    Time()

    4 byte current time

    Cc,Cs

    8 byte client and server challenges Rc,Rs: 8 byte client and server credentials

    Protocol

     C->S ReqChal,Cc
     S->C Cs
     
    @@ -1361,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)
    -

    Comments

    +

    Comments

    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 @@ -1382,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

    +

    SIDs and RIDs

    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). -

    Well-known SIDs

    Universal well-known SIDs

    Null SID

    S-1-0-0

    World

    S-1-1-0

    Local

    S-1-2-0

    Creator Owner ID

    S-1-3-0

    Creator Group ID

    S-1-3-1

    Creator Owner Server ID

    S-1-3-2

    Creator Group Server ID

    S-1-3-3

    (Non-unique IDs)

    S-1-4

    NT well-known SIDs

    NT Authority

    S-1-5

    Dialup

    S-1-5-1

    Network

    S-1-5-2

    Batch

    S-1-5-3

    Interactive

    S-1-5-4

    Service

    S-1-5-6

    AnonymousLogon(aka null logon session)

    S-1-5-7

    Proxy

    S-1-5-8

    ServerLogon(aka domain controller account)

    S-1-5-8

    (Logon IDs)

    S-1-5-5-X-Y

    (NT non-unique IDs)

    S-1-5-0x15-...

    (Built-in domain)

    s-1-5-0x20

    Well-known RIDS

    +

    Well-known SIDs

    Universal well-known SIDs

    Null SID

    S-1-0-0

    World

    S-1-1-0

    Local

    S-1-2-0

    Creator Owner ID

    S-1-3-0

    Creator Group ID

    S-1-3-1

    Creator Owner Server ID

    S-1-3-2

    Creator Group Server ID

    S-1-3-3

    (Non-unique IDs)

    S-1-4

    NT well-known SIDs

    NT Authority

    S-1-5

    Dialup

    S-1-5-1

    Network

    S-1-5-2

    Batch

    S-1-5-3

    Interactive

    S-1-5-4

    Service

    S-1-5-6

    AnonymousLogon(aka null logon session)

    S-1-5-7

    Proxy

    S-1-5-8

    ServerLogon(aka domain controller account)

    S-1-5-8

    (Logon IDs)

    S-1-5-5-X-Y

    (NT non-unique IDs)

    S-1-5-0x15-...

    (Built-in domain)

    s-1-5-0x20

    Well-known RIDS

    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. -

    Well-known RID users

    Groupname: DOMAIN_USER_RID_ADMIN

    ????: 0x0000

    RID: 01F4

    Groupname: DOMAIN_USER_RID_GUEST

    ????: 0x0000

    RID: 01F5

    Well-known RID groups

    Groupname: DOMAIN_GROUP_RID_ADMINS

    ????: 0x0000

    RID: 0200

    Groupname: DOMAIN_GROUP_RID_USERS

    ????: 0x0000

    RID: 0201

    Groupname: DOMAIN_GROUP_RID_GUESTS

    ????: 0x0000

    RID: 0202

    Well-known RID aliases

    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

    Chapter 11. Samba Printing Internals

    Gerald Carter

    October 2002

    Table of Contents

    Abstract
    +

    Well-known RID users

    Groupname: DOMAIN_USER_RID_ADMIN

    ????: 0x0000

    RID: 01F4

    Groupname: DOMAIN_USER_RID_GUEST

    ????: 0x0000

    RID: 01F5

    Well-known RID groups

    Groupname: DOMAIN_GROUP_RID_ADMINS

    ????: 0x0000

    RID: 0200

    Groupname: DOMAIN_GROUP_RID_USERS

    ????: 0x0000

    RID: 0201

    Groupname: DOMAIN_GROUP_RID_GUESTS

    ????: 0x0000

    RID: 0202

    Well-known RID aliases

    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

    Chapter 11. Samba Printing Internals

    Gerald Carter

    October 2002

    Abstract

    +

    Abstract

    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. -

    +

    Printing Interface to Various Back ends

    Samba uses a table of function pointers to seven functions. The @@ -1416,7 +1413,7 @@ 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).

    + the CUPS libraries were located at compile time).

    Print Queue TDB's

    Samba provides periodic caching of the output from the "lpq command" @@ -1505,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. -

    +

    ChangeID and Client Caching of Printer Information

    [To be filled in later] -

    +

    Windows NT/2K Printer Change Notify

    When working with Windows NT+ clients, it is possible for a @@ -1607,7 +1604,7 @@ 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.

  • Chapter 12. Samba WINS Internals

    Gerald Carter

    October 2002

    Table of Contents

    WINS Failover

    WINS Failover

    +data values.

    Chapter 12. Samba WINS Internals

    Gerald Carter

    October 2002

    Table of Contents

    WINS Failover

    WINS Failover

    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 @@ -1649,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. -

    Chapter 13. The Upcoming SAM System

    Andrew Bartlett

    1 October 2002

    Security in the 'new SAM'

    One of the biggest problems with passdb is it's implementation of +

    Chapter 13. The Upcoming SAM System

    Andrew Bartlett

    1 October 2002

    Security in the 'new SAM'

    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 @@ -1709,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. -

    Standalone from UNIX

    +

    Standalone from UNIX

    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 @@ -1719,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. -

    Handles and Races in the new SAM

    +

    Handles and Races in the new SAM

    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, @@ -1744,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. -

    Layers

    Application

    +

    Layers

    Application

    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. -

    SAM Interface

    +

    SAM Interface

    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, @@ -1759,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. -

    SAM Modules

    +

    SAM 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 @@ -1767,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. -

    SAM Modules

    Special Module: sam_passdb

    +

    SAM Modules

    Special Module: sam_passdb

    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. -

    sam_ads

    +

    sam_ads

    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 @@ -1785,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. -

    Memory Management

    +

    Memory Management

    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 @@ -1814,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

    +

    Testing

    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. @@ -1831,25 +1828,25 @@ already proved vital in testing. I expect SAM module authors will find it particularly valuable.

    Example useage:

    $ bin/samtest

     > context ads:ldap://192.168.1.96
    -
    +

    (this loads a new context, using the new ADS module. The parameter is the 'location' of the ldap server) -

    +

     > lookup_name DOMAIN abartlet
    -
    +

    (returns a sid). -

    +

    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.

    Chapter 14. LanMan and NT Password Encryption

    Jeremy Allison

    Samba Team

    19 Apr 1999

    Introduction

    With the development of LanManager and Windows NT +

    19 Apr 1999

    Introduction

    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.

    How does it work?

    LanManager encryption is somewhat similar to UNIX + the part about security and the "PROS and CONS" section.

    How does it work?

    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 @@ -1886,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.

    The smbpasswd file

    In order for Samba to participate in the above protocol + are never transmitted over the network - thus increasing security.

    The smbpasswd file

    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 @@ -1943,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.

    Chapter 15. Modules

    Jelmer Vernooij

    Samba Team

    19 March 2003

    Advantages

    + sensitive than a normal unix /etc/passwd file.

    Chapter 15. Modules

    Jelmer Vernooij

    Samba Team

    19 March 2003

    Advantages

    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)

    Loading modules

    +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 modulesNo nasty #define stuff anymoreAll backends are available as plugin now (including pdb_ldap and pdb_tdb)

    Loading 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, @@ -1956,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. -

    Static modules

    +

    Static modules

    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): @@ -1966,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. -

    Shared modules

    +

    Shared modules

    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). @@ -1976,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. -

    Writing modules

    +

    Writing modules

    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: @@ -1991,7 +1988,7 @@ smb_register_passdb(PASSDB_INTERFACE_VERSION, "ldapsam", pdb_init_ldap smb_register_passdb(PASSDB_INTERFACE_VERSION, "ldapsam_nua", pdb_init_ldapsam_nua); return NT_STATUS_OK; } -

    Static/Shared selection in configure.in

    +

    Static/Shared selection in configure.in

    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'. @@ -2010,13 +2007,13 @@ be replaced with the names of the plugins to build.

    You must make sure all .c files that contain defines that can be changed by ./configure are rebuilded in the 'modules_clean' make target. Practically, this means all c files that contain static_init_subsystem; calls need to be rebuilded. -

    Chapter 16. RPC Pluggable Modules

    Anthony Liguori

    Jelmer Vernooij

    Samba Team

    January 2003

    Table of Contents

    About
    General Overview

    About

    +

    Chapter 16. RPC Pluggable Modules

    Anthony Liguori

    Jelmer Vernooij

    Samba Team

    January 2003

    Table of Contents

    About
    General Overview

    About

    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. -

    General Overview

    +

    General Overview

    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 @@ -2033,7 +2030,7 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *s argument.

    clnt

    the Client name of the named pipe

    srv

    the Server name of the named pipe

    cmds

    a list of api_structs that map RPC ordinal numbers to function calls

    size

    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. -

    Chapter 17. VFS Modules

    Alexander Bokovoy

    Stefan Metzmacher

    27 May 2003

    The Samba (Posix) VFS layer

    The general interface

    +

    Chapter 17. VFS Modules

    Alexander Bokovoy

    Stefan Metzmacher

    27 May 2003

    The Samba (Posix) VFS layer

    The general interface

    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.) @@ -2056,7 +2053,7 @@ typedef enum _vfs_op_type { SMB_VFS_OP_LAST } vfs_op_type; -This struct contains the function and handle pointers for all operations.

    +

    This struct contains the function and handle pointers for all operations.

     struct vfs_ops {
     	struct vfs_fn_pointers {
     		...
    @@ -2098,10 +2095,10 @@ struct vfs_ops {
     		...
     	} handles;
     };
    -
    +

    This macros SHOULD be used to call any vfs operation. DO NOT ACCESS conn->vfs.ops.* directly !!! -

    +

     ...
     	
     /* File operations */
    @@ -2129,7 +2126,7 @@ DO NOT ACCESS conn->vfs.ops.* directly !!!
     	 (tofd), (fsp), (fromfd), (header), (offset), (count)))
     
     ...
    -

    Possible VFS operation layers

    +

    Possible VFS operation layers

    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. @@ -2158,19 +2155,19 @@ 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; -

    The Interaction between the Samba VFS subsystem and the modules

    Initialization and registration

    +

    The Interaction between the Samba VFS subsystem and the modules

    Initialization and registration

    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. -

    +

    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. +

    This should be the only non static function inside the module. Global variables should also be static! -

    +

    The module should register its functions via the -

    +

     NTSTATUS smb_register_vfs(int version, const char *name, vfs_op_tuple *vfs_op_tuples);
    -
    function. -
    version

    should be filled with SMB_VFS_INTERFACE_VERSION

    name

    this is the name witch can be listed in the +

    function. +

    version

    should be filled with SMB_VFS_INTERFACE_VERSION

    name

    this is the name witch can be listed in the vfs objects parameter to use this module.

    vfs_op_tuples

    this is an array of vfs_op_tuple's. (vfs_op_tuples is descripted in details below.) @@ -2198,7 +2195,7 @@ NTSTATUS init_module(void) { return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "example", example_op_tuples); } -

    How the Modules handle per connection data

    Each VFS function has as first parameter a pointer to the modules vfs_handle_struct. +

    How the Modules handle per connection data

    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;
    @@ -2299,7 +2296,7 @@ you can set this function pointer to NULL.

    Some useful MAC (handle)->vfs_next.handles.sendfile,\ (tofd), (fsp), (fromfd), (header), (offset), (count))) ... -

    Upgrading to the New VFS Interface

    Upgrading from 2.2.* and 3.0aplha modules

    1. +

    Upgrading to the New VFS Interface

    Upgrading from 2.2.* and 3.0aplha modules

    1. 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); @@ -2315,12 +2312,12 @@ e.g. smb_vfs_next_connect(conn, service, user); 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); -

    2. +

    3. (Only for 2.2.* modules) Convert the old struct vfs_ops example_ops to a vfs_op_tuple example_op_tuples[] array. e.g. -

      +

       struct vfs_ops example_ops = {
       	/* Disk operations */
       	example_connect,		/* connect */
      @@ -2390,9 +2387,9 @@ struct vfs_ops example_ops = {
       	NULL,				/* sys_acl_free_acl */
       	NULL				/* sys_acl_free_qualifier */
       };
      -
      +

      -> -

       
      +

       
       static vfs_op_tuple example_op_tuples[] = {
       	{SMB_VFS_OP(example_connect),	SMB_VFS_OP_CONNECT,	SMB_VFS_LAYER_TRANSPARENT},
       	{SMB_VFS_OP(example_disconnect),	SMB_VFS_OP_DISCONNECT,	SMB_VFS_LAYER_TRANSPARENT},
      @@ -2403,42 +2400,42 @@ static vfs_op_tuple example_op_tuples[] = {
       
       	{SMB_VFS_OP(NULL),				SMB_VFS_OP_NOOP,	SMB_VFS_LAYER_NOOP}
       };
      -
      -
    4. +

      +

    5. Move the example_op_tuples[] array to the end of the file. -

    6. +

    7. Add the init_module() function at the end of the file. e.g. -

      +

       NTSTATUS init_module(void)
       {
       	return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,"example",example_op_tuples);
       }
      -
      -
    8. +

      +

    9. Check if your vfs_init() function does more then just prepare the vfs_ops structs or remember the struct smb_vfs_handle_struct. -
      If NOT you can remove the vfs_init() function.
      If YES decide if you want to move the code to the example_connect() operation or to the init_module(). And then remove vfs_init(). - e.g. a debug class registration should go into init_module() and the allocation of private data should go to example_connect().
      -

    10. +

      If NOT you can remove the vfs_init() function.
      If YES decide if you want to move the code to the example_connect() operation or to the init_module(). And then remove vfs_init(). + e.g. a debug class registration should go into init_module() and the allocation of private data should go to example_connect().

      +

    11. (Only for 3.0alpha* modules) Check if your vfs_done() function contains needed code. -
      If NOT you can remove the vfs_done() function.
      If YES decide if you can move the code to the example_disconnect() operation. Otherwise register a SMB_EXIT_EVENT with smb_register_exit_event(); (Described in the modules section) And then remove vfs_done(). e.g. the freeing of private data should go to example_disconnect(). -
      -

    12. +

      If NOT you can remove the vfs_done() function.
      If YES decide if you can move the code to the example_disconnect() operation. Otherwise register a SMB_EXIT_EVENT with smb_register_exit_event(); (Described in the modules section) And then remove vfs_done(). e.g. the freeing of private data should go to example_disconnect(). +

      +

    13. Check if you have any global variables left. Decide if it wouldn't be better to have this data on a connection basis. -
      If NOT leave them as they are. (e.g. this could be the variable for the private debug class.)
      If YES pack all this data into a struct. You can use handle->data to point to such a struct on a per connection basis.
      +

      If NOT leave them as they are. (e.g. this could be the variable for the private debug class.)
      If YES pack all this data into a struct. You can use handle->data to point to such a struct on a per connection basis.

      e.g. if you have such a struct: -

          
      +

          
       struct example_privates {
       	char *some_string;
       	int db_connection;
       };
      -
      +

      first way of doing it: -

      +

       static int example_connect(vfs_handle_struct *handle,
       	connection_struct *conn, const char *service, 
       	const char* user)
      @@ -2485,9 +2482,9 @@ static int example_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
       	
       	return SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
       }
      -
      +

      second way of doing it: -

      +

       static void free_example_privates(void **datap)
       {
       	struct example_privates *data = (struct example_privates *)*datap;
      @@ -2545,8 +2542,8 @@ static int example_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
       	
       	return SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
       }
      -
      -
    14. +

      +

    15. To make it easy to build 3rd party modules it would be usefull to provide configure.in, (configure), install.sh and Makefile.in with the module. (Take a look at the example in examples/VFS.) @@ -2559,21 +2556,21 @@ give you more warnings. The idea is that you can extend this configure.in and Makefile.in scripts for your module. -

    16. +

    17. Compiling & Testing... -
      ./configure --enable-developer ...
      make
      Try to fix all compiler warnings
      make
      Testing, Testing, Testing ...
      -

    Some Notes

    Implement TRANSPARENT functions

    +

    ./configure --enable-developer ...
    make
    Try to fix all compiler warnings
    make
    Testing, Testing, Testing ...

    +

    Some Notes

    Implement TRANSPARENT functions

    Avoid writing functions like this: -

    +

     static int example_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
     {
     	return SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
     }
    -
    +

    Overload only the functions you really need to! -

    Implement OPAQUE functions

    +

    Implement OPAQUE functions

    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) @@ -2593,12 +2590,12 @@ static int example_rename(vfs_handle_struct *handle, connection_struct *conn, errno = ENOSYS; return -1; } -

    Chapter 18. Notes to packagers

    Jelmer Vernooij

    Table of Contents

    Versioning
    Modules

    Versioning

    Please, please update the version number in +

    Chapter 18. Notes to packagers

    Jelmer Vernooij

    Table of Contents

    Versioning
    Modules

    Versioning

    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
    -

    Modules

    Samba now has support for building parts of samba as plugins. This +

    Modules

    Samba now has support for building parts of samba as plugins. This makes it possible to, for example, put ldap or mysql support in a seperate package, thus making it possible to have a normal samba package not depending on ldap or mysql. To build as much parts of samba @@ -2621,8 +2618,8 @@ as a plugin, run:

     			e.g. files generated by diff -u. 
     		

    If you are modifying a copy of samba you retrieved from CVS, you can easily generate a diff file of these changes by running - cvs diff -u.

    Points of attention when modifying samba source code
    -
    Don't simply copy code from other places and modify it until it + cvs diff -u.

    Points of attention when modifying samba source code

    +

    Don't simply copy code from other places and modify it until it works. Code needs to be clean and logical. Duplicate code is to be avoided.
    Test your patch. It might take a while before one of us looks at your patch so it will take longer before your patch when your patch @@ -2630,8 +2627,8 @@ as a plugin, run:

     		it harder to read, understand and test the patch. You might 
     		also risk not getting a good patch committed because you mixed it 
     		with one that had issues. 
    Make sure your patch complies to the samba coding style as - suggested in the coding-suggestions chapter.
    -
    Sending in bugfixes

    Bugfixes to bugs in samba should be submitted to samba's + suggested in the coding-suggestions chapter.

    +

    Sending in bugfixes

    Bugfixes to bugs in samba should be submitted to samba's bugzilla system, along with a description of the bug.

    Sending in feature patches

    Send feature patches along with a description of what the -- cgit