diff options
Diffstat (limited to 'docs/htmldocs/Samba-Developers-Guide.html')
-rw-r--r-- | docs/htmldocs/Samba-Developers-Guide.html | 10356 |
1 files changed, 1313 insertions, 9043 deletions
diff --git a/docs/htmldocs/Samba-Developers-Guide.html b/docs/htmldocs/Samba-Developers-Guide.html index 142d9dc537..cc12fe60f8 100644 --- a/docs/htmldocs/Samba-Developers-Guide.html +++ b/docs/htmldocs/Samba-Developers-Guide.html @@ -1,1176 +1,176 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<HTML -><HEAD -><TITLE ->SAMBA Developers Guide</TITLE -><META -NAME="GENERATOR" -CONTENT="Modular DocBook HTML Stylesheet Version 1.7"></HEAD -><BODY -CLASS="BOOK" -BGCOLOR="#FFFFFF" -TEXT="#000000" -LINK="#0000FF" -VLINK="#840084" -ALINK="#0000FF" -><DIV -CLASS="BOOK" -><A -NAME="SAMBA-DEVELOPERS-GUIDE" -></A -><DIV -CLASS="TITLEPAGE" -><H1 -CLASS="TITLE" -><A -NAME="SAMBA-DEVELOPERS-GUIDE" ->SAMBA Developers Guide</A -></H1 -><H3 -CLASS="AUTHOR" -><A -NAME="AEN4" -></A ->SAMBA Team</H3 -><HR></DIV -><HR><H1 -><A -NAME="AEN8" -></A ->Abstract</H1 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Last Update</I -></SPAN -> : Mon Sep 30 15:23:53 CDT 2002</P -><P ->This book is a collection of documents that might be useful for +<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>SAMBA Developers Guide</title><link rel="stylesheet" href="samba.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.59.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" lang="en"><div class="titlepage"><div><h1 class="title"><a name="Samba-Developers-Guide"></a>SAMBA Developers Guide</h1></div><div><div class="author"><h3 class="author">SAMBA Team</h3></div></div><hr></div><div class="dedication" lang="en"><div class="titlepage"><div><h2 class="title"><a name="id2791718"></a>Abstract</h2></div></div><p> +<span class="emphasis"><em>Last Update</em></span> : Mon Sep 30 15:23:53 CDT 2002 +</p><p> +This book is a collection of documents that might be useful for people developing samba or those interested in doing so. It's nothing more than a collection of documents written by samba developers about the internals of various parts of samba and the SMB protocol. It's still incomplete. The most recent version of this document -can be found at <A -HREF="http://devel.samba.org/" -TARGET="_top" ->http://devel.samba.org/</A ->. -Please send updates to <A -HREF="mailto:jelmer@samba.org" -TARGET="_top" ->jelmer@samba.org</A ->.</P -><P ->This documentation is distributed under the GNU General Public License (GPL) +can be found at <a href="http://devel.samba.org/" target="_top">http://devel.samba.org/</a>. +Please send updates to <a href="mailto:jelmer@samba.org" target="_top">Jelmer Veenrooij</a>. +</p><p> +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 <A -HREF="http://www.fsf.org/licenses/gpl.txt" -TARGET="_top" ->http://www.fsf.org/licenses/gpl.txt</A -></P -><DIV -CLASS="TOC" -><DL -><DT -><B ->Table of Contents</B -></DT -><DT ->1. <A -HREF="#NETBIOS" ->Definition of NetBIOS Protocol and Name Resolution Modes</A -></DT -><DD -><DL -><DT ->1.1. <A -HREF="#AEN24" ->NETBIOS</A -></DT -><DT ->1.2. <A -HREF="#AEN35" ->BROADCAST NetBIOS</A -></DT -><DT ->1.3. <A -HREF="#AEN39" ->NBNS NetBIOS</A -></DT -></DL -></DD -><DT ->2. <A -HREF="#ARCHITECTURE" ->Samba Architecture</A -></DT -><DD -><DL -><DT ->2.1. <A -HREF="#AEN54" ->Introduction</A -></DT -><DT ->2.2. <A -HREF="#AEN65" ->Multithreading and Samba</A -></DT -><DT ->2.3. <A -HREF="#AEN70" ->Threading smbd</A -></DT -><DT ->2.4. <A -HREF="#AEN86" ->Threading nmbd</A -></DT -><DT ->2.5. <A -HREF="#AEN92" ->nbmd Design</A -></DT -></DL -></DD -><DT ->3. <A -HREF="#DEBUG" ->The samba DEBUG system</A -></DT -><DD -><DL -><DT ->3.1. <A -HREF="#AEN103" ->New Output Syntax</A -></DT -><DT ->3.2. <A -HREF="#AEN128" ->The DEBUG() Macro</A -></DT -><DT ->3.3. <A -HREF="#AEN151" ->The DEBUGADD() Macro</A -></DT -><DT ->3.4. <A -HREF="#AEN159" ->The DEBUGLVL() Macro</A -></DT -><DT ->3.5. <A -HREF="#AEN179" ->New Functions</A -></DT -><DD -><DL -><DT ->3.5.1. <A -HREF="#AEN181" ->dbgtext()</A -></DT -><DT ->3.5.2. <A -HREF="#AEN184" ->dbghdr()</A -></DT -><DT ->3.5.3. <A -HREF="#AEN188" ->format_debug_text()</A -></DT -></DL -></DD -></DL -></DD -><DT ->4. <A -HREF="#CODINGSUGGESTIONS" ->Coding Suggestions</A -></DT -><DT ->5. <A -HREF="#INTERNALS" ->Samba Internals</A -></DT -><DD -><DL -><DT ->5.1. <A -HREF="#AEN284" ->Character Handling</A -></DT -><DT ->5.2. <A -HREF="#AEN288" ->The new functions</A -></DT -><DT ->5.3. <A -HREF="#AEN317" ->Macros in byteorder.h</A -></DT -><DD -><DL -><DT ->5.3.1. <A -HREF="#AEN320" ->CVAL(buf,pos)</A -></DT -><DT ->5.3.2. <A -HREF="#AEN323" ->PVAL(buf,pos)</A -></DT -><DT ->5.3.3. <A -HREF="#AEN326" ->SCVAL(buf,pos,val)</A -></DT -><DT ->5.3.4. <A -HREF="#AEN329" ->SVAL(buf,pos)</A -></DT -><DT ->5.3.5. <A -HREF="#AEN332" ->IVAL(buf,pos)</A -></DT -><DT ->5.3.6. <A -HREF="#AEN335" ->SVALS(buf,pos)</A -></DT -><DT ->5.3.7. <A -HREF="#AEN338" ->IVALS(buf,pos)</A -></DT -><DT ->5.3.8. <A -HREF="#AEN341" ->SSVAL(buf,pos,val)</A -></DT -><DT ->5.3.9. <A -HREF="#AEN344" ->SIVAL(buf,pos,val)</A -></DT -><DT ->5.3.10. <A -HREF="#AEN347" ->SSVALS(buf,pos,val)</A -></DT -><DT ->5.3.11. <A -HREF="#AEN350" ->SIVALS(buf,pos,val)</A -></DT -><DT ->5.3.12. <A -HREF="#AEN353" ->RSVAL(buf,pos)</A -></DT -><DT ->5.3.13. <A -HREF="#AEN356" ->RIVAL(buf,pos)</A -></DT -><DT ->5.3.14. <A -HREF="#AEN359" ->RSSVAL(buf,pos,val)</A -></DT -><DT ->5.3.15. <A -HREF="#AEN362" ->RSIVAL(buf,pos,val)</A -></DT -></DL -></DD -><DT ->5.4. <A -HREF="#AEN365" ->LAN Manager Samba API</A -></DT -><DD -><DL -><DT ->5.4.1. <A -HREF="#AEN371" ->Parameters</A -></DT -><DT ->5.4.2. <A -HREF="#AEN406" ->Return value</A -></DT -></DL -></DD -><DT ->5.5. <A -HREF="#AEN420" ->Code character table</A -></DT -></DL -></DD -><DT ->6. <A -HREF="#PARSING" ->The smb.conf file</A -></DT -><DD -><DL -><DT ->6.1. <A -HREF="#AEN451" ->Lexical Analysis</A -></DT -><DD -><DL -><DT ->6.1.1. <A -HREF="#AEN472" ->Handling of Whitespace</A -></DT -><DT ->6.1.2. <A -HREF="#AEN484" ->Handling of Line Continuation</A -></DT -><DT ->6.1.3. <A -HREF="#AEN495" ->Line Continuation Quirks</A -></DT -></DL -></DD -><DT ->6.2. <A -HREF="#AEN515" ->Syntax</A -></DT -><DD -><DL -><DT ->6.2.1. <A -HREF="#AEN530" ->About params.c</A -></DT -></DL -></DD -></DL -></DD -><DT ->7. <A -HREF="#UNIX-SMB" ->NetBIOS in a Unix World</A -></DT -><DD -><DL -><DT ->7.1. <A -HREF="#AEN540" ->Introduction</A -></DT -><DT ->7.2. <A -HREF="#AEN544" ->Usernames</A -></DT -><DT ->7.3. <A -HREF="#AEN552" ->File Ownership</A -></DT -><DT ->7.4. <A -HREF="#AEN557" ->Passwords</A -></DT -><DT ->7.5. <A -HREF="#AEN563" ->Locking</A -></DT -><DT ->7.6. <A -HREF="#AEN571" ->Deny Modes</A -></DT -><DT ->7.7. <A -HREF="#AEN575" ->Trapdoor UIDs</A -></DT -><DT ->7.8. <A -HREF="#AEN579" ->Port numbers</A -></DT -><DT ->7.9. <A -HREF="#AEN584" ->Protocol Complexity</A -></DT -></DL -></DD -><DT ->8. <A -HREF="#TRACING" ->Tracing samba system calls</A -></DT -><DT ->9. <A -HREF="#NTDOMAIN" ->NT Domain RPC's</A -></DT -><DD -><DL -><DT ->9.1. <A -HREF="#AEN652" ->Introduction</A -></DT -><DD -><DL -><DT ->9.1.1. <A -HREF="#AEN688" ->Sources</A -></DT -><DT ->9.1.2. <A -HREF="#AEN695" ->Credits</A -></DT -></DL -></DD -><DT ->9.2. <A -HREF="#AEN702" ->Notes and Structures</A -></DT -><DD -><DL -><DT ->9.2.1. <A -HREF="#AEN704" ->Notes</A -></DT -><DT ->9.2.2. <A -HREF="#AEN717" ->Enumerations</A -></DT -><DT ->9.2.3. <A -HREF="#AEN775" ->Structures</A -></DT -></DL -></DD -><DT ->9.3. <A -HREF="#AEN1571" ->MSRPC over Transact Named Pipe</A -></DT -><DD -><DL -><DT ->9.3.1. <A -HREF="#AEN1574" ->MSRPC Pipes</A -></DT -><DT ->9.3.2. <A -HREF="#AEN1588" ->Header</A -></DT -><DT ->9.3.3. <A -HREF="#AEN1842" ->Tail</A -></DT -><DT ->9.3.4. <A -HREF="#AEN1854" ->RPC Bind / Bind Ack</A -></DT -><DT ->9.3.5. <A -HREF="#AEN1898" ->NTLSA Transact Named Pipe</A -></DT -><DT ->9.3.6. <A -HREF="#AEN1939" ->LSA Open Policy</A -></DT -><DT ->9.3.7. <A -HREF="#AEN1973" ->LSA Query Info Policy</A -></DT -><DT ->9.3.8. <A -HREF="#AEN2001" ->LSA Enumerate Trusted Domains</A -></DT -><DT ->9.3.9. <A -HREF="#AEN2025" ->LSA Open Secret</A -></DT -><DT ->9.3.10. <A -HREF="#AEN2054" ->LSA Close</A -></DT -><DT ->9.3.11. <A -HREF="#AEN2071" ->LSA Lookup SIDS</A -></DT -><DT ->9.3.12. <A -HREF="#AEN2130" ->LSA Lookup Names</A -></DT -></DL -></DD -><DT ->9.4. <A -HREF="#AEN2193" ->NETLOGON rpc Transact Named Pipe</A -></DT -><DD -><DL -><DT ->9.4.1. <A -HREF="#AEN2232" ->LSA Request Challenge</A -></DT -><DT ->9.4.2. <A -HREF="#AEN2267" ->LSA Authenticate 2</A -></DT -><DT ->9.4.3. <A -HREF="#AEN2306" ->LSA Server Password Set</A -></DT -><DT ->9.4.4. <A -HREF="#AEN2335" ->LSA SAM Logon</A -></DT -><DT ->9.4.5. <A -HREF="#AEN2359" ->LSA SAM Logoff</A -></DT -></DL -></DD -><DT ->9.5. <A -HREF="#AEN2382" ->\\MAILSLOT\NET\NTLOGON</A -></DT -><DD -><DL -><DT ->9.5.1. <A -HREF="#AEN2386" ->Query for PDC</A -></DT -><DT ->9.5.2. <A -HREF="#AEN2460" ->SAM Logon</A -></DT -></DL -></DD -><DT ->9.6. <A -HREF="#AEN2550" ->SRVSVC Transact Named Pipe</A -></DT -><DD -><DL -><DT ->9.6.1. <A -HREF="#AEN2562" ->Net Share Enum</A -></DT -><DT ->9.6.2. <A -HREF="#AEN2623" ->Net Server Get Info</A -></DT -></DL -></DD -><DT ->9.7. <A -HREF="#AEN2654" ->Cryptographic side of NT Domain Authentication</A -></DT -><DD -><DL -><DT ->9.7.1. <A -HREF="#AEN2656" ->Definitions</A -></DT -><DT ->9.7.2. <A -HREF="#AEN2699" ->Protocol</A -></DT -><DT ->9.7.3. <A -HREF="#AEN2709" ->Comments</A -></DT -></DL -></DD -><DT ->9.8. <A -HREF="#AEN2716" ->SIDs and RIDs</A -></DT -><DD -><DL -><DT ->9.8.1. <A -HREF="#AEN2724" ->Well-known SIDs</A -></DT -><DT ->9.8.2. <A -HREF="#AEN2812" ->Well-known RIDS</A -></DT -></DL -></DD -></DL -></DD -><DT ->10. <A -HREF="#PRINTING" ->Samba Printing Internals</A -></DT -><DD -><DL -><DT ->10.1. <A -HREF="#AEN2896" ->Abstract</A -></DT -><DT ->10.2. <A -HREF="#AEN2899" ->Printing Interface to Various Back ends</A -></DT -><DT ->10.3. <A -HREF="#AEN2925" ->Print Queue TDB's</A -></DT -><DT ->10.4. <A -HREF="#AEN2959" ->ChangeID and Client Caching of Printer Information</A -></DT -><DT ->10.5. <A -HREF="#AEN2962" ->Windows NT/2K Printer Change Notify</A -></DT -></DL -></DD -><DT ->11. <A -HREF="#WINS" ->Samba WINS Internals</A -></DT -><DD -><DL -><DT ->11.1. <A -HREF="#AEN3033" ->WINS Failover</A -></DT -></DL -></DD -><DT ->12. <A -HREF="#SAM" ->The Upcoming SAM System</A -></DT -><DD -><DL -><DT ->12.1. <A -HREF="#AEN3054" ->Security in the 'new SAM'</A -></DT -><DT ->12.2. <A -HREF="#AEN3071" ->Standalone from UNIX</A -></DT -><DT ->12.3. <A -HREF="#AEN3075" ->Handles and Races in the new SAM</A -></DT -><DT ->12.4. <A -HREF="#AEN3086" ->Layers</A -></DT -><DD -><DL -><DT ->12.4.1. <A -HREF="#AEN3088" ->Application</A -></DT -><DT ->12.4.2. <A -HREF="#AEN3091" ->SAM Interface</A -></DT -><DT ->12.4.3. <A -HREF="#AEN3095" ->SAM Modules</A -></DT -></DL -></DD -><DT ->12.5. <A -HREF="#AEN3098" ->SAM Modules</A -></DT -><DD -><DL -><DT ->12.5.1. <A -HREF="#AEN3100" ->Special Module: sam_passdb</A -></DT -><DT ->12.5.2. <A -HREF="#AEN3103" ->sam_ads</A -></DT -></DL -></DD -><DT ->12.6. <A -HREF="#AEN3107" ->Memory Management</A -></DT -><DT ->12.7. <A -HREF="#AEN3121" ->Testing</A -></DT -></DL -></DD -><DT ->13. <A -HREF="#PWENCRYPT" ->LanMan and NT Password Encryption</A -></DT -><DD -><DL -><DT ->13.1. <A -HREF="#AEN3147" ->Introduction</A -></DT -><DT ->13.2. <A -HREF="#AEN3151" ->How does it work?</A -></DT -><DT ->13.3. <A -HREF="#AEN3162" -><A -NAME="SMBPASSWDFILEFORMAT" -></A ->>The smbpasswd file</A -></DT -></DL -></DD -><DT ->14. <A -HREF="#MODULES" ->Modules</A -></DT -><DD -><DL -><DT ->14.1. <A -HREF="#AEN3225" ->Advantages</A -></DT -><DT ->14.2. <A -HREF="#AEN3234" ->Loading modules</A -></DT -><DD -><DL -><DT ->14.2.1. <A -HREF="#AEN3240" ->Static modules</A -></DT -><DT ->14.2.2. <A -HREF="#AEN3247" ->Shared modules</A -></DT -></DL -></DD -><DT ->14.3. <A -HREF="#AEN3251" ->Writing modules</A -></DT -><DD -><DL -><DT ->14.3.1. <A -HREF="#AEN3262" ->Static/Shared selection in configure.in</A -></DT -></DL -></DD -></DL -></DD -><DT ->15. <A -HREF="#RPC-PLUGIN" ->RPC Pluggable Modules</A -></DT -><DD -><DL -><DT ->15.1. <A -HREF="#AEN3301" ->About</A -></DT -><DT ->15.2. <A -HREF="#AEN3304" ->General Overview</A -></DT -></DL -></DD -><DT ->16. <A -HREF="#PACKAGING" ->Notes to packagers</A -></DT -><DD -><DL -><DT ->16.1. <A -HREF="#AEN3337" ->Versioning</A -></DT -><DT ->16.2. <A -HREF="#AEN3343" ->Modules</A -></DT -></DL -></DD -></DL -></DIV -><DIV -CLASS="CHAPTER" -><HR><H1 -><A -NAME="NETBIOS" -></A ->Chapter 1. Definition of NetBIOS Protocol and Name Resolution Modes</H1 -><DIV -CLASS="SECT1" -><H2 -CLASS="SECT1" -><A -NAME="AEN24" ->1.1. NETBIOS</A -></H2 -><P ->NetBIOS runs over the following tranports: TCP/IP; NetBEUI and IPX/SPX. +distribution. A copy can be found on-line at <a href="http://www.fsf.org/licenses/gpl.txt" target="_top">http://www.fsf.org/licenses/gpl.txt</a> +</p></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>1. <a href="#netbios">Definition of NetBIOS Protocol and Name Resolution Modes</a></dt><dd><dl><dt><a href="#id2791176">NETBIOS</a></dt><dt><a href="#id2791260">BROADCAST NetBIOS</a></dt><dt><a href="#id2791291">NBNS NetBIOS</a></dt></dl></dd><dt>2. <a href="#architecture">Samba Architecture</a></dt><dd><dl><dt><a href="#id2795118">Introduction</a></dt><dt><a href="#id2795170">Multithreading and Samba</a></dt><dt><a href="#id2790937">Threading smbd</a></dt><dt><a href="#id2843423">Threading nmbd</a></dt><dt><a href="#id2791332">nbmd Design</a></dt></dl></dd><dt>3. <a href="#debug">The samba DEBUG system</a></dt><dd><dl><dt><a href="#id2790677">New Output Syntax</a></dt><dt><a href="#id2791433">The DEBUG() Macro</a></dt><dt><a href="#id2791102">The DEBUGADD() Macro</a></dt><dt><a href="#id2790705">The DEBUGLVL() Macro</a></dt><dt><a href="#id2790812">New Functions</a></dt><dd><dl><dt><a href="#id2790819">dbgtext()</a></dt><dt><a href="#id2790839">dbghdr()</a></dt><dt><a href="#id2790862">format_debug_text()</a></dt></dl></dd></dl></dd><dt>4. <a href="#CodingSuggestions">Coding Suggestions</a></dt><dt>5. <a href="#internals">Samba Internals</a></dt><dd><dl><dt><a href="#id2857490">Character Handling</a></dt><dt><a href="#id2857515">The new functions</a></dt><dt><a href="#id2857977">Macros in byteorder.h</a></dt><dd><dl><dt><a href="#id2857991">CVAL(buf,pos)</a></dt><dt><a href="#id2858005">PVAL(buf,pos)</a></dt><dt><a href="#id2858019">SCVAL(buf,pos,val)</a></dt><dt><a href="#id2858032">SVAL(buf,pos)</a></dt><dt><a href="#id2858048">IVAL(buf,pos)</a></dt><dt><a href="#id2858062">SVALS(buf,pos)</a></dt><dt><a href="#id2858077">IVALS(buf,pos)</a></dt><dt><a href="#id2858091">SSVAL(buf,pos,val)</a></dt><dt><a href="#id2858106">SIVAL(buf,pos,val)</a></dt><dt><a href="#id2858120">SSVALS(buf,pos,val)</a></dt><dt><a href="#id2858134">SIVALS(buf,pos,val)</a></dt><dt><a href="#id2858149">RSVAL(buf,pos)</a></dt><dt><a href="#id2858163">RIVAL(buf,pos)</a></dt><dt><a href="#id2858177">RSSVAL(buf,pos,val)</a></dt><dt><a href="#id2858192">RSIVAL(buf,pos,val)</a></dt></dl></dd><dt><a href="#id2858208">LAN Manager Samba API</a></dt><dd><dl><dt><a href="#id2858243">Parameters</a></dt><dt><a href="#id2858395">Return value</a></dt></dl></dd><dt><a href="#id2858481">Code character table</a></dt></dl></dd><dt>6. <a href="#parsing">The smb.conf file</a></dt><dd><dl><dt><a href="#id2857849">Lexical Analysis</a></dt><dd><dl><dt><a href="#id2857787">Handling of Whitespace</a></dt><dt><a href="#id2858749">Handling of Line Continuation</a></dt><dt><a href="#id2858813">Line Continuation Quirks</a></dt></dl></dd><dt><a href="#id2858913">Syntax</a></dt><dd><dl><dt><a href="#id2858982">About params.c</a></dt></dl></dd></dl></dd><dt>7. <a href="#unix-smb">NetBIOS in a Unix World</a></dt><dd><dl><dt><a href="#id2858682">Introduction</a></dt><dt><a href="#id2858703">Usernames</a></dt><dt><a href="#id2858620">File Ownership</a></dt><dt><a href="#id2858644">Passwords</a></dt><dt><a href="#id2859208">Locking</a></dt><dt><a href="#id2859270">Deny Modes</a></dt><dt><a href="#id2859300">Trapdoor UIDs</a></dt><dt><a href="#id2859325">Port numbers</a></dt><dt><a href="#id2859371">Protocol Complexity</a></dt></dl></dd><dt>8. <a href="#tracing">Tracing samba system calls</a></dt><dt>9. <a href="#ntdomain">NT Domain RPC's</a></dt><dd><dl><dt><a href="#id2859563">Introduction</a></dt><dd><dl><dt><a href="#id2859980">Sources</a></dt><dt><a href="#id2860014">Credits</a></dt></dl></dd><dt><a href="#id2860053">Notes and Structures</a></dt><dd><dl><dt><a href="#id2860060">Notes</a></dt><dt><a href="#id2860137">Enumerations</a></dt><dt><a href="#id2860350">Structures</a></dt></dl></dd><dt><a href="#id2863307">MSRPC over Transact Named Pipe</a></dt><dd><dl><dt><a href="#id2863320">MSRPC Pipes</a></dt><dt><a href="#id2863422">Header</a></dt><dt><a href="#id2864296">Tail</a></dt><dt><a href="#id2864342">RPC Bind / Bind Ack</a></dt><dt><a href="#id2864522">NTLSA Transact Named Pipe</a></dt><dt><a href="#id2864687">LSA Open Policy</a></dt><dt><a href="#id2864813">LSA Query Info Policy</a></dt><dt><a href="#id2864921">LSA Enumerate Trusted Domains</a></dt><dt><a href="#id2865012">LSA Open Secret</a></dt><dt><a href="#id2865122">LSA Close</a></dt><dt><a href="#id2865188">LSA Lookup SIDS</a></dt><dt><a href="#id2865399">LSA Lookup Names</a></dt></dl></dd><dt><a href="#id2865625">NETLOGON rpc Transact Named Pipe</a></dt><dd><dl><dt><a href="#id2865786">LSA Request Challenge</a></dt><dt><a href="#id2865921">LSA Authenticate 2</a></dt><dt><a href="#id2866069">LSA Server Password Set</a></dt><dt><a href="#id2866185">LSA SAM Logon</a></dt><dt><a href="#id2866299">LSA SAM Logoff</a></dt></dl></dd><dt><a href="#id2866391">\\MAILSLOT\NET\NTLOGON</a></dt><dd><dl><dt><a href="#id2866408">Query for PDC</a></dt><dt><a href="#id2866670">SAM Logon</a></dt></dl></dd><dt><a href="#id2866996">SRVSVC Transact Named Pipe</a></dt><dd><dl><dt><a href="#id2867041">Net Share Enum</a></dt><dt><a href="#id2867261">Net Server Get Info</a></dt></dl></dd><dt><a href="#id2867378">Cryptographic side of NT Domain Authentication</a></dt><dd><dl><dt><a href="#id2867386">Definitions</a></dt><dt><a href="#id2867548">Protocol</a></dt><dt><a href="#id2867629">Comments</a></dt></dl></dd><dt><a href="#id2867679">SIDs and RIDs</a></dt><dd><dl><dt><a href="#id2867719">Well-known SIDs</a></dt><dt><a href="#id2868034">Well-known RIDS</a></dt></dl></dd></dl></dd><dt>10. <a href="#printing">Samba Printing Internals</a></dt><dd><dl><dt><a href="#id2859754">Abstract</a></dt><dt><a href="#id2859770"> +Printing Interface to Various Back ends +</a></dt><dt><a href="#id2859712"> +Print Queue TDB's +</a></dt><dt><a href="#id2868639"> +ChangeID and Client Caching of Printer Information +</a></dt><dt><a href="#id2868653"> +Windows NT/2K Printer Change Notify +</a></dt></dl></dd><dt>11. <a href="#wins">Samba WINS Internals</a></dt><dd><dl><dt><a href="#id2868400">WINS Failover</a></dt></dl></dd><dt>12. <a href="#sam">The Upcoming SAM System</a></dt><dd><dl><dt><a href="#id2869126">Security in the 'new SAM'</a></dt><dt><a href="#id2869257">Standalone from UNIX</a></dt><dt><a href="#id2869292">Handles and Races in the new SAM</a></dt><dt><a href="#id2869361">Layers</a></dt><dd><dl><dt><a href="#id2869368">Application</a></dt><dt><a href="#id2869384">SAM Interface</a></dt><dt><a href="#id2869412">SAM Modules</a></dt></dl></dd><dt><a href="#id2869434">SAM Modules</a></dt><dd><dl><dt><a href="#id2869441">Special Module: sam_passdb</a></dt><dt><a href="#id2869459">sam_ads</a></dt></dl></dd><dt><a href="#id2869498">Memory Management</a></dt><dt><a href="#id2869589">Testing</a></dt></dl></dd><dt>13. <a href="#pwencrypt">LanMan and NT Password Encryption</a></dt><dd><dl><dt><a href="#id2869092">Introduction</a></dt><dt><a href="#id2868961">How does it work?</a></dt><dt><a href="#id2869678">The smbpasswd file</a></dt></dl></dd><dt>14. <a href="#modules">Modules</a></dt><dd><dl><dt><a href="#id2870133">Advantages</a></dt><dt><a href="#id2869868">Loading modules</a></dt><dd><dl><dt><a href="#id2869901">Static modules</a></dt><dt><a href="#id2870337">Shared modules</a></dt></dl></dd><dt><a href="#id2870365">Writing modules</a></dt><dd><dl><dt><a href="#id2870425">Static/Shared selection in configure.in</a></dt></dl></dd></dl></dd><dt>15. <a href="#rpc-plugin">RPC Pluggable Modules</a></dt><dd><dl><dt><a href="#id2869935">About</a></dt><dt><a href="#id2869954">General Overview</a></dt></dl></dd><dt>16. <a href="#Packaging">Notes to packagers</a></dt><dd><dl><dt><a href="#id2870644">Versioning</a></dt><dt><a href="#id2870677">Modules</a></dt></dl></dd></dl></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="netbios"></a>Chapter 1. Definition of NetBIOS Protocol and Name Resolution Modes</h2></div><div><div class="author"><h3 class="author">Luke Leighton</h3></div></div><div><p class="pubdate">12 June 1997</p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#id2791176">NETBIOS</a></dt><dt><a href="#id2791260">BROADCAST NetBIOS</a></dt><dt><a href="#id2791291">NBNS NetBIOS</a></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2791176"></a>NETBIOS</h2></div></div><p> +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 -rfc1001.txt and rfc1002.txt.</P -><P -> +rfc1001.txt and rfc1002.txt. +</p><p> NetBEUI is a raw NetBIOS frame protocol implementation that allows NetBIOS datagrams to be sent out over the 'wire' embedded within LLC frames. NetBEUI is not required when using NetBIOS over TCP/IP protocols and it -is preferable NOT to install NetBEUI if it can be avoided.</P -><P -> +is preferable NOT to install NetBEUI if it can be avoided. +</p><p> IPX/SPX is also not required when using NetBIOS over TCP/IP, and it is preferable NOT to install the IPX/SPX transport unless you are using Novell servers. At the very least, it is recommended that you do not install -'NetBIOS over IPX/SPX'.</P -><P ->[When installing Windows 95, you will find that NetBEUI and IPX/SPX are +'NetBIOS over IPX/SPX'. +</p><p> +[When installing Windows 95, you will find that NetBEUI and IPX/SPX are installed as the default protocols. This is because they are the simplest -to manage: no Windows 95 user-configuration is required].</P -><P -> +to manage: no Windows 95 user-configuration is required]. +</p><p> NetBIOS applications (such as samba) offer their services (for example, SMB file and print sharing) on a NetBIOS name. They must claim this name on the network before doing so. The NetBIOS session service will then accept connections on the application's behalf (on the NetBIOS name claimed by the application). A NetBIOS session between the application -and the client can then commence.</P -><P -> +and the client can then commence. +</p><p> NetBIOS names consist of 15 characters plus a 'type' character. This is similar, in concept, to an IP address and a TCP port number, respectively. A NetBIOS-aware application on a host will offer different services under different NetBIOS name types, just as a host will offer different TCP/IP -services on different port numbers.</P -><P -> +services on different port numbers. +</p><p> NetBIOS names must be claimed on a network, and must be defended. The use of NetBIOS names is most suitable on a single subnet; a Local Area Network -or a Wide Area Network.</P -><P -> +or a Wide Area Network. +</p><p> NetBIOS names are either UNIQUE or GROUP. Only one application can claim a -UNIQUE NetBIOS name on a network.</P -><P ->There are two kinds of NetBIOS Name resolution: Broadcast and Point-to-Point.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN35" ->1.2. BROADCAST NetBIOS</A -></H2 -><P -> +UNIQUE NetBIOS name on a network. +</p><p> +There are two kinds of NetBIOS Name resolution: Broadcast and Point-to-Point. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2791260"></a>BROADCAST NetBIOS</h2></div></div><p> 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 SMB file/print sharing: see cifs4.txt) working on a LAN or WAN is to make -your routers forward all broadcast packets from TCP/IP ports 137, 138 and 139.</P -><P -> +your routers forward all broadcast packets from TCP/IP ports 137, 138 and 139. +</p><p> This, however, is not recommended. If you have a large LAN or WAN, you will 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!].</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN39" ->1.3. NBNS NetBIOS</A -></H2 -><P ->rfc1001.txt describes, amongst other things, the implementation and use +every twelve minutes, great swathes of broadcast traffic!]. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2791291"></a>NBNS NetBIOS</h2></div></div><p> +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 with certain NetBIOS names in order to make it useful. (for example, it -deals with the registration of <1c> <1d> <1e> names all in different ways. +deals with the registration of <1c> <1d> <1e> names all in different ways. I recommend the reading of the Microsoft WINS Server Help files for full -details).</P -><P -> +details). +</p><p> The use of a WINS server cuts down on broadcast network traffic for NetBIOS name resolution. It has the effect of pulling all the broadcast isolated subnets together into a single NetBIOS scope, across your LAN -or WAN, while avoiding the use of TCP/IP broadcast packets.</P -><P ->When you have a WINS server on your LAN, WINS clients will be able to +or WAN, while avoiding the use of TCP/IP broadcast packets. +</p><p> +When you have a WINS server on your LAN, WINS clients will be able to contact the WINS server to resolve NetBIOS names. Note that only those WINS clients that have registered with the same WINS server will be visible. The WINS server _can_ have static NetBIOS entries added to its database (usually for security reasons you might want to consider putting your domain controllers or other important servers as static entries, but you should not rely on this as your sole means of security), but for -the most part, NetBIOS names are registered dynamically.</P -><P ->This provides some confusion for lots of people, and is worth mentioning +the most part, NetBIOS names are registered dynamically. +</p><p> +This provides some confusion for lots of people, and is worth mentioning here: a Browse Server is NOT a WINS Server, even if these services are implemented in the same application. A Browse Server _needs_ a WINS server -because a Browse Server is a WINS client, which is _not_ the same thing].</P -><P ->Clients can claim names, and therefore offer services on successfully claimed +because a Browse Server is a WINS client, which is _not_ the same thing]. +</p><p> +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 SMB file/print sharing: see cifs6.txt) working on a LAN or WAN is to make your routers forward all broadcast packets from TCP/IP ports 137, 138 and 139. You will find, however, if you do this on a large LAN or a WAN, that your network is completely swamped by NetBIOS and browsing packets, which is why -WINS was developed to minimise the necessity of broadcast traffic.</P -><P -> +WINS was developed to minimise the necessity of broadcast traffic. +</p><p> 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.</P -></DIV -></DIV -><DIV -CLASS="CHAPTER" -><HR><H1 -><A -NAME="ARCHITECTURE" -></A ->Chapter 2. Samba Architecture</H1 -><DIV -CLASS="SECT1" -><H2 -CLASS="SECT1" -><A -NAME="AEN54" ->2.1. Introduction</A -></H2 -><P ->This document gives a general overview of how Samba works +contact the WINS server to resolve a NetBIOS name. +</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="architecture"></a>Chapter 2. Samba Architecture</h2></div><div><div class="author"><h3 class="author">Dan Shearer</h3></div></div><div><p class="pubdate"> November 1997</p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#id2795118">Introduction</a></dt><dt><a href="#id2795170">Multithreading and Samba</a></dt><dt><a href="#id2790937">Threading smbd</a></dt><dt><a href="#id2843423">Threading nmbd</a></dt><dt><a href="#id2791332">nbmd Design</a></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2795118"></a>Introduction</h2></div></div><p> +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 and the constraints imposed by the very messy SMB and CIFS -protocol. </P -><P ->It also tries to answer some of the frequently asked questions such as:</P -><P -></P -><OL -TYPE="1" -><LI -><P -> Is Samba secure when running on Unix? The xyz platform? - What about the root priveliges issue?</P -></LI -><LI -><P ->Pros and cons of multithreading in various parts of Samba</P -></LI -><LI -><P ->Why not have a separate process for name resolution, WINS, and browsing?</P -></LI -></OL -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN65" ->2.2. Multithreading and Samba</A -></H2 -><P ->People sometimes tout threads as a uniformly good thing. They are very +protocol. +</p><p> +It also tries to answer some of the frequently asked questions such as: +</p><div class="orderedlist"><ol type="1"><li><p> + Is Samba secure when running on Unix? The xyz platform? + What about the root priveliges issue? +</p></li><li><p>Pros and cons of multithreading in various parts of Samba</p></li><li><p>Why not have a separate process for name resolution, WINS, and browsing?</p></li></ol></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2795170"></a>Multithreading and Samba</h2></div></div><p> +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. </P -><P ->The short version is that smbd is not multithreaded, and alternative +another matter, and multi-threading it would be very nice. +</p><p> +The short version is that smbd is not multithreaded, and alternative servers that take this approach under Unix (such as Syntax, at the time of writing) suffer tremendous performance penalties and are less robust. nmbd is not threaded either, but this is because it is not possible to do it while keeping code consistent and portable across 35 -or more platforms. (This drawback also applies to threading smbd.)</P -><P ->The longer versions is that there are very good reasons for not making +or more platforms. (This drawback also applies to threading smbd.) +</p><p> +The longer versions is that there are very good reasons for not making 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.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN70" ->2.3. Threading smbd</A -></H2 -><P ->A few problems that would arise from a threaded smbd are:</P -><P -></P -><OL -TYPE="1" -><LI -><P -> It's not only to create threads instead of processes, but you +biggest advantages. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2790937"></a>Threading smbd</h2></div></div><p> +A few problems that would arise from a threaded smbd are: +</p><div class="orderedlist"><ol type="1"><li><p> + It's not only to create threads instead of processes, but you must care about all variables if they have to be thread specific - (currently they would be global).</P -></LI -><LI -><P -> if one thread dies (eg. a seg fault) then all threads die. We can - immediately throw robustness out the window.</P -></LI -><LI -><P -> many of the system calls we make are blocking. Non-blocking + (currently they would be global). +</p></li><li><p> + if one thread dies (eg. a seg fault) then all threads die. We can + immediately throw robustness out the window. +</p></li><li><p> + many of the system calls we make are blocking. Non-blocking equivalents of many calls are either not available or are awkward (and slow) to use. So while we block in one thread all clients are waiting. Imagine if one share is a slow NFS filesystem and the others - are fast, we will end up slowing all clients to the speed of NFS.</P -></LI -><LI -><P -> you can't run as a different uid in different threads. This means + are fast, we will end up slowing all clients to the speed of NFS. +</p></li><li><p> + you can't run as a different uid in different threads. This means we would have to switch uid/gid on _every_ SMB packet. It would be - horrendously slow.</P -></LI -><LI -><P -> the per process file descriptor limit would mean that we could only - support a limited number of clients.</P -></LI -><LI -><P -> we couldn't use the system locking calls as the locking context of - fcntl() is a process, not a thread.</P -></LI -></OL -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN86" ->2.4. Threading nmbd</A -></H2 -><P ->This would be ideal, but gets sunk by portability requirements.</P -><P ->Andrew tried to write a test threads library for nmbd that used only + horrendously slow. +</p></li><li><p> + the per process file descriptor limit would mean that we could only + support a limited number of clients. +</p></li><li><p> + we couldn't use the system locking calls as the locking context of + fcntl() is a process, not a thread. +</p></li></ol></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2843423"></a>Threading nmbd</h2></div></div><p> +This would be ideal, but gets sunk by portability requirements. +</p><p> +Andrew tried to write a test threads library for nmbd that used only ansi-C constructs (using setjmp and longjmp). Unfortunately some OSes defeat this by restricting longjmp to calling addresses that are shallower than the current address on the stack (apparently AIX does @@ -1180,31 +180,22 @@ and without threads, and as the real aim of threads is to make the code clearer we would not have gained anything. (it is a myth that threads make things faster. threading is like recursion, it can make things clear but the same thing can always be done faster by some -other method)</P -><P ->Chris tried to spec out a general design that would abstract threading +other method) +</p><p> +Chris tried to spec out a general design that would abstract threading vs separate processes (vs other methods?) and make them accessible through some general API. This doesn't work because of the data sharing requirements of the protocol (packets in the future depending on packets now, etc.) At least, the code would work but would be very -clumsy, and besides the fork() type model would never work on Unix. (Is there an OS that it would work on, for nmbd?)</P -><P ->A fork() is cheap, but not nearly cheap enough to do on every UDP +clumsy, and besides the fork() type model would never work on Unix. (Is there an OS that it would work on, for nmbd?) +</p><p> +A fork() is cheap, but not nearly cheap enough to do on every UDP 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.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN92" ->2.5. nbmd Design</A -></H2 -><P ->Originally Andrew used recursion to simulate a multi-threaded +platform having a shared memory system. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2791332"></a>nbmd Design</h2></div></div><p> +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 queuing system that keeps state information on each packet. The @@ -1216,361 +207,197 @@ and a pointer to a user-defined memory block. This suddenly made things much simpler: large numbers of functions could be made static, and modularised. This is the same principle as used in NT's kernel, and achieves the same effect as threads, but in -a single process.</P -><P ->Then Jeremy rewrote nmbd. The packet data in nmbd isn't what's on the +a single process. +</p><p> +Then Jeremy rewrote nmbd. The packet data in nmbd isn't what's on the wire. It's a nice format that is very amenable to processing but still -keeps the idea of a distinct packet. See "struct packet_struct" in +keeps the idea of a distinct packet. See "struct packet_struct" in nameserv.h. It has all the detail but none of the on-the-wire mess. This makes it ideal for using in disk or memory-based databases -for browsing and WINS support. </P -></DIV -></DIV -><DIV -CLASS="CHAPTER" -><HR><H1 -><A -NAME="DEBUG" -></A ->Chapter 3. The samba DEBUG system</H1 -><DIV -CLASS="SECT1" -><H2 -CLASS="SECT1" -><A -NAME="AEN103" ->3.1. New Output Syntax</A -></H2 -><P -> The syntax of a debugging log file is represented as:</P -><P -><PRE -CLASS="PROGRAMLISTING" -> >debugfile< :== { >debugmsg< } +for browsing and WINS support. +</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="debug"></a>Chapter 3. The samba DEBUG system</h2></div><div><div class="author"><h3 class="author">Chris Hertel</h3></div></div><div><p class="pubdate">July 1998</p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#id2790677">New Output Syntax</a></dt><dt><a href="#id2791433">The DEBUG() Macro</a></dt><dt><a href="#id2791102">The DEBUGADD() Macro</a></dt><dt><a href="#id2790705">The DEBUGLVL() Macro</a></dt><dt><a href="#id2790812">New Functions</a></dt><dd><dl><dt><a href="#id2790819">dbgtext()</a></dt><dt><a href="#id2790839">dbghdr()</a></dt><dt><a href="#id2790862">format_debug_text()</a></dt></dl></dd></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2790677"></a>New Output Syntax</h2></div></div><p> + The syntax of a debugging log file is represented as: +</p><pre class="programlisting"> + >debugfile< :== { >debugmsg< } - >debugmsg< :== >debughdr< '\n' >debugtext< + >debugmsg< :== >debughdr< '\n' >debugtext< - >debughdr< :== '[' TIME ',' LEVEL ']' FILE ':' [FUNCTION] '(' LINE ')' + >debughdr< :== '[' TIME ',' LEVEL ']' FILE ':' [FUNCTION] '(' LINE ')' - >debugtext< :== { >debugline< } + >debugtext< :== { >debugline< } - >debugline< :== TEXT '\n'</PRE -></P -><P ->TEXT is a string of characters excluding the newline character.</P -><P ->LEVEL is the DEBUG level of the message (an integer in the range - 0..10).</P -><P ->TIME is a timestamp.</P -><P ->FILE is the name of the file from which the debug message was -generated.</P -><P ->FUNCTION is the function from which the debug message was generated.</P -><P ->LINE is the line number of the debug statement that generated the -message.</P -><P ->Basically, what that all means is:</P -><P -></P -><OL -TYPE="1" -><LI -><P ->A debugging log file is made up of debug messages.</P -></LI -><LI -><P ->Each debug message is made up of a header and text. The header is -separated from the text by a newline.</P -></LI -><LI -><P ->The header begins with the timestamp and debug level of the + >debugline< :== TEXT '\n' +</pre><p> +TEXT is a string of characters excluding the newline character. +</p><p> +LEVEL is the DEBUG level of the message (an integer in the range + 0..10). +</p><p> +TIME is a timestamp. +</p><p> +FILE is the name of the file from which the debug message was +generated. +</p><p> +FUNCTION is the function from which the debug message was generated. +</p><p> +LINE is the line number of the debug statement that generated the +message. +</p><p>Basically, what that all means is:</p><div class="orderedlist"><ol type="1"><li><p> +A debugging log file is made up of debug messages. +</p></li><li><p> +Each debug message is made up of a header and text. The header is +separated from the text by a newline. +</p></li><li><p> +The header begins with the timestamp and debug level of the message enclosed in brackets. The filename, function, and line number at which the message was generated follow. The filename is terminated by a colon, and the function name is terminated by the parenthesis which contain the line number. Depending upon the compiler, the function name may be missing (it is generated by the -__FUNCTION__ macro, which is not universally implemented, dangit).</P -></LI -><LI -><P ->The message text is made up of zero or more lines, each terminated -by a newline.</P -></LI -></OL -><P ->Here's some example output:</P -><P -><PRE -CLASS="PROGRAMLISTING" -> [1998/08/03 12:55:25, 1] nmbd.c:(659) +__FUNCTION__ macro, which is not universally implemented, dangit). +</p></li><li><p> +The message text is made up of zero or more lines, each terminated +by a newline. +</p></li></ol></div><p>Here's some example output:</p><pre class="programlisting"> + [1998/08/03 12:55:25, 1] nmbd.c:(659) Netbios nameserver version 1.9.19-prealpha started. Copyright Andrew Tridgell 1994-1997 [1998/08/03 12:55:25, 3] loadparm.c:(763) - Initializing global parameters</PRE -></P -><P ->Note that in the above example the function names are not listed on + Initializing global parameters +</pre><p> +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.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN128" ->3.2. The DEBUG() Macro</A -></H2 -><P ->Use of the DEBUG() macro is unchanged. DEBUG() takes two parameters. +SGI Indy, and the SGI compiler doesn't support the __FUNCTION__ macro. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2791433"></a>The DEBUG() Macro</h2></div></div><p> +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.</P -><P ->That's confusing.</P -><P ->Here's an example which may help a bit. If you would write</P -><P -><PRE -CLASS="PROGRAMLISTING" ->printf( "This is a %s message.\n", "debug" );</PRE -></P -><P ->to send the output to stdout, then you would write</P -><P -><PRE -CLASS="PROGRAMLISTING" ->DEBUG( 0, ( "This is a %s message.\n", "debug" ) );</PRE -></P -><P ->to send the output to the debug file. All of the normal printf() -formatting escapes work.</P -><P ->Note that in the above example the DEBUG message level is set to 0. +call to the Debug1() function. +</p><p>That's confusing.</p><p>Here's an example which may help a bit. If you would write</p><pre class="programlisting"> +printf( "This is a %s message.\n", "debug" ); +</pre><p> +to send the output to stdout, then you would write +</p><pre class="programlisting"> +DEBUG( 0, ( "This is a %s message.\n", "debug" ) ); +</pre><p> +to send the output to the debug file. All of the normal printf() +formatting escapes work. +</p><p> +Note that in the above example the DEBUG message level is set to 0. Messages at level 0 always print. Basically, if the message level is less than or equal to the global value DEBUGLEVEL, then the DEBUG -statement is processed.</P -><P ->The output of the above example would be something like:</P -><P -><PRE -CLASS="PROGRAMLISTING" -> [1998/07/30 16:00:51, 0] file.c:function(128) - This is a debug message.</PRE -></P -><P ->Each call to DEBUG() creates a new header *unless* the output produced +statement is processed. +</p><p> +The output of the above example would be something like: +</p><pre class="programlisting"> + [1998/07/30 16:00:51, 0] file.c:function(128) + This is a debug message. +</pre><p> +Each call to DEBUG() creates a new header *unless* the output produced by the previous call to DEBUG() did not end with a '\n'. Output to the debug file is passed through a formatting buffer which is flushed every time a newline is encountered. If the buffer is not empty when -DEBUG() is called, the new input is simply appended.</P -><P ->...but that's really just a Kludge. It was put in place because +DEBUG() is called, the new input is simply appended. +</p><p> +...but that's really just a Kludge. It was put in place because DEBUG() has been used to write partial lines. Here's a simple (dumb) -example of the kind of thing I'm talking about:</P -><P -><PRE -CLASS="PROGRAMLISTING" -> DEBUG( 0, ("The test returned " ) ); +example of the kind of thing I'm talking about: +</p><pre class="programlisting"> + DEBUG( 0, ("The test returned " ) ); if( test() ) - DEBUG(0, ("True") ); + DEBUG(0, ("True") ); else - DEBUG(0, ("False") ); - DEBUG(0, (".\n") );</PRE -></P -><P ->Without the format buffer, the output (assuming test() returned true) -would look like this:</P -><P -><PRE -CLASS="PROGRAMLISTING" -> [1998/07/30 16:00:51, 0] file.c:function(256) + DEBUG(0, ("False") ); + DEBUG(0, (".\n") ); +</pre><p> +Without the format buffer, the output (assuming test() returned true) +would look like this: +</p><pre class="programlisting"> + [1998/07/30 16:00:51, 0] file.c:function(256) The test returned [1998/07/30 16:00:51, 0] file.c:function(258) True [1998/07/30 16:00:51, 0] file.c:function(261) - .</PRE -></P -><P ->Which isn't much use. The format buffer kludge fixes this problem.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN151" ->3.3. The DEBUGADD() Macro</A -></H2 -><P ->In addition to the kludgey solution to the broken line problem + . +</pre><p>Which isn't much use. The format buffer kludge fixes this problem. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2791102"></a>The DEBUGADD() Macro</h2></div></div><p> +In addition to the kludgey solution to the broken line problem described above, there is a clean solution. The DEBUGADD() macro never generates a header. It will append new text to the current debug message even if the format buffer is empty. The syntax of the -DEBUGADD() macro is the same as that of the DEBUG() macro.</P -><P -><PRE -CLASS="PROGRAMLISTING" -> DEBUG( 0, ("This is the first line.\n" ) ); - DEBUGADD( 0, ("This is the second line.\nThis is the third line.\n" ) );</PRE -></P -><P ->Produces</P -><P -><PRE -CLASS="PROGRAMLISTING" -> [1998/07/30 16:00:51, 0] file.c:function(512) +DEBUGADD() macro is the same as that of the DEBUG() macro. +</p><pre class="programlisting"> + DEBUG( 0, ("This is the first line.\n" ) ); + DEBUGADD( 0, ("This is the second line.\nThis is the third line.\n" ) ); +</pre><p>Produces</p><pre class="programlisting"> + [1998/07/30 16:00:51, 0] file.c:function(512) This is the first line. This is the second line. - This is the third line.</PRE -></P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN159" ->3.4. The DEBUGLVL() Macro</A -></H2 -><P ->One of the problems with the DEBUG() macro was that DEBUG() lines + This is the third line. +</pre></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2790705"></a>The DEBUGLVL() Macro</h2></div></div><p> +One of the problems with the DEBUG() macro was that DEBUG() lines tended to get a bit long. Consider this example from -nmbd_sendannounce.c:</P -><P -><PRE -CLASS="PROGRAMLISTING" -> DEBUG(3,("send_local_master_announcement: type %x for name %s on subnet %s for workgroup %s\n", - type, global_myname, subrec->subnet_name, work->work_group));</PRE -></P -><P ->One solution to this is to break it down using DEBUG() and DEBUGADD(), -as follows:</P -><P -><PRE -CLASS="PROGRAMLISTING" -> DEBUG( 3, ( "send_local_master_announcement: " ) ); - DEBUGADD( 3, ( "type %x for name %s ", type, global_myname ) ); - DEBUGADD( 3, ( "on subnet %s ", subrec->subnet_name ) ); - DEBUGADD( 3, ( "for workgroup %s\n", work->work_group ) );</PRE -></P -><P ->A similar, but arguably nicer approach is to use the DEBUGLVL() macro. +nmbd_sendannounce.c: +</p><pre class="programlisting"> + DEBUG(3,("send_local_master_announcement: type %x for name %s on subnet %s for workgroup %s\n", + type, global_myname, subrec->subnet_name, work->work_group)); +</pre><p> +One solution to this is to break it down using DEBUG() and DEBUGADD(), +as follows: +</p><pre class="programlisting"> + DEBUG( 3, ( "send_local_master_announcement: " ) ); + DEBUGADD( 3, ( "type %x for name %s ", type, global_myname ) ); + DEBUGADD( 3, ( "on subnet %s ", subrec->subnet_name ) ); + DEBUGADD( 3, ( "for workgroup %s\n", work->work_group ) ); +</pre><p> +A similar, but arguably nicer approach is to use the DEBUGLVL() macro. This macro returns True if the message level is less than or equal to -the global DEBUGLEVEL value, so:</P -><P -><PRE -CLASS="PROGRAMLISTING" -> if( DEBUGLVL( 3 ) ) +the global DEBUGLEVEL value, so: +</p><pre class="programlisting"> + if( DEBUGLVL( 3 ) ) { - dbgtext( "send_local_master_announcement: " ); - dbgtext( "type %x for name %s ", type, global_myname ); - dbgtext( "on subnet %s ", subrec->subnet_name ); - dbgtext( "for workgroup %s\n", work->work_group ); - }</PRE -></P -><P ->(The dbgtext() function is explained below.)</P -><P ->There are a few advantages to this scheme:</P -><P -></P -><OL -TYPE="1" -><LI -><P ->The test is performed only once.</P -></LI -><LI -><P ->You can allocate variables off of the stack that will only be used -within the DEBUGLVL() block.</P -></LI -><LI -><P ->Processing that is only relevant to debug output can be contained -within the DEBUGLVL() block.</P -></LI -></OL -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN179" ->3.5. New Functions</A -></H2 -><DIV -CLASS="SECT2" -><H3 -CLASS="SECT2" -><A -NAME="AEN181" ->3.5.1. dbgtext()</A -></H3 -><P ->This function prints debug message text to the debug file (and + dbgtext( "send_local_master_announcement: " ); + dbgtext( "type %x for name %s ", type, global_myname ); + dbgtext( "on subnet %s ", subrec->subnet_name ); + dbgtext( "for workgroup %s\n", work->work_group ); + } +</pre><p>(The dbgtext() function is explained below.)</p><p>There are a few advantages to this scheme:</p><div class="orderedlist"><ol type="1"><li><p> +The test is performed only once. +</p></li><li><p> +You can allocate variables off of the stack that will only be used +within the DEBUGLVL() block. +</p></li><li><p> +Processing that is only relevant to debug output can be contained +within the DEBUGLVL() block. +</p></li></ol></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2790812"></a>New Functions</h2></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2790819"></a>dbgtext()</h3></div></div><p> +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 input is printed into a buffer using the vslprintf() function, and then passed to format_debug_text(). If you use DEBUGLVL() you will probably print the body of the -message using dbgtext(). </P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN184" ->3.5.2. dbghdr()</A -></H3 -><P ->This is the function that writes a debug message header. +message using dbgtext(). +</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2790839"></a>dbghdr()</h3></div></div><p> +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 -produce any output. See the comments in dbghdr() for more info.</P -><P ->It is not likely that this function will be called directly. It -is used by DEBUG() and DEBUGADD().</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN188" ->3.5.3. format_debug_text()</A -></H3 -><P ->This is a static function in debug.c. It stores the output text +produce any output. See the comments in dbghdr() for more info. +</p><p> +It is not likely that this function will be called directly. It +is used by DEBUG() and DEBUGADD(). +</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2790862"></a>format_debug_text()</h3></div></div><p> +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 written to the debug file via the Debug1() function, and the buffer is reset. This allows us to add the indentation at the beginning of each line of the message body, and also ensures that the output is written a line at a time (which cleans up -syslog output).</P -></DIV -></DIV -></DIV -><DIV -CLASS="CHAPTER" -><HR><H1 -><A -NAME="CODINGSUGGESTIONS" -></A ->Chapter 4. Coding Suggestions</H1 -><P ->So you want to add code to Samba ...</P -><P ->One of the daunting tasks facing a programmer attempting to write code for +syslog output). +</p></div></div></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="CodingSuggestions"></a>Chapter 4. Coding Suggestions</h2></div><div><div class="author"><h3 class="author">Steve French</h3></div></div><div><div class="author"><h3 class="author">Simo Sorce</h3></div></div><div><div class="author"><h3 class="author">Andrew Bartlett</h3></div></div><div><div class="author"><h3 class="author">Tim Potter</h3></div></div><div><div class="author"><h3 class="author">Martin Pool</h3></div></div></div><p> +So you want to add code to Samba ... +</p><p> +One of the daunting tasks facing a programmer attempting to write code for Samba is understanding the various coding conventions used by those most active in the project. These conventions were mostly unwritten and helped improve either the portability, stability or consistency of the code. This @@ -1578,305 +405,181 @@ document will attempt to document a few of the more important coding practices used at this time on the Samba project. The coding practices are expected to change slightly over time, and even to grow as more is learned about obscure portability considerations. Two existing documents -<TT -CLASS="FILENAME" ->samba/source/internals.doc</TT -> and -<TT -CLASS="FILENAME" ->samba/source/architecture.doc</TT -> provide -additional information.</P -><P ->The loosely related question of coding style is very personal and this +<tt>samba/source/internals.doc</tt> and +<tt>samba/source/architecture.doc</tt> provide +additional information. +</p><p> +The loosely related question of coding style is very personal and this document does not attempt to address that subject, except to say that I have observed that eight character tabs seem to be preferred in Samba source. If you are interested in the topic of coding style, two oft-quoted -documents are:</P -><P -><A -HREF="http://lxr.linux.no/source/Documentation/CodingStyle" -TARGET="_top" ->http://lxr.linux.no/source/Documentation/CodingStyle</A -></P -><P -><A -HREF="http://www.fsf.org/prep/standards_toc.html" -TARGET="_top" ->http://www.fsf.org/prep/standards_toc.html</A -></P -><P ->But note that coding style in Samba varies due to the many different -programmers who have contributed.</P -><P ->Following are some considerations you should use when adding new code to -Samba. First and foremost remember that:</P -><P ->Portability is a primary consideration in adding function, as is network +documents are: +</p><p> +<a href="http://lxr.linux.no/source/Documentation/CodingStyle" target="_top">http://lxr.linux.no/source/Documentation/CodingStyle</a> +</p><p> +<a href="http://www.fsf.org/prep/standards_toc.html" target="_top">http://www.fsf.org/prep/standards_toc.html</a> +</p><p> +But note that coding style in Samba varies due to the many different +programmers who have contributed. +</p><p> +Following are some considerations you should use when adding new code to +Samba. First and foremost remember that: +</p><p> +Portability is a primary consideration in adding function, as is network compatability with de facto, existing, real world CIFS/SMB implementations. There are lots of platforms that Samba builds on so use caution when adding a call to a library function that is not invoked in existing Samba code. Also note that there are many quite different SMB/CIFS clients that Samba tries to support, not all of which follow the SNIA CIFS Technical Reference (or the earlier Microsoft reference documents or the X/Open book on the SMB -Standard) perfectly.</P -><P ->Here are some other suggestions:</P -><P -></P -><OL -TYPE="1" -><LI -><P -> use d_printf instead of printf for display text - reason: enable auto-substitution of translated language text </P -></LI -><LI -><P -> use SAFE_FREE instead of free - reason: reduce traps due to null pointers</P -></LI -><LI -><P -> don't use bzero use memset, or ZERO_STRUCT and ZERO_STRUCTP macros - reason: not POSIX</P -></LI -><LI -><P -> don't use strcpy and strlen (use safe_* equivalents) - reason: to avoid traps due to buffer overruns</P -></LI -><LI -><P -> don't use getopt_long, use popt functions instead - reason: portability</P -></LI -><LI -><P -> explicitly add const qualifiers on parm passing in functions where parm - is input only (somewhat controversial but const can be #defined away)</P -></LI -><LI -><P -> when passing a va_list as an arg, or assigning one to another +Standard) perfectly. +</p><p> +Here are some other suggestions: +</p><div class="orderedlist"><ol type="1"><li><p> + use d_printf instead of printf for display text + reason: enable auto-substitution of translated language text +</p></li><li><p> + use SAFE_FREE instead of free + reason: reduce traps due to null pointers +</p></li><li><p> + don't use bzero use memset, or ZERO_STRUCT and ZERO_STRUCTP macros + reason: not POSIX +</p></li><li><p> + don't use strcpy and strlen (use safe_* equivalents) + reason: to avoid traps due to buffer overruns +</p></li><li><p> + don't use getopt_long, use popt functions instead + reason: portability +</p></li><li><p> + explicitly add const qualifiers on parm passing in functions where parm + is input only (somewhat controversial but const can be #defined away) +</p></li><li><p> + when passing a va_list as an arg, or assigning one to another please use the VA_COPY() macro reason: on some platforms, va_list is a struct that must be - initialized in each function...can SEGV if you don't.</P -></LI -><LI -><P -> discourage use of threads - reason: portability (also see architecture.doc)</P -></LI -><LI -><P -> don't explicitly include new header files in C files - new h files + initialized in each function...can SEGV if you don't. +</p></li><li><p> + discourage use of threads + reason: portability (also see architecture.doc) +</p></li><li><p> + don't explicitly include new header files in C files - new h files should be included by adding them once to includes.h - reason: consistency</P -></LI -><LI -><P -> don't explicitly extern functions (they are autogenerated by - "make proto" into proto.h) - reason: consistency</P -></LI -><LI -><P -> use endian safe macros when unpacking SMBs (see byteorder.h and + reason: consistency +</p></li><li><p> + don't explicitly extern functions (they are autogenerated by + "make proto" into proto.h) + reason: consistency +</p></li><li><p> + use endian safe macros when unpacking SMBs (see byteorder.h and internals.doc) - reason: not everyone uses Intel</P -></LI -><LI -><P -> Note Unicode implications of charset handling (see internals.doc). See + reason: not everyone uses Intel +</p></li><li><p> + Note Unicode implications of charset handling (see internals.doc). See pull_* and push_* and convert_string functions. - reason: Internationalization</P -></LI -><LI -><P -> Don't assume English only - reason: See above</P -></LI -><LI -><P -> Try to avoid using in/out parameters (functions that return data which + reason: Internationalization +</p></li><li><p> + Don't assume English only + reason: See above +</p></li><li><p> + Try to avoid using in/out parameters (functions that return data which overwrites input parameters) - reason: Can cause stability problems</P -></LI -><LI -><P -> Ensure copyright notices are correct, don't append Tridge's name to code + reason: Can cause stability problems +</p></li><li><p> + Ensure copyright notices are correct, don't append Tridge's name to code that he didn't write. If you did not write the code, make sure that it - can coexist with the rest of the Samba GPLed code.</P -></LI -><LI -><P -> Consider usage of DATA_BLOBs for length specified byte-data. - reason: stability</P -></LI -><LI -><P -> Take advantage of tdbs for database like function - reason: consistency</P -></LI -><LI -><P -> Don't access the SAM_ACCOUNT structure directly, they should be accessed + can coexist with the rest of the Samba GPLed code. +</p></li><li><p> + Consider usage of DATA_BLOBs for length specified byte-data. + reason: stability +</p></li><li><p> + Take advantage of tdbs for database like function + reason: consistency +</p></li><li><p> + Don't access the SAM_ACCOUNT structure directly, they should be accessed via pdb_get...() and pdb_set...() functions. - reason: stability, consistency</P -></LI -><LI -><P -> Don't check a password directly against the passdb, always use the + reason: stability, consistency +</p></li><li><p> + Don't check a password directly against the passdb, always use the check_password() interface. - reason: long term pluggability</P -></LI -><LI -><P -> Try to use asprintf rather than pstrings and fstrings where possible</P -></LI -><LI -><P -> Use normal C comments / * instead of C++ comments // like + reason: long term pluggability +</p></li><li><p> + Try to use asprintf rather than pstrings and fstrings where possible +</p></li><li><p> + Use normal C comments / * instead of C++ comments // like this. Although the C++ comment format is part of the C99 - standard, some older vendor C compilers do not accept it.</P -></LI -><LI -><P -> Try to write documentation for API functions and structures + standard, some older vendor C compilers do not accept it. +</p></li><li><p> + Try to write documentation for API functions and structures explaining the point of the code, the way it should be used, and any special conditions or results. Mark these with a double-star comment start / ** so that they can be picked up by Doxygen, as in - this file.</P -></LI -><LI -><P -> Keep the scope narrow. This means making functions/variables + this file. +</p></li><li><p> + Keep the scope narrow. This means making functions/variables static whenever possible. We don't want our namespace polluted. Each module should have a minimal number of externally - visible functions or variables.</P -></LI -><LI -><P -> Use function pointers to keep knowledge about particular pieces of + visible functions or variables. +</p></li><li><p> + Use function pointers to keep knowledge about particular pieces of code isolated in one place. We don't want a particular piece of functionality to be spread out across lots of places - that makes for fragile, hand to maintain code. Instead, design an interface and use tables containing function pointers to implement specific functionality. This is particularly important for command - interpreters. </P -></LI -><LI -><P -> Think carefully about what it will be like for someone else to add + interpreters. +</p></li><li><p> + Think carefully about what it will be like for someone else to add to and maintain your code. If it would be hard for someone else to - maintain then do it another way. </P -></LI -></OL -><P ->The suggestions above are simply that, suggestions, but the information may + maintain then do it another way. +</p></li></ol></div><p> +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.</P -></DIV -><DIV -CLASS="CHAPTER" -><HR><H1 -><A -NAME="INTERNALS" -></A ->Chapter 5. Samba Internals</H1 -><DIV -CLASS="SECT1" -><H2 -CLASS="SECT1" -><A -NAME="AEN284" ->5.1. Character Handling</A -></H2 -><P ->This section describes character set handling in Samba, as implemented in -Samba 3.0 and above</P -><P ->In the past Samba had very ad-hoc character set handling. Scattered +added. +</p></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="internals"></a>Chapter 5. Samba Internals</h2></div><div><div class="author"><h3 class="author">David Chappell</h3><div class="affiliation"><div class="address"><p><tt><<a href="mailto:David.Chappell@mail.trincoll.edu">David.Chappell@mail.trincoll.edu</a>></tt></p></div></div></div></div><div><p class="pubdate">8 May 1996</p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#id2857490">Character Handling</a></dt><dt><a href="#id2857515">The new functions</a></dt><dt><a href="#id2857977">Macros in byteorder.h</a></dt><dd><dl><dt><a href="#id2857991">CVAL(buf,pos)</a></dt><dt><a href="#id2858005">PVAL(buf,pos)</a></dt><dt><a href="#id2858019">SCVAL(buf,pos,val)</a></dt><dt><a href="#id2858032">SVAL(buf,pos)</a></dt><dt><a href="#id2858048">IVAL(buf,pos)</a></dt><dt><a href="#id2858062">SVALS(buf,pos)</a></dt><dt><a href="#id2858077">IVALS(buf,pos)</a></dt><dt><a href="#id2858091">SSVAL(buf,pos,val)</a></dt><dt><a href="#id2858106">SIVAL(buf,pos,val)</a></dt><dt><a href="#id2858120">SSVALS(buf,pos,val)</a></dt><dt><a href="#id2858134">SIVALS(buf,pos,val)</a></dt><dt><a href="#id2858149">RSVAL(buf,pos)</a></dt><dt><a href="#id2858163">RIVAL(buf,pos)</a></dt><dt><a href="#id2858177">RSSVAL(buf,pos,val)</a></dt><dt><a href="#id2858192">RSIVAL(buf,pos,val)</a></dt></dl></dd><dt><a href="#id2858208">LAN Manager Samba API</a></dt><dd><dl><dt><a href="#id2858243">Parameters</a></dt><dt><a href="#id2858395">Return value</a></dt></dl></dd><dt><a href="#id2858481">Code character table</a></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2857490"></a>Character Handling</h2></div></div><p> +This section describes character set handling in Samba, as implemented in +Samba 3.0 and above +</p><p> +In the past Samba had very ad-hoc character set handling. Scattered throughout the code were numerous calls which converted particular 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.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN288" ->5.2. The new functions</A -></H2 -><P ->The new system works like this:</P -><P -></P -><OL -TYPE="1" -><LI -><P -> all char* strings inside Samba are "unix" strings. These are - multi-byte strings that are in the charset defined by the "unix - charset" option in smb.conf. </P -></LI -><LI -><P -> there is no single fixed character set for unix strings, but any +particular cases without handlingt the general case. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2857515"></a>The new functions</h2></div></div><p> +The new system works like this: +</p><div class="orderedlist"><ol type="1"><li><p> + all char* strings inside Samba are "unix" strings. These are + multi-byte strings that are in the charset defined by the "unix + charset" option in smb.conf. +</p></li><li><p> + there is no single fixed character set for unix strings, but any character set that is used does need the following properties: - </P -><P -></P -><OL -TYPE="a" -><LI -><P -> must not contain NULLs except for termination - </P -></LI -><LI -><P -> must be 7-bit compatible with C strings, so that a constant + </p><div class="orderedlist"><ol type="a"><li><p> + must not contain NULLs except for termination + </p></li><li><p> + must be 7-bit compatible with C strings, so that a constant string or character in C will be byte-for-byte identical to the equivalent string in the chosen character set. - </P -></LI -><LI -><P -> when you uppercase or lowercase a string it does not become + </p></li><li><p> + when you uppercase or lowercase a string it does not become longer than the original string - </P -></LI -><LI -><P -> must be able to correctly hold all characters that your client + </p></li><li><p> + must be able to correctly hold all characters that your client will throw at it - </P -></LI -></OL -><P -> For example, UTF-8 is fine, and most multi-byte asian character sets + </p></li></ol></div><p> + For example, UTF-8 is fine, and most multi-byte asian character sets are fine, but UCS2 could not be used for unix strings as they contain nulls. - </P -></LI -><LI -><P -> when you need to put a string into a buffer that will be sent on the + </p></li><li><p> + when you need to put a string into a buffer that will be sent on the wire, or you need a string in a character set format that is compatible with the clients character set then you need to use a pull_ or push_ function. The pull_ functions pull a string from a wire buffer into a (multi-byte) unix string. The push_ functions - push a string out to a wire buffer. </P -></LI -><LI -><P -> the two main pull_ and push_ functions you need to understand are + push a string out to a wire buffer. +</p></li><li><p> + the two main pull_ and push_ functions you need to understand are pull_string and push_string. These functions take a base pointer that should point at the start of the SMB packet that the string is in. The functions will check the flags field in this packet to @@ -1886,953 +589,426 @@ TYPE="a" STR_ASCII flags. For use in smbd/ and libsmb/ there are wrapper functions clistr_ and srvstr_ that call the pull_/push_ functions with the appropriate first argument. - </P -><P -> You may also call the pull_ascii/pull_ucs2 or push_ascii/push_ucs2 + </p><p> + You may also call the pull_ascii/pull_ucs2 or push_ascii/push_ucs2 functions if you know that a particular string is ascii or unicode. There are also a number of other convenience functions in charcnv.c that call the pull_/push_ functions with particularly common arguments, such as pull_ascii_pstring() - </P -></LI -><LI -><P -> The biggest thing to remember is that internal (unix) strings in Samba + </p></li><li><p> + The biggest thing to remember is that internal (unix) strings in Samba may now contain multi-byte characters. This means you cannot assume that characters are always 1 byte long. Often this means that you will have to convert strings to ucs2 and back again in order to do some (seemingly) simple task. For examples of how to do this see functions like strchr_m(). I know this is very slow, and we will eventually - speed it up but right now we want this stuff correct not fast.</P -></LI -><LI -><P -> all lp_ functions now return unix strings. The magic "DOS" flag on - parameters is gone.</P -></LI -><LI -><P -> all vfs functions take unix strings. Don't convert when passing to them</P -></LI -></OL -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN317" ->5.3. Macros in byteorder.h</A -></H2 -><P ->This section describes the macros defined in byteorder.h. These macros -are used extensively in the Samba code.</P -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN320" ->5.3.1. CVAL(buf,pos)</A -></H3 -><P ->returns the byte at offset pos within buffer buf as an unsigned character.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN323" ->5.3.2. PVAL(buf,pos)</A -></H3 -><P ->returns the value of CVAL(buf,pos) cast to type unsigned integer.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN326" ->5.3.3. SCVAL(buf,pos,val)</A -></H3 -><P ->sets the byte at offset pos within buffer buf to value val.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN329" ->5.3.4. SVAL(buf,pos)</A -></H3 -><P -> returns the value of the unsigned short (16 bit) little-endian integer at + speed it up but right now we want this stuff correct not fast. +</p></li><li><p> + all lp_ functions now return unix strings. The magic "DOS" flag on + parameters is gone. +</p></li><li><p> + all vfs functions take unix strings. Don't convert when passing to them +</p></li></ol></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2857977"></a>Macros in byteorder.h</h2></div></div><p> +This section describes the macros defined in byteorder.h. These macros +are used extensively in the Samba code. +</p><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2857991"></a>CVAL(buf,pos)</h3></div></div><p> +returns the byte at offset pos within buffer buf as an unsigned character. +</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858005"></a>PVAL(buf,pos)</h3></div></div><p>returns the value of CVAL(buf,pos) cast to type unsigned integer.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858019"></a>SCVAL(buf,pos,val)</h3></div></div><p>sets the byte at offset pos within buffer buf to value val.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858032"></a>SVAL(buf,pos)</h3></div></div><p> + 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".</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN332" ->5.3.5. IVAL(buf,pos)</A -></H3 -><P ->returns the value of the unsigned 32 bit little-endian integer at offset -pos within buffer buf.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN335" ->5.3.6. SVALS(buf,pos)</A -></H3 -><P ->returns the value of the signed short (16 bit) little-endian integer at -offset pos within buffer buf.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN338" ->5.3.7. IVALS(buf,pos)</A -></H3 -><P ->returns the value of the signed 32 bit little-endian integer at offset pos -within buffer buf.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN341" ->5.3.8. SSVAL(buf,pos,val)</A -></H3 -><P ->sets the unsigned short (16 bit) little-endian integer at offset pos within -buffer buf to value val.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN344" ->5.3.9. SIVAL(buf,pos,val)</A -></H3 -><P ->sets the unsigned 32 bit little-endian integer at offset pos within buffer -buf to the value val.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN347" ->5.3.10. SSVALS(buf,pos,val)</A -></H3 -><P ->sets the short (16 bit) signed little-endian integer at offset pos within -buffer buf to the value val.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN350" ->5.3.11. SIVALS(buf,pos,val)</A -></H3 -><P ->sets the signed 32 bit little-endian integer at offset pos withing buffer -buf to the value val.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN353" ->5.3.12. RSVAL(buf,pos)</A -></H3 -><P ->returns the value of the unsigned short (16 bit) big-endian integer at -offset pos within buffer buf.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN356" ->5.3.13. RIVAL(buf,pos)</A -></H3 -><P ->returns the value of the unsigned 32 bit big-endian integer at offset -pos within buffer buf.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN359" ->5.3.14. RSSVAL(buf,pos,val)</A -></H3 -><P ->sets the value of the unsigned short (16 bit) big-endian integer at + refered to as "USHORT". +</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858048"></a>IVAL(buf,pos)</h3></div></div><p>returns the value of the unsigned 32 bit little-endian integer at offset +pos within buffer buf.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858062"></a>SVALS(buf,pos)</h3></div></div><p>returns the value of the signed short (16 bit) little-endian integer at +offset pos within buffer buf.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858077"></a>IVALS(buf,pos)</h3></div></div><p>returns the value of the signed 32 bit little-endian integer at offset pos +within buffer buf.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858091"></a>SSVAL(buf,pos,val)</h3></div></div><p>sets the unsigned short (16 bit) little-endian integer at offset pos within +buffer buf to value val.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858106"></a>SIVAL(buf,pos,val)</h3></div></div><p>sets the unsigned 32 bit little-endian integer at offset pos within buffer +buf to the value val.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858120"></a>SSVALS(buf,pos,val)</h3></div></div><p>sets the short (16 bit) signed little-endian integer at offset pos within +buffer buf to the value val.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858134"></a>SIVALS(buf,pos,val)</h3></div></div><p>sets the signed 32 bit little-endian integer at offset pos withing buffer +buf to the value val.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858149"></a>RSVAL(buf,pos)</h3></div></div><p>returns the value of the unsigned short (16 bit) big-endian integer at +offset pos within buffer buf.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858163"></a>RIVAL(buf,pos)</h3></div></div><p>returns the value of the unsigned 32 bit big-endian integer at offset +pos within buffer buf.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858177"></a>RSSVAL(buf,pos,val)</h3></div></div><p>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".</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN362" ->5.3.15. RSIVAL(buf,pos,val)</A -></H3 -><P ->sets the value of the unsigned 32 bit big-endian integer at offset -pos within buffer buf to value val.</P -></DIV -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN365" ->5.4. LAN Manager Samba API</A -></H2 -><P ->This section describes the functions need to make a LAN Manager RPC call. +refered to as "USHORT".</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858192"></a>RSIVAL(buf,pos,val)</h3></div></div><p>sets the value of the unsigned 32 bit big-endian integer at offset +pos within buffer buf to value val.</p></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2858208"></a>LAN Manager Samba API</h2></div></div><p> +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.</P -><P -><PRE -CLASS="PROGRAMLISTING" ->call_api(int prcnt, int drcnt, int mprcnt, int mdrcnt, - char *param, char *data, char **rparam, char **rdata);</PRE -></P -><P ->This function is defined in client.c. It uses an SMB transaction to call a -remote api.</P -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN371" ->5.4.1. Parameters</A -></H3 -><P ->The parameters are as follows:</P -><P -></P -><OL -TYPE="1" -><LI -><P -> prcnt: the number of bytes of parameters begin sent.</P -></LI -><LI -><P -> drcnt: the number of bytes of data begin sent.</P -></LI -><LI -><P -> mprcnt: the maximum number of bytes of parameters which should be returned</P -></LI -><LI -><P -> mdrcnt: the maximum number of bytes of data which should be returned</P -></LI -><LI -><P -> param: a pointer to the parameters to be sent.</P -></LI -><LI -><P -> data: a pointer to the data to be sent.</P -></LI -><LI -><P -> rparam: a pointer to a pointer which will be set to point to the returned - paramters. The caller of call_api() must deallocate this memory.</P -></LI -><LI -><P -> rdata: a pointer to a pointer which will be set to point to the returned - data. The caller of call_api() must deallocate this memory.</P -></LI -></OL -><P ->These are the parameters which you ought to send, in the order of their -appearance in the parameter block:</P -><P -></P -><OL -TYPE="1" -><LI -><P ->An unsigned 16 bit integer API number. You should set this value with -SSVAL(). I do not know where these numbers are described.</P -></LI -><LI -><P ->An ASCIIZ string describing the parameters to the API function as defined +reliable. +</p><p> +</p><pre class="programlisting"> +call_api(int prcnt, int drcnt, int mprcnt, int mdrcnt, + char *param, char *data, char **rparam, char **rdata); +</pre><p> +</p><p> +This function is defined in client.c. It uses an SMB transaction to call a +remote api. +</p><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858243"></a>Parameters</h3></div></div><p>The parameters are as follows:</p><div class="orderedlist"><ol type="1"><li><p> + prcnt: the number of bytes of parameters begin sent. +</p></li><li><p> + drcnt: the number of bytes of data begin sent. +</p></li><li><p> + mprcnt: the maximum number of bytes of parameters which should be returned +</p></li><li><p> + mdrcnt: the maximum number of bytes of data which should be returned +</p></li><li><p> + param: a pointer to the parameters to be sent. +</p></li><li><p> + data: a pointer to the data to be sent. +</p></li><li><p> + rparam: a pointer to a pointer which will be set to point to the returned + paramters. The caller of call_api() must deallocate this memory. +</p></li><li><p> + rdata: a pointer to a pointer which will be set to point to the returned + data. The caller of call_api() must deallocate this memory. +</p></li></ol></div><p> +These are the parameters which you ought to send, in the order of their +appearance in the parameter block: +</p><div class="orderedlist"><ol type="1"><li><p> +An unsigned 16 bit integer API number. You should set this value with +SSVAL(). I do not know where these numbers are described. +</p></li><li><p> +An ASCIIZ string describing the parameters to the API function as defined in the LAN Manager documentation. The first parameter, which is the server name, is ommited. This string is based uppon the API function as described -in the manual, not the data which is actually passed.</P -></LI -><LI -><P ->An ASCIIZ string describing the data structure which ought to be returned.</P -></LI -><LI -><P ->Any parameters which appear in the function call, as defined in the LAN -Manager API documentation, after the "Server" and up to and including the -"uLevel" parameters.</P -></LI -><LI -><P ->An unsigned 16 bit integer which gives the size in bytes of the buffer we +in the manual, not the data which is actually passed. +</p></li><li><p> +An ASCIIZ string describing the data structure which ought to be returned. +</p></li><li><p> +Any parameters which appear in the function call, as defined in the LAN +Manager API documentation, after the "Server" and up to and including the +"uLevel" parameters. +</p></li><li><p> +An unsigned 16 bit integer which gives the size in bytes of the buffer we will use to receive the returned array of data structures. Presumably this -should be the same as mdrcnt. This value should be set with SSVAL().</P -></LI -><LI -><P ->An ASCIIZ string describing substructures which should be returned. If no -substructures apply, this string is of zero length.</P -></LI -></OL -><P ->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.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN406" ->5.4.2. Return value</A -></H3 -><P ->The returned parameters (pointed to by rparam), in their order of appearance -are:</P -><P -></P -><OL -TYPE="1" -><LI -><P ->An unsigned 16 bit integer which contains the API function's return code. -This value should be read with SVAL().</P -></LI -><LI -><P ->An adjustment which tells the amount by which pointers in the returned +should be the same as mdrcnt. This value should be set with SSVAL(). +</p></li><li><p> +An ASCIIZ string describing substructures which should be returned. If no +substructures apply, this string is of zero length. +</p></li></ol></div><p> +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. +</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858395"></a>Return value</h3></div></div><p> +The returned parameters (pointed to by rparam), in their order of appearance +are:</p><div class="orderedlist"><ol type="1"><li><p> +An unsigned 16 bit integer which contains the API function's return code. +This value should be read with SVAL(). +</p></li><li><p> +An adjustment which tells the amount by which pointers in the returned data should be adjusted. This value should be read with SVAL(). Basically, the address of the start of the returned data buffer should have the returned pointer value added to it and then have this value subtracted from it in -order to obtain the currect offset into the returned data buffer.</P -></LI -><LI -><P ->A count of the number of elements in the array of structures returned. -It is also possible that this may sometimes be the number of bytes returned.</P -></LI -></OL -><P ->When call_api() returns, rparam points to the returned parameters. The +order to obtain the currect offset into the returned data buffer. +</p></li><li><p> +A count of the number of elements in the array of structures returned. +It is also possible that this may sometimes be the number of bytes returned. +</p></li></ol></div><p> +When call_api() returns, rparam points to the returned parameters. The first if these is the result code. It will be zero if the API call -suceeded. This value by be read with "SVAL(rparam,0)".</P -><P ->The second parameter may be read as "SVAL(rparam,2)". It is a 16 bit offset +suceeded. This value by be read with "SVAL(rparam,0)". +</p><p> +The second parameter may be read as "SVAL(rparam,2)". It is a 16 bit offset which indicates what the base address of the returned data buffer was when it was built on the server. It should be used to correct pointer before -use.</P -><P ->The returned data buffer contains the array of returned data structures. +use. +</p><p> +The returned data buffer contains the array of returned data structures. Note that all pointers must be adjusted before use. The function -fix_char_ptr() in client.c can be used for this purpose.</P -><P ->The third parameter (which may be read as "SVAL(rparam,4)") has something to +fix_char_ptr() in client.c can be used for this purpose. +</p><p> +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.</P -></DIV -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN420" ->5.5. Code character table</A -></H2 -><P ->Certain data structures are described by means of ASCIIz strings containing -code characters. These are the code characters:</P -><P -></P -><OL -TYPE="1" -><LI -><P ->W a type byte little-endian unsigned integer</P -></LI -><LI -><P ->N a count of substructures which follow</P -></LI -><LI -><P ->D a four byte little-endian unsigned integer</P -></LI -><LI -><P ->B a byte (with optional count expressed as trailing ASCII digits)</P -></LI -><LI -><P ->z a four byte offset to a NULL terminated string</P -></LI -><LI -><P ->l a four byte offset to non-string user data</P -></LI -><LI -><P ->b an offset to data (with count expressed as trailing ASCII digits)</P -></LI -><LI -><P ->r pointer to returned data buffer???</P -></LI -><LI -><P ->L length in bytes of returned data buffer???</P -></LI -><LI -><P ->h number of bytes of information available???</P -></LI -></OL -></DIV -></DIV -><DIV -CLASS="CHAPTER" -><HR><H1 -><A -NAME="PARSING" -></A ->Chapter 6. The smb.conf file</H1 -><DIV -CLASS="SECT1" -><H2 -CLASS="SECT1" -><A -NAME="AEN451" ->6.1. Lexical Analysis</A -></H2 -><P ->Basically, the file is processed on a line by line basis. There are +data which can be returned if enough buffer space is allowed. +</p></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2858481"></a>Code character table</h2></div></div><p> +Certain data structures are described by means of ASCIIz strings containing +code characters. These are the code characters: +</p><div class="orderedlist"><ol type="1"><li><p> +W a type byte little-endian unsigned integer +</p></li><li><p> +N a count of substructures which follow +</p></li><li><p> +D a four byte little-endian unsigned integer +</p></li><li><p> +B a byte (with optional count expressed as trailing ASCII digits) +</p></li><li><p> +z a four byte offset to a NULL terminated string +</p></li><li><p> +l a four byte offset to non-string user data +</p></li><li><p> +b an offset to data (with count expressed as trailing ASCII digits) +</p></li><li><p> +r pointer to returned data buffer??? +</p></li><li><p> +L length in bytes of returned data buffer??? +</p></li><li><p> +h number of bytes of information available??? +</p></li></ol></div></div></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="parsing"></a>Chapter 6. The smb.conf file</h2></div><div><div class="author"><h3 class="author">Chris Hertel</h3></div></div><div><p class="pubdate">November 1997</p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#id2857849">Lexical Analysis</a></dt><dd><dl><dt><a href="#id2857787">Handling of Whitespace</a></dt><dt><a href="#id2858749">Handling of Line Continuation</a></dt><dt><a href="#id2858813">Line Continuation Quirks</a></dt></dl></dd><dt><a href="#id2858913">Syntax</a></dt><dd><dl><dt><a href="#id2858982">About params.c</a></dt></dl></dd></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2857849"></a>Lexical Analysis</h2></div></div><p> +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):</P -><P -></P -><OL -TYPE="1" -><LI -><P ->Blank lines - Lines containing only whitespace.</P -></LI -><LI -><P ->Comment lines - Lines beginning with either a semi-colon or a -pound sign (';' or '#').</P -></LI -><LI -><P ->Section header lines - Lines beginning with an open square bracket ('[').</P -></LI -><LI -><P ->Parameter lines - Lines beginning with any other character. -(The default line type.)</P -></LI -></OL -><P ->The first two are handled exclusively by the lexical analyzer, which -ignores them. The latter two line types are scanned for</P -><P -></P -><OL -TYPE="1" -><LI -><P -> - Section names</P -></LI -><LI -><P -> - Parameter names</P -></LI -><LI -><P -> - Parameter values</P -></LI -></OL -><P ->These are the only tokens passed to the parameter loader +(params.c): +</p><div class="orderedlist"><ol type="1"><li><p> +Blank lines - Lines containing only whitespace. +</p></li><li><p> +Comment lines - Lines beginning with either a semi-colon or a +pound sign (';' or '#'). +</p></li><li><p> +Section header lines - Lines beginning with an open square bracket ('['). +</p></li><li><p> +Parameter lines - Lines beginning with any other character. +(The default line type.) +</p></li></ol></div><p> +The first two are handled exclusively by the lexical analyzer, which +ignores them. The latter two line types are scanned for +</p><div class="orderedlist"><ol type="1"><li><p> + - Section names +</p></li><li><p> + - Parameter names +</p></li><li><p> + - Parameter values +</p></li></ol></div><p> +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: '='.</P -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN472" ->6.1.1. Handling of Whitespace</A -></H3 -><P ->Whitespace is defined as all characters recognized by the isspace() +another by an equal sign: '='. +</p><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2857787"></a>Handling of Whitespace</h3></div></div><p> +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.</P -><P -></P -><OL -TYPE="1" -><LI -><P ->The lexical analyzer scans past white space at the beginning of a line.</P -></LI -><LI -><P ->Section and parameter names may contain internal white space. All -whitespace within a name is compressed to a single space character. </P -></LI -><LI -><P ->Internal whitespace within a parameter value is kept verbatim with +The newline is excluded because it identifies the end of the line. +</p><div class="orderedlist"><ol type="1"><li><p> +The lexical analyzer scans past white space at the beginning of a line. +</p></li><li><p> +Section and parameter names may contain internal white space. All +whitespace within a name is compressed to a single space character. +</p></li><li><p> +Internal whitespace within a parameter value is kept verbatim with the exception of carriage return characters ('\r'), all of which -are removed.</P -></LI -><LI -><P ->Leading and trailing whitespace is removed from names and values.</P -></LI -></OL -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN484" ->6.1.2. Handling of Line Continuation</A -></H3 -><P ->Long section header and parameter lines may be extended across +are removed. +</p></li><li><p> +Leading and trailing whitespace is removed from names and values. +</p></li></ol></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858749"></a>Handling of Line Continuation</h3></div></div><p> +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.</P -><P ->If the last (non-whitespace) character within a section header or on +continuation is ignored for blank and comment lines. +</p><p> +If the last (non-whitespace) character within a section header or on a parameter line is a backslash, then the next line will be (logically) concatonated with the current line by the lexical -analyzer. For example:</P -><P -><PRE -CLASS="PROGRAMLISTING" -> param name = parameter value string \ - with line continuation.</PRE -></P -><P ->Would be read as</P -><P -><PRE -CLASS="PROGRAMLISTING" -> param name = parameter value string with line continuation.</PRE -></P -><P ->Note that there are five spaces following the word 'string', +analyzer. For example: +</p><pre class="programlisting"> + param name = parameter value string \ + with line continuation. +</pre><p>Would be read as</p><pre class="programlisting"> + param name = parameter value string with line continuation. +</pre><p> +Note that there are five spaces following the word 'string', representing the one space between 'string' and '\\' in the top line, plus the four preceeding the word 'with' in the second line. -(Yes, I'm counting the indentation.)</P -><P ->Line continuation characters are ignored on blank lines and at the end +(Yes, I'm counting the indentation.) +</p><p> +Line continuation characters are ignored on blank lines and at the end of comments. They are *only* recognized within section and parameter -lines.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN495" ->6.1.3. Line Continuation Quirks</A -></H3 -><P ->Note the following example:</P -><P -><PRE -CLASS="PROGRAMLISTING" -> param name = parameter value string \ +lines. +</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858813"></a>Line Continuation Quirks</h3></div></div><p>Note the following example:</p><pre class="programlisting"> + param name = parameter value string \ \ - with line continuation.</PRE -></P -><P ->The middle line is *not* parsed as a blank line because it is first -concatonated with the top line. The result is</P -><P -><PRE -CLASS="PROGRAMLISTING" ->param name = parameter value string with line continuation.</PRE -></P -><P ->The same is true for comment lines.</P -><P -><PRE -CLASS="PROGRAMLISTING" -> param name = parameter value string \ + with line continuation. +</pre><p> +The middle line is *not* parsed as a blank line because it is first +concatonated with the top line. The result is +</p><pre class="programlisting"> +param name = parameter value string with line continuation. +</pre><p>The same is true for comment lines.</p><pre class="programlisting"> + param name = parameter value string \ ; comment \ - with a comment.</PRE -></P -><P ->This becomes:</P -><P -><PRE -CLASS="PROGRAMLISTING" ->param name = parameter value string ; comment with a comment.</PRE -></P -><P ->On a section header line, the closing bracket (']') is considered a -terminating character, and the rest of the line is ignored. The lines</P -><P -><PRE -CLASS="PROGRAMLISTING" -> [ section name ] garbage \ - param name = value</PRE -></P -><P ->are read as</P -><P -><PRE -CLASS="PROGRAMLISTING" -> [section name] - param name = value</PRE -></P -></DIV -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN515" ->6.2. Syntax</A -></H2 -><P ->The syntax of the smb.conf file is as follows:</P -><P -><PRE -CLASS="PROGRAMLISTING" -> <file> :== { <section> } EOF - <section> :== <section header> { <parameter line> } - <section header> :== '[' NAME ']' - <parameter line> :== NAME '=' VALUE NL</PRE -></P -><P ->Basically, this means that</P -><P -></P -><OL -TYPE="1" -><LI -><P -> a file is made up of zero or more sections, and is terminated by - an EOF (we knew that).</P -></LI -><LI -><P -> A section is made up of a section header followed by zero or more - parameter lines.</P -></LI -><LI -><P -> A section header is identified by an opening bracket and + with a comment. +</pre><p>This becomes:</p><pre class="programlisting"> +param name = parameter value string ; comment with a comment. +</pre><p> +On a section header line, the closing bracket (']') is considered a +terminating character, and the rest of the line is ignored. The lines +</p><pre class="programlisting"> + [ section name ] garbage \ + param name = value +</pre><p>are read as</p><pre class="programlisting"> + [section name] + param name = value +</pre></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2858913"></a>Syntax</h2></div></div><p>The syntax of the smb.conf file is as follows:</p><pre class="programlisting"> + <file> :== { <section> } EOF + <section> :== <section header> { <parameter line> } + <section header> :== '[' NAME ']' + <parameter line> :== NAME '=' VALUE NL +</pre><p>Basically, this means that</p><div class="orderedlist"><ol type="1"><li><p> + a file is made up of zero or more sections, and is terminated by + an EOF (we knew that). +</p></li><li><p> + A section is made up of a section header followed by zero or more + parameter lines. +</p></li><li><p> + A section header is identified by an opening bracket and terminated by the closing bracket. The enclosed NAME identifies - the section.</P -></LI -><LI -><P -> A parameter line is divided into a NAME and a VALUE. The *first* + the section. +</p></li><li><p> + 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').</P -></LI -></OL -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN530" ->6.2.1. About params.c</A -></H3 -><P ->The parsing of the config file is a bit unusual if you are used to + VALUE is terminated by a newline character (NL = '\n'). +</p></li></ol></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2858982"></a>About params.c</h3></div></div><p> +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.</P -></DIV -></DIV -></DIV -><DIV -CLASS="CHAPTER" -><HR><H1 -><A -NAME="UNIX-SMB" -></A ->Chapter 7. NetBIOS in a Unix World</H1 -><DIV -CLASS="SECT1" -><H2 -CLASS="SECT1" -><A -NAME="AEN540" ->7.1. Introduction</A -></H2 -><P ->This is a short document that describes some of the issues that +loadparm.c. +</p></div></div></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="unix-smb"></a>Chapter 7. NetBIOS in a Unix World</h2></div><div><div class="author"><h3 class="author">Andrew Tridgell</h3></div></div><div><p class="pubdate">April 1995</p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#id2858682">Introduction</a></dt><dt><a href="#id2858703">Usernames</a></dt><dt><a href="#id2858620">File Ownership</a></dt><dt><a href="#id2858644">Passwords</a></dt><dt><a href="#id2859208">Locking</a></dt><dt><a href="#id2859270">Deny Modes</a></dt><dt><a href="#id2859300">Trapdoor UIDs</a></dt><dt><a href="#id2859325">Port numbers</a></dt><dt><a href="#id2859371">Protocol Complexity</a></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2858682"></a>Introduction</h2></div></div><p> +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 -interoperability.</P -><P ->It was written to help out a person who was writing a paper on unix to -PC connectivity.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN544" ->7.2. Usernames</A -></H2 -><P ->The SMB protocol has only a loose username concept. Early SMB +them. They may help people who are looking at unix<->PC +interoperability. +</p><p> +It was written to help out a person who was writing a paper on unix to +PC connectivity. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2858703"></a>Usernames</h2></div></div><p> +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 (particularly printer operations) without first validating a username -on the server.</P -><P ->Unix security is based around username/password pairs. A unix box +on the server. +</p><p> +Unix security is based around username/password pairs. A unix box should not allow clients to do any substantive operation without some -sort of validation. </P -><P ->The problem mostly manifests itself when the unix server is in "share -level" security mode. This is the default mode as the alternative -"user level" security mode usually forces a client to connect to the +sort of validation. +</p><p> +The problem mostly manifests itself when the unix server is in "share +level" security mode. This is the default mode as the alternative +"user level" security mode usually forces a client to connect to the server as the same user for each connected share, which is -inconvenient in many sites.</P -><P ->In "share level" security the client normally gives a username in the -"session setup" protocol, but does not supply an accompanying -password. The client then connects to resources using the "tree -connect" protocol, and supplies a password. The problem is that the +inconvenient in many sites. +</p><p> +In "share level" security the client normally gives a username in the +"session setup" protocol, but does not supply an accompanying +password. The client then connects to resources using the "tree +connect" protocol, and supplies a password. The problem is that the user on the PC types the username and the password in different contexts, unaware that they need to go together to give access to the server. The username is normally the one the user typed in when they -"logged onto" the PC (this assumes Windows for Workgroups). The -password is the one they chose when connecting to the disk or printer.</P -><P ->The user often chooses a totally different username for their login as +"logged onto" the PC (this assumes Windows for Workgroups). The +password is the one they chose when connecting to the disk or printer. +</p><p> +The user often chooses a totally different username for their login as for the drive connection. Often they also want to access different drives as different usernames. The unix server needs some way of -divining the correct username to combine with each password.</P -><P ->Samba tries to avoid this problem using several methods. These succeed +divining the correct username to combine with each password. +</p><p> +Samba tries to avoid this problem using several methods. These succeed 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).</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN552" ->7.3. File Ownership</A -></H2 -><P ->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.</P -><P ->This brings up all sorts of interesting problems. For example, when +(either directly or via the user= option). +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2858620"></a>File Ownership</h2></div></div><p> +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. +</p><p> +This brings up all sorts of interesting problems. For example, when you copy a file to a unix drive, and the file is world writeable but owned by another user the file will transfer correctly but will receive the wrong date. This is because the utime() call under unix only succeeds for the owner of the file, or root, even if the file is world writeable. For security reasons Samba does all file operations as the validated user, not root, so the utime() fails. This can stuff -up shared development diectories as programs like "make" will not get -file time comparisons right.</P -><P ->There are several possible solutions to this problem, including +up shared development diectories as programs like "make" will not get +file time comparisons right. +</p><p> +There are several possible solutions to this problem, including username mapping, and forcing a specific username for particular -shares.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN557" ->7.4. Passwords</A -></H2 -><P ->Many SMB clients uppercase passwords before sending them. I have no +shares. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2858644"></a>Passwords</h2></div></div><p> +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 -obviously it isn't just the data entry routines that are to blame.</P -><P ->Unix passwords are case sensitive. So if users use mixed case -passwords they are in trouble.</P -><P ->Samba can try to cope with this by either using the "password level" +obviously it isn't just the data entry routines that are to blame. +</p><p> +Unix passwords are case sensitive. So if users use mixed case +passwords they are in trouble. +</p><p> +Samba can try to cope with this by either using the "password level" option which causes Samba to try the offered password with up to the -specified number of case changes, or by using the "password server" +specified number of case changes, or by using the "password server" option which allows Samba to do its validation via another machine -(typically a WinNT server).</P -><P ->Samba supports the password encryption method used by SMB +(typically a WinNT server). +</p><p> +Samba supports the password encryption method used by SMB clients. Note that the use of password encryption in Microsoft -networking leads to password hashes that are "plain text equivalent". +networking leads to password hashes that are "plain text equivalent". This means that it is *VERY* important to ensure that the Samba smbpasswd file containing these password hashes is only readable by the root user. See the documentation ENCRYPTION.txt for more -details.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN563" ->7.5. Locking</A -></H2 -><P ->Since samba 2.2, samba supports other types of locking as well. This -section is outdated.</P -><P ->The locking calls available under a DOS/Windows environment are much +details. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2859208"></a>Locking</h2></div></div><p> +Since samba 2.2, samba supports other types of locking as well. This +section is outdated. +</p><p> +The locking calls available under a DOS/Windows environment are much richer than those available in unix. This means a unix server (like Samba) choosing to use the standard fcntl() based unix locking calls -to implement SMB locking has to improvise a bit.</P -><P ->One major problem is that dos locks can be in a 32 bit (unsigned) +to implement SMB locking has to improvise a bit. +</p><p> +One major problem is that dos locks can be in a 32 bit (unsigned) range. Unix locking calls are 32 bits, but are signed, giving only a 31 bit range. Unfortunately OLE2 clients use the top bit to select a -locking range used for OLE semaphores.</P -><P ->To work around this problem Samba compresses the 32 bit range into 31 +locking range used for OLE semaphores. +</p><p> +To work around this problem Samba compresses the 32 bit range into 31 bits by appropriate bit shifting. This seems to work but is not ideal. In a future version a separate SMB lockd may be added to cope -with the problem.</P -><P ->It also doesn't help that many unix lockd daemons are very buggy and +with the problem. +</p><p> +It also doesn't help that many unix lockd daemons are very buggy and crash at the slightest provocation. They normally go mostly unused in a unix environment because few unix programs use byte range locking. The stress of huge numbers of lock requests from dos/windows -clients can kill the daemon on some systems.</P -><P ->The second major problem is the "opportunistic locking" requested by +clients can kill the daemon on some systems. +</p><p> +The second major problem is the "opportunistic locking" requested by some clients. If a client requests opportunistic locking then it is asking the server to notify it if anyone else tries to do something on the same file, at which time the client will say if it is willing to give up its lock. Unix has no simple way of implementing -opportunistic locking, and currently Samba has no support for it.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN571" ->7.6. Deny Modes</A -></H2 -><P ->When a SMB client opens a file it asks for a particular "deny mode" to +opportunistic locking, and currently Samba has no support for it. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2859270"></a>Deny Modes</h2></div></div><p> +When a SMB client opens a file it asks for a particular "deny mode" to be placed on the file. These modes (DENY_NONE, DENY_READ, DENY_WRITE, DENY_ALL, DENY_FCB and DENY_DOS) specify what actions should be allowed by anyone else who tries to use the file at the same time. If DENY_READ is placed on the file, for example, then any attempt to open -the file for reading should fail.</P -><P ->Unix has no equivalent notion. To implement this Samba uses either lock +the file for reading should fail. +</p><p> +Unix has no equivalent notion. To implement this Samba uses either lock files based on the files inode and placed in a separate lock 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.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN575" ->7.7. Trapdoor UIDs</A -></H2 -><P ->A SMB session can run with several uids on the one socket. This +by default for those systems that support it. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2859300"></a>Trapdoor UIDs</h2></div></div><p> +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 within the one process. On some unixes (such as SCO) this is not possible. This means that on those unixes the client is restricted to -a single uid.</P -><P ->Note that you can also get the "trapdoor uid" message for other -reasons. Please see the FAQ for details.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN579" ->7.8. Port numbers</A -></H2 -><P ->There is a convention that clients on sockets use high "unprivilaged" -port numbers (>1000) and connect to servers on low "privilaged" port +a single uid. +</p><p> +Note that you can also get the "trapdoor uid" message for other +reasons. Please see the FAQ for details. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2859325"></a>Port numbers</h2></div></div><p> +There is a convention that clients on sockets use high "unprivilaged" +port numbers (>1000) and connect to servers on low "privilaged" port numbers. This is enforced in Unix as non-root users can't open a -socket for listening on port numbers less than 1000.</P -><P ->Most PC based SMB clients (such as WfWg and WinNT) don't follow this +socket for listening on port numbers less than 1000. +</p><p> +Most PC based SMB clients (such as WfWg and WinNT) don't follow this convention completely. The main culprit is the netbios nameserving on udp port 137. Name query requests come from a source port of 137. This is a problem when you combine it with the common firewalling technique of not allowing incoming packets on low port numbers. This means that these clients can't query a netbios nameserver on the other side of a -low port based firewall.</P -><P ->The problem is more severe with netbios node status queries. I've +low port based firewall. +</p><p> +The problem is more severe with netbios node status queries. I've found that WfWg, Win95 and WinNT3.5 all respond to netbios node status queries on port 137 no matter what the source port was in the request. This works between machines that are both using port 137, but @@ -2840,421 +1016,179 @@ it means it's not possible for a unix user to do a node status request 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.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN584" ->7.9. Protocol Complexity</A -></H2 -><P ->There are many "protocol levels" in the SMB protocol. It seems that +responses back to the source port in the request. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2859371"></a>Protocol Complexity</h2></div></div><p> +There are many "protocol levels" in the SMB protocol. It seems that each time new functionality was added to a Microsoft operating system, they added the equivalent functions in a new protocol level of the SMB -protocol to "externalise" the new capabilities.</P -><P ->This means the protocol is very "rich", offering many ways of doing +protocol to "externalise" the new capabilities. +</p><p> +This means the protocol is very "rich", offering many ways of doing each file operation. This means SMB servers need to be complex and large. It also means it is very difficult to make them bug free. It is not just Samba that suffers from this problem, other servers such as WinNT don't support every variation of every call and it has almost certainly been a headache for MS developers to support the myriad of -SMB calls that are available.</P -><P ->There are about 65 "top level" operations in the SMB protocol (things +SMB calls that are available. +</p><p> +There are about 65 "top level" operations in the SMB protocol (things like SMBread and SMBwrite). Some of these include hundreds of sub-functions (SMBtrans has at least 120 sub-functions, like DosPrintQAdd and NetSessionEnum). All of them take several options that can change the way they work. Many take dozens of possible -"information levels" that change the structures that need to be -returned. Samba supports all but 2 of the "top level" functions. It +"information levels" that change the structures that need to be +returned. Samba supports all but 2 of the "top level" functions. It supports only 8 (so far) of the SMBtrans sub-functions. Even NT -doesn't support them all.</P -><P ->Samba currently supports up to the "NT LM 0.12" protocol, which is the +doesn't support them all. +</p><p> +Samba currently supports up to the "NT LM 0.12" protocol, which is the one preferred by Win95 and WinNT3.5. Luckily this protocol level has a -"capabilities" field which specifies which super-duper new-fangled +"capabilities" field which specifies which super-duper new-fangled options the server suports. This helps to make the implementation of -this protocol level much easier.</P -><P ->There is also a problem with the SMB specications. SMB is a X/Open +this protocol level much easier. +</p><p> +There is also a problem with the SMB specications. SMB is a X/Open spec, but the X/Open book is far from ideal, and fails to cover many important issues, leaving much to the imagination. Microsoft recently renamed the SMB protocol CIFS (Common Internet File System) and have published new specifications. These are far superior to the old X/Open documents but there are still undocumented calls and features. This specification is actively being worked on by a CIFS developers -mailing list hosted by Microsft.</P -></DIV -></DIV -><DIV -CLASS="CHAPTER" -><HR><H1 -><A -NAME="TRACING" -></A ->Chapter 8. Tracing samba system calls</H1 -><P ->This file describes how to do a system call trace on Samba to work out +mailing list hosted by Microsft. +</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="tracing"></a>Chapter 8. Tracing samba system calls</h2></div><div><div class="author"><h3 class="author">Andrew Tridgell</h3><div class="affiliation"><span class="orgname">Samba Team<br></span></div></div></div></div><p> +This file describes how to do a system call trace on Samba to work out what its doing wrong. This is not for the faint of heart, but if you -are reading this then you are probably desperate.</P -><P ->Actually its not as bad as the the above makes it sound, just don't -expect the output to be very pretty :-)</P -><P ->Ok, down to business. One of the big advantages of unix systems is +are reading this then you are probably desperate. +</p><p> +Actually its not as bad as the the above makes it sound, just don't +expect the output to be very pretty :-) +</p><p> +Ok, down to business. One of the big advantages of unix systems is that they nearly all come with a system trace utility that allows you to monitor all system calls that a program is making. This is extremely using for debugging and also helps when trying to work out why something is slower than you expect. You can use system tracing -without any special compilation options. </P -><P ->The system trace utility is called different things on different +without any special compilation options. +</p><p> +The system trace utility is called different things on different systems. On Linux systems its called strace. Under SunOS 4 its called trace. Under SVR4 style systems (including solaris) its called -truss. Under many BSD systems its called ktrace. </P -><P ->The first thing you should do is read the man page for your native +truss. Under many BSD systems its called ktrace. +</p><p> +The first thing you should do is read the man page for your native system call tracer. In the discussion below I'll assume its called strace as strace is the only portable system tracer (its available for free for many unix types) and its also got some of the nicest -features.</P -><P ->Next, try using strace on some simple commands. For example, <B -CLASS="COMMAND" ->strace -ls</B -> or <B -CLASS="COMMAND" ->strace echo hello</B ->.</P -><P -> +features. +</p><p> +Next, try using strace on some simple commands. For example, <b>strace +ls</b> or <b>strace echo hello</b>. +</p><p> You'll notice that it produces a LOT of output. It is showing you the arguments to every system call that the program makes and the result. Very little happens in a program without a system call so you get lots of output. You'll also find that it produces a lot of -"preamble" stuff showing the loading of shared libraries etc. Ignore -this (unless its going wrong!)</P -><P ->For example, the only line that really matters in the <B -CLASS="COMMAND" ->strace echo -hello</B -> output is:</P -><P -><PRE -CLASS="PROGRAMLISTING" ->write(1, "hello\n", 6) = 6</PRE -></P -><P ->all the rest is just setting up to run the program.</P -><P ->Ok, now you're familiar with strace. To use it on Samba you need to +"preamble" stuff showing the loading of shared libraries etc. Ignore +this (unless its going wrong!) +</p><p> +For example, the only line that really matters in the <b>strace echo +hello</b> output is: +</p><pre class="programlisting"> +write(1, "hello\n", 6) = 6 +</pre><p>all the rest is just setting up to run the program.</p><p> +Ok, now you're familiar with strace. To use it on Samba you need to strace the running smbd daemon. The way I tend ot use it is to first login from my Windows PC to the Samba server, then use smbstatus to find which process ID that client is attached to, then as root I do -<B -CLASS="COMMAND" ->strace -p PID</B -> to attach to that process. I normally redirect the +<b>strace -p PID</b> to attach to that process. I normally redirect the stderr output from this command to a file for later perusal. For -example, if I'm using a csh style shell:</P -><P -><B -CLASS="COMMAND" ->strace -f -p 3872 >& strace.out</B -></P -><P ->or with a sh style shell:</P -><P -><B -CLASS="COMMAND" ->strace -f -p 3872 > strace.out 2>&1</B -></P -><P ->Note the "-f" option. This is only available on some systems, and +example, if I'm using a csh style shell: +</p><p><b>strace -f -p 3872 >& strace.out</b></p><p>or with a sh style shell:</p><p><b>strace -f -p 3872 > strace.out 2>&1</b></p><p> +Note the "-f" option. This is only available on some systems, and allows you to trace not just the current process, but any children it forks. This is great for finding printing problems caused by the -"print command" being wrong.</P -><P ->Once you are attached you then can do whatever it is on the client +"print command" being wrong. +</p><p> +Once you are attached you then can do whatever it is on the client that is causing problems and you will capture all the system calls -that smbd makes. </P -><P ->So how do you interpret the results? Generally I search through the +that smbd makes. +</p><p> +So how do you interpret the results? Generally I search through the output for strings that I know will appear when the problem happens. For example, if I am having touble with permissions on a file I would search for that files name in the strace output and look at the surrounding lines. Another trick is to match up file descriptor -numbers and "follow" what happens to an open file until it is closed.</P -><P ->Beyond this you will have to use your initiative. To give you an idea +numbers and "follow" what happens to an open file until it is closed. +</p><p> +Beyond this you will have to use your initiative. To give you an idea of what you are looking for here is a piece of strace output that -shows that <TT -CLASS="FILENAME" ->/dev/null</TT -> is not world writeable, which -causes printing to fail with Samba:</P -><P -><PRE -CLASS="PROGRAMLISTING" ->[pid 28268] open("/dev/null", O_RDWR) = -1 EACCES (Permission denied) -[pid 28268] open("/dev/null", O_WRONLY) = -1 EACCES (Permission denied)</PRE -></P -><P ->The process is trying to first open <TT -CLASS="FILENAME" ->/dev/null</TT -> read-write -then read-only. Both fail. This means <TT -CLASS="FILENAME" ->/dev/null</TT -> has -incorrect permissions.</P -></DIV -><DIV -CLASS="CHAPTER" -><HR><H1 -><A -NAME="NTDOMAIN" -></A ->Chapter 9. NT Domain RPC's</H1 -><DIV -CLASS="SECT1" -><H2 -CLASS="SECT1" -><A -NAME="AEN652" ->9.1. Introduction</A -></H2 -><P ->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 <A -HREF="http://mailhost.cb1.com/~lkcl/cifsntdomain.txt" -TARGET="_top" ->http://mailhost.cb1.com/~lkcl/cifsntdomain.txt</A ->, controlled by Luke.</P -><P ->It should be possible to select a domain instead of a workgroup (in the NT +shows that <tt>/dev/null</tt> is not world writeable, which +causes printing to fail with Samba: +</p><pre class="programlisting"> +[pid 28268] open("/dev/null", O_RDWR) = -1 EACCES (Permission denied) +[pid 28268] open("/dev/null", O_WRONLY) = -1 EACCES (Permission denied) +</pre><p> +The process is trying to first open <tt>/dev/null</tt> read-write +then read-only. Both fail. This means <tt>/dev/null</tt> has +incorrect permissions. +</p></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="ntdomain"></a>Chapter 9. NT Domain RPC's</h2></div><div><div class="author"><h3 class="author">Luke Leighton</h3><div class="affiliation"><div class="address"><p><tt><<a href="mailto:lkcl@switchboard.net">lkcl@switchboard.net</a>></tt></p></div></div></div></div><div><div class="author"><h3 class="author">Paul Ashton</h3><div class="affiliation"><div class="address"><p><tt><<a href="mailto:paul@argo.demon.co.uk">paul@argo.demon.co.uk</a>></tt></p></div></div></div></div><div><div class="author"><h3 class="author">Duncan Stansfield</h3><div class="affiliation"><div class="address"><p><tt><<a href="mailto:duncans@sco.com">duncans@sco.com</a>></tt></p></div></div></div></div><div><p class="pubdate">01 November 97(version 0.0.24)</p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#id2859563">Introduction</a></dt><dd><dl><dt><a href="#id2859980">Sources</a></dt><dt><a href="#id2860014">Credits</a></dt></dl></dd><dt><a href="#id2860053">Notes and Structures</a></dt><dd><dl><dt><a href="#id2860060">Notes</a></dt><dt><a href="#id2860137">Enumerations</a></dt><dt><a href="#id2860350">Structures</a></dt></dl></dd><dt><a href="#id2863307">MSRPC over Transact Named Pipe</a></dt><dd><dl><dt><a href="#id2863320">MSRPC Pipes</a></dt><dt><a href="#id2863422">Header</a></dt><dt><a href="#id2864296">Tail</a></dt><dt><a href="#id2864342">RPC Bind / Bind Ack</a></dt><dt><a href="#id2864522">NTLSA Transact Named Pipe</a></dt><dt><a href="#id2864687">LSA Open Policy</a></dt><dt><a href="#id2864813">LSA Query Info Policy</a></dt><dt><a href="#id2864921">LSA Enumerate Trusted Domains</a></dt><dt><a href="#id2865012">LSA Open Secret</a></dt><dt><a href="#id2865122">LSA Close</a></dt><dt><a href="#id2865188">LSA Lookup SIDS</a></dt><dt><a href="#id2865399">LSA Lookup Names</a></dt></dl></dd><dt><a href="#id2865625">NETLOGON rpc Transact Named Pipe</a></dt><dd><dl><dt><a href="#id2865786">LSA Request Challenge</a></dt><dt><a href="#id2865921">LSA Authenticate 2</a></dt><dt><a href="#id2866069">LSA Server Password Set</a></dt><dt><a href="#id2866185">LSA SAM Logon</a></dt><dt><a href="#id2866299">LSA SAM Logoff</a></dt></dl></dd><dt><a href="#id2866391">\\MAILSLOT\NET\NTLOGON</a></dt><dd><dl><dt><a href="#id2866408">Query for PDC</a></dt><dt><a href="#id2866670">SAM Logon</a></dt></dl></dd><dt><a href="#id2866996">SRVSVC Transact Named Pipe</a></dt><dd><dl><dt><a href="#id2867041">Net Share Enum</a></dt><dt><a href="#id2867261">Net Server Get Info</a></dt></dl></dd><dt><a href="#id2867378">Cryptographic side of NT Domain Authentication</a></dt><dd><dl><dt><a href="#id2867386">Definitions</a></dt><dt><a href="#id2867548">Protocol</a></dt><dt><a href="#id2867629">Comments</a></dt></dl></dd><dt><a href="#id2867679">SIDs and RIDs</a></dt><dd><dl><dt><a href="#id2867719">Well-known SIDs</a></dt><dt><a href="#id2868034">Well-known RIDS</a></dt></dl></dd></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2859563"></a>Introduction</h2></div></div><p> +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 <a href="http://mailhost.cb1.com/~lkcl/cifsntdomain.txt" target="_top">http://mailhost.cb1.com/~lkcl/cifsntdomain.txt</a>, controlled by Luke. +</p><p> +It should be possible to select a domain instead of a workgroup (in the NT workstation's TCP/IP settings) and after the obligatory reboot, type in a username, password, select a domain and successfully log in. I would appreciate any feedback on your experiences with this process, and any -comments, corrections and additions to this document.</P -><P ->The packets described here can be easily derived from (and are probably +comments, corrections and additions to this document. +</p><p> +The packets described here can be easily derived from (and are probably better understood using) Netmon.exe. You will need to use the version of Netmon that matches your system, in order to correctly decode the NETLOGON, lsarpc and srvsvc Transact pipes. This document is derived from NT Service Pack 1 and its corresponding version of Netmon. It is intended that an annotated packet trace be produced, which will likely be more -instructive than this document.</P -><P ->Also needed, to fully implement NT Domain Login Services, is the +instructive than this document. +</p><p> +Also needed, to fully implement NT Domain Login Services, is the document describing the cryptographic part of the NT authentication. This document is available from comp.protocols.smb; from the ntsecurity.net -digest and from the samba digest, amongst other sources.</P -><P ->A copy is available from:</P -><P -><A -HREF="http://ntbugtraq.rc.on.ca/SCRIPTS/WA.EXE?A2=ind9708;L=ntbugtraq;O=A;P=2935" -TARGET="_top" ->http://ntbugtraq.rc.on.ca/SCRIPTS/WA.EXE?A2=ind9708;L=ntbugtraq;O=A;P=2935</A -></P -><P -><A -HREF="http://mailhost.cb1.com/~lkcl/crypt.html" -TARGET="_top" ->http://mailhost.cb1.com/~lkcl/crypt.html</A -></P -><P ->A c-code implementation, provided by <A -HREF="mailto:linus@incolumitas.se" -TARGET="_top" ->Linus Nordberg</A -> -of this protocol is available from:</P -><P -><A -HREF="http://samba.org/cgi-bin/mfs/01/digest/1997/97aug/0391.html" -TARGET="_top" ->http://samba.org/cgi-bin/mfs/01/digest/1997/97aug/0391.html</A -></P -><P -><A -HREF="http://mailhost.cb1.com/~lkcl/crypt.txt" -TARGET="_top" ->http://mailhost.cb1.com/~lkcl/crypt.txt</A -></P -><P ->Also used to provide debugging information is the Check Build version of +digest and from the samba digest, amongst other sources. +</p><p> +A copy is available from: +</p><p><a href="http://ntbugtraq.rc.on.ca/SCRIPTS/WA.EXE?A2=ind9708;L=ntbugtraq;O=A;P=2935" target="_top">http://ntbugtraq.rc.on.ca/SCRIPTS/WA.EXE?A2=ind9708;L=ntbugtraq;O=A;P=2935</a></p><p><a href="http://mailhost.cb1.com/~lkcl/crypt.html" target="_top">http://mailhost.cb1.com/~lkcl/crypt.html</a></p><p> +A c-code implementation, provided by <a href="mailto:linus@incolumitas.se" target="_top">Linus Nordberg</a> +of this protocol is available from: +</p><p><a href="http://samba.org/cgi-bin/mfs/01/digest/1997/97aug/0391.html" target="_top">http://samba.org/cgi-bin/mfs/01/digest/1997/97aug/0391.html</a></p><p><a href="http://mailhost.cb1.com/~lkcl/crypt.txt" target="_top">http://mailhost.cb1.com/~lkcl/crypt.txt</a></p><p> +Also used to provide debugging information is the Check Build version of NT workstation, and enabling full debugging in NETLOGON. This is -achieved by setting the following REG_SZ registry key to 0x1ffffff:</P -><P -><TT -CLASS="FILENAME" ->HKLM\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters</TT -></P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Incorrect direct editing of the registry can cause your +achieved by setting the following REG_SZ registry key to 0x1ffffff: +</p><p><tt>HKLM\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters</tt></p><p><span class="emphasis"><em>Incorrect direct editing of the registry can cause your machine to fail. Then again, so can incorrect implementation of this -protocol. See "Liability:" above.</I -></SPAN -></P -><P ->Bear in mind that each packet over-the-wire will have its origin in an +protocol. See "Liability:" above.</em></span></p><p> +Bear in mind that each packet over-the-wire will have its origin in an API call. Therefore, there are likely to be structures, enumerations -and defines that are usefully documented elsewhere.</P -><P ->This document is by no means complete or authoritative. Missing sections -include, but are not limited to:</P -><P -></P -><OL -TYPE="1" -><LI -><P ->Mappings of RIDs to usernames (and vice-versa).</P -></LI -><LI -><P ->What a User ID is and what a Group ID is.</P -></LI -><LI -><P ->The exact meaning/definition of various magic constants or enumerations.</P -></LI -><LI -><P ->The reply error code and use of that error code when a +and defines that are usefully documented elsewhere. +</p><p> +This document is by no means complete or authoritative. Missing sections +include, but are not limited to: +</p><div class="orderedlist"><ol type="1"><li><p>Mappings of RIDs to usernames (and vice-versa).</p></li><li><p>What a User ID is and what a Group ID is.</p></li><li><p>The exact meaning/definition of various magic constants or enumerations.</p></li><li><p>The reply error code and use of that error code when a workstation becomes a member of a domain (to be described later). Failure to return this error code will make the workstation report -that it is already a member of the domain.</P -></LI -><LI -><P ->the cryptographic side of the NetrServerPasswordSet command, +that it is already a member of the domain.</p></li><li><p>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].</P -></LI -></OL -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN688" ->9.1.1. Sources</A -></H3 -><P -></P -><TABLE -BORDER="0" -><TBODY -><TR -><TD ->cket Traces from Netmonitor (Service Pack 1 and above)</TD -></TR -><TR -><TD ->ul Ashton and Luke Leighton's other "NT Domain" doc.</TD -></TR -><TR -><TD ->FS documentation - cifs6.txt</TD -></TR -><TR -><TD ->FS documentation - cifsrap2.txt</TD -></TR -></TBODY -></TABLE -><P -></P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN695" ->9.1.2. Credits</A -></H3 -><P -></P -><TABLE -BORDER="0" -><TBODY -><TR -><TD ->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.</TD -></TR -><TR -><TD ->Duncan Stansfield: low-level analysis of MSRPC Pipes.</TD -></TR -><TR -><TD ->Linus Nordberg: producing c-code from Paul's crypto spec.</TD -></TR -><TR -><TD ->Windows Sourcer development team</TD -></TR -></TBODY -></TABLE -><P -></P -></DIV -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN702" ->9.2. Notes and Structures</A -></H2 -><DIV -CLASS="SECT2" -><H3 -CLASS="SECT2" -><A -NAME="AEN704" ->9.2.1. Notes</A -></H3 -><P -></P -><OL -TYPE="1" -><LI -><P ->In the SMB Transact pipes, some "Structures", described here, appear to be +command, and keep the default workstation password].</p></li></ol></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2859980"></a>Sources</h3></div></div><table class="simplelist" border="0" summary="Simple list"><tr><td>cket Traces from Netmonitor (Service Pack 1 and above)</td></tr><tr><td>ul Ashton and Luke Leighton's other "NT Domain" doc.</td></tr><tr><td>FS documentation - cifs6.txt</td></tr><tr><td>FS documentation - cifsrap2.txt</td></tr></table></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2860014"></a>Credits</h3></div></div><table class="simplelist" border="0" summary="Simple list"><tr><td>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.</td></tr><tr><td>Duncan Stansfield: low-level analysis of MSRPC Pipes.</td></tr><tr><td>Linus Nordberg: producing c-code from Paul's crypto spec.</td></tr><tr><td>Windows Sourcer development team</td></tr></table></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2860053"></a>Notes and Structures</h2></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2860060"></a>Notes</h3></div></div><div class="orderedlist"><ol type="1"><li><p> +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.</P -></LI -><LI -><P ->In the UDP NTLOGON Mailslots, some "Structures", described here, appear to be -2-byte aligned with the start of the mailslot, at their start.</P -></LI -><LI -><P ->Domain SID is of the format S-revision-version-auth1-auth2...authN. -e.g S-1-5-123-456-789-123-456. the 5 could be a sub-revision.</P -></LI -><LI -><P ->any undocumented buffer pointers must be non-zero if the string buffer it +"Structures" need aligning is not precisely known or documented. +</p></li><li><p> +In the UDP NTLOGON Mailslots, some "Structures", described here, appear to be +2-byte aligned with the start of the mailslot, at their start. +</p></li><li><p> +Domain SID is of the format S-revision-version-auth1-auth2...authN. +e.g S-1-5-123-456-789-123-456. the 5 could be a sub-revision. +</p></li><li><p> +any undocumented buffer pointers must be non-zero if the string buffer it refers to contains characters. exactly what value they should be is unknown. 0x0000 0002 seems to do the trick to indicate that the buffer exists. a NULL buffer pointer indicates that the string buffer is of zero length. @@ -3263,3707 +1197,90 @@ refers to is NOT put into (or taken out of) the SMB data stream. This is empirically derived from, for example, the LSA SAM Logon response packet, where if the buffer pointer is NULL, the user information is not inserted into the data stream. Exactly what happens with an array of buffer pointers -is not known, although an educated guess can be made.</P -></LI -><LI -><P ->an array of structures (a container) appears to have a count and a pointer. +is not known, although an educated guess can be made. +</p></li><li><p> +an array of structures (a container) appears to have a count and a pointer. if the count is zero, the pointer is also zero. no further data is put 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.</P -></LI -></OL -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN717" ->9.2.2. Enumerations</A -></H3 -><DIV -CLASS="SECT3" -><H4 -CLASS="SECT3" -><A -NAME="AEN719" ->9.2.2.1. MSRPC Header type</A -></H4 -><P ->command number in the msrpc packet header</P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->MSRPC_Request:</DT -><DD -><P ->0x00</P -></DD -><DT ->MSRPC_Response:</DT -><DD -><P ->0x02</P -></DD -><DT ->MSRPC_Bind:</DT -><DD -><P ->0x0B</P -></DD -><DT ->MSRPC_BindAck:</DT -><DD -><P ->0x0C</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN739" ->9.2.2.2. MSRPC Packet info</A -></H4 -><P ->The meaning of these flags is undocumented</P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->FirstFrag:</DT -><DD -><P ->0x01 </P -></DD -><DT ->LastFrag:</DT -><DD -><P ->0x02 </P -></DD -><DT ->NotaFrag:</DT -><DD -><P ->0x04 </P -></DD -><DT ->RecRespond:</DT -><DD -><P ->0x08 </P -></DD -><DT ->NoMultiplex:</DT -><DD -><P ->0x10 </P -></DD -><DT ->NotForIdemp:</DT -><DD -><P ->0x20 </P -></DD -><DT ->NotforBcast:</DT -><DD -><P ->0x40 </P -></DD -><DT ->NoUuid:</DT -><DD -><P ->0x80 </P -></DD -></DL -></DIV -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN775" ->9.2.3. Structures</A -></H3 -><DIV -CLASS="SECT3" -><H4 -CLASS="SECT3" -><A -NAME="AEN777" ->9.2.3.1. VOID *</A -></H4 -><P ->sizeof VOID* is 32 bits.</P -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN780" ->9.2.3.2. char</A -></H4 -><P ->sizeof char is 8 bits.</P -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN783" ->9.2.3.3. UTIME</A -></H4 -><P ->UTIME is 32 bits, indicating time in seconds since 01jan1970. documented in cifs6.txt (section 3.5 page, page 30).</P -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN786" ->9.2.3.4. NTTIME</A -></H4 -><P ->NTTIME is 64 bits. documented in cifs6.txt (section 3.5 page, page 30).</P -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN789" ->9.2.3.5. DOM_SID (domain SID structure)</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT32</DT -><DD -><P ->num of sub-authorities in domain SID</P -></DD -><DT ->UINT8</DT -><DD -><P ->SID revision number</P -></DD -><DT ->UINT8</DT -><DD -><P ->num of sub-authorities in domain SID</P -></DD -><DT ->UINT8[6]</DT -><DD -><P ->6 bytes for domain SID - Identifier Authority.</P -></DD -><DT ->UINT16[n_subauths]</DT -><DD -><P ->domain SID sub-authorities</P -></DD -></DL -></DIV -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: the domain SID is documented elsewhere.</I -></SPAN -></P -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN814" ->9.2.3.6. STR (string)</A -></H4 -><P ->STR (string) is a char[] : a null-terminated string of ascii characters.</P -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN817" ->9.2.3.7. UNIHDR (unicode string header)</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT16</DT -><DD -><P ->length of unicode string</P -></DD -><DT ->UINT16</DT -><DD -><P ->max length of unicode string</P -></DD -><DT ->UINT32</DT -><DD -><P ->4 - undocumented.</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN832" ->9.2.3.8. UNIHDR2 (unicode string header plus buffer pointer)</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UNIHDR</DT -><DD -><P ->unicode string header</P -></DD -><DT ->VOID*</DT -><DD -><P ->undocumented buffer pointer</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN843" ->9.2.3.9. UNISTR (unicode string)</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT16[]</DT -><DD -><P ->null-terminated string of unicode characters.</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN850" ->9.2.3.10. NAME (length-indicated unicode string)</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT32</DT -><DD -><P ->length of unicode string</P -></DD -><DT ->UINT16[]</DT -><DD -><P ->null-terminated string of unicode characters.</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN861" ->9.2.3.11. UNISTR2 (aligned unicode string)</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT8[]</DT -><DD -><P ->padding to get unicode string 4-byte aligned with the start of the SMB header.</P -></DD -><DT ->UINT32</DT -><DD -><P ->max length of unicode string</P -></DD -><DT ->UINT32</DT -><DD -><P ->0 - undocumented</P -></DD -><DT ->UINT32</DT -><DD -><P ->length of unicode string</P -></DD -><DT ->UINT16[]</DT -><DD -><P ->string of uncode characters</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN884" ->9.2.3.12. OBJ_ATTR (object attributes)</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT32</DT -><DD -><P ->0x18 - length (in bytes) including the length field.</P -></DD -><DT ->VOID*</DT -><DD -><P ->0 - root directory (pointer)</P -></DD -><DT ->VOID*</DT -><DD -><P ->0 - object name (pointer)</P -></DD -><DT ->UINT32</DT -><DD -><P ->0 - attributes (undocumented)</P -></DD -><DT ->VOID*</DT -><DD -><P ->0 - security descriptior (pointer)</P -></DD -><DT ->UINT32</DT -><DD -><P ->0 - security quality of service</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN911" ->9.2.3.13. POL_HND (LSA policy handle)</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->char[20]</DT -><DD -><P ->policy handle</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN918" ->9.2.3.14. DOM_SID2 (domain SID structure, SIDS stored in unicode)</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT32</DT -><DD -><P ->5 - SID type</P -></DD -><DT ->UINT32</DT -><DD -><P ->0 - undocumented</P -></DD -><DT ->UNIHDR2</DT -><DD -><P ->domain SID unicode string header</P -></DD -><DT ->UNISTR</DT -><DD -><P ->domain SID unicode string</P -></DD -></DL -></DIV -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->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.</I -></SPAN -></P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: the SID type indicates, for example, an alias; a well-known group etc. this is documented somewhere.</I -></SPAN -></P -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN941" ->9.2.3.15. DOM_RID (domain RID structure)</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT32</DT -><DD -><P ->5 - well-known SID. 1 - user SID (see ShowACLs)</P -></DD -><DT ->UINT32</DT -><DD -><P ->5 - undocumented</P -></DD -><DT ->UINT32</DT -><DD -><P ->domain RID </P -></DD -><DT ->UINT32</DT -><DD -><P ->0 - domain index out of above reference domains</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN960" ->9.2.3.16. LOG_INFO (server, account, client structure)</A -></H4 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: logon server name starts with two '\' characters and is upper case.</I -></SPAN -></P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: account name is the logon client name from the LSA Request Challenge, with a $ on the end of it, in upper case.</I -></SPAN -></P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->VOID*</DT -><DD -><P ->undocumented buffer pointer</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->logon server unicode string</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->account name unicode string</P -></DD -><DT ->UINT16</DT -><DD -><P ->sec_chan - security channel type</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->logon client machine unicode string</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN987" ->9.2.3.17. CLNT_SRV (server, client names structure)</A -></H4 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: logon server name starts with two '\' characters and is upper case.</I -></SPAN -></P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->VOID*</DT -><DD -><P ->undocumented buffer pointer</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->logon server unicode string</P -></DD -><DT ->VOID*</DT -><DD -><P ->undocumented buffer pointer</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->logon client machine unicode string</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1008" ->9.2.3.18. CREDS (credentials + time stamp)</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->char[8]</DT -><DD -><P ->credentials</P -></DD -><DT ->UTIME</DT -><DD -><P ->time stamp</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1019" ->9.2.3.19. CLNT_INFO2 (server, client structure, client credentials)</A -></H4 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->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.</I -></SPAN -></P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->CLNT_SRV</DT -><DD -><P ->client and server names</P -></DD -><DT ->UINT8[]</DT -><DD -><P ->???? padding, for 4-byte alignment with SMB header.</P -></DD -><DT ->VOID*</DT -><DD -><P ->pointer to client credentials.</P -></DD -><DT ->CREDS</DT -><DD -><P ->client-calculated credentials + client time</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1040" ->9.2.3.20. CLNT_INFO (server, account, client structure, client credentials)</A -></H4 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->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.</I -></SPAN -></P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->LOG_INFO</DT -><DD -><P ->logon account info</P -></DD -><DT ->CREDS</DT -><DD -><P ->client-calculated credentials + client time</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1053" ->9.2.3.21. ID_INFO_1 (id info structure, auth level 1)</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->VOID*</DT -><DD -><P ->ptr_id_info_1</P -></DD -><DT ->UNIHDR</DT -><DD -><P ->domain name unicode header</P -></DD -><DT ->UINT32</DT -><DD -><P ->param control</P -></DD -><DT ->UINT64</DT -><DD -><P ->logon ID</P -></DD -><DT ->UNIHDR</DT -><DD -><P ->user name unicode header</P -></DD -><DT ->UNIHDR</DT -><DD -><P ->workgroup name unicode header</P -></DD -><DT ->char[16]</DT -><DD -><P ->arc4 LM OWF Password</P -></DD -><DT ->char[16]</DT -><DD -><P ->arc4 NT OWF Password</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->domain name unicode string</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->user name unicode string</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->workstation name unicode string</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1100" ->9.2.3.22. SAM_INFO (sam logon/logoff id info structure)</A -></H4 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: presumably, the return credentials is supposedly for the server to verify that the credential chain hasn't been compromised.</I -></SPAN -></P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->CLNT_INFO2</DT -><DD -><P ->client identification/authentication info</P -></DD -><DT ->VOID*</DT -><DD -><P ->pointer to return credentials.</P -></DD -><DT ->CRED</DT -><DD -><P ->return credentials - ignored.</P -></DD -><DT ->UINT16</DT -><DD -><P ->logon level</P -></DD -><DT ->UINT16</DT -><DD -><P ->switch value</P -></DD -></DL -></DIV -><P -><PRE -CLASS="PROGRAMLISTING" -> switch (switch_value) +appears a third time after the last sub-structure. +</p></li></ol></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2860137"></a>Enumerations</h3></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860144"></a>MSRPC Header type</h4></div></div><p>command number in the msrpc packet header</p><div class="variablelist"><dl><dt><span class="term">MSRPC_Request:</span></dt><dd><p>0x00</p></dd><dt><span class="term">MSRPC_Response:</span></dt><dd><p>0x02</p></dd><dt><span class="term">MSRPC_Bind:</span></dt><dd><p>0x0B</p></dd><dt><span class="term">MSRPC_BindAck:</span></dt><dd><p>0x0C</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860218"></a>MSRPC Packet info</h4></div></div><p>The meaning of these flags is undocumented</p><div class="variablelist"><dl><dt><span class="term">FirstFrag:</span></dt><dd><p>0x01 </p></dd><dt><span class="term">LastFrag:</span></dt><dd><p>0x02 </p></dd><dt><span class="term">NotaFrag:</span></dt><dd><p>0x04 </p></dd><dt><span class="term">RecRespond:</span></dt><dd><p>0x08 </p></dd><dt><span class="term">NoMultiplex:</span></dt><dd><p>0x10 </p></dd><dt><span class="term">NotForIdemp:</span></dt><dd><p>0x20 </p></dd><dt><span class="term">NotforBcast:</span></dt><dd><p>0x40 </p></dd><dt><span class="term">NoUuid:</span></dt><dd><p>0x80 </p></dd></dl></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2860350"></a>Structures</h3></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860357"></a>VOID *</h4></div></div><p>sizeof VOID* is 32 bits.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860368"></a>char</h4></div></div><p>sizeof char is 8 bits.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860380"></a>UTIME</h4></div></div><p>UTIME is 32 bits, indicating time in seconds since 01jan1970. documented in cifs6.txt (section 3.5 page, page 30).</p></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860393"></a>NTTIME</h4></div></div><p>NTTIME is 64 bits. documented in cifs6.txt (section 3.5 page, page 30).</p></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860405"></a>DOM_SID (domain SID structure)</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT32</span></dt><dd><p>num of sub-authorities in domain SID</p></dd><dt><span class="term">UINT8</span></dt><dd><p>SID revision number</p></dd><dt><span class="term">UINT8</span></dt><dd><p>num of sub-authorities in domain SID</p></dd><dt><span class="term">UINT8[6]</span></dt><dd><p>6 bytes for domain SID - Identifier Authority.</p></dd><dt><span class="term">UINT16[n_subauths]</span></dt><dd><p>domain SID sub-authorities</p></dd></dl></div><p><span class="emphasis"><em>Note: the domain SID is documented elsewhere.</em></span> +</p></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860499"></a>STR (string)</h4></div></div><p>STR (string) is a char[] : a null-terminated string of ascii characters.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860513"></a>UNIHDR (unicode string header) </h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT16</span></dt><dd><p>length of unicode string</p></dd><dt><span class="term">UINT16</span></dt><dd><p>max length of unicode string</p></dd><dt><span class="term">UINT32</span></dt><dd><p>4 - undocumented.</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860569"></a>UNIHDR2 (unicode string header plus buffer pointer)</h4></div></div><div class="variablelist"><dl><dt><span class="term">UNIHDR</span></dt><dd><p>unicode string header</p></dd><dt><span class="term">VOID*</span></dt><dd><p>undocumented buffer pointer</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860611"></a>UNISTR (unicode string)</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT16[]</span></dt><dd><p>null-terminated string of unicode characters.</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860639"></a>NAME (length-indicated unicode string)</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT32</span></dt><dd><p>length of unicode string</p></dd><dt><span class="term">UINT16[]</span></dt><dd><p>null-terminated string of unicode characters.</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860682"></a>UNISTR2 (aligned unicode string)</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT8[]</span></dt><dd><p>padding to get unicode string 4-byte aligned with the start of the SMB header.</p></dd><dt><span class="term">UINT32</span></dt><dd><p>max length of unicode string</p></dd><dt><span class="term">UINT32</span></dt><dd><p>0 - undocumented</p></dd><dt><span class="term">UINT32</span></dt><dd><p>length of unicode string</p></dd><dt><span class="term">UINT16[]</span></dt><dd><p>string of uncode characters</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860768"></a>OBJ_ATTR (object attributes)</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT32</span></dt><dd><p>0x18 - length (in bytes) including the length field.</p></dd><dt><span class="term">VOID*</span></dt><dd><p>0 - root directory (pointer)</p></dd><dt><span class="term">VOID*</span></dt><dd><p>0 - object name (pointer)</p></dd><dt><span class="term">UINT32</span></dt><dd><p>0 - attributes (undocumented)</p></dd><dt><span class="term">VOID*</span></dt><dd><p>0 - security descriptior (pointer)</p></dd><dt><span class="term">UINT32</span></dt><dd><p>0 - security quality of service</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860861"></a>POL_HND (LSA policy handle)</h4></div></div><div class="variablelist"><dl><dt><span class="term">char[20]</span></dt><dd><p>policy handle</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860889"></a>DOM_SID2 (domain SID structure, SIDS stored in unicode)</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT32</span></dt><dd><p>5 - SID type</p></dd><dt><span class="term">UINT32</span></dt><dd><p>0 - undocumented</p></dd><dt><span class="term">UNIHDR2</span></dt><dd><p>domain SID unicode string header</p></dd><dt><span class="term">UNISTR</span></dt><dd><p>domain SID unicode string</p></dd></dl></div><p><span class="emphasis"><em>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.</em></span></p><p><span class="emphasis"><em>Note: the SID type indicates, for example, an alias; a well-known group etc. this is documented somewhere.</em></span></p></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2860976"></a>DOM_RID (domain RID structure)</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT32</span></dt><dd><p>5 - well-known SID. 1 - user SID (see ShowACLs)</p></dd><dt><span class="term">UINT32</span></dt><dd><p>5 - undocumented</p></dd><dt><span class="term">UINT32</span></dt><dd><p>domain RID </p></dd><dt><span class="term">UINT32</span></dt><dd><p>0 - domain index out of above reference domains</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2861045"></a>LOG_INFO (server, account, client structure)</h4></div></div><p><span class="emphasis"><em>Note: logon server name starts with two '\' characters and is upper case.</em></span></p><p><span class="emphasis"><em>Note: account name is the logon client name from the LSA Request Challenge, with a $ on the end of it, in upper case.</em></span></p><div class="variablelist"><dl><dt><span class="term">VOID*</span></dt><dd><p>undocumented buffer pointer</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>logon server unicode string</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>account name unicode string</p></dd><dt><span class="term">UINT16</span></dt><dd><p>sec_chan - security channel type</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>logon client machine unicode string</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2861145"></a>CLNT_SRV (server, client names structure)</h4></div></div><p><span class="emphasis"><em>Note: logon server name starts with two '\' characters and is upper case.</em></span></p><div class="variablelist"><dl><dt><span class="term">VOID*</span></dt><dd><p>undocumented buffer pointer</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>logon server unicode string</p></dd><dt><span class="term">VOID*</span></dt><dd><p>undocumented buffer pointer</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>logon client machine unicode string</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2861223"></a>CREDS (credentials + time stamp)</h4></div></div><div class="variablelist"><dl><dt><span class="term">char[8]</span></dt><dd><p>credentials</p></dd><dt><span class="term">UTIME</span></dt><dd><p>time stamp</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2861264"></a>CLNT_INFO2 (server, client structure, client credentials)</h4></div></div><p><span class="emphasis"><em>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.</em></span></p><div class="variablelist"><dl><dt><span class="term">CLNT_SRV</span></dt><dd><p>client and server names</p></dd><dt><span class="term">UINT8[]</span></dt><dd><p>???? padding, for 4-byte alignment with SMB header.</p></dd><dt><span class="term">VOID*</span></dt><dd><p>pointer to client credentials.</p></dd><dt><span class="term">CREDS</span></dt><dd><p>client-calculated credentials + client time</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2861347"></a>CLNT_INFO (server, account, client structure, client credentials)</h4></div></div><p><span class="emphasis"><em>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.</em></span></p><div class="variablelist"><dl><dt><span class="term">LOG_INFO</span></dt><dd><p>logon account info</p></dd><dt><span class="term">CREDS</span></dt><dd><p>client-calculated credentials + client time</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2861400"></a>ID_INFO_1 (id info structure, auth level 1)</h4></div></div><div class="variablelist"><dl><dt><span class="term">VOID*</span></dt><dd><p>ptr_id_info_1</p></dd><dt><span class="term">UNIHDR</span></dt><dd><p>domain name unicode header</p></dd><dt><span class="term">UINT32</span></dt><dd><p>param control</p></dd><dt><span class="term">UINT64</span></dt><dd><p>logon ID</p></dd><dt><span class="term">UNIHDR</span></dt><dd><p>user name unicode header</p></dd><dt><span class="term">UNIHDR</span></dt><dd><p>workgroup name unicode header</p></dd><dt><span class="term">char[16]</span></dt><dd><p>arc4 LM OWF Password</p></dd><dt><span class="term">char[16]</span></dt><dd><p>arc4 NT OWF Password</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>domain name unicode string</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>user name unicode string</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>workstation name unicode string</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2861570"></a>SAM_INFO (sam logon/logoff id info structure)</h4></div></div><p><span class="emphasis"><em>Note: presumably, the return credentials is supposedly for the server to verify that the credential chain hasn't been compromised.</em></span></p><div class="variablelist"><dl><dt><span class="term">CLNT_INFO2</span></dt><dd><p>client identification/authentication info</p></dd><dt><span class="term">VOID*</span></dt><dd><p>pointer to return credentials.</p></dd><dt><span class="term">CRED</span></dt><dd><p>return credentials - ignored.</p></dd><dt><span class="term">UINT16</span></dt><dd><p>logon level</p></dd><dt><span class="term">UINT16</span></dt><dd><p>switch value</p></dd></dl></div><pre class="programlisting"> + switch (switch_value) case 1: { ID_INFO_1 id_info_1; - }</PRE -></P -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1127" ->9.2.3.23. GID (group id info)</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT32</DT -><DD -><P ->group id</P -></DD -><DT ->UINT32</DT -><DD -><P ->user attributes (only used by NT 3.1 and 3.51)</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1138" ->9.2.3.24. DOM_REF (domain reference info)</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->VOID*</DT -><DD -><P ->undocumented buffer pointer.</P -></DD -><DT ->UINT32</DT -><DD -><P ->num referenced domains?</P -></DD -><DT ->VOID*</DT -><DD -><P ->undocumented domain name buffer pointer.</P -></DD -><DT ->UINT32</DT -><DD -><P ->32 - max number of entries</P -></DD -><DT ->UINT32</DT -><DD -><P ->4 - num referenced domains?</P -></DD -><DT ->UNIHDR2</DT -><DD -><P ->domain name unicode string header</P -></DD -><DT ->UNIHDR2[num_ref_doms-1]</DT -><DD -><P ->referenced domain unicode string headers</P -></DD -><DT ->UNISTR</DT -><DD -><P ->domain name unicode string</P -></DD -><DT ->DOM_SID[num_ref_doms]</DT -><DD -><P ->referenced domain SIDs</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1177" ->9.2.3.25. DOM_INFO (domain info, levels 3 and 5 are the same))</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT8[]</DT -><DD -><P ->??? padding to get 4-byte alignment with start of SMB header</P -></DD -><DT ->UINT16</DT -><DD -><P ->domain name string length * 2</P -></DD -><DT ->UINT16</DT -><DD -><P ->domain name string length * 2</P -></DD -><DT ->VOID*</DT -><DD -><P ->undocumented domain name string buffer pointer</P -></DD -><DT ->VOID*</DT -><DD -><P ->undocumented domain SID string buffer pointer</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->domain name (unicode string)</P -></DD -><DT ->DOM_SID</DT -><DD -><P ->domain SID</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1208" ->9.2.3.26. USER_INFO (user logon info)</A -></H4 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: it would be nice to know what the 16 byte user session key is for.</I -></SPAN -></P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->NTTIME</DT -><DD -><P ->logon time</P -></DD -><DT ->NTTIME</DT -><DD -><P ->logoff time</P -></DD -><DT ->NTTIME</DT -><DD -><P ->kickoff time</P -></DD -><DT ->NTTIME</DT -><DD -><P ->password last set time</P -></DD -><DT ->NTTIME</DT -><DD -><P ->password can change time</P -></DD -><DT ->NTTIME</DT -><DD -><P ->password must change time</P -></DD -><DT ->UNIHDR</DT -><DD -><P ->username unicode string header</P -></DD -><DT ->UNIHDR</DT -><DD -><P ->user's full name unicode string header</P -></DD -><DT ->UNIHDR</DT -><DD -><P ->logon script unicode string header</P -></DD -><DT ->UNIHDR</DT -><DD -><P ->profile path unicode string header</P -></DD -><DT ->UNIHDR</DT -><DD -><P ->home directory unicode string header</P -></DD -><DT ->UNIHDR</DT -><DD -><P ->home directory drive unicode string header</P -></DD -><DT ->UINT16</DT -><DD -><P ->logon count</P -></DD -><DT ->UINT16</DT -><DD -><P ->bad password count</P -></DD -><DT ->UINT32</DT -><DD -><P ->User ID</P -></DD -><DT ->UINT32</DT -><DD -><P ->Group ID</P -></DD -><DT ->UINT32</DT -><DD -><P ->num groups</P -></DD -><DT ->VOID*</DT -><DD -><P ->undocumented buffer pointer to groups.</P -></DD -><DT ->UINT32</DT -><DD -><P ->user flags</P -></DD -><DT ->char[16]</DT -><DD -><P ->user session key</P -></DD -><DT ->UNIHDR</DT -><DD -><P ->logon server unicode string header</P -></DD -><DT ->UNIHDR</DT -><DD -><P ->logon domain unicode string header</P -></DD -><DT ->VOID*</DT -><DD -><P ->undocumented logon domain id pointer</P -></DD -><DT ->char[40]</DT -><DD -><P ->40 undocumented padding bytes. future expansion?</P -></DD -><DT ->UINT32</DT -><DD -><P ->0 - num_other_sids?</P -></DD -><DT ->VOID*</DT -><DD -><P ->NULL - undocumented pointer to other domain SIDs.</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->username unicode string</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->user's full name unicode string</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->logon script unicode string</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->profile path unicode string</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->home directory unicode string</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->home directory drive unicode string</P -></DD -><DT ->UINT32</DT -><DD -><P ->num groups</P -></DD -><DT ->GID[num_groups]</DT -><DD -><P ->group info</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->logon server unicode string</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->logon domain unicode string</P -></DD -><DT ->DOM_SID</DT -><DD -><P ->domain SID</P -></DD -><DT ->DOM_SID[num_sids]</DT -><DD -><P ->other domain SIDs?</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1365" ->9.2.3.27. SH_INFO_1_PTR (pointers to level 1 share info strings)</A -></H4 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: see cifsrap2.txt section5, page 10.</I -></SPAN -></P -><P -></P -><TABLE -BORDER="0" -><TBODY -><TR -><TD ->0 for shi1_type indicates a Disk.</TD -></TR -><TR -><TD ->1 for shi1_type indicates a Print Queue.</TD -></TR -><TR -><TD ->2 for shi1_type indicates a Device.</TD -></TR -><TR -><TD ->3 for shi1_type indicates an IPC pipe.</TD -></TR -><TR -><TD ->0x8000 0000 (top bit set in shi1_type) indicates a hidden share.</TD -></TR -></TBODY -></TABLE -><P -></P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->VOID*</DT -><DD -><P ->shi1_netname - pointer to net name</P -></DD -><DT ->UINT32</DT -><DD -><P ->shi1_type - type of share. 0 - undocumented.</P -></DD -><DT ->VOID*</DT -><DD -><P ->shi1_remark - pointer to comment.</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1388" ->9.2.3.28. SH_INFO_1_STR (level 1 share info strings)</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UNISTR2</DT -><DD -><P ->shi1_netname - unicode string of net name</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->shi1_remark - unicode string of comment.</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1399" ->9.2.3.29. SHARE_INFO_1_CTR</A -></H4 -><P ->share container with 0 entries:</P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT32</DT -><DD -><P ->0 - EntriesRead</P -></DD -><DT ->UINT32</DT -><DD -><P ->0 - Buffer</P -></DD -></DL -></DIV -><P ->share container with > 0 entries:</P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT32</DT -><DD -><P ->EntriesRead</P -></DD -><DT ->UINT32</DT -><DD -><P ->non-zero - Buffer</P -></DD -><DT ->UINT32</DT -><DD -><P ->EntriesRead</P -></DD -><DT ->SH_INFO_1_PTR[EntriesRead]</DT -><DD -><P ->share entry pointers</P -></DD -><DT ->SH_INFO_1_STR[EntriesRead]</DT -><DD -><P ->share entry strings</P -></DD -><DT ->UINT8[]</DT -><DD -><P ->padding to get unicode string 4-byte aligned with start of the SMB header.</P -></DD -><DT ->UINT32</DT -><DD -><P ->EntriesRead</P -></DD -><DT ->UINT32</DT -><DD -><P ->0 - padding</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1445" ->9.2.3.30. SERVER_INFO_101</A -></H4 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->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. </I -></SPAN -></P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->SV_TYPE_WORKSTATION</DT -><DD -><P ->0x00000001 All workstations</P -></DD -><DT ->SV_TYPE_SERVER</DT -><DD -><P ->0x00000002 All servers</P -></DD -><DT ->SV_TYPE_SQLSERVER</DT -><DD -><P ->0x00000004 Any server running with SQL server</P -></DD -><DT ->SV_TYPE_DOMAIN_CTRL</DT -><DD -><P ->0x00000008 Primary domain controller</P -></DD -><DT ->SV_TYPE_DOMAIN_BAKCTRL</DT -><DD -><P ->0x00000010 Backup domain controller</P -></DD -><DT ->SV_TYPE_TIME_SOURCE</DT -><DD -><P ->0x00000020 Server running the timesource service</P -></DD -><DT ->SV_TYPE_AFP</DT -><DD -><P ->0x00000040 Apple File Protocol servers</P -></DD -><DT ->SV_TYPE_NOVELL</DT -><DD -><P ->0x00000080 Novell servers</P -></DD -><DT ->SV_TYPE_DOMAIN_MEMBER</DT -><DD -><P ->0x00000100 Domain Member</P -></DD -><DT ->SV_TYPE_PRINTQ_SERVER</DT -><DD -><P ->0x00000200 Server sharing print queue</P -></DD -><DT ->SV_TYPE_DIALIN_SERVER</DT -><DD -><P ->0x00000400 Server running dialin service.</P -></DD -><DT ->SV_TYPE_XENIX_SERVER</DT -><DD -><P ->0x00000800 Xenix server</P -></DD -><DT ->SV_TYPE_NT</DT -><DD -><P ->0x00001000 NT server</P -></DD -><DT ->SV_TYPE_WFW</DT -><DD -><P ->0x00002000 Server running Windows for </P -></DD -><DT ->SV_TYPE_SERVER_NT</DT -><DD -><P ->0x00008000 Windows NT non DC server</P -></DD -><DT ->SV_TYPE_POTENTIAL_BROWSER</DT -><DD -><P ->0x00010000 Server that can run the browser service</P -></DD -><DT ->SV_TYPE_BACKUP_BROWSER</DT -><DD -><P ->0x00020000 Backup browser server</P -></DD -><DT ->SV_TYPE_MASTER_BROWSER</DT -><DD -><P ->0x00040000 Master browser server</P -></DD -><DT ->SV_TYPE_DOMAIN_MASTER</DT -><DD -><P ->0x00080000 Domain Master Browser server</P -></DD -><DT ->SV_TYPE_LOCAL_LIST_ONLY</DT -><DD -><P ->0x40000000 Enumerate only entries marked "local"</P -></DD -><DT ->SV_TYPE_DOMAIN_ENUM</DT -><DD -><P ->0x80000000 Enumerate Domains. The pszServer and pszDomain parameters must be NULL.</P -></DD -></DL -></DIV -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT32</DT -><DD -><P ->500 - platform_id</P -></DD -><DT ->VOID*</DT -><DD -><P ->pointer to name</P -></DD -><DT ->UINT32</DT -><DD -><P ->5 - major version</P -></DD -><DT ->UINT32</DT -><DD -><P ->4 - minor version</P -></DD -><DT ->UINT32</DT -><DD -><P ->type (SV_TYPE_... bit field)</P -></DD -><DT ->VOID*</DT -><DD -><P ->pointer to comment</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->sv101_name - unicode string of server name</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->sv_101_comment - unicode string of server comment.</P -></DD -><DT ->UINT8[]</DT -><DD -><P ->padding to get unicode string 4-byte aligned with start of the SMB header.</P -></DD -></DL -></DIV -></DIV -></DIV -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN1571" ->9.3. MSRPC over Transact Named Pipe</A -></H2 -><P ->For details on the SMB Transact Named Pipe, see cifs6.txt</P -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN1574" ->9.3.1. MSRPC Pipes</A -></H3 -><P ->The MSRPC is conducted over an SMB Transact Pipe with a name of -<TT -CLASS="FILENAME" ->\PIPE\</TT ->. You must first obtain a 16 bit file handle, by -sending a SMBopenX with the pipe name <TT -CLASS="FILENAME" ->\PIPE\srvsvc</TT -> for + } +</pre></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2861675"></a>GID (group id info)</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT32</span></dt><dd><p>group id</p></dd><dt><span class="term">UINT32</span></dt><dd><p>user attributes (only used by NT 3.1 and 3.51)</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2861713"></a>DOM_REF (domain reference info)</h4></div></div><div class="variablelist"><dl><dt><span class="term">VOID*</span></dt><dd><p>undocumented buffer pointer.</p></dd><dt><span class="term">UINT32</span></dt><dd><p>num referenced domains?</p></dd><dt><span class="term">VOID*</span></dt><dd><p>undocumented domain name buffer pointer.</p></dd><dt><span class="term">UINT32</span></dt><dd><p>32 - max number of entries</p></dd><dt><span class="term">UINT32</span></dt><dd><p>4 - num referenced domains?</p></dd><dt><span class="term">UNIHDR2</span></dt><dd><p>domain name unicode string header</p></dd><dt><span class="term">UNIHDR2[num_ref_doms-1]</span></dt><dd><p>referenced domain unicode string headers</p></dd><dt><span class="term">UNISTR</span></dt><dd><p>domain name unicode string</p></dd><dt><span class="term">DOM_SID[num_ref_doms]</span></dt><dd><p>referenced domain SIDs</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2861857"></a>DOM_INFO (domain info, levels 3 and 5 are the same))</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT8[]</span></dt><dd><p>??? padding to get 4-byte alignment with start of SMB header</p></dd><dt><span class="term">UINT16</span></dt><dd><p>domain name string length * 2</p></dd><dt><span class="term">UINT16</span></dt><dd><p>domain name string length * 2</p></dd><dt><span class="term">VOID*</span></dt><dd><p>undocumented domain name string buffer pointer</p></dd><dt><span class="term">VOID*</span></dt><dd><p>undocumented domain SID string buffer pointer</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>domain name (unicode string)</p></dd><dt><span class="term">DOM_SID</span></dt><dd><p>domain SID</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2861970"></a>USER_INFO (user logon info)</h4></div></div><p><span class="emphasis"><em>Note: it would be nice to know what the 16 byte user session key is for.</em></span></p><div class="variablelist"><dl><dt><span class="term">NTTIME</span></dt><dd><p>logon time</p></dd><dt><span class="term">NTTIME</span></dt><dd><p>logoff time</p></dd><dt><span class="term">NTTIME</span></dt><dd><p>kickoff time</p></dd><dt><span class="term">NTTIME</span></dt><dd><p>password last set time</p></dd><dt><span class="term">NTTIME</span></dt><dd><p>password can change time</p></dd><dt><span class="term">NTTIME</span></dt><dd><p>password must change time</p></dd><dt><span class="term">UNIHDR</span></dt><dd><p>username unicode string header</p></dd><dt><span class="term">UNIHDR</span></dt><dd><p>user's full name unicode string header</p></dd><dt><span class="term">UNIHDR</span></dt><dd><p>logon script unicode string header</p></dd><dt><span class="term">UNIHDR</span></dt><dd><p>profile path unicode string header</p></dd><dt><span class="term">UNIHDR</span></dt><dd><p>home directory unicode string header</p></dd><dt><span class="term">UNIHDR</span></dt><dd><p>home directory drive unicode string header</p></dd><dt><span class="term">UINT16</span></dt><dd><p>logon count</p></dd><dt><span class="term">UINT16</span></dt><dd><p>bad password count</p></dd><dt><span class="term">UINT32</span></dt><dd><p>User ID</p></dd><dt><span class="term">UINT32</span></dt><dd><p>Group ID</p></dd><dt><span class="term">UINT32</span></dt><dd><p>num groups</p></dd><dt><span class="term">VOID*</span></dt><dd><p>undocumented buffer pointer to groups.</p></dd><dt><span class="term">UINT32</span></dt><dd><p>user flags</p></dd><dt><span class="term">char[16]</span></dt><dd><p>user session key</p></dd><dt><span class="term">UNIHDR</span></dt><dd><p>logon server unicode string header</p></dd><dt><span class="term">UNIHDR</span></dt><dd><p>logon domain unicode string header</p></dd><dt><span class="term">VOID*</span></dt><dd><p>undocumented logon domain id pointer</p></dd><dt><span class="term">char[40]</span></dt><dd><p>40 undocumented padding bytes. future expansion?</p></dd><dt><span class="term">UINT32</span></dt><dd><p>0 - num_other_sids?</p></dd><dt><span class="term">VOID*</span></dt><dd><p>NULL - undocumented pointer to other domain SIDs.</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>username unicode string</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>user's full name unicode string</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>logon script unicode string</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>profile path unicode string</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>home directory unicode string</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>home directory drive unicode string</p></dd><dt><span class="term">UINT32</span></dt><dd><p>num groups</p></dd><dt><span class="term">GID[num_groups]</span></dt><dd><p>group info</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>logon server unicode string</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>logon domain unicode string</p></dd><dt><span class="term">DOM_SID</span></dt><dd><p>domain SID</p></dd><dt><span class="term">DOM_SID[num_sids]</span></dt><dd><p>other domain SIDs?</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2862534"></a>SH_INFO_1_PTR (pointers to level 1 share info strings)</h4></div></div><p><span class="emphasis"><em>Note: see cifsrap2.txt section5, page 10.</em></span></p><table class="simplelist" border="0" summary="Simple list"><tr><td>0 for shi1_type indicates a Disk.</td></tr><tr><td>1 for shi1_type indicates a Print Queue.</td></tr><tr><td>2 for shi1_type indicates a Device.</td></tr><tr><td>3 for shi1_type indicates an IPC pipe.</td></tr><tr><td>0x8000 0000 (top bit set in shi1_type) indicates a hidden share.</td></tr></table><div class="variablelist"><dl><dt><span class="term">VOID*</span></dt><dd><p>shi1_netname - pointer to net name</p></dd><dt><span class="term">UINT32</span></dt><dd><p>shi1_type - type of share. 0 - undocumented.</p></dd><dt><span class="term">VOID*</span></dt><dd><p>shi1_remark - pointer to comment.</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2862629"></a>SH_INFO_1_STR (level 1 share info strings)</h4></div></div><div class="variablelist"><dl><dt><span class="term">UNISTR2</span></dt><dd><p>shi1_netname - unicode string of net name</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>shi1_remark - unicode string of comment.</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2862671"></a>SHARE_INFO_1_CTR</h4></div></div><p>share container with 0 entries:</p><div class="variablelist"><dl><dt><span class="term">UINT32</span></dt><dd><p>0 - EntriesRead</p></dd><dt><span class="term">UINT32</span></dt><dd><p>0 - Buffer</p></dd></dl></div><p>share container with > 0 entries:</p><div class="variablelist"><dl><dt><span class="term">UINT32</span></dt><dd><p>EntriesRead</p></dd><dt><span class="term">UINT32</span></dt><dd><p>non-zero - Buffer</p></dd><dt><span class="term">UINT32</span></dt><dd><p>EntriesRead</p></dd><dt><span class="term">SH_INFO_1_PTR[EntriesRead]</span></dt><dd><p>share entry pointers</p></dd><dt><span class="term">SH_INFO_1_STR[EntriesRead]</span></dt><dd><p>share entry strings</p></dd><dt><span class="term">UINT8[]</span></dt><dd><p>padding to get unicode string 4-byte aligned with start of the SMB header.</p></dd><dt><span class="term">UINT32</span></dt><dd><p>EntriesRead</p></dd><dt><span class="term">UINT32</span></dt><dd><p>0 - padding</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2862841"></a>SERVER_INFO_101</h4></div></div><p><span class="emphasis"><em>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. </em></span></p><div class="variablelist"><dl><dt><span class="term">SV_TYPE_WORKSTATION</span></dt><dd><p>0x00000001 All workstations</p></dd><dt><span class="term">SV_TYPE_SERVER</span></dt><dd><p>0x00000002 All servers</p></dd><dt><span class="term">SV_TYPE_SQLSERVER</span></dt><dd><p>0x00000004 Any server running with SQL server</p></dd><dt><span class="term">SV_TYPE_DOMAIN_CTRL</span></dt><dd><p>0x00000008 Primary domain controller</p></dd><dt><span class="term">SV_TYPE_DOMAIN_BAKCTRL</span></dt><dd><p>0x00000010 Backup domain controller</p></dd><dt><span class="term">SV_TYPE_TIME_SOURCE</span></dt><dd><p>0x00000020 Server running the timesource service</p></dd><dt><span class="term">SV_TYPE_AFP</span></dt><dd><p>0x00000040 Apple File Protocol servers</p></dd><dt><span class="term">SV_TYPE_NOVELL</span></dt><dd><p>0x00000080 Novell servers</p></dd><dt><span class="term">SV_TYPE_DOMAIN_MEMBER</span></dt><dd><p>0x00000100 Domain Member</p></dd><dt><span class="term">SV_TYPE_PRINTQ_SERVER</span></dt><dd><p>0x00000200 Server sharing print queue</p></dd><dt><span class="term">SV_TYPE_DIALIN_SERVER</span></dt><dd><p>0x00000400 Server running dialin service.</p></dd><dt><span class="term">SV_TYPE_XENIX_SERVER</span></dt><dd><p>0x00000800 Xenix server</p></dd><dt><span class="term">SV_TYPE_NT</span></dt><dd><p>0x00001000 NT server</p></dd><dt><span class="term">SV_TYPE_WFW</span></dt><dd><p>0x00002000 Server running Windows for </p></dd><dt><span class="term">SV_TYPE_SERVER_NT</span></dt><dd><p>0x00008000 Windows NT non DC server</p></dd><dt><span class="term">SV_TYPE_POTENTIAL_BROWSER</span></dt><dd><p>0x00010000 Server that can run the browser service</p></dd><dt><span class="term">SV_TYPE_BACKUP_BROWSER</span></dt><dd><p>0x00020000 Backup browser server</p></dd><dt><span class="term">SV_TYPE_MASTER_BROWSER</span></dt><dd><p>0x00040000 Master browser server</p></dd><dt><span class="term">SV_TYPE_DOMAIN_MASTER</span></dt><dd><p>0x00080000 Domain Master Browser server</p></dd><dt><span class="term">SV_TYPE_LOCAL_LIST_ONLY</span></dt><dd><p>0x40000000 Enumerate only entries marked "local"</p></dd><dt><span class="term">SV_TYPE_DOMAIN_ENUM</span></dt><dd><p>0x80000000 Enumerate Domains. The pszServer and pszDomain parameters must be NULL.</p></dd></dl></div><div class="variablelist"><dl><dt><span class="term">UINT32</span></dt><dd><p>500 - platform_id</p></dd><dt><span class="term">VOID*</span></dt><dd><p>pointer to name</p></dd><dt><span class="term">UINT32</span></dt><dd><p>5 - major version</p></dd><dt><span class="term">UINT32</span></dt><dd><p>4 - minor version</p></dd><dt><span class="term">UINT32</span></dt><dd><p>type (SV_TYPE_... bit field)</p></dd><dt><span class="term">VOID*</span></dt><dd><p>pointer to comment</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>sv101_name - unicode string of server name</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>sv_101_comment - unicode string of server comment.</p></dd><dt><span class="term">UINT8[]</span></dt><dd><p>padding to get unicode string 4-byte aligned with start of the SMB header.</p></dd></dl></div></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2863307"></a>MSRPC over Transact Named Pipe</h2></div></div><p>For details on the SMB Transact Named Pipe, see cifs6.txt</p><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2863320"></a>MSRPC Pipes</h3></div></div><p> +The MSRPC is conducted over an SMB Transact Pipe with a name of +<tt>\PIPE\</tt>. You must first obtain a 16 bit file handle, by +sending a SMBopenX with the pipe name <tt>\PIPE\srvsvc</tt> for example. You can then perform an SMB Trans, -and must carry out an SMBclose on the file handle once you are finished.</P -><P ->Trans Requests must be sent with two setup UINT16s, no UINT16 params (none +and must carry out an SMBclose on the file handle once you are finished. +</p><p> +Trans Requests must be sent with two setup UINT16s, no UINT16 params (none known about), and UINT8 data parameters sufficient to contain the MSRPC header, and MSRPC data. The first UINT16 setup parameter must be either 0x0026 to indicate an RPC, or 0x0001 to indicate Set Named Pipe Handle state. The second UINT16 parameter must be the file handle for the pipe, -obtained above.</P -><P ->The Data section for an API Command of 0x0026 (RPC pipe) in the Trans +obtained above. +</p><p> +The Data section for an API Command of 0x0026 (RPC pipe) in the Trans Request is the RPC Header, followed by the RPC Data. The Data section for an API Command of 0x0001 (Set Named Pipe Handle state) is two bytes. The -only value seen for these two bytes is 0x00 0x43.</P -><P ->MSRPC Responses are sent as response data inside standard SMB Trans -responses, with the MSRPC Header, MSRPC Data and MSRPC tail.</P -><P ->It is suspected that the Trans Requests will need to be at least 2-byte +only value seen for these two bytes is 0x00 0x43. +</p><p> +MSRPC Responses are sent as response data inside standard SMB Trans +responses, with the MSRPC Header, MSRPC Data and MSRPC tail. +</p><p> +It is suspected that the Trans Requests will need to be at least 2-byte aligned (probably 4-byte). This is standard practice for SMBs. It is also independent of the observed 4-byte alignments with the start of the MSRPC header, including the 4-byte alignment between the MSRPC header and the -MSRPC data.</P -><P ->First, an SMBtconX connection is made to the IPC$ share. The connection +MSRPC data. +</p><p> +First, an SMBtconX connection is made to the IPC$ share. The connection must be made using encrypted passwords, not clear-text. Then, an SMBopenX is made on the pipe. Then, a Set Named Pipe Handle State must be sent, after which the pipe is ready to accept API commands. Lastly, and SMBclose -is sent.</P -><P ->To be resolved:</P -><P ->lkcl/01nov97 there appear to be two additional bytes after the null-terminated \PIPE\ name for the RPC pipe. Values seen so far are -listed below:</P -><P -><PRE -CLASS="PROGRAMLISTING" -> initial SMBopenX request: RPC API command 0x26 params: - "\\PIPE\\lsarpc" 0x65 0x63; 0x72 0x70; 0x44 0x65; - "\\PIPE\\srvsvc" 0x73 0x76; 0x4E 0x00; 0x5C 0x43;</PRE -></P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN1588" ->9.3.2. Header</A -></H3 -><P ->[section to be rewritten, following receipt of work by Duncan Stansfield]</P -><P ->Interesting note: if you set packed data representation to 0x0100 0000 -then all 4-byte and 2-byte word ordering is turned around!</P -><P ->The start of each of the NTLSA and NETLOGON named pipes begins with:</P -><P -><B ->offset: </B ->00</P -><P -><B ->Variable type: </B ->UINT8</P -><P -><B ->Variable data: </B ->5 - RPC major version</P -><P -><B ->offset: </B ->01</P -><P -><B ->Variable type: </B ->UINT8</P -><P -><B ->Variable data: </B ->0 - RPC minor version</P -><P -><B ->offset: </B ->02</P -><P -><B ->Variable type: </B ->UINT8</P -><P -><B ->Variable data: </B ->2 - RPC response packet</P -><P -><B ->offset: </B ->03</P -><P -><B ->Variable type: </B ->UINT8</P -><P -><B ->Variable data: </B ->3 - (FirstFrag bit-wise or with LastFrag)</P -><P -><B ->offset: </B ->04</P -><P -><B ->Variable type: </B ->UINT32</P -><P -><B ->Variable data: </B ->0x1000 0000 - packed data representation</P -><P -><B ->offset: </B ->08</P -><P -><B ->Variable type: </B ->UINT16</P -><P -><B ->Variable data: </B ->fragment length - data size (bytes) inc header and tail.</P -><P -><B ->offset: </B ->0A</P -><P -><B ->Variable type: </B ->UINT16</P -><P -><B ->Variable data: </B ->0 - authentication length </P -><P -><B ->offset: </B ->0C</P -><P -><B ->Variable type: </B ->UINT32</P -><P -><B ->Variable data: </B ->call identifier. matches 12th UINT32 of incoming RPC data.</P -><P -><B ->offset: </B ->10</P -><P -><B ->Variable type: </B ->UINT32</P -><P -><B ->Variable data: </B ->allocation hint - data size (bytes) minus header and tail.</P -><P -><B ->offset: </B ->14</P -><P -><B ->Variable type: </B ->UINT16</P -><P -><B ->Variable data: </B ->0 - presentation context identifier</P -><P -><B ->offset: </B ->16</P -><P -><B ->Variable type: </B ->UINT8</P -><P -><B ->Variable data: </B ->0 - cancel count</P -><P -><B ->offset: </B ->17</P -><P -><B ->Variable type: </B ->UINT8</P -><P -><B ->Variable data: </B ->in replies: 0 - reserved; in requests: opnum - see #defines.</P -><P -><B ->offset: </B ->18</P -><P -><B ->Variable type: </B ->......</P -><P -><B ->Variable data: </B ->start of data (goes on for allocation_hint bytes)</P -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1649" ->9.3.2.1. RPC_Packet for request, response, bind and bind acknowledgement</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT8 versionmaj</DT -><DD -><P ->reply same as request (0x05)</P -></DD -><DT ->UINT8 versionmin</DT -><DD -><P ->reply same as request (0x00)</P -></DD -><DT ->UINT8 type</DT -><DD -><P ->one of the MSRPC_Type enums</P -></DD -><DT ->UINT8 flags</DT -><DD -><P ->reply same as request (0x00 for Bind, 0x03 for Request)</P -></DD -><DT ->UINT32 representation</DT -><DD -><P ->reply same as request (0x00000010)</P -></DD -><DT ->UINT16 fraglength</DT -><DD -><P ->the length of the data section of the SMB trans packet</P -></DD -><DT ->UINT16 authlength</DT -><DD -><P -></P -></DD -><DT ->UINT32 callid</DT -><DD -><P ->call identifier. (e.g. 0x00149594)</P -></DD -><DT ->* stub USE TvPacket</DT -><DD -><P ->the remainder of the packet depending on the "type"</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1688" ->9.3.2.2. Interface identification</A -></H4 -><P ->the interfaces are numbered. as yet I haven't seen more than one interface used on the same pipe name srvsvc</P -><P -><PRE -CLASS="PROGRAMLISTING" ->abstract (0x4B324FC8, 0x01D31670, 0x475A7812, 0x88E16EBF, 0x00000003) -transfer (0x8A885D04, 0x11C91CEB, 0x0008E89F, 0x6048102B, 0x00000002)</PRE -></P -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1693" ->9.3.2.3. RPC_Iface RW</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT8 byte[16]</DT -><DD -><P ->16 bytes of number</P -></DD -><DT ->UINT32 version</DT -><DD -><P ->the interface number</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1704" ->9.3.2.4. RPC_ReqBind RW</A -></H4 -><P ->the remainder of the packet after the header if "type" was Bind in the response header, "type" should be BindAck</P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT16 maxtsize</DT -><DD -><P ->maximum transmission fragment size (0x1630)</P -></DD -><DT ->UINT16 maxrsize</DT -><DD -><P ->max receive fragment size (0x1630)</P -></DD -><DT ->UINT32 assocgid</DT -><DD -><P ->associated group id (0x0)</P -></DD -><DT ->UINT32 numelements</DT -><DD -><P ->the number of elements (0x1)</P -></DD -><DT ->UINT16 contextid</DT -><DD -><P ->presentation context identifier (0x0)</P -></DD -><DT ->UINT8 numsyntaxes</DT -><DD -><P ->the number of syntaxes (has always been 1?)(0x1)</P -></DD -><DT ->UINT8[]</DT -><DD -><P ->4-byte alignment padding, against SMB header</P -></DD -><DT ->* abstractint USE RPC_Iface</DT -><DD -><P ->num and vers. of interface client is using</P -></DD -><DT ->* transferint USE RPC_Iface</DT -><DD -><P ->num and vers. of interface to use for replies</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1744" ->9.3.2.5. RPC_Address RW</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT16 length</DT -><DD -><P ->length of the string including null terminator</P -></DD -><DT ->* port USE string</DT -><DD -><P ->the string above in single byte, null terminated form</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1755" ->9.3.2.6. RPC_ResBind RW</A -></H4 -><P ->the response to place after the header in the reply packet</P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT16 maxtsize</DT -><DD -><P ->same as request</P -></DD -><DT ->UINT16 maxrsize</DT -><DD -><P ->same as request</P -></DD -><DT ->UINT32 assocgid</DT -><DD -><P ->zero</P -></DD -><DT ->* secondaddr USE RPC_Address</DT -><DD -><P ->the address string, as described earlier</P -></DD -><DT ->UINT8[]</DT -><DD -><P ->4-byte alignment padding, against SMB header</P -></DD -><DT ->UINT8 numresults</DT -><DD -><P ->the number of results (0x01)</P -></DD -><DT ->UINT8[]</DT -><DD -><P ->4-byte alignment padding, against SMB header</P -></DD -><DT ->UINT16 result</DT -><DD -><P ->result (0x00 = accept)</P -></DD -><DT ->UINT16 reason</DT -><DD -><P ->reason (0x00 = no reason specified)</P -></DD -><DT ->* transfersyntax USE RPC_Iface</DT -><DD -><P ->the transfer syntax from the request</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1799" ->9.3.2.7. RPC_ReqNorm RW</A -></H4 -><P ->the remainder of the packet after the header for every other other request</P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT32 allochint</DT -><DD -><P ->the size of the stub data in bytes</P -></DD -><DT ->UINT16 prescontext</DT -><DD -><P ->presentation context identifier (0x0)</P -></DD -><DT ->UINT16 opnum</DT -><DD -><P ->operation number (0x15)</P -></DD -><DT ->* stub USE TvPacket</DT -><DD -><P ->a packet dependent on the pipe name (probably the interface) and the op number)</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1819" ->9.3.2.8. RPC_ResNorm RW</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT32 allochint</DT -><DD -><P -># size of the stub data in bytes</P -></DD -><DT ->UINT16 prescontext</DT -><DD -><P -># presentation context identifier (same as request)</P -></DD -><DT ->UINT8 cancelcount</DT -><DD -><P -># cancel count? (0x0)</P -></DD -><DT ->UINT8 reserved</DT -><DD -><P -># 0 - one byte padding</P -></DD -><DT ->* stub USE TvPacket</DT -><DD -><P -># the remainder of the reply</P -></DD -></DL -></DIV -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN1842" ->9.3.3. Tail</A -></H3 -><P ->The end of each of the NTLSA and NETLOGON named pipes ends with:</P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->......</DT -><DD -><P ->end of data</P -></DD -><DT ->UINT32</DT -><DD -><P ->return code</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN1854" ->9.3.4. RPC Bind / Bind Ack</A -></H3 -><P ->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.</P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: The RPC_ResBind SMB Transact request is sent with two uint16 setup parameters. The first is 0x0026; the second is the file handle - returned by the SMBopenX Transact response.</I -></SPAN -></P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: The RPC_ResBind members maxtsize, maxrsize and assocgid are the same in the response as the same members in the RPC_ReqBind. The +is sent. +</p><p> +To be resolved: +</p><p> +lkcl/01nov97 there appear to be two additional bytes after the null-terminated \PIPE\ name for the RPC pipe. Values seen so far are +listed below:</p><pre class="programlisting"> + initial SMBopenX request: RPC API command 0x26 params: + "\\PIPE\\lsarpc" 0x65 0x63; 0x72 0x70; 0x44 0x65; + "\\PIPE\\srvsvc" 0x73 0x76; 0x4E 0x00; 0x5C 0x43; +</pre></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2863422"></a>Header</h3></div></div><p>[section to be rewritten, following receipt of work by Duncan Stansfield]</p><p>Interesting note: if you set packed data representation to 0x0100 0000 +then all 4-byte and 2-byte word ordering is turned around!</p><p>The start of each of the NTLSA and NETLOGON named pipes begins with:</p><div class="segmentedlist"><p><b>offset: </b>00</p><p><b>Variable type: </b>UINT8</p><p><b>Variable data: </b>5 - RPC major version</p><p><b>offset: </b>01</p><p><b>Variable type: </b>UINT8</p><p><b>Variable data: </b>0 - RPC minor version</p><p><b>offset: </b>02</p><p><b>Variable type: </b>UINT8</p><p><b>Variable data: </b>2 - RPC response packet</p><p><b>offset: </b>03</p><p><b>Variable type: </b>UINT8</p><p><b>Variable data: </b>3 - (FirstFrag bit-wise or with LastFrag)</p><p><b>offset: </b>04</p><p><b>Variable type: </b>UINT32</p><p><b>Variable data: </b>0x1000 0000 - packed data representation</p><p><b>offset: </b>08</p><p><b>Variable type: </b>UINT16</p><p><b>Variable data: </b>fragment length - data size (bytes) inc header and tail.</p><p><b>offset: </b>0A</p><p><b>Variable type: </b>UINT16</p><p><b>Variable data: </b>0 - authentication length </p><p><b>offset: </b>0C</p><p><b>Variable type: </b>UINT32</p><p><b>Variable data: </b>call identifier. matches 12th UINT32 of incoming RPC data.</p><p><b>offset: </b>10</p><p><b>Variable type: </b>UINT32</p><p><b>Variable data: </b>allocation hint - data size (bytes) minus header and tail.</p><p><b>offset: </b>14</p><p><b>Variable type: </b>UINT16</p><p><b>Variable data: </b>0 - presentation context identifier</p><p><b>offset: </b>16</p><p><b>Variable type: </b>UINT8</p><p><b>Variable data: </b>0 - cancel count</p><p><b>offset: </b>17</p><p><b>Variable type: </b>UINT8</p><p><b>Variable data: </b>in replies: 0 - reserved; in requests: opnum - see #defines.</p><p><b>offset: </b>18</p><p><b>Variable type: </b>......</p><p><b>Variable data: </b>start of data (goes on for allocation_hint bytes)</p></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2863612"></a>RPC_Packet for request, response, bind and bind acknowledgement</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT8 versionmaj</span></dt><dd><p>reply same as request (0x05)</p></dd><dt><span class="term">UINT8 versionmin</span></dt><dd><p>reply same as request (0x00)</p></dd><dt><span class="term">UINT8 type</span></dt><dd><p>one of the MSRPC_Type enums</p></dd><dt><span class="term">UINT8 flags</span></dt><dd><p>reply same as request (0x00 for Bind, 0x03 for Request)</p></dd><dt><span class="term">UINT32 representation</span></dt><dd><p>reply same as request (0x00000010)</p></dd><dt><span class="term">UINT16 fraglength</span></dt><dd><p>the length of the data section of the SMB trans packet</p></dd><dt><span class="term">UINT16 authlength</span></dt><dd><p></p></dd><dt><span class="term">UINT32 callid</span></dt><dd><p>call identifier. (e.g. 0x00149594)</p></dd><dt><span class="term">* stub USE TvPacket</span></dt><dd><p>the remainder of the packet depending on the "type"</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2863746"></a>Interface identification</h4></div></div><p>the interfaces are numbered. as yet I haven't seen more than one interface used on the same pipe name srvsvc</p><pre class="programlisting"> +abstract (0x4B324FC8, 0x01D31670, 0x475A7812, 0x88E16EBF, 0x00000003) +transfer (0x8A885D04, 0x11C91CEB, 0x0008E89F, 0x6048102B, 0x00000002) +</pre></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2863772"></a>RPC_Iface RW</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT8 byte[16]</span></dt><dd><p>16 bytes of number</p></dd><dt><span class="term">UINT32 version</span></dt><dd><p>the interface number</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2863811"></a>RPC_ReqBind RW</h4></div></div><p>the remainder of the packet after the header if "type" was Bind in the response header, "type" should be BindAck</p><div class="variablelist"><dl><dt><span class="term">UINT16 maxtsize</span></dt><dd><p>maximum transmission fragment size (0x1630)</p></dd><dt><span class="term">UINT16 maxrsize</span></dt><dd><p>max receive fragment size (0x1630)</p></dd><dt><span class="term">UINT32 assocgid</span></dt><dd><p>associated group id (0x0)</p></dd><dt><span class="term">UINT32 numelements</span></dt><dd><p>the number of elements (0x1)</p></dd><dt><span class="term">UINT16 contextid</span></dt><dd><p>presentation context identifier (0x0)</p></dd><dt><span class="term">UINT8 numsyntaxes</span></dt><dd><p>the number of syntaxes (has always been 1?)(0x1)</p></dd><dt><span class="term">UINT8[]</span></dt><dd><p>4-byte alignment padding, against SMB header</p></dd><dt><span class="term">* abstractint USE RPC_Iface</span></dt><dd><p>num and vers. of interface client is using</p></dd><dt><span class="term">* transferint USE RPC_Iface</span></dt><dd><p>num and vers. of interface to use for replies</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2863952"></a>RPC_Address RW</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT16 length</span></dt><dd><p>length of the string including null terminator</p></dd><dt><span class="term">* port USE string</span></dt><dd><p>the string above in single byte, null terminated form</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2863992"></a>RPC_ResBind RW</h4></div></div><p>the response to place after the header in the reply packet</p><div class="variablelist"><dl><dt><span class="term">UINT16 maxtsize</span></dt><dd><p>same as request</p></dd><dt><span class="term">UINT16 maxrsize</span></dt><dd><p>same as request</p></dd><dt><span class="term">UINT32 assocgid</span></dt><dd><p>zero</p></dd><dt><span class="term">* secondaddr USE RPC_Address</span></dt><dd><p>the address string, as described earlier</p></dd><dt><span class="term">UINT8[]</span></dt><dd><p>4-byte alignment padding, against SMB header</p></dd><dt><span class="term">UINT8 numresults</span></dt><dd><p>the number of results (0x01)</p></dd><dt><span class="term">UINT8[]</span></dt><dd><p>4-byte alignment padding, against SMB header</p></dd><dt><span class="term">UINT16 result</span></dt><dd><p>result (0x00 = accept)</p></dd><dt><span class="term">UINT16 reason</span></dt><dd><p>reason (0x00 = no reason specified)</p></dd><dt><span class="term">* transfersyntax USE RPC_Iface</span></dt><dd><p>the transfer syntax from the request</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2864143"></a>RPC_ReqNorm RW</h4></div></div><p>the remainder of the packet after the header for every other other request</p><div class="variablelist"><dl><dt><span class="term">UINT32 allochint</span></dt><dd><p>the size of the stub data in bytes</p></dd><dt><span class="term">UINT16 prescontext</span></dt><dd><p>presentation context identifier (0x0)</p></dd><dt><span class="term">UINT16 opnum</span></dt><dd><p>operation number (0x15)</p></dd><dt><span class="term">* stub USE TvPacket</span></dt><dd><p>a packet dependent on the pipe name (probably the interface) and the op number)</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2864215"></a>RPC_ResNorm RW</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT32 allochint</span></dt><dd><p># size of the stub data in bytes</p></dd><dt><span class="term">UINT16 prescontext</span></dt><dd><p># presentation context identifier (same as request)</p></dd><dt><span class="term">UINT8 cancelcount</span></dt><dd><p># cancel count? (0x0)</p></dd><dt><span class="term">UINT8 reserved</span></dt><dd><p># 0 - one byte padding</p></dd><dt><span class="term">* stub USE TvPacket</span></dt><dd><p># the remainder of the reply</p></dd></dl></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2864296"></a>Tail</h3></div></div><p>The end of each of the NTLSA and NETLOGON named pipes ends with:</p><div class="variablelist"><dl><dt><span class="term">......</span></dt><dd><p>end of data</p></dd><dt><span class="term">UINT32</span></dt><dd><p>return code</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2864342"></a>RPC Bind / Bind Ack</h3></div></div><p> +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. +</p><p><span class="emphasis"><em>Note: The RPC_ResBind SMB Transact request is sent with two uint16 setup parameters. The first is 0x0026; the second is the file handle + returned by the SMBopenX Transact response.</em></span></p><p><span class="emphasis"><em>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</I -></SPAN -></P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->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:</I -></SPAN -></P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->initial SMBopenX request:</DT -><DD -><P ->RPC_ResBind response:</P -></DD -><DT ->"\\PIPE\\srvsvc"</DT -><DD -><P ->"\\PIPE\\ntsvcs"</P -></DD -><DT ->"\\PIPE\\samr"</DT -><DD -><P ->"\\PIPE\\lsass"</P -></DD -><DT ->"\\PIPE\\lsarpc"</DT -><DD -><P ->"\\PIPE\\lsass"</P -></DD -><DT ->"\\PIPE\\wkssvc"</DT -><DD -><P ->"\\PIPE\\wksvcs"</P -></DD -><DT ->"\\PIPE\\NETLOGON"</DT -><DD -><P ->"\\PIPE\\NETLOGON"</P -></DD -></DL -></DIV -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->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.</I -></SPAN -></P -><P ->Request:</P -><P -></P -><TABLE -BORDER="0" -><TBODY -><TR -><TD ->RPC_Packet</TD -></TR -><TR -><TD ->RPC_ReqBind</TD -></TR -></TBODY -></TABLE -><P -></P -><P ->Response:</P -><P -></P -><TABLE -BORDER="0" -><TBODY -><TR -><TD ->RPC_Packet</TD -></TR -><TR -><TD ->RPC_ResBind</TD -></TR -></TBODY -></TABLE -><P -></P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN1898" ->9.3.5. NTLSA Transact Named Pipe</A -></H3 -><P ->The sequence of actions taken on this pipe are:</P -><P -></P -><TABLE -BORDER="0" -><TBODY -><TR -><TD ->Establish a connection to the IPC$ share (SMBtconX). use encrypted passwords.</TD -></TR -><TR -><TD ->Open an RPC Pipe with the name "\\PIPE\\lsarpc". Store the file handle.</TD -></TR -><TR -><TD ->Using the file handle, send a Set Named Pipe Handle state to 0x4300.</TD -></TR -><TR -><TD ->Send an LSA Open Policy request. Store the Policy Handle.</TD -></TR -><TR -><TD ->Using the Policy Handle, send LSA Query Info Policy requests, etc.</TD -></TR -><TR -><TD ->Using the Policy Handle, send an LSA Close.</TD -></TR -><TR -><TD ->Close the IPC$ share.</TD -></TR -></TBODY -></TABLE -><P -></P -><P ->Defines for this pipe, identifying the query are:</P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->LSA Open Policy:</DT -><DD -><P ->0x2c</P -></DD -><DT ->LSA Query Info Policy:</DT -><DD -><P ->0x07</P -></DD -><DT ->LSA Enumerate Trusted Domains:</DT -><DD -><P ->0x0d</P -></DD -><DT ->LSA Open Secret:</DT -><DD -><P ->0xff</P -></DD -><DT ->LSA Lookup SIDs:</DT -><DD -><P ->0xfe</P -></DD -><DT ->LSA Lookup Names:</DT -><DD -><P ->0xfd</P -></DD -><DT ->LSA Close:</DT -><DD -><P ->0x00</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN1939" ->9.3.6. LSA Open Policy</A -></H3 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: The policy handle can be anything you like.</I -></SPAN -></P -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1943" ->9.3.6.1. Request</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->VOID*</DT -><DD -><P ->buffer pointer</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->server name - unicode string starting with two '\'s</P -></DD -><DT ->OBJ_ATTR</DT -><DD -><P ->object attributes</P -></DD -><DT ->UINT32</DT -><DD -><P ->1 - desired access</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1962" ->9.3.6.2. Response</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->POL_HND</DT -><DD -><P ->LSA policy handle</P -></DD -><DT ->return</DT -><DD -><P ->0 - indicates success</P -></DD -></DL -></DIV -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN1973" ->9.3.7. LSA Query Info Policy</A -></H3 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: The info class in response must be the same as that in the request.</I -></SPAN -></P -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1977" ->9.3.7.1. Request</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->POL_HND</DT -><DD -><P ->LSA policy handle</P -></DD -><DT ->UINT16</DT -><DD -><P ->info class (also a policy handle?)</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN1988" ->9.3.7.2. Response</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->VOID*</DT -><DD -><P ->undocumented buffer pointer</P -></DD -><DT ->UINT16</DT -><DD -><P ->info class (same as info class in request).</P -></DD -></DL -></DIV -><P -><PRE -CLASS="PROGRAMLISTING" ->switch (info class) + the</em></span></p><p><span class="emphasis"><em>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:</em></span></p><div class="variablelist"><dl><dt><span class="term">initial SMBopenX request:</span></dt><dd><p>RPC_ResBind response:</p></dd><dt><span class="term">"\\PIPE\\srvsvc"</span></dt><dd><p>"\\PIPE\\ntsvcs"</p></dd><dt><span class="term">"\\PIPE\\samr"</span></dt><dd><p>"\\PIPE\\lsass"</p></dd><dt><span class="term">"\\PIPE\\lsarpc"</span></dt><dd><p>"\\PIPE\\lsass"</p></dd><dt><span class="term">"\\PIPE\\wkssvc"</span></dt><dd><p>"\\PIPE\\wksvcs"</p></dd><dt><span class="term">"\\PIPE\\NETLOGON"</span></dt><dd><p>"\\PIPE\\NETLOGON"</p></dd></dl></div><p><span class="emphasis"><em>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.</em></span></p><p>Request:</p><table class="simplelist" border="0" summary="Simple list"><tr><td>RPC_Packet</td></tr><tr><td>RPC_ReqBind</td></tr></table><p>Response:</p><table class="simplelist" border="0" summary="Simple list"><tr><td>RPC_Packet</td></tr><tr><td>RPC_ResBind</td></tr></table></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2864522"></a>NTLSA Transact Named Pipe</h3></div></div><p>The sequence of actions taken on this pipe are:</p><table class="simplelist" border="0" summary="Simple list"><tr><td>Establish a connection to the IPC$ share (SMBtconX). use encrypted passwords.</td></tr><tr><td>Open an RPC Pipe with the name "\\PIPE\\lsarpc". Store the file handle.</td></tr><tr><td>Using the file handle, send a Set Named Pipe Handle state to 0x4300.</td></tr><tr><td>Send an LSA Open Policy request. Store the Policy Handle.</td></tr><tr><td>Using the Policy Handle, send LSA Query Info Policy requests, etc.</td></tr><tr><td>Using the Policy Handle, send an LSA Close.</td></tr><tr><td>Close the IPC$ share.</td></tr></table><p>Defines for this pipe, identifying the query are:</p><div class="variablelist"><dl><dt><span class="term">LSA Open Policy:</span></dt><dd><p>0x2c</p></dd><dt><span class="term">LSA Query Info Policy:</span></dt><dd><p>0x07</p></dd><dt><span class="term">LSA Enumerate Trusted Domains:</span></dt><dd><p>0x0d</p></dd><dt><span class="term">LSA Open Secret:</span></dt><dd><p>0xff</p></dd><dt><span class="term">LSA Lookup SIDs:</span></dt><dd><p>0xfe</p></dd><dt><span class="term">LSA Lookup Names:</span></dt><dd><p>0xfd</p></dd><dt><span class="term">LSA Close:</span></dt><dd><p>0x00</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2864687"></a>LSA Open Policy</h3></div></div><p><span class="emphasis"><em>Note: The policy handle can be anything you like.</em></span></p><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2864701"></a>Request</h4></div></div><div class="variablelist"><dl><dt><span class="term">VOID*</span></dt><dd><p>buffer pointer</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>server name - unicode string starting with two '\'s</p></dd><dt><span class="term">OBJ_ATTR</span></dt><dd><p>object attributes</p></dd><dt><span class="term">UINT32</span></dt><dd><p>1 - desired access</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2864771"></a>Response</h4></div></div><div class="variablelist"><dl><dt><span class="term">POL_HND</span></dt><dd><p>LSA policy handle</p></dd><dt><span class="term">return</span></dt><dd><p>0 - indicates success</p></dd></dl></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2864813"></a>LSA Query Info Policy</h3></div></div><p><span class="emphasis"><em>Note: The info class in response must be the same as that in the request.</em></span></p><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2864828"></a>Request</h4></div></div><div class="variablelist"><dl><dt><span class="term">POL_HND</span></dt><dd><p>LSA policy handle</p></dd><dt><span class="term">UINT16</span></dt><dd><p>info class (also a policy handle?)</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2864866"></a>Response</h4></div></div><div class="variablelist"><dl><dt><span class="term">VOID*</span></dt><dd><p>undocumented buffer pointer</p></dd><dt><span class="term">UINT16</span></dt><dd><p>info class (same as info class in request).</p></dd></dl></div><pre class="programlisting"> +switch (info class) case 3: case 5: { DOM_INFO domain info, levels 3 and 5 (are the same). } -return 0 - indicates success</PRE -></P -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2001" ->9.3.8. LSA Enumerate Trusted Domains</A -></H3 -><DIV -CLASS="SECT3" -><H4 -CLASS="SECT3" -><A -NAME="AEN2003" ->9.3.8.1. Request</A -></H4 -><P ->no extra data</P -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2006" ->9.3.8.2. Response</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT32</DT -><DD -><P ->0 - enumeration context</P -></DD -><DT ->UINT32</DT -><DD -><P ->0 - entries read</P -></DD -><DT ->UINT32</DT -><DD -><P ->0 - trust information</P -></DD -><DT ->return</DT -><DD -><P ->0x8000 001a - "no trusted domains" success code</P -></DD -></DL -></DIV -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2025" ->9.3.9. LSA Open Secret</A -></H3 -><DIV -CLASS="SECT3" -><H4 -CLASS="SECT3" -><A -NAME="AEN2027" ->9.3.9.1. Request</A -></H4 -><P ->no extra data</P -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2030" ->9.3.9.2. Response</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT32</DT -><DD -><P ->0 - undocumented</P -></DD -><DT ->UINT32</DT -><DD -><P ->0 - undocumented</P -></DD -><DT ->UINT32</DT -><DD -><P ->0 - undocumented</P -></DD -><DT ->UINT32</DT -><DD -><P ->0 - undocumented</P -></DD -><DT ->UINT32</DT -><DD -><P ->0 - undocumented</P -></DD -></DL -></DIV -><P ->return 0x0C00 0034 - "no such secret" success code</P -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2054" ->9.3.10. LSA Close</A -></H3 -><DIV -CLASS="SECT3" -><H4 -CLASS="SECT3" -><A -NAME="AEN2056" ->9.3.10.1. Request</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->POL_HND</DT -><DD -><P ->policy handle to be closed</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2063" ->9.3.10.2. Response</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->POL_HND</DT -><DD -><P ->0s - closed policy handle (all zeros)</P -></DD -></DL -></DIV -><P ->return 0 - indicates success</P -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2071" ->9.3.11. LSA Lookup SIDS</A -></H3 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: num_entries in response must be same as num_entries in request.</I -></SPAN -></P -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2075" ->9.3.11.1. Request</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->POL_HND</DT -><DD -><P ->LSA policy handle</P -></DD -><DT ->UINT32</DT -><DD -><P ->num_entries</P -></DD -><DT ->VOID*</DT -><DD -><P ->undocumented domain SID buffer pointer</P -></DD -><DT ->VOID*</DT -><DD -><P ->undocumented domain name buffer pointer</P -></DD -><DT ->VOID*[num_entries] undocumented domain SID pointers to be looked up.</DT -><DD -><P ->DOM_SID[num_entries] domain SIDs to be looked up.</P -></DD -><DT ->char[16]</DT -><DD -><P ->completely undocumented 16 bytes.</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2102" ->9.3.11.2. Response</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->DOM_REF</DT -><DD -><P ->domain reference response</P -></DD -><DT ->UINT32</DT -><DD -><P ->num_entries (listed above)</P -></DD -><DT ->VOID*</DT -><DD -><P ->undocumented buffer pointer</P -></DD -><DT ->UINT32</DT -><DD -><P ->num_entries (listed above)</P -></DD -><DT ->DOM_SID2[num_entries]</DT -><DD -><P ->domain SIDs (from Request, listed above).</P -></DD -><DT ->UINT32</DT -><DD -><P ->num_entries (listed above)</P -></DD -></DL -></DIV -><P ->return 0 - indicates success</P -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2130" ->9.3.12. LSA Lookup Names</A -></H3 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: num_entries in response must be same as num_entries in request.</I -></SPAN -></P -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2134" ->9.3.12.1. Request</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->POL_HND</DT -><DD -><P ->LSA policy handle</P -></DD -><DT ->UINT32</DT -><DD -><P ->num_entries</P -></DD -><DT ->UINT32</DT -><DD -><P ->num_entries</P -></DD -><DT ->VOID*</DT -><DD -><P ->undocumented domain SID buffer pointer</P -></DD -><DT ->VOID*</DT -><DD -><P ->undocumented domain name buffer pointer</P -></DD -><DT ->NAME[num_entries]</DT -><DD -><P ->names to be looked up.</P -></DD -><DT ->char[]</DT -><DD -><P ->undocumented bytes - falsely translated SID structure?</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2165" ->9.3.12.2. Response</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->DOM_REF</DT -><DD -><P ->domain reference response</P -></DD -><DT ->UINT32</DT -><DD -><P ->num_entries (listed above)</P -></DD -><DT ->VOID*</DT -><DD -><P ->undocumented buffer pointer</P -></DD -><DT ->UINT32</DT -><DD -><P ->num_entries (listed above)</P -></DD -><DT ->DOM_RID[num_entries]</DT -><DD -><P ->domain SIDs (from Request, listed above).</P -></DD -><DT ->UINT32</DT -><DD -><P ->num_entries (listed above)</P -></DD -></DL -></DIV -><P ->return 0 - indicates success</P -></DIV -></DIV -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN2193" ->9.4. NETLOGON rpc Transact Named Pipe</A -></H2 -><P ->The sequence of actions taken on this pipe are:</P -><P -></P -><TABLE -BORDER="0" -><TBODY -><TR -><TD ->tablish a connection to the IPC$ share (SMBtconX). use encrypted passwords.</TD -></TR -><TR -><TD ->en an RPC Pipe with the name "\\PIPE\\NETLOGON". Store the file handle.</TD -></TR -><TR -><TD ->ing the file handle, send a Set Named Pipe Handle state to 0x4300.</TD -></TR -><TR -><TD ->eate Client Challenge. Send LSA Request Challenge. Store Server Challenge.</TD -></TR -><TR -><TD ->lculate Session Key. Send an LSA Auth 2 Challenge. Store Auth2 Challenge.</TD -></TR -><TR -><TD ->lc/Verify Client Creds. Send LSA Srv PW Set. Calc/Verify Server Creds.</TD -></TR -><TR -><TD ->lc/Verify Client Creds. Send LSA SAM Logon . Calc/Verify Server Creds.</TD -></TR -><TR -><TD ->lc/Verify Client Creds. Send LSA SAM Logoff. Calc/Verify Server Creds.</TD -></TR -><TR -><TD ->ose the IPC$ share.</TD -></TR -></TBODY -></TABLE -><P -></P -><P ->Defines for this pipe, identifying the query are</P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->LSA Request Challenge:</DT -><DD -><P ->0x04</P -></DD -><DT ->LSA Server Password Set:</DT -><DD -><P ->0x06</P -></DD -><DT ->LSA SAM Logon:</DT -><DD -><P ->0x02</P -></DD -><DT ->LSA SAM Logoff:</DT -><DD -><P ->0x03</P -></DD -><DT ->LSA Auth 2:</DT -><DD -><P ->0x0f</P -></DD -><DT ->LSA Logon Control:</DT -><DD -><P ->0x0e</P -></DD -></DL -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2232" ->9.4.1. LSA Request Challenge</A -></H3 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: logon server name starts with two '\' characters and is upper case.</I -></SPAN -></P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: logon client is the machine, not the user.</I -></SPAN -></P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->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).</I -></SPAN -></P -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2240" ->9.4.1.1. Request</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->VOID*</DT -><DD -><P ->undocumented buffer pointer</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->logon server unicode string</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->logon client unicode string</P -></DD -><DT ->char[8]</DT -><DD -><P ->client challenge</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2259" ->9.4.1.2. Response</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->char[8]</DT -><DD -><P ->server challenge</P -></DD -></DL -></DIV -><P ->return 0 - indicates success</P -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2267" ->9.4.2. LSA Authenticate 2</A -></H3 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->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).</I -></SPAN -></P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: neg_flags in the response is the same as that in the request.</I -></SPAN -></P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: you must take a copy of the client-calculated credentials received here, because they will be used in subsequent authentication packets.</I -></SPAN -></P -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2275" ->9.4.2.1. Request</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->LOG_INFO</DT -><DD -><P ->client identification info</P -></DD -><DT ->char[8]</DT -><DD -><P ->client-calculated credentials</P -></DD -><DT ->UINT8[]</DT -><DD -><P ->padding to 4-byte align with start of SMB header.</P -></DD -><DT ->UINT32</DT -><DD -><P ->neg_flags - negotiated flags (usual value is 0x0000 01ff)</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2294" ->9.4.2.2. Response</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->char[8]</DT -><DD -><P ->server credentials.</P -></DD -><DT ->UINT32</DT -><DD -><P ->neg_flags - same as neg_flags in request.</P -></DD -></DL -></DIV -><P ->return 0 - indicates success. failure value unknown.</P -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2306" ->9.4.3. LSA Server Password Set</A -></H3 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: the new password is suspected to be a DES encryption using the old password to generate the key.</I -></SPAN -></P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->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).</I -></SPAN -></P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: the server credentials are constructed from the client-calculated credentials and the client time + 1 second.</I -></SPAN -></P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: you must take a copy of the client-calculated credentials received here, because they will be used in subsequent authentication packets.</I -></SPAN -></P -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2316" ->9.4.3.1. Request</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->CLNT_INFO</DT -><DD -><P ->client identification/authentication info</P -></DD -><DT ->char[]</DT -><DD -><P ->new password - undocumented.</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2327" ->9.4.3.2. Response</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->CREDS</DT -><DD -><P ->server credentials. server time stamp appears to be ignored.</P -></DD -></DL -></DIV -><P ->return 0 - indicates success; 0xC000 006a indicates failure</P -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2335" ->9.4.4. LSA SAM Logon</A -></H3 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: valid_user is True iff the username and password hash are valid for - the requested domain.</I -></SPAN -></P -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2339" ->9.4.4.1. Request</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->SAM_INFO</DT -><DD -><P ->sam_id structure</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2346" ->9.4.4.2. Response</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->VOID*</DT -><DD -><P ->undocumented buffer pointer</P -></DD -><DT ->CREDS</DT -><DD -><P ->server credentials. server time stamp appears to be ignored.</P -></DD -></DL -></DIV -><P -><PRE -CLASS="PROGRAMLISTING" ->if (valid_user) +return 0 - indicates success +</pre></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2864921"></a>LSA Enumerate Trusted Domains</h3></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2864928"></a>Request</h4></div></div><p>no extra data</p></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2864941"></a>Response</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT32</span></dt><dd><p>0 - enumeration context</p></dd><dt><span class="term">UINT32</span></dt><dd><p>0 - entries read</p></dd><dt><span class="term">UINT32</span></dt><dd><p>0 - trust information</p></dd><dt><span class="term">return</span></dt><dd><p>0x8000 001a - "no trusted domains" success code</p></dd></dl></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2865012"></a>LSA Open Secret</h3></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2865020"></a>Request</h4></div></div><p>no extra data</p></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2865032"></a>Response</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT32</span></dt><dd><p>0 - undocumented</p></dd><dt><span class="term">UINT32</span></dt><dd><p>0 - undocumented</p></dd><dt><span class="term">UINT32</span></dt><dd><p>0 - undocumented</p></dd><dt><span class="term">UINT32</span></dt><dd><p>0 - undocumented</p></dd><dt><span class="term">UINT32</span></dt><dd><p>0 - undocumented</p></dd></dl></div><p>return 0x0C00 0034 - "no such secret" success code</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2865122"></a>LSA Close</h3></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2865129"></a>Request</h4></div></div><div class="variablelist"><dl><dt><span class="term">POL_HND</span></dt><dd><p>policy handle to be closed</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2865157"></a>Response</h4></div></div><div class="variablelist"><dl><dt><span class="term">POL_HND</span></dt><dd><p>0s - closed policy handle (all zeros)</p></dd></dl></div><p>return 0 - indicates success</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2865188"></a>LSA Lookup SIDS</h3></div></div><p><span class="emphasis"><em>Note: num_entries in response must be same as num_entries in request.</em></span></p><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2865203"></a>Request</h4></div></div><div class="variablelist"><dl><dt><span class="term">POL_HND</span></dt><dd><p>LSA policy handle</p></dd><dt><span class="term">UINT32</span></dt><dd><p>num_entries</p></dd><dt><span class="term">VOID*</span></dt><dd><p>undocumented domain SID buffer pointer</p></dd><dt><span class="term">VOID*</span></dt><dd><p>undocumented domain name buffer pointer</p></dd><dt><span class="term">VOID*[num_entries] undocumented domain SID pointers to be looked up. +</span></dt><dd><p>DOM_SID[num_entries] domain SIDs to be looked up.</p></dd><dt><span class="term">char[16]</span></dt><dd><p>completely undocumented 16 bytes.</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2865302"></a>Response</h4></div></div><div class="variablelist"><dl><dt><span class="term">DOM_REF</span></dt><dd><p>domain reference response</p></dd><dt><span class="term">UINT32</span></dt><dd><p>num_entries (listed above)</p></dd><dt><span class="term">VOID*</span></dt><dd><p>undocumented buffer pointer</p></dd><dt><span class="term">UINT32</span></dt><dd><p>num_entries (listed above)</p></dd><dt><span class="term">DOM_SID2[num_entries]</span></dt><dd><p>domain SIDs (from Request, listed above).</p></dd><dt><span class="term">UINT32</span></dt><dd><p>num_entries (listed above)</p></dd></dl></div><p>return 0 - indicates success</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2865399"></a>LSA Lookup Names</h3></div></div><p><span class="emphasis"><em>Note: num_entries in response must be same as num_entries in request.</em></span></p><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2865413"></a>Request</h4></div></div><div class="variablelist"><dl><dt><span class="term">POL_HND</span></dt><dd><p>LSA policy handle</p></dd><dt><span class="term">UINT32</span></dt><dd><p>num_entries</p></dd><dt><span class="term">UINT32</span></dt><dd><p>num_entries</p></dd><dt><span class="term">VOID*</span></dt><dd><p>undocumented domain SID buffer pointer</p></dd><dt><span class="term">VOID*</span></dt><dd><p>undocumented domain name buffer pointer</p></dd><dt><span class="term">NAME[num_entries]</span></dt><dd><p>names to be looked up.</p></dd><dt><span class="term">char[]</span></dt><dd><p>undocumented bytes - falsely translated SID structure?</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2865527"></a>Response</h4></div></div><div class="variablelist"><dl><dt><span class="term">DOM_REF</span></dt><dd><p>domain reference response</p></dd><dt><span class="term">UINT32</span></dt><dd><p>num_entries (listed above)</p></dd><dt><span class="term">VOID*</span></dt><dd><p>undocumented buffer pointer</p></dd><dt><span class="term">UINT32</span></dt><dd><p>num_entries (listed above)</p></dd><dt><span class="term">DOM_RID[num_entries]</span></dt><dd><p>domain SIDs (from Request, listed above).</p></dd><dt><span class="term">UINT32</span></dt><dd><p>num_entries (listed above)</p></dd></dl></div><p>return 0 - indicates success</p></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2865625"></a>NETLOGON rpc Transact Named Pipe</h2></div></div><p>The sequence of actions taken on this pipe are:</p><table class="simplelist" border="0" summary="Simple list"><tr><td>tablish a connection to the IPC$ share (SMBtconX). use encrypted passwords.</td></tr><tr><td>en an RPC Pipe with the name "\\PIPE\\NETLOGON". Store the file handle.</td></tr><tr><td>ing the file handle, send a Set Named Pipe Handle state to 0x4300.</td></tr><tr><td>eate Client Challenge. Send LSA Request Challenge. Store Server Challenge.</td></tr><tr><td>lculate Session Key. Send an LSA Auth 2 Challenge. Store Auth2 Challenge.</td></tr><tr><td>lc/Verify Client Creds. Send LSA Srv PW Set. Calc/Verify Server Creds.</td></tr><tr><td>lc/Verify Client Creds. Send LSA SAM Logon . Calc/Verify Server Creds.</td></tr><tr><td>lc/Verify Client Creds. Send LSA SAM Logoff. Calc/Verify Server Creds.</td></tr><tr><td>ose the IPC$ share.</td></tr></table><p>Defines for this pipe, identifying the query are</p><div class="variablelist"><dl><dt><span class="term">LSA Request Challenge:</span></dt><dd><p>0x04</p></dd><dt><span class="term">LSA Server Password Set:</span></dt><dd><p>0x06</p></dd><dt><span class="term">LSA SAM Logon:</span></dt><dd><p>0x02</p></dd><dt><span class="term">LSA SAM Logoff:</span></dt><dd><p>0x03</p></dd><dt><span class="term">LSA Auth 2:</span></dt><dd><p>0x0f</p></dd><dt><span class="term">LSA Logon Control:</span></dt><dd><p>0x0e</p></dd></dl></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2865786"></a>LSA Request Challenge</h3></div></div><p><span class="emphasis"><em>Note: logon server name starts with two '\' characters and is upper case.</em></span></p><p><span class="emphasis"><em>Note: logon client is the machine, not the user.</em></span></p><p><span class="emphasis"><em>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).</em></span></p><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2865818"></a>Request</h4></div></div><div class="variablelist"><dl><dt><span class="term">VOID*</span></dt><dd><p>undocumented buffer pointer</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>logon server unicode string</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>logon client unicode string</p></dd><dt><span class="term">char[8]</span></dt><dd><p>client challenge</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2865888"></a>Response</h4></div></div><div class="variablelist"><dl><dt><span class="term">char[8]</span></dt><dd><p>server challenge</p></dd></dl></div><p>return 0 - indicates success</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2865921"></a>LSA Authenticate 2</h3></div></div><p><span class="emphasis"><em>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).</em></span></p><p><span class="emphasis"><em>Note: neg_flags in the response is the same as that in the request.</em></span></p><p><span class="emphasis"><em>Note: you must take a copy of the client-calculated credentials received here, because they will be used in subsequent authentication packets.</em></span></p><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2865952"></a>Request</h4></div></div><div class="variablelist"><dl><dt><span class="term">LOG_INFO</span></dt><dd><p>client identification info</p></dd><dt><span class="term">char[8]</span></dt><dd><p>client-calculated credentials</p></dd><dt><span class="term">UINT8[]</span></dt><dd><p>padding to 4-byte align with start of SMB header.</p></dd><dt><span class="term">UINT32</span></dt><dd><p>neg_flags - negotiated flags (usual value is 0x0000 01ff)</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2866021"></a>Response</h4></div></div><div class="variablelist"><dl><dt><span class="term">char[8]</span></dt><dd><p>server credentials.</p></dd><dt><span class="term">UINT32</span></dt><dd><p>neg_flags - same as neg_flags in request.</p></dd></dl></div><p>return 0 - indicates success. failure value unknown.</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2866069"></a>LSA Server Password Set</h3></div></div><p><span class="emphasis"><em>Note: the new password is suspected to be a DES encryption using the old password to generate the key.</em></span></p><p><span class="emphasis"><em>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).</em></span></p><p><span class="emphasis"><em>Note: the server credentials are constructed from the client-calculated credentials and the client time + 1 second.</em></span></p><p><span class="emphasis"><em>Note: you must take a copy of the client-calculated credentials received here, because they will be used in subsequent authentication packets.</em></span></p><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2866109"></a>Request</h4></div></div><div class="variablelist"><dl><dt><span class="term">CLNT_INFO</span></dt><dd><p>client identification/authentication info</p></dd><dt><span class="term">char[]</span></dt><dd><p>new password - undocumented.</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2866151"></a>Response</h4></div></div><div class="variablelist"><dl><dt><span class="term">CREDS</span></dt><dd><p>server credentials. server time stamp appears to be ignored.</p></dd></dl></div><p>return 0 - indicates success; 0xC000 006a indicates failure</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2866185"></a>LSA SAM Logon</h3></div></div><p><span class="emphasis"><em> +Note: valid_user is True iff the username and password hash are valid for + the requested domain. +</em></span></p><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2866200"></a>Request</h4></div></div><div class="variablelist"><dl><dt><span class="term">SAM_INFO</span></dt><dd><p>sam_id structure</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2866227"></a>Response</h4></div></div><div class="variablelist"><dl><dt><span class="term">VOID*</span></dt><dd><p>undocumented buffer pointer</p></dd><dt><span class="term">CREDS</span></dt><dd><p>server credentials. server time stamp appears to be ignored.</p></dd></dl></div><pre class="programlisting"> +if (valid_user) { UINT16 3 - switch value indicating USER_INFO structure. VOID* non-zero - pointer to USER_INFO structure @@ -6981,1340 +1298,117 @@ else UINT32 1 - Authoritative response; 0 - Non-Auth? return 0xC000 0064 - NT_STATUS_NO_SUCH_USER. -}</PRE -></P -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2359" ->9.4.5. LSA SAM Logoff</A -></H3 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: presumably, the SAM_INFO structure is validated, and a (currently - undocumented) error code returned if the Logoff is invalid.</I -></SPAN -></P -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2363" ->9.4.5.1. Request</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->SAM_INFO</DT -><DD -><P ->sam_id structure</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2370" ->9.4.5.2. Response</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->VOID*</DT -><DD -><P ->undocumented buffer pointer</P -></DD -><DT ->CREDS</DT -><DD -><P ->server credentials. server time stamp appears to be ignored.</P -></DD -></DL -></DIV -><P ->return 0 - indicates success. undocumented failure indication.</P -></DIV -></DIV -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN2382" ->9.5. \\MAILSLOT\NET\NTLOGON</A -></H2 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->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.</I -></SPAN -></P -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2386" ->9.5.1. Query for PDC</A -></H3 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: NTversion, LMNTtoken, LM20token in response are the same as those given in the request.</I -></SPAN -></P -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2390" ->9.5.1.1. Request</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT16</DT -><DD -><P ->0x0007 - Query for PDC</P -></DD -><DT ->STR</DT -><DD -><P ->machine name</P -></DD -><DT ->STR</DT -><DD -><P ->response mailslot</P -></DD -><DT ->UINT8[]</DT -><DD -><P ->padding to 2-byte align with start of mailslot.</P -></DD -><DT ->UNISTR</DT -><DD -><P ->machine name</P -></DD -><DT ->UINT32</DT -><DD -><P ->NTversion</P -></DD -><DT ->UINT16</DT -><DD -><P ->LMNTtoken</P -></DD -><DT ->UINT16</DT -><DD -><P ->LM20token</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2425" ->9.5.1.2. Response</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT16</DT -><DD -><P ->0x000A - Respose to Query for PDC</P -></DD -><DT ->STR</DT -><DD -><P ->machine name (in uppercase)</P -></DD -><DT ->UINT8[]</DT -><DD -><P ->padding to 2-byte align with start of mailslot.</P -></DD -><DT ->UNISTR</DT -><DD -><P ->machine name</P -></DD -><DT ->UNISTR</DT -><DD -><P ->domain name</P -></DD -><DT ->UINT32</DT -><DD -><P ->NTversion (same as received in request)</P -></DD -><DT ->UINT16</DT -><DD -><P ->LMNTtoken (same as received in request)</P -></DD -><DT ->UINT16</DT -><DD -><P ->LM20token (same as received in request)</P -></DD -></DL -></DIV -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2460" ->9.5.2. SAM Logon</A -></H3 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: machine name in response is preceded by two '\' characters.</I -></SPAN -></P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: NTversion, LMNTtoken, LM20token in response are the same as those given in the request.</I -></SPAN -></P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: user name in the response is presumably the same as that in the request.</I -></SPAN -></P -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2468" ->9.5.2.1. Request</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT16</DT -><DD -><P ->0x0012 - SAM Logon</P -></DD -><DT ->UINT16</DT -><DD -><P ->request count</P -></DD -><DT ->UNISTR</DT -><DD -><P ->machine name</P -></DD -><DT ->UNISTR</DT -><DD -><P ->user name</P -></DD -><DT ->STR</DT -><DD -><P ->response mailslot</P -></DD -><DT ->UINT32</DT -><DD -><P ->alloweable account</P -></DD -><DT ->UINT32</DT -><DD -><P ->domain SID size</P -></DD -><DT ->char[sid_size]</DT -><DD -><P ->domain SID, of sid_size bytes.</P -></DD -><DT ->UINT8[]</DT -><DD -><P ->???? padding to 4? 2? -byte align with start of mailslot.</P -></DD -><DT ->UINT32</DT -><DD -><P ->NTversion</P -></DD -><DT ->UINT16</DT -><DD -><P ->LMNTtoken</P -></DD -><DT ->UINT16</DT -><DD -><P ->LM20token</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2519" ->9.5.2.2. Response</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT16</DT -><DD -><P ->0x0013 - Response to SAM Logon</P -></DD -><DT ->UNISTR</DT -><DD -><P ->machine name</P -></DD -><DT ->UNISTR</DT -><DD -><P ->user name - workstation trust account</P -></DD -><DT ->UNISTR</DT -><DD -><P ->domain name </P -></DD -><DT ->UINT32</DT -><DD -><P ->NTversion</P -></DD -><DT ->UINT16</DT -><DD -><P ->LMNTtoken</P -></DD -><DT ->UINT16</DT -><DD -><P ->LM20token</P -></DD -></DL -></DIV -></DIV -></DIV -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN2550" ->9.6. SRVSVC Transact Named Pipe</A -></H2 -><P ->Defines for this pipe, identifying the query are:</P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->Net Share Enum</DT -><DD -><P ->0x0f</P -></DD -><DT ->Net Server Get Info</DT -><DD -><P ->0x15</P -></DD -></DL -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2562" ->9.6.1. Net Share Enum</A -></H3 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: share level and switch value in the response are presumably the same as those in the request.</I -></SPAN -></P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: cifsrap2.txt (section 5) may be of limited assistance here.</I -></SPAN -></P -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2568" ->9.6.1.1. Request</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->VOID*</DT -><DD -><P ->pointer (to server name?)</P -></DD -><DT ->UNISTR2</DT -><DD -><P ->server name</P -></DD -><DT ->UINT8[]</DT -><DD -><P ->padding to get unicode string 4-byte aligned with the start of the SMB header.</P -></DD -><DT ->UINT32</DT -><DD -><P ->share level</P -></DD -><DT ->UINT32</DT -><DD -><P ->switch value</P -></DD -><DT ->VOID*</DT -><DD -><P ->pointer to SHARE_INFO_1_CTR</P -></DD -><DT ->SHARE_INFO_1_CTR</DT -><DD -><P ->share info with 0 entries</P -></DD -><DT ->UINT32</DT -><DD -><P ->preferred maximum length (0xffff ffff)</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2603" ->9.6.1.2. Response</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT32</DT -><DD -><P ->share level</P -></DD -><DT ->UINT32</DT -><DD -><P ->switch value</P -></DD -><DT ->VOID*</DT -><DD -><P ->pointer to SHARE_INFO_1_CTR</P -></DD -><DT ->SHARE_INFO_1_CTR</DT -><DD -><P ->share info (only added if share info ptr is non-zero)</P -></DD -></DL -></DIV -><P ->return 0 - indicates success</P -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2623" ->9.6.2. Net Server Get Info</A -></H3 -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note: level is the same value as in the request.</I -></SPAN -></P -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2627" ->9.6.2.1. Request</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UNISTR2</DT -><DD -><P ->server name</P -></DD -><DT ->UINT32</DT -><DD -><P ->switch level</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2638" ->9.6.2.2. Response</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->UINT32</DT -><DD -><P ->switch level</P -></DD -><DT ->VOID*</DT -><DD -><P ->pointer to SERVER_INFO_101</P -></DD -><DT ->SERVER_INFO_101</DT -><DD -><P ->server info (only added if server info ptr is non-zero)</P -></DD -></DL -></DIV -><P ->return 0 - indicates success</P -></DIV -></DIV -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN2654" ->9.7. Cryptographic side of NT Domain Authentication</A -></H2 -><DIV -CLASS="SECT2" -><H3 -CLASS="SECT2" -><A -NAME="AEN2656" ->9.7.1. Definitions</A -></H3 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->Add(A1,A2)</DT -><DD -><P ->Intel byte ordered addition of corresponding 4 byte words in arrays A1 and A2</P -></DD -><DT ->E(K,D)</DT -><DD -><P ->DES ECB encryption of 8 byte data D using 7 byte key K</P -></DD -><DT ->lmowf()</DT -><DD -><P ->Lan man hash</P -></DD -><DT ->ntowf()</DT -><DD -><P ->NT hash</P -></DD -><DT ->PW</DT -><DD -><P ->md4(machine_password) == md4(lsadump $machine.acc) == -pwdump(machine$) (initially) == md4(lmowf(unicode(machine)))</P -></DD -><DT ->ARC4(K,Lk,D,Ld)</DT -><DD -><P ->ARC4 encryption of data D of length Ld with key K of length Lk</P -></DD -><DT ->v[m..n(,l)]</DT -><DD -><P ->subset of v from bytes m to n, optionally padded with zeroes to length l</P -></DD -><DT ->Cred(K,D)</DT -><DD -><P ->E(K[7..7,7],E(K[0..6],D)) computes a credential</P -></DD -><DT ->Time()</DT -><DD -><P ->4 byte current time</P -></DD -><DT ->Cc,Cs</DT -><DD -><P ->8 byte client and server challenges Rc,Rs: 8 byte client and server credentials</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2699" ->9.7.2. Protocol</A -></H3 -><PRE -CLASS="PROGRAMLISTING" ->C->S ReqChal,Cc -S->C Cs</PRE -><PRE -CLASS="PROGRAMLISTING" ->C & S compute session key Ks = E(PW[9..15],E(PW[0..6],Add(Cc,Cs)))</PRE -><PRE -CLASS="PROGRAMLISTING" ->C: Rc = Cred(Ks,Cc) -C->S Authenticate,Rc +} +</pre></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2866299"></a>LSA SAM Logoff</h3></div></div><p><span class="emphasis"><em> +Note: presumably, the SAM_INFO structure is validated, and a (currently + undocumented) error code returned if the Logoff is invalid. +</em></span></p><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2866314"></a>Request</h4></div></div><div class="variablelist"><dl><dt><span class="term">SAM_INFO</span></dt><dd><p>sam_id structure</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2866341"></a>Response</h4></div></div><div class="variablelist"><dl><dt><span class="term">VOID*</span></dt><dd><p>undocumented buffer pointer</p></dd><dt><span class="term">CREDS</span></dt><dd><p>server credentials. server time stamp appears to be ignored.</p></dd></dl></div><p>return 0 - indicates success. undocumented failure indication.</p></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2866391"></a>\\MAILSLOT\NET\NTLOGON</h2></div></div><p><span class="emphasis"><em> +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. +</em></span></p><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2866408"></a>Query for PDC</h3></div></div><p><span class="emphasis"><em>Note: NTversion, LMNTtoken, LM20token in response are the same as those given in the request.</em></span></p><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2866422"></a>Request</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT16</span></dt><dd><p>0x0007 - Query for PDC</p></dd><dt><span class="term">STR</span></dt><dd><p>machine name</p></dd><dt><span class="term">STR</span></dt><dd><p>response mailslot</p></dd><dt><span class="term">UINT8[]</span></dt><dd><p>padding to 2-byte align with start of mailslot.</p></dd><dt><span class="term">UNISTR</span></dt><dd><p>machine name</p></dd><dt><span class="term">UINT32</span></dt><dd><p>NTversion</p></dd><dt><span class="term">UINT16</span></dt><dd><p>LMNTtoken</p></dd><dt><span class="term">UINT16</span></dt><dd><p>LM20token</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2866549"></a>Response</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT16</span></dt><dd><p>0x000A - Respose to Query for PDC</p></dd><dt><span class="term">STR</span></dt><dd><p>machine name (in uppercase)</p></dd><dt><span class="term">UINT8[]</span></dt><dd><p>padding to 2-byte align with start of mailslot.</p></dd><dt><span class="term">UNISTR</span></dt><dd><p>machine name</p></dd><dt><span class="term">UNISTR</span></dt><dd><p>domain name</p></dd><dt><span class="term">UINT32</span></dt><dd><p>NTversion (same as received in request)</p></dd><dt><span class="term">UINT16</span></dt><dd><p>LMNTtoken (same as received in request)</p></dd><dt><span class="term">UINT16</span></dt><dd><p>LM20token (same as received in request)</p></dd></dl></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2866670"></a>SAM Logon</h3></div></div><p><span class="emphasis"><em>Note: machine name in response is preceded by two '\' characters.</em></span></p><p><span class="emphasis"><em>Note: NTversion, LMNTtoken, LM20token in response are the same as those given in the request.</em></span></p><p><span class="emphasis"><em>Note: user name in the response is presumably the same as that in the request.</em></span></p><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2866698"></a>Request</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT16</span></dt><dd><p>0x0012 - SAM Logon</p></dd><dt><span class="term">UINT16</span></dt><dd><p>request count</p></dd><dt><span class="term">UNISTR</span></dt><dd><p>machine name</p></dd><dt><span class="term">UNISTR</span></dt><dd><p>user name</p></dd><dt><span class="term">STR</span></dt><dd><p>response mailslot</p></dd><dt><span class="term">UINT32</span></dt><dd><p>alloweable account</p></dd><dt><span class="term">UINT32</span></dt><dd><p>domain SID size</p></dd><dt><span class="term">char[sid_size]</span></dt><dd><p>domain SID, of sid_size bytes.</p></dd><dt><span class="term">UINT8[]</span></dt><dd><p>???? padding to 4? 2? -byte align with start of mailslot.</p></dd><dt><span class="term">UINT32</span></dt><dd><p>NTversion</p></dd><dt><span class="term">UINT16</span></dt><dd><p>LMNTtoken</p></dd><dt><span class="term">UINT16</span></dt><dd><p>LM20token</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2866881"></a>Response</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT16</span></dt><dd><p>0x0013 - Response to SAM Logon</p></dd><dt><span class="term">UNISTR</span></dt><dd><p>machine name</p></dd><dt><span class="term">UNISTR</span></dt><dd><p>user name - workstation trust account</p></dd><dt><span class="term">UNISTR</span></dt><dd><p>domain name </p></dd><dt><span class="term">UINT32</span></dt><dd><p>NTversion</p></dd><dt><span class="term">UINT16</span></dt><dd><p>LMNTtoken</p></dd><dt><span class="term">UINT16</span></dt><dd><p>LM20token</p></dd></dl></div></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2866996"></a>SRVSVC Transact Named Pipe</h2></div></div><p>Defines for this pipe, identifying the query are:</p><div class="variablelist"><dl><dt><span class="term">Net Share Enum</span></dt><dd><p>0x0f</p></dd><dt><span class="term">Net Server Get Info</span></dt><dd><p>0x15</p></dd></dl></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2867041"></a>Net Share Enum</h3></div></div><p><span class="emphasis"><em>Note: share level and switch value in the response are presumably the same as those in the request.</em></span></p><p><span class="emphasis"><em>Note: cifsrap2.txt (section 5) may be of limited assistance here.</em></span></p><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2867062"></a>Request</h4></div></div><div class="variablelist"><dl><dt><span class="term">VOID*</span></dt><dd><p>pointer (to server name?)</p></dd><dt><span class="term">UNISTR2</span></dt><dd><p>server name</p></dd><dt><span class="term">UINT8[]</span></dt><dd><p>padding to get unicode string 4-byte aligned with the start of the SMB header.</p></dd><dt><span class="term">UINT32</span></dt><dd><p>share level</p></dd><dt><span class="term">UINT32</span></dt><dd><p>switch value</p></dd><dt><span class="term">VOID*</span></dt><dd><p>pointer to SHARE_INFO_1_CTR</p></dd><dt><span class="term">SHARE_INFO_1_CTR</span></dt><dd><p>share info with 0 entries</p></dd><dt><span class="term">UINT32</span></dt><dd><p>preferred maximum length (0xffff ffff)</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2867188"></a>Response</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT32</span></dt><dd><p>share level</p></dd><dt><span class="term">UINT32</span></dt><dd><p>switch value</p></dd><dt><span class="term">VOID*</span></dt><dd><p>pointer to SHARE_INFO_1_CTR</p></dd><dt><span class="term">SHARE_INFO_1_CTR</span></dt><dd><p>share info (only added if share info ptr is non-zero)</p></dd></dl></div><p>return 0 - indicates success</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2867261"></a>Net Server Get Info</h3></div></div><p><span class="emphasis"><em>Note: level is the same value as in the request.</em></span></p><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2867275"></a>Request</h4></div></div><div class="variablelist"><dl><dt><span class="term">UNISTR2</span></dt><dd><p>server name</p></dd><dt><span class="term">UINT32</span></dt><dd><p>switch level</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2867316"></a>Response</h4></div></div><div class="variablelist"><dl><dt><span class="term">UINT32</span></dt><dd><p>switch level</p></dd><dt><span class="term">VOID*</span></dt><dd><p>pointer to SERVER_INFO_101</p></dd><dt><span class="term">SERVER_INFO_101</span></dt><dd><p>server info (only added if server info ptr is non-zero)</p></dd></dl></div><p>return 0 - indicates success</p></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2867378"></a>Cryptographic side of NT Domain Authentication</h2></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2867386"></a>Definitions</h3></div></div><div class="variablelist"><dl><dt><span class="term">Add(A1,A2)</span></dt><dd><p>Intel byte ordered addition of corresponding 4 byte words in arrays A1 and A2</p></dd><dt><span class="term">E(K,D)</span></dt><dd><p>DES ECB encryption of 8 byte data D using 7 byte key K</p></dd><dt><span class="term">lmowf()</span></dt><dd><p>Lan man hash</p></dd><dt><span class="term">ntowf()</span></dt><dd><p>NT hash</p></dd><dt><span class="term">PW</span></dt><dd><p>md4(machine_password) == md4(lsadump $machine.acc) == +pwdump(machine$) (initially) == md4(lmowf(unicode(machine))) +</p></dd><dt><span class="term">ARC4(K,Lk,D,Ld)</span></dt><dd><p>ARC4 encryption of data D of length Ld with key K of length Lk</p></dd><dt><span class="term">v[m..n(,l)]</span></dt><dd><p>subset of v from bytes m to n, optionally padded with zeroes to length l</p></dd><dt><span class="term">Cred(K,D)</span></dt><dd><p>E(K[7..7,7],E(K[0..6],D)) computes a credential</p></dd><dt><span class="term">Time()</span></dt><dd><p>4 byte current time</p></dd><dt><span class="term">Cc,Cs</span></dt><dd><p>8 byte client and server challenges Rc,Rs: 8 byte client and server credentials</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2867548"></a>Protocol</h3></div></div><pre class="programlisting"> +C->S ReqChal,Cc +S->C Cs +</pre><pre class="programlisting"> +C & S compute session key Ks = E(PW[9..15],E(PW[0..6],Add(Cc,Cs))) +</pre><pre class="programlisting"> +C: Rc = Cred(Ks,Cc) +C->S Authenticate,Rc S: Rs = Cred(Ks,Cs), assert(Rc == Cred(Ks,Cc)) -S->C Rs -C: assert(Rs == Cred(Ks,Cs))</PRE -><P ->On joining the domain the client will optionally attempt to change its +S->C Rs +C: assert(Rs == Cred(Ks,Cs)) +</pre><p> +On joining the domain the client will optionally attempt to change its password and the domain controller may refuse to update it depending -on registry settings. This will also occur weekly afterwards.</P -><PRE -CLASS="PROGRAMLISTING" ->C: Tc = Time(), Rc' = Cred(Ks,Rc+Tc) -C->S ServerPasswordSet,Rc',Tc,arc4(Ks[0..7,16],lmowf(randompassword()) +on registry settings. This will also occur weekly afterwards. +</p><pre class="programlisting"> +C: Tc = Time(), Rc' = Cred(Ks,Rc+Tc) +C->S ServerPasswordSet,Rc',Tc,arc4(Ks[0..7,16],lmowf(randompassword()) C: Rc = Cred(Ks,Rc+Tc+1) S: assert(Rc' == Cred(Ks,Rc+Tc)), Ts = Time() S: Rs' = Cred(Ks,Rs+Tc+1) -S->C Rs',Ts +S->C Rs',Ts C: assert(Rs' == Cred(Ks,Rs+Tc+1)) -S: Rs = Rs'</PRE -><P ->User: U with password P wishes to login to the domain (incidental data -such as workstation and domain omitted)</P -><PRE -CLASS="PROGRAMLISTING" ->C: Tc = Time(), Rc' = Cred(Ks,Rc+Tc) -C->S NetLogonSamLogon,Rc',Tc,U,arc4(Ks[0..7,16],16,ntowf(P),16), arc4(Ks[0..7,16],16,lmowf(P),16) +S: Rs = Rs' +</pre><p> +User: U with password P wishes to login to the domain (incidental data +such as workstation and domain omitted) +</p><pre class="programlisting"> +C: Tc = Time(), Rc' = Cred(Ks,Rc+Tc) +C->S NetLogonSamLogon,Rc',Tc,U,arc4(Ks[0..7,16],16,ntowf(P),16), arc4(Ks[0..7,16],16,lmowf(P),16) S: assert(Rc' == Cred(Ks,Rc+Tc)) assert(passwords match those in SAM) -S: Ts = Time()</PRE -><PRE -CLASS="PROGRAMLISTING" ->S->C Cred(Ks,Cred(Ks,Rc+Tc+1)),userinfo(logon script,UID,SIDs,etc) +S: Ts = Time() +</pre><pre class="programlisting"> +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)</PRE -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2709" ->9.7.3. Comments</A -></H3 -><P ->On first joining the domain the session key could be computed by +C: Rc = Cred(Ks,Rc+Tc+1) +</pre></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2867629"></a>Comments</h3></div></div><p> +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 key to encrypt NT and LM one way functions of passwords which are password equivalents. Any user who logs in before the machine has been rebooted a second time will have their password equivalent exposed. Of -course the new machine password is exposed at this time anyway.</P -><P ->None of the returned user info such as logon script, profile path and -SIDs *appear* to be protected by anything other than the TCP checksum.</P -><P ->The server time stamps appear to be ignored.</P -><P ->The client sends a ReturnAuthenticator in the SamLogon request which I +course the new machine password is exposed at this time anyway. +</p><p> +None of the returned user info such as logon script, profile path and +SIDs *appear* to be protected by anything other than the TCP checksum. +</p><p> +The server time stamps appear to be ignored. +</p><p> +The client sends a ReturnAuthenticator in the SamLogon request which I can't find a use for. However its time is used as the timestamp -returned by the server.</P -><P ->The password OWFs should NOT be sent over the network reversibly +returned by the server. +</p><p> +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.</P -></DIV -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN2716" ->9.8. SIDs and RIDs</A -></H2 -><P ->SIDs and RIDs are well documented elsewhere.</P -><P ->A SID is an NT Security ID (see DOM_SID structure). They are of the form:</P -><P -></P -><TABLE -BORDER="0" -><TBODY -><TR -><TD ->revision-NN-SubAuth1-SubAuth2-SubAuth3... </TD -></TR -><TR -><TD ->revision-0xNNNNNNNNNNNN-SubAuth1-SubAuth2-SubAuth3...</TD -></TR -></TBODY -></TABLE -><P -></P -><P ->currently, the SID revision is 1. -The Sub-Authorities are known as Relative IDs (RIDs).</P -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2724" ->9.8.1. Well-known SIDs</A -></H3 -><DIV -CLASS="SECT3" -><H4 -CLASS="SECT3" -><A -NAME="AEN2726" ->9.8.1.1. Universal well-known SIDs</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->Null SID</DT -><DD -><P ->S-1-0-0</P -></DD -><DT ->World</DT -><DD -><P ->S-1-1-0</P -></DD -><DT ->Local</DT -><DD -><P ->S-1-2-0</P -></DD -><DT ->Creator Owner ID</DT -><DD -><P ->S-1-3-0</P -></DD -><DT ->Creator Group ID</DT -><DD -><P ->S-1-3-1</P -></DD -><DT ->Creator Owner Server ID</DT -><DD -><P ->S-1-3-2</P -></DD -><DT ->Creator Group Server ID</DT -><DD -><P ->S-1-3-3</P -></DD -><DT ->(Non-unique IDs)</DT -><DD -><P ->S-1-4</P -></DD -></DL -></DIV -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2761" ->9.8.1.2. NT well-known SIDs</A -></H4 -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->NT Authority</DT -><DD -><P ->S-1-5</P -></DD -><DT ->Dialup</DT -><DD -><P ->S-1-5-1</P -></DD -><DT ->Network</DT -><DD -><P ->S-1-5-2</P -></DD -><DT ->Batch</DT -><DD -><P ->S-1-5-3</P -></DD -><DT ->Interactive</DT -><DD -><P ->S-1-5-4</P -></DD -><DT ->Service</DT -><DD -><P ->S-1-5-6</P -></DD -><DT ->AnonymousLogon(aka null logon session)</DT -><DD -><P ->S-1-5-7</P -></DD -><DT ->Proxy</DT -><DD -><P ->S-1-5-8</P -></DD -><DT ->ServerLogon(aka domain controller account)</DT -><DD -><P ->S-1-5-8</P -></DD -><DT ->(Logon IDs)</DT -><DD -><P ->S-1-5-5-X-Y</P -></DD -><DT ->(NT non-unique IDs)</DT -><DD -><P ->S-1-5-0x15-...</P -></DD -><DT ->(Built-in domain)</DT -><DD -><P ->s-1-5-0x20</P -></DD -></DL -></DIV -></DIV -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN2812" ->9.8.2. Well-known RIDS</A -></H3 -><P ->A RID is a sub-authority value, as part of either a SID, or in the case +computing the same function using the owf values in the SAM. +</p></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2867679"></a>SIDs and RIDs</h2></div></div><p> +SIDs and RIDs are well documented elsewhere. +</p><p> +A SID is an NT Security ID (see DOM_SID structure). They are of the form: +</p><table class="simplelist" border="0" summary="Simple list"><tr><td>revision-NN-SubAuth1-SubAuth2-SubAuth3... </td></tr><tr><td>revision-0xNNNNNNNNNNNN-SubAuth1-SubAuth2-SubAuth3...</td></tr></table><p> +currently, the SID revision is 1. +The Sub-Authorities are known as Relative IDs (RIDs). +</p><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2867719"></a>Well-known SIDs</h3></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2867726"></a>Universal well-known SIDs</h4></div></div><div class="variablelist"><dl><dt><span class="term">Null SID</span></dt><dd><p>S-1-0-0</p></dd><dt><span class="term">World</span></dt><dd><p>S-1-1-0</p></dd><dt><span class="term">Local</span></dt><dd><p>S-1-2-0</p></dd><dt><span class="term">Creator Owner ID</span></dt><dd><p>S-1-3-0</p></dd><dt><span class="term">Creator Group ID</span></dt><dd><p>S-1-3-1</p></dd><dt><span class="term">Creator Owner Server ID</span></dt><dd><p>S-1-3-2</p></dd><dt><span class="term">Creator Group Server ID</span></dt><dd><p>S-1-3-3</p></dd><dt><span class="term">(Non-unique IDs)</span></dt><dd><p>S-1-4</p></dd></dl></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2867852"></a>NT well-known SIDs</h4></div></div><div class="variablelist"><dl><dt><span class="term">NT Authority</span></dt><dd><p>S-1-5</p></dd><dt><span class="term">Dialup</span></dt><dd><p>S-1-5-1</p></dd><dt><span class="term">Network</span></dt><dd><p>S-1-5-2</p></dd><dt><span class="term">Batch</span></dt><dd><p>S-1-5-3</p></dd><dt><span class="term">Interactive</span></dt><dd><p>S-1-5-4</p></dd><dt><span class="term">Service</span></dt><dd><p>S-1-5-6</p></dd><dt><span class="term">AnonymousLogon(aka null logon session)</span></dt><dd><p>S-1-5-7</p></dd><dt><span class="term">Proxy</span></dt><dd><p>S-1-5-8</p></dd><dt><span class="term">ServerLogon(aka domain controller account)</span></dt><dd><p>S-1-5-8</p></dd><dt><span class="term">(Logon IDs)</span></dt><dd><p>S-1-5-5-X-Y</p></dd><dt><span class="term">(NT non-unique IDs)</span></dt><dd><p>S-1-5-0x15-...</p></dd><dt><span class="term">(Built-in domain)</span></dt><dd><p>s-1-5-0x20</p></dd></dl></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2868034"></a>Well-known RIDS</h3></div></div><p> +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.</P -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2815" ->9.8.2.1. Well-known RID users</A -></H4 -><P -><B ->Groupname: </B ->DOMAIN_USER_RID_ADMIN</P -><P -><B ->????: </B ->0x0000</P -><P -><B ->RID: </B ->01F4</P -><P -><B ->Groupname: </B ->DOMAIN_USER_RID_GUEST</P -><P -><B ->????: </B ->0x0000</P -><P -><B ->RID: </B ->01F5</P -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2829" ->9.8.2.2. Well-known RID groups</A -></H4 -><P -><B ->Groupname: </B -> DOMAIN_GROUP_RID_ADMINS</P -><P -><B ->????: </B ->0x0000</P -><P -><B ->RID: </B ->0200</P -><P -><B ->Groupname: </B -> DOMAIN_GROUP_RID_USERS</P -><P -><B ->????: </B ->0x0000</P -><P -><B ->RID: </B ->0201</P -><P -><B ->Groupname: </B -> DOMAIN_GROUP_RID_GUESTS</P -><P -><B ->????: </B ->0x0000</P -><P -><B ->RID: </B ->0202</P -></DIV -><DIV -CLASS="SECT3" -><HR><H4 -CLASS="SECT3" -><A -NAME="AEN2847" ->9.8.2.3. Well-known RID aliases</A -></H4 -><P -><B ->Groupname: </B -> DOMAIN_ALIAS_RID_ADMINS</P -><P -><B ->????: </B ->0x0000</P -><P -><B ->RID: </B ->0220</P -><P -><B ->Groupname: </B -> DOMAIN_ALIAS_RID_USERS</P -><P -><B ->????: </B ->0x0000</P -><P -><B ->RID: </B ->0221</P -><P -><B ->Groupname: </B -> DOMAIN_ALIAS_RID_GUESTS</P -><P -><B ->????: </B ->0x0000</P -><P -><B ->RID: </B ->0222</P -><P -><B ->Groupname: </B -> DOMAIN_ALIAS_RID_POWER_USERS</P -><P -><B ->????: </B ->0x0000</P -><P -><B ->RID: </B ->0223</P -><P -><B ->Groupname: </B -> DOMAIN_ALIAS_RID_ACCOUNT_OPS</P -><P -><B ->????: </B ->0x0000</P -><P -><B ->RID: </B ->0224</P -><P -><B ->Groupname: </B -> DOMAIN_ALIAS_RID_SYSTEM_OPS</P -><P -><B ->????: </B ->0x0000</P -><P -><B ->RID: </B ->0225</P -><P -><B ->Groupname: </B -> DOMAIN_ALIAS_RID_PRINT_OPS</P -><P -><B ->????: </B ->0x0000</P -><P -><B ->RID: </B ->0226</P -><P -><B ->Groupname: </B -> DOMAIN_ALIAS_RID_BACKUP_OPS</P -><P -><B ->????: </B ->0x0000</P -><P -><B ->RID: </B ->0227</P -><P -><B ->Groupname: </B -> DOMAIN_ALIAS_RID_REPLICATOR</P -><P -><B ->????: </B ->0x0000</P -><P -><B ->RID: </B ->0228</P -></DIV -></DIV -></DIV -></DIV -><DIV -CLASS="CHAPTER" -><HR><H1 -><A -NAME="PRINTING" -></A ->Chapter 10. Samba Printing Internals</H1 -><DIV -CLASS="SECT1" -><H2 -CLASS="SECT1" -><A -NAME="AEN2896" ->10.1. Abstract</A -></H2 -><P ->The purpose of this document is to provide some insight into +structure, in the LSA SAM Logon response. +</p><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2868049"></a>Well-known RID users</h4></div></div><div class="segmentedlist"><p><b>Groupname: </b>DOMAIN_USER_RID_ADMIN</p><p><b>????: </b>0x0000</p><p><b>RID: </b>01F4</p><p><b>Groupname: </b>DOMAIN_USER_RID_GUEST</p><p><b>????: </b>0x0000</p><p><b>RID: </b>01F5</p></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2868097"></a>Well-known RID groups</h4></div></div><div class="segmentedlist"><p><b>Groupname: </b> DOMAIN_GROUP_RID_ADMINS</p><p><b>????: </b>0x0000</p><p><b>RID: </b>0200</p><p><b>Groupname: </b> DOMAIN_GROUP_RID_USERS</p><p><b>????: </b>0x0000</p><p><b>RID: </b>0201</p><p><b>Groupname: </b> DOMAIN_GROUP_RID_GUESTS</p><p><b>????: </b>0x0000</p><p><b>RID: </b>0202</p></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2868157"></a>Well-known RID aliases</h4></div></div><div class="segmentedlist"><p><b>Groupname: </b> DOMAIN_ALIAS_RID_ADMINS</p><p><b>????: </b>0x0000</p><p><b>RID: </b>0220</p><p><b>Groupname: </b> DOMAIN_ALIAS_RID_USERS</p><p><b>????: </b>0x0000</p><p><b>RID: </b>0221</p><p><b>Groupname: </b> DOMAIN_ALIAS_RID_GUESTS</p><p><b>????: </b>0x0000</p><p><b>RID: </b>0222</p><p><b>Groupname: </b> DOMAIN_ALIAS_RID_POWER_USERS</p><p><b>????: </b>0x0000</p><p><b>RID: </b>0223</p><p><b>Groupname: </b> DOMAIN_ALIAS_RID_ACCOUNT_OPS</p><p><b>????: </b>0x0000</p><p><b>RID: </b>0224</p><p><b>Groupname: </b> DOMAIN_ALIAS_RID_SYSTEM_OPS</p><p><b>????: </b>0x0000</p><p><b>RID: </b>0225</p><p><b>Groupname: </b> DOMAIN_ALIAS_RID_PRINT_OPS</p><p><b>????: </b>0x0000</p><p><b>RID: </b>0226</p><p><b>Groupname: </b> DOMAIN_ALIAS_RID_BACKUP_OPS</p><p><b>????: </b>0x0000</p><p><b>RID: </b>0227</p><p><b>Groupname: </b> DOMAIN_ALIAS_RID_REPLICATOR</p><p><b>????: </b>0x0000</p><p><b>RID: </b>0228</p></div></div></div></div></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="printing"></a>Chapter 10. Samba Printing Internals</h2></div><div><div class="author"><h3 class="author">Gerald Carter</h3></div></div><div><p class="pubdate">October 2002</p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#id2859754">Abstract</a></dt><dt><a href="#id2859770"> +Printing Interface to Various Back ends +</a></dt><dt><a href="#id2859712"> +Print Queue TDB's +</a></dt><dt><a href="#id2868639"> +ChangeID and Client Caching of Printer Information +</a></dt><dt><a href="#id2868653"> +Windows NT/2K Printer Change Notify +</a></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2859754"></a>Abstract</h2></div></div><p> +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.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN2899" ->10.2. Printing Interface to Various Back ends</A -></H2 -><P ->Samba uses a table of function pointers to seven functions. The -function prototypes are defined in the <VAR -CLASS="VARNAME" ->printif</VAR -> structure declared -in <TT -CLASS="FILENAME" ->printing.h</TT ->.</P -><P -></P -><UL -><LI -><P ->retrieve the contents of a print queue</P -></LI -><LI -><P ->pause the print queue</P -></LI -><LI -><P ->resume a paused print queue</P -></LI -><LI -><P ->delete a job from the queue</P -></LI -><LI -><P ->pause a job in the print queue</P -></LI -><LI -><P ->result a paused print job in the queue</P -></LI -><LI -><P ->submit a job to the print queue</P -></LI -></UL -><P ->Currently there are only two printing back end implementations -defined.</P -><P -></P -><UL -><LI -><P ->a generic set of functions for working with standard UNIX - printing subsystems</P -></LI -><LI -><P ->a set of CUPS specific functions (this is only enabled if - the CUPS libraries were located at compile time).</P -></LI -></UL -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN2925" ->10.3. Print Queue TDB's</A -></H2 -><P ->Samba provides periodic caching of the output from the "lpq command" +of certain features of Windows client printing. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2859770"></a> +Printing Interface to Various Back ends +</h2></div></div><p> +Samba uses a table of function pointers to seven functions. The +function prototypes are defined in the <tt>printif</tt> structure declared +in <tt>printing.h</tt>. +</p><div class="itemizedlist"><ul type="disc"><li><p>retrieve the contents of a print queue</p></li><li><p>pause the print queue</p></li><li><p>resume a paused print queue</p></li><li><p>delete a job from the queue</p></li><li><p>pause a job in the print queue</p></li><li><p>result a paused print job in the queue</p></li><li><p>submit a job to the print queue</p></li></ul></div><p> +Currently there are only two printing back end implementations +defined. +</p><div class="itemizedlist"><ul type="disc"><li><p>a generic set of functions for working with standard UNIX + printing subsystems</p></li><li><p>a set of CUPS specific functions (this is only enabled if + the CUPS libraries were located at compile time).</p></li></ul></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2859712"></a> +Print Queue TDB's +</h2></div></div><p> +Samba provides periodic caching of the output from the "lpq command" for performance reasons. This cache time is configurable in seconds. Obviously the longer the cache time the less often smbd will be required to exec a copy of lpq. However, the accuracy of the print -queue contents displayed to clients will be diminished as well.</P -><P ->The list of currently opened print queue TDB's can be found +queue contents displayed to clients will be diminished as well. +</p><p> +The list of currently opened print queue TDB's can be found be examining the list of tdb_print_db structures ( see print_db_head in printing.c ). A queue TDB is opened using the wrapper function printing.c:get_print_db_byname(). The function ensures that smbd @@ -8322,17 +1416,15 @@ does not open more than MAX_PRINT_DBS_OPEN in an effort to prevent a large print server from exhausting all available file descriptors. If the number of open queue TDB's exceeds the MAX_PRINT_DBS_OPEN limit, smbd falls back to a most recently used algorithm for maintaining -a list of open TDB's.</P -><P ->There are two ways in which a a print job can be entered into +a list of open TDB's. +</p><p> +There are two ways in which a a print job can be entered into a print queue's TDB. The first is to submit the job from a Windows client which will insert the job information directly into the TDB. The second method is to have the print job picked up by executing the -"lpq command".</P -><P -><PRE -CLASS="PROGRAMLISTING" ->/* included from printing.h */ +"lpq command". +</p><pre class="programlisting"> +/* included from printing.h */ struct printjob { pid_t pid; /* which process launched the job */ int sysjob; /* the system (lp) job number */ @@ -8348,61 +1440,28 @@ struct printjob { fstring user; /* the user who started the job */ fstring queuename; /* service number of printer for this job */ NT_DEVICEMODE *nt_devmode; -};</PRE -></P -><P ->The current manifestation of the printjob structure contains a field -for the UNIX job id returned from the "lpq command" and a Windows job +}; +</pre><p> +The current manifestation of the printjob structure contains a field +for the UNIX job id returned from the "lpq command" and a Windows job ID (32-bit bounded by PRINT_MAX_JOBID). When a print job is returned -by the "lpq command" that does not match an existing job in the queue's -TDB, a 32-bit job ID above the <*vance doesn't know what word is missing here*> is generating by adding UNIX_JOB_START to -the id reported by lpq.</P -><P ->In order to match a 32-bit Windows jobid onto a 16-bit lanman print job +by the "lpq command" that does not match an existing job in the queue's +TDB, a 32-bit job ID above the <*vance doesn't know what word is missing here*> is generating by adding UNIX_JOB_START to +the id reported by lpq. +</p><p> +In order to match a 32-bit Windows jobid onto a 16-bit lanman print job id, smbd uses an in memory TDB to match the former to a number appropriate -for old lanman clients.</P -><P ->When updating a print queue, smbd will perform the following -steps ( refer to <TT -CLASS="FILENAME" ->print.c:print_queue_update()</TT -> ):</P -><P -></P -><OL -TYPE="1" -><LI -><P ->Check to see if another smbd is currently in +for old lanman clients. +</p><p> +When updating a print queue, smbd will perform the following +steps ( refer to <tt>print.c:print_queue_update()</tt> ): +</p><div class="orderedlist"><ol type="1"><li><p>Check to see if another smbd is currently in the process of updating the queue contents by checking the pid - stored in <CODE -CLASS="CONSTANT" ->LOCK/<VAR -CLASS="REPLACEABLE" ->printer_name</VAR -></CODE ->. - If so, then do not update the TDB.</P -></LI -><LI -><P ->Lock the mutex entry in the TDB and store our own pid. - Check that this succeeded, else fail.</P -></LI -><LI -><P ->Store the updated time stamp for the new cache - listing</P -></LI -><LI -><P ->Retrieve the queue listing via "lpq command"</P -></LI -><LI -><P -><PRE -CLASS="PROGRAMLISTING" -> foreach job in the queue + stored in <tt>LOCK/<i><tt>printer_name</tt></i></tt>. + If so, then do not update the TDB.</p></li><li><p>Lock the mutex entry in the TDB and store our own pid. + Check that this succeeded, else fail.</p></li><li><p>Store the updated time stamp for the new cache + listing</p></li><li><p>Retrieve the queue listing via "lpq command"</p></li><li><pre class="programlisting"> + foreach job in the queue { if the job is a UNIX job, create a new entry; if the job has a Windows based jobid, then @@ -8413,119 +1472,51 @@ CLASS="PROGRAMLISTING" else update the job status only } - }</PRE -></P -></LI -><LI -><P ->Delete any jobs in the TDB that are not - in the in the lpq listing</P -></LI -><LI -><P ->Store the print queue status in the TDB</P -></LI -><LI -><P ->update the cache time stamp again</P -></LI -></OL -><P ->Note that it is the contents of this TDB that is returned to Windows -clients and not the actual listing from the "lpq command".</P -><P ->The NT_DEVICEMODE stored as part of the printjob structure is used to + }</pre></li><li><p>Delete any jobs in the TDB that are not + in the in the lpq listing</p></li><li><p>Store the print queue status in the TDB</p></li><li><p>update the cache time stamp again</p></li></ol></div><p> +Note that it is the contents of this TDB that is returned to Windows +clients and not the actual listing from the "lpq command". +</p><p> +The NT_DEVICEMODE stored as part of the printjob structure is used to store a pointer to a non-default DeviceMode associated with the print job. The pointer will be non-null when the client included a Device Mode in the OpenPrinterEx() call and subsequently submitted a job for printing on that same handle. If the client did not include a Device Mode in the OpenPrinterEx() request, the nt_devmode field is NULL -and the job has the printer's device mode associated with it by default.</P -><P ->Only non-default Device Mode are stored with print jobs in the print +and the job has the printer's device mode associated with it by default. +</p><p> +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.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN2959" ->10.4. ChangeID and Client Caching of Printer Information</A -></H2 -><P ->[To be filled in later]</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN2962" ->10.5. Windows NT/2K Printer Change Notify</A -></H2 -><P ->When working with Windows NT+ clients, it is possible for a +object when the client issues a GetJob(level == 2) request. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2868639"></a> +ChangeID and Client Caching of Printer Information +</h2></div></div><p> +[To be filled in later] +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2868653"></a> +Windows NT/2K Printer Change Notify +</h2></div></div><p> +When working with Windows NT+ clients, it is possible for a print server to use RPC to send asynchronous change notification events to clients for certain printer and print job attributes. This can be useful when the client needs to know that a new job has been added to the queue for a given printer or that the driver for a printer has been changed. Note that this is done entirely orthogonal to cache updates based on a new ChangeID for -a printer object.</P -><P ->The basic set of RPC's used to implement change notification are</P -><P -></P -><UL -><LI -><P ->RemoteFindFirstPrinterChangeNotifyEx ( RFFPCN )</P -></LI -><LI -><P ->RemoteFindNextPrinterChangeNotifyEx ( RFNPCN )</P -></LI -><LI -><P ->FindClosePrinterChangeNotify( FCPCN )</P -></LI -><LI -><P ->ReplyOpenPrinter</P -></LI -><LI -><P ->ReplyClosePrinter</P -></LI -><LI -><P ->RouteRefreshPrinterChangeNotify ( RRPCN )</P -></LI -></UL -><P ->One additional RPC is available to a server, but is never used by the -Windows spooler service:</P -><P -></P -><UL -><LI -><P ->RouteReplyPrinter()</P -></LI -></UL -><P ->The opnum for all of these RPC's are defined in include/rpc_spoolss.h</P -><P ->Windows NT print servers use a bizarre method of sending print +a printer object. +</p><p> +The basic set of RPC's used to implement change notification are +</p><div class="itemizedlist"><ul type="disc"><li><p>RemoteFindFirstPrinterChangeNotifyEx ( RFFPCN )</p></li><li><p>RemoteFindNextPrinterChangeNotifyEx ( RFNPCN )</p></li><li><p>FindClosePrinterChangeNotify( FCPCN )</p></li><li><p>ReplyOpenPrinter</p></li><li><p>ReplyClosePrinter</p></li><li><p>RouteRefreshPrinterChangeNotify ( RRPCN )</p></li></ul></div><p> +One additional RPC is available to a server, but is never used by the +Windows spooler service: +</p><div class="itemizedlist"><ul type="disc"><li><p>RouteReplyPrinter()</p></li></ul></div><p> +The opnum for all of these RPC's are defined in include/rpc_spoolss.h +</p><p> +Windows NT print servers use a bizarre method of sending print notification event to clients. The process of registering a new change notification handle is as follows. The 'C' is for client and the -'S' is for server. All error conditions have been eliminated.</P -><P -><PRE -CLASS="PROGRAMLISTING" ->C: Obtain handle to printer or to the printer +'S' is for server. All error conditions have been eliminated. +</p><pre class="programlisting"> +C: Obtain handle to printer or to the printer server via the standard OpenPrinterEx() call. S: Respond with a valid handle to object @@ -8534,7 +1525,7 @@ C: Send a RFFPCN request with the previously obtained to monitor, or (b) a PRINTER_NOTIFY_OPTIONS structure containing the event information to monitor. The windows spooler has only been observed to use (b). -S: The <* another missing word*> opens a new TCP session to the client (thus requiring +S: The <* another missing word*> opens a new TCP session to the client (thus requiring all print clients to be CIFS servers as well) and sends a ReplyOpenPrinter() request to the client. C: The client responds with a printer handle that can be used to @@ -8555,452 +1546,229 @@ C: If the change notification handle is ever released by the or a piece of data was wrong. S: The server closes the internal change notification handle (POLICY_HND) and does not send any further change notification - events to the client for that printer or job.</PRE -></P -><P ->The current list of notification events supported by Samba can be -found by examining the internal tables in srv_spoolss_nt.c</P -><P -></P -><UL -><LI -><P ->printer_notify_table[]</P -></LI -><LI -><P ->job_notify_table[]</P -></LI -></UL -><P ->When an event occurs that could be monitored, smbd sends a message + events to the client for that printer or job. +</pre><p> +The current list of notification events supported by Samba can be +found by examining the internal tables in srv_spoolss_nt.c +</p><div class="itemizedlist"><ul type="disc"><li><p>printer_notify_table[]</p></li><li><p>job_notify_table[]</p></li></ul></div><p> +When an event occurs that could be monitored, smbd sends a message to itself about the change. The list of events to be transmitted are queued by the smbd process sending the message to prevent an overload of TDB usage and the internal message is sent during smbd's idle loop (refer to printing/notify.c and the functions -send_spoolss_notify2_msg() and print_notify_send_messages() ).</P -><P ->The decision of whether or not the change is to be sent to connected +send_spoolss_notify2_msg() and print_notify_send_messages() ). +</p><p> +The decision of whether or not the change is to be sent to connected clients is made by the routine which actually sends the notification. -( refer to srv_spoolss_nt.c:recieve_notify2_message() ).</P -><P ->Because it possible to receive a listing of multiple changes for +( refer to srv_spoolss_nt.c:recieve_notify2_message() ). +</p><p> +Because it possible to receive a listing of multiple changes for multiple printers, the notification events must be split into categories by the printer name. This makes it possible to group multiple change events to be sent in a single RPC according to the -printer handle obtained via a ReplyOpenPrinter().</P -><P ->The actual change notification is performed using the RRPCN request -RPC. This packet contains</P -><P -></P -><UL -><LI -><P ->the printer handle registered with the -client's spooler on which the change occurred</P -></LI -><LI -><P ->The change_low value which was sent as part -of the last RFNPCN request from the client</P -></LI -><LI -><P ->The SPOOL_NOTIFY_INFO container with the event -information</P -></LI -></UL -><P ->A <VAR -CLASS="VARNAME" ->SPOOL_NOTIFY_INFO</VAR -> contains:</P -><P -></P -><UL -><LI -><P ->the version and flags field are predefined -and should not be changed</P -></LI -><LI -><P ->The count field is the number of entries -in the SPOOL_NOTIFY_INFO_DATA array</P -></LI -></UL -><P ->The <VAR -CLASS="VARNAME" ->SPOOL_NOTIFY_INFO_DATA</VAR -> entries contain:</P -><P -></P -><UL -><LI -><P ->The type defines whether or not this event -is for a printer or a print job</P -></LI -><LI -><P ->The field is the flag identifying the event</P -></LI -><LI -><P ->the notify_data union contains the new valuie of the -attribute</P -></LI -><LI -><P ->The enc_type defines the size of the structure for marshalling -and unmarshalling</P -></LI -><LI -><P ->(a) the id must be 0 for a printer event on a printer handle. +printer handle obtained via a ReplyOpenPrinter(). +</p><p> +The actual change notification is performed using the RRPCN request +RPC. This packet contains +</p><div class="itemizedlist"><ul type="disc"><li><p>the printer handle registered with the +client's spooler on which the change occurred</p></li><li><p>The change_low value which was sent as part +of the last RFNPCN request from the client</p></li><li><p>The SPOOL_NOTIFY_INFO container with the event +information</p></li></ul></div><p> +A <tt>SPOOL_NOTIFY_INFO</tt> contains: +</p><div class="itemizedlist"><ul type="disc"><li><p>the version and flags field are predefined +and should not be changed</p></li><li><p>The count field is the number of entries +in the SPOOL_NOTIFY_INFO_DATA array</p></li></ul></div><p> +The <tt>SPOOL_NOTIFY_INFO_DATA</tt> entries contain: +</p><div class="itemizedlist"><ul type="disc"><li><p>The type defines whether or not this event +is for a printer or a print job</p></li><li><p>The field is the flag identifying the event</p></li><li><p>the notify_data union contains the new valuie of the +attribute</p></li><li><p>The enc_type defines the size of the structure for marshalling +and unmarshalling</p></li><li><p>(a) the id must be 0 for a printer event on a printer handle. (b) the id must be the job id for an event on a printer job (c) the id must be the matching number of the printer index used in the response packet to the RFNPCN when using a print server 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.</P -></LI -><LI -><P ->The size is either (a) the string length in UNICODE for strings, +has been modified since the notification handle was registered.</p></li><li><p>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.</P -></LI -></UL -></DIV -></DIV -><DIV -CLASS="CHAPTER" -><HR><H1 -><A -NAME="WINS" -></A ->Chapter 11. Samba WINS Internals</H1 -><DIV -CLASS="SECT1" -><H2 -CLASS="SECT1" -><A -NAME="AEN3033" ->11.1. WINS Failover</A -></H2 -><P ->The current Samba codebase possesses the capability to use groups of WINS +data values.</p></li></ul></div></div></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="wins"></a>Chapter 11. Samba WINS Internals</h2></div><div><div class="author"><h3 class="author">Gerald Carter</h3></div></div><div><p class="pubdate">October 2002</p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#id2868400">WINS Failover</a></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2868400"></a>WINS Failover</h2></div></div><p> +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</P -><P -><PRE -CLASS="PROGRAMLISTING" -> WINS_SERVER_PARAM = SERVER [ SEPARATOR SERVER_LIST ] - WINS_SERVER_PARAM = "wins server" +resolution. The formal parameter syntax is +</p><pre class="programlisting"> + WINS_SERVER_PARAM = SERVER [ SEPARATOR SERVER_LIST ] + WINS_SERVER_PARAM = "wins server" SERVER = ADDR[:TAG] ADDR = ip_addr | fqdn TAG = string SEPARATOR = comma | \s+ - SERVER_LIST = SERVER [ SEPARATOR SERVER_LIST ]</PRE -></P -><P ->A simple example of a valid wins server setting is</P -><P -><PRE -CLASS="PROGRAMLISTING" ->[global] - wins server = 192.168.1.2 192.168.1.3</PRE -></P -><P ->In the event that no TAG is defined in for a SERVER in the list, smbd assigns a default -TAG of "*". A TAG is used to group servers of a shared NetBIOS namespace together. Upon + SERVER_LIST = SERVER [ SEPARATOR SERVER_LIST ] +</pre><p> +A simple example of a valid wins server setting is +</p><pre class="programlisting"> +[global] + wins server = 192.168.1.2 192.168.1.3 +</pre><p> +In the event that no TAG is defined in for a SERVER in the list, smbd assigns a default +TAG of "*". A TAG is used to group servers of a shared NetBIOS namespace together. Upon startup, nmbd will attempt to register the netbios name value with one server in each -tagged group.</P -><P ->An example using tags to group WINS servers together is show here. Note that the use of -interface names in the tags is only by convention and is not a technical requirement.</P -><P -><PRE -CLASS="PROGRAMLISTING" ->[global] - wins server = 192.168.1.2:eth0 192.168.1.3:eth0 192.168.2.2:eth1</PRE -></P -><P ->Using this configuration, nmbd would attempt to register the server's NetBIOS name -with one WINS server in each group. Because the "eth0" group has two servers, the +tagged group. +</p><p> +An example using tags to group WINS servers together is show here. Note that the use of +interface names in the tags is only by convention and is not a technical requirement. +</p><pre class="programlisting"> +[global] + wins server = 192.168.1.2:eth0 192.168.1.3:eth0 192.168.2.2:eth1 +</pre><p> +Using this configuration, nmbd would attempt to register the server's NetBIOS name +with one WINS server in each group. Because the "eth0" group has two servers, the second server would only be used when a registration (or resolution) request to -the first server in that group timed out.</P -><P ->NetBIOS name resolution follows a similar pattern as name registration. When resolving +the first server in that group timed out. +</p><p> +NetBIOS name resolution follows a similar pattern as name registration. When resolving a NetBIOS name via WINS, smbd and other Samba programs will attempt to query a single WINS server in a tagged group until either a positive response is obtained at least once or until a server from every tagged group has responded negatively to the name query request. If a timeout occurs when querying a specific WINS server, that server is marked as down to 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.</P -></DIV -></DIV -><DIV -CLASS="CHAPTER" -><HR><H1 -><A -NAME="SAM" -></A ->Chapter 12. The Upcoming SAM System</H1 -><DIV -CLASS="SECT1" -><H2 -CLASS="SECT1" -><A -NAME="AEN3054" ->12.1. Security in the 'new SAM'</A -></H2 -><P ->One of the biggest problems with passdb is it's implementation of +for a period of 10 minutes. +</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="sam"></a>Chapter 12. The Upcoming SAM System</h2></div><div><div class="author"><h3 class="author">Andrew Bartlett</h3></div></div><div><p class="pubdate">1 October 2002</p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#id2869126">Security in the 'new SAM'</a></dt><dt><a href="#id2869257">Standalone from UNIX</a></dt><dt><a href="#id2869292">Handles and Races in the new SAM</a></dt><dt><a href="#id2869361">Layers</a></dt><dd><dl><dt><a href="#id2869368">Application</a></dt><dt><a href="#id2869384">SAM Interface</a></dt><dt><a href="#id2869412">SAM Modules</a></dt></dl></dd><dt><a href="#id2869434">SAM Modules</a></dt><dd><dl><dt><a href="#id2869441">Special Module: sam_passdb</a></dt><dt><a href="#id2869459">sam_ads</a></dt></dl></dd><dt><a href="#id2869498">Memory Management</a></dt><dt><a href="#id2869589">Testing</a></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2869126"></a>Security in the 'new SAM'</h2></div></div><p>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.</P -><P ->We took this very seriously when we started work, and the new structure +'magic' 'are you root' checks.</p><p>We took this very seriously when we started work, and the new structure is designed with this in mind, from the ground up. Each call to the SAM has a NT_TOKEN and (if relevant) an 'access desired'. This is either provided as a parameter, or implicitly supplied by the object being -accessed.</P -><P ->For example, when you call </P -><PRE -CLASS="PROGRAMLISTING" ->NTSTATUS sam_get_account_by_name(const SAM_CONTEXT *context, const +accessed.</p><p> +For example, when you call +</p><pre class="programlisting"> +NTSTATUS sam_get_account_by_name(const SAM_CONTEXT *context, const NT_USER_TOKEN *access_token, uint32 access_desired, const char *domain, -const char *name, SAM_ACCOUNT_HANDLE **account)</PRE -><P ->The context can be NULL (and is used to allow import/export by setting -up 2 contexts, and allowing calls on both simultaneously)</P -><P ->The access token *must* be specified. Normally the user's token out of -current_user, this can also be a global 'system' context.</P -><P ->The access desired is as per the ACL, for passing to the seaccess stuff.</P -><P ->The domain/username are standard. Even if we only have one domain, +const char *name, SAM_ACCOUNT_HANDLE **account) +</pre><p> +The context can be NULL (and is used to allow import/export by setting +up 2 contexts, and allowing calls on both simultaneously) +</p><p> +The access token *must* be specified. Normally the user's token out of +current_user, this can also be a global 'system' context. +</p><p> +The access desired is as per the ACL, for passing to the seaccess stuff. +</p><p> +The domain/username are standard. Even if we only have one domain, keeping this ensures that we don't get 'unqualified' usernames (same -problem as we had with unqualified SIDs).</P -><P ->We return a 'handle'. This is opaque to the rest of Samba, but is -operated on by get/set routines, all of which return NTSTATUS.</P -><P ->The access checking is done by the SAM module. The reason it is not +problem as we had with unqualified SIDs). +</p><p> +We return a 'handle'. This is opaque to the rest of Samba, but is +operated on by get/set routines, all of which return NTSTATUS. +</p><p> +The access checking is done by the SAM module. The reason it is not done 'above' the interface is to ensure a 'choke point'. I put a lot of effort into the auth subsystem to ensure we never 'accidentally' forgot to check for null passwords, missed a restriction etc. I intend the SAM -to be written with the same caution.</P -><P ->The reason the access checking is not handled by the interface itself is +to be written with the same caution. +</p><p> +The reason the access checking is not handled by the interface itself is due to the different implementations it make take on. For example, on ADS, you cannot set a password over a non-SSL connection. Other backends may have similar requirements - we need to leave this policy up to the modules. They will naturally have access to 'helper' procedures -and good examples to avoid mishaps.</P -><P ->(Furthermore, some backends my actually chose to push the whole ACL +and good examples to avoid mishaps. +</p><p> +(Furthermore, some backends my actually chose to push the whole ACL issue to the remote server, and - assuming ldap for this example - bind -as the user directly)</P -><P ->Each returned handle has an internal 'access permitted', which allows +as the user directly) +</p><p> +Each returned handle has an internal 'access permitted', which allows the 'get' and 'set' routines to return 'ACCESS_DENIED' for things that were not able to be retrieved from the backend. This removes the need to specify the NT_TOKEN on every operation, and allows for 'object not -present' to be easily distinguished from 'access denied'.</P -><P ->When you 'set' an object (calling sam_update_account) the internal +present' to be easily distinguished from 'access denied'. +</p><p> +When you 'set' an object (calling sam_update_account) the internal details are again used. Each change that has been made to the object has been flagged, so as to avoid race conditions (on unmodified components) and to avoid violating any extra ACL requirements on the -actual data store (like the LDAP server).</P -><P ->Finally, we have generic get_sec_desc() and set_sec_desc() routines to -allow external ACL manipulation. These do lookups based on SID.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN3071" ->12.2. Standalone from UNIX</A -></H2 -><P ->One of the primary tenants of the 'new SAM' is that it would not attempt +actual data store (like the LDAP server). +</p><p> +Finally, we have generic get_sec_desc() and set_sec_desc() routines to +allow external ACL manipulation. These do lookups based on SID. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2869257"></a>Standalone from UNIX</h2></div></div><p> +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 winbind. We have had constructive discussion on how 'basic' unix accounts like 'root' would be handled, and we think this can work. -Accounts not preexisting in unix would be served up via winbind.</P -><P ->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.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN3075" ->12.3. Handles and Races in the new SAM</A -></H2 -><P ->One of the things that the 'new SAM' work has tried to face is both +Accounts not preexisting in unix would be served up via winbind. +</p><p> +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. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2869292"></a>Handles and Races in the new SAM</h2></div></div><p> +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, because if we get alignment with that wrong, things get more, rather than less complex. Also, most other parts of Samba are much more -flexible with what they can allow.</P -><P ->In any case, that was a decision taken as to how the general design -would progress. BTW, my understanding of SAMR may be completely flawed.</P -><P ->One of the most race-prone areas of the new code is the conflicting -update problem. We have taken two approaches: </P -><P -></P -><UL -><LI -><P ->'Not conflicting' conflicts. Due to the way usrmgr operates, it will +flexible with what they can allow. +</p><p> +In any case, that was a decision taken as to how the general design +would progress. BTW, my understanding of SAMR may be completely flawed. +</p><p> +One of the most race-prone areas of the new code is the conflicting +update problem. We have taken two approaches: +</p><div class="itemizedlist"><ul type="disc"><li><p>'Not conflicting' conflicts. Due to the way usrmgr operates, it will open a user, display all the properties and *save* them all, even if you -don't change any.</P -><P ->For this, see what I've done in rpc_server/srv_samr_util.c. I intend +don't change any. +</p><p> +For this, see what I've done in rpc_server/srv_samr_util.c. I intend to take this one step further, and operate on the 'handle' that the values were read from. This should mean that we only update things that -have *really* changed.</P -></LI -><LI -><P ->'conflicting' updates: Currently we don't deal with this (in passdb +have *really* changed. +</p></li><li><p> +'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.</P -></LI -></UL -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN3086" ->12.4. Layers</A -></H2 -><DIV -CLASS="SECT2" -><H3 -CLASS="SECT2" -><A -NAME="AEN3088" ->12.4.1. Application</A -></H3 -><P ->This is where smbd, samtest and whatever end-user replacement we have +a second update. I don't foresee locking records however. +</p></li></ul></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2869361"></a>Layers</h2></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2869368"></a>Application</h3></div></div><p> +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.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN3091" ->12.4.2. SAM Interface</A -></H3 -><P ->This level 'owns' the various handle structures, the get/set routines on +'special knowledge' of what is below them. +</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2869384"></a>SAM Interface</h3></div></div><p> +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, else a default, self-initialising context will be supplied. This layser finds the appropriate backend module for the task, and tries very hard not to need to much 'knowledge'. It should just provide the required -abstraction to the modules below, and arrange for their initial loading.</P -><P ->We could possibly add ACL checking at this layer, to avoid discrepancies -in implementation modules.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN3095" ->12.4.3. SAM Modules</A -></H3 -><P ->These do not communicate with the application directly, only by setting +abstraction to the modules below, and arrange for their initial loading. +</p><p> +We could possibly add ACL checking at this layer, to avoid discrepancies +in implementation modules. +</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2869412"></a>SAM Modules</h3></div></div><p> +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 .private into (say) an LDAP modification list. The module is expected 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.</P -></DIV -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN3098" ->12.5. SAM Modules</A -></H2 -><DIV -CLASS="SECT2" -><H3 -CLASS="SECT2" -><A -NAME="AEN3100" ->12.5.1. Special Module: sam_passdb</A -></H3 -><P ->In order for there to be a smooth transition, kai is writing a module +routine. +</p></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2869434"></a>SAM Modules</h2></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2869441"></a>Special Module: sam_passdb</h3></div></div><p> +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.</P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN3103" ->12.5.2. sam_ads</A -></H3 -><P ->This is the first of the SAM modules to be committed to the tree - +interface. +</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2869459"></a>sam_ads</h3></div></div><p> +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 Active Directory LDAP client, suitable for use on a mixed-mode DC. While it is currently being tested against Win2k servers (with a password in the smb.conf file) it is expected to eventually use a (possibly modified) OpenLDAP server. We hope that this will assist in -the construction of an Samba AD DC.</P -><P ->We also intend to construct a Samba 2.2/3.0 compatible ldap module, -again using libads code.</P -></DIV -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN3107" ->12.6. Memory Management</A -></H2 -><P -> +the construction of an Samba AD DC. +</p><p> +We also intend to construct a Samba 2.2/3.0 compatible ldap module, +again using libads code. +</p></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2869498"></a>Memory Management</h2></div></div><p> 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 @@ -9008,132 +1776,63 @@ context' on many objects. That is, the creation of an object would initiate it's own internal talloc context, and this would be used for all operations on that object. Much of this is already implemented in passdb. Also, like passdb, it will be possible to specify that some -object actually be created on a specified context. </P -><P ->Memory management is important here because the APIs in the 'new SAM' do +object actually be created on a specified context. +</p><p> +Memory management is important here because the APIs in the 'new SAM' do not use 'pdb_init()' or an equivalent. They always allocate new objects. Enumeration's are slightly different, and occur on a supplied context that 'owns' the entire list, rather than per-element. (the enumeration functions return an array of all elements - not full handles just basic (and public) info) Likewise for things that fill in a char -**.</P -><P ->For example:</P -><P -><PRE -CLASS="PROGRAMLISTING" ->NTSTATUS sam_lookup_sid(const SAM_CONTEXT *context, const NT_USER_TOKEN +**. +</p><p>For example:</p><pre class="programlisting"> +NTSTATUS sam_lookup_sid(const SAM_CONTEXT *context, const NT_USER_TOKEN *access_token, TALLOC_CTX *mem_ctx, const DOM_SID *sid, char **name, -uint32 *type)</PRE -></P -><P ->Takes a context to allocate the 'name' on, while:</P -><P -><PRE -CLASS="PROGRAMLISTING" ->NTSTATUS sam_get_account_by_sid(const SAM_CONTEXT *context, const +uint32 *type) +</pre><p>Takes a context to allocate the 'name' on, while:</p><pre class="programlisting"> +NTSTATUS sam_get_account_by_sid(const SAM_CONTEXT *context, const NT_USER_TOKEN *access_token, uint32 access_desired, const DOM_SID -*accountsid, SAM_ACCOUNT_HANDLE **account)</PRE -></P -><P ->Allocates a handle and stores the allocation context on that handle.</P -><P ->I think that the following:</P -><P -><PRE -CLASS="PROGRAMLISTING" ->NTSTATUS sam_enum_accounts(const SAM_CONTEXT *context, const +*accountsid, SAM_ACCOUNT_HANDLE **account) +</pre><p>Allocates a handle and stores the allocation context on that handle.</p><p>I think that the following:</p><pre class="programlisting"> +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)</PRE -></P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN3121" ->12.7. Testing</A -></H2 -><P ->Testing is vital in any piece of software, and Samba is certainly no +int32 *account_count, SAM_ACCOUNT_ENUM **accounts) +</pre></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2869589"></a>Testing</h2></div></div><p> +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.</P -><P ->To this end, Jelmer has constructed 'samtest'. </P -><P ->This utility (see torture/samtest.c) is structured like rpcclient, but +it is easily tested, independent of outside protocols. +</p><p> +To this end, Jelmer has constructed 'samtest'. +</p><p> +This utility (see torture/samtest.c) is structured like rpcclient, but instead operates on the SAM subsystem. It creates a 'custom' SAM context, that may be distinct from the default values used by the rest -of the system, and can load a separate configuration file. </P -><P ->A small number of commands are currently implemented, but these have +of the system, and can load a separate configuration file. +</p><p> +A small number of commands are currently implemented, but these have already proved vital in testing. I expect SAM module authors will find -it particularly valuable.</P -><P ->Example useage:</P -><P -><SAMP -CLASS="PROMPT" ->$</SAMP -> <B -CLASS="COMMAND" ->bin/samtest</B -></P -><P -><PRE -CLASS="PROGRAMLISTING" ->> context ads:ldap://192.168.1.96</PRE -> +it particularly valuable. +</p><p>Example useage:</p><p><tt>$</tt> <b>bin/samtest</b></p><pre class="programlisting"> +> context ads:ldap://192.168.1.96 +</pre><p> (this loads a new context, using the new ADS module. The parameter is -the 'location' of the ldap server)</P -><P -><PRE -CLASS="PROGRAMLISTING" ->> lookup_name DOMAIN abartlet</PRE -> -(returns a sid).</P -><P ->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.</P -></DIV -></DIV -><DIV -CLASS="CHAPTER" -><HR><H1 -><A -NAME="PWENCRYPT" -></A ->Chapter 13. LanMan and NT Password Encryption</H1 -><DIV -CLASS="SECT1" -><H2 -CLASS="SECT1" -><A -NAME="AEN3147" ->13.1. Introduction</A -></H2 -><P ->With the development of LanManager and Windows NT +the 'location' of the ldap server) +</p><pre class="programlisting"> +> lookup_name DOMAIN abartlet +</pre><p> +(returns a sid). +</p><p> +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. +</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="pwencrypt"></a>Chapter 13. LanMan and NT Password Encryption</h2></div><div><div class="author"><h3 class="author">Jeremy Allison</h3><div class="affiliation"><span class="orgname">Samba Team<br></span><div class="address"><p><br> + <tt><<a href="mailto:samba@samba.org">samba@samba.org</a>></tt><br> + </p></div></div></div></div><div><p class="pubdate">19 Apr 1999</p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#id2869092">Introduction</a></dt><dt><a href="#id2868961">How does it work?</a></dt><dt><a href="#id2869678">The smbpasswd file</a></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2869092"></a>Introduction</h2></div></div><p>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.</P -><P ->This document describes how the SMB password encryption + a LanManager or Windows NT server.</p><p>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.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN3151" ->13.2. How does it work?</A -></H2 -><P ->LanManager encryption is somewhat similar to UNIX + the part about security and the "PROS and CONS" section.</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2868961"></a>How does it work?</h2></div></div><p>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 @@ -9141,619 +1840,190 @@ NAME="AEN3151" This 14 byte value is used as two 56 bit DES keys to encrypt a 'magic' eight byte value, forming a 16 byte value which is stored by the server and client. Let this value be known as - the "hashed password".</P -><P ->Windows NT encryption is a higher quality mechanism, + the "hashed password".</p><p>Windows NT encryption is a higher quality mechanism, consisting of doing an MD4 hash on a Unicode version of the user's password. This also produces a 16 byte hash value that is - non-reversible.</P -><P ->When a client (LanManager, Windows for WorkGroups, Windows + non-reversible.</p><p>When a client (LanManager, Windows for WorkGroups, Windows 95 or Windows NT) wishes to mount a Samba drive (or use a Samba resource), it first requests a connection and negotiates the protocol that the client and server will use. In the reply to this request the Samba server generates and appends an 8 byte, random value - this is stored in the Samba server after the reply is sent - and is known as the "challenge". The challenge is different for - every client connection.</P -><P ->The client then uses the hashed password (16 byte values + and is known as the "challenge". The challenge is different for + every client connection.</p><p>The client then uses the hashed password (16 byte values described above), appended with 5 null bytes, as three 56 bit DES keys, each of which is used to encrypt the challenge 8 byte - value, forming a 24 byte value known as the "response".</P -><P ->In the SMB call SMBsessionsetupX (when user level security + value, forming a 24 byte value known as the "response".</p><p>In the SMB call SMBsessionsetupX (when user level security is selected) or the call SMBtconX (when share level security is selected), the 24 byte response is returned by the client to the Samba server. For Windows NT protocol levels the above calculation is done on both hashes of the user's password and both responses are - returned in the SMB call, giving two 24 byte values.</P -><P ->The Samba server then reproduces the above calculation, using + returned in the SMB call, giving two 24 byte values.</p><p>The Samba server then reproduces the above calculation, using its own stored value of the 16 byte hashed password (read from the - <TT -CLASS="FILENAME" ->smbpasswd</TT -> file - described later) and the challenge + <tt>smbpasswd</tt> file - described later) and the challenge value that it kept from the negotiate protocol reply. It then checks to see if the 24 byte value it calculates matches the 24 byte value - returned to it from the client.</P -><P ->If these values match exactly, then the client knew the + returned to it from the client.</p><p>If these values match exactly, then the client knew the correct password (or the 16 byte hashed value - see security note below) and is thus allowed access. If not, then the client did not - know the correct password and is denied access.</P -><P ->Note that the Samba server never knows or stores the cleartext + know the correct password and is denied access.</p><p>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.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN3162" ->13.3. <A -NAME="SMBPASSWDFILEFORMAT" -></A ->>The smbpasswd file</A -></H2 -><P ->In order for Samba to participate in the above protocol + are never transmitted over the network - thus increasing security.</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2869678"></a>The smbpasswd file</h2></div></div><a name="SMBPASSWDFILEFORMAT"></a><p>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 password given the UNIX hash of it), a separate password file containing this 16 byte value must be kept. To minimise problems with - these two password files, getting out of sync, the UNIX <TT -CLASS="FILENAME" -> /etc/passwd</TT -> and the <TT -CLASS="FILENAME" ->smbpasswd</TT -> file, - a utility, <B -CLASS="COMMAND" ->mksmbpasswd.sh</B ->, is provided to generate - a smbpasswd file from a UNIX <TT -CLASS="FILENAME" ->/etc/passwd</TT -> file. - </P -><P ->To generate the smbpasswd file from your <TT -CLASS="FILENAME" ->/etc/passwd - </TT -> file use the following command:</P -><P -><SAMP -CLASS="PROMPT" ->$ </SAMP -><KBD -CLASS="USERINPUT" ->cat /etc/passwd | mksmbpasswd.sh - > /usr/local/samba/private/smbpasswd</KBD -></P -><P ->If you are running on a system that uses NIS, use</P -><P -><SAMP -CLASS="PROMPT" ->$ </SAMP -><KBD -CLASS="USERINPUT" ->ypcat passwd | mksmbpasswd.sh - > /usr/local/samba/private/smbpasswd</KBD -></P -><P ->The <B -CLASS="COMMAND" ->mksmbpasswd.sh</B -> program is found in + these two password files, getting out of sync, the UNIX <tt> + /etc/passwd</tt> and the <tt>smbpasswd</tt> file, + a utility, <b>mksmbpasswd.sh</b>, is provided to generate + a smbpasswd file from a UNIX <tt>/etc/passwd</tt> file. + </p><p>To generate the smbpasswd file from your <tt>/etc/passwd + </tt> file use the following command:</p><p><tt>$ </tt><b><tt>cat /etc/passwd | mksmbpasswd.sh + > /usr/local/samba/private/smbpasswd</tt></b></p><p>If you are running on a system that uses NIS, use</p><p><tt>$ </tt><b><tt>ypcat passwd | mksmbpasswd.sh + > /usr/local/samba/private/smbpasswd</tt></b></p><p>The <b>mksmbpasswd.sh</b> program is found in the Samba source directory. By default, the smbpasswd file is - stored in :</P -><P -><TT -CLASS="FILENAME" ->/usr/local/samba/private/smbpasswd</TT -></P -><P ->The owner of the <TT -CLASS="FILENAME" ->/usr/local/samba/private/</TT -> + stored in :</p><p><tt>/usr/local/samba/private/smbpasswd</tt></p><p>The owner of the <tt>/usr/local/samba/private/</tt> directory should be set to root, and the permissions on it should - be set to 0500 (<B -CLASS="COMMAND" ->chmod 500 /usr/local/samba/private</B ->). - </P -><P ->Likewise, the smbpasswd file inside the private directory should + be set to 0500 (<b>chmod 500 /usr/local/samba/private</b>). + </p><p>Likewise, the smbpasswd file inside the private directory should be owned by root and the permissions on is should be set to 0600 - (<B -CLASS="COMMAND" ->chmod 600 smbpasswd</B ->).</P -><P ->The format of the smbpasswd file is (The line has been + (<b>chmod 600 smbpasswd</b>).</p><p>The format of the smbpasswd file is (The line has been wrapped here. It should appear as one entry per line in - your smbpasswd file.)</P -><P -><PRE -CLASS="PROGRAMLISTING" ->username:uid:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: - [Account type]:LCT-<last-change-time>:Long name - </PRE -></P -><P ->Although only the <VAR -CLASS="REPLACEABLE" ->username</VAR ->, - <VAR -CLASS="REPLACEABLE" ->uid</VAR ->, <VAR -CLASS="REPLACEABLE" -> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</VAR ->, - [<VAR -CLASS="REPLACEABLE" ->Account type</VAR ->] and <VAR -CLASS="REPLACEABLE" -> last-change-time</VAR -> sections are significant - and are looked at in the Samba code.</P -><P ->It is <SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->VITALLY</I -></SPAN -> important that there by 32 + your smbpasswd file.)</p><pre class="programlisting"> +username:uid:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: + [Account type]:LCT-<last-change-time>:Long name + </pre><p>Although only the <i><tt>username</tt></i>, + <i><tt>uid</tt></i>, <i><tt> + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</tt></i>, + [<i><tt>Account type</tt></i>] and <i><tt> + last-change-time</tt></i> sections are significant + and are looked at in the Samba code.</p><p>It is <span class="emphasis"><em>VITALLY</em></span> important that there by 32 'X' characters between the two ':' characters in the XXX sections - the smbpasswd and Samba code will fail to validate any entries that do not have 32 characters between ':' characters. The first XXX section is for the Lanman password hash, the second is for the - Windows NT version.</P -><P ->When the password file is created all users have password entries + Windows NT version.</p><p>When the password file is created all users have password entries consisting of 32 'X' characters. By default this disallows any access as this user. When a user has a password set, the 'X' characters change to 32 ascii hexadecimal digits (0-9, A-F). These are an ascii - representation of the 16 byte hashed value of a user's password.</P -><P ->To set a user to have no password (not recommended), edit the file + representation of the 16 byte hashed value of a user's password.</p><p>To set a user to have no password (not recommended), edit the file using vi, and replace the first 11 characters with the ascii text - <CODE -CLASS="CONSTANT" ->"NO PASSWORD"</CODE -> (minus the quotes).</P -><P ->For example, to clear the password for user bob, his smbpasswd file - entry would look like :</P -><P -><PRE -CLASS="PROGRAMLISTING" -> bob:100:NO PASSWORDXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:[U ]:LCT-00000000:Bob's full name:/bobhome:/bobshell - </PRE -></P -><P ->If you are allowing users to use the smbpasswd command to set + <tt>"NO PASSWORD"</tt> (minus the quotes).</p><p>For example, to clear the password for user bob, his smbpasswd file + entry would look like :</p><pre class="programlisting"> +bob:100:NO PASSWORDXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: + [U ]:LCT-00000000:Bob's full name:/bobhome:/bobshell + </pre><p>If you are allowing users to use the smbpasswd command to set their own passwords, you may want to give users NO PASSWORD initially so they do not have to enter a previous password when changing to their new password (not recommended). In order for you to allow this the - <B -CLASS="COMMAND" ->smbpasswd</B -> program must be able to connect to the - <B -CLASS="COMMAND" ->smbd</B -> daemon as that user with no password. Enable this - by adding the line :</P -><P -><B -CLASS="COMMAND" ->null passwords = yes</B -></P -><P ->to the [global] section of the smb.conf file (this is why + <b>smbpasswd</b> program must be able to connect to the + <b>smbd</b> daemon as that user with no password. Enable this + by adding the line :</p><p><b>null passwords = yes</b></p><p>to the [global] section of the smb.conf file (this is why the above scenario is not recommended). Preferably, allocate your users a default password to begin with, so you do not have - to enable this on your server.</P -><P -><SPAN -CLASS="emphasis" -><I -CLASS="EMPHASIS" ->Note : </I -></SPAN ->This file should be protected very + to enable this on your server.</p><p><span class="emphasis"><em>Note : </em></span>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 <TT -CLASS="FILENAME" ->/etc/passwd</TT -> file.</P -></DIV -></DIV -><DIV -CLASS="CHAPTER" -><HR><H1 -><A -NAME="MODULES" -></A ->Chapter 14. Modules</H1 -><DIV -CLASS="SECT1" -><H2 -CLASS="SECT1" -><A -NAME="AEN3225" ->14.1. Advantages</A -></H2 -><P ->The new modules system has the following advantages:</P -><P -></P -><TABLE -BORDER="0" -><TBODY -><TR -><TD ->Transparent loading of static and shared modules (no need -for a subsystem to know about modules)</TD -></TR -><TR -><TD ->Simple selection between shared and static modules at configure time</TD -></TR -><TR -><TD ->"preload modules" option for increasing performance for stable modules</TD -></TR -><TR -><TD ->No nasty #define stuff anymore</TD -></TR -><TR -><TD ->All backends are available as plugin now (including pdb_ldap and pdb_tdb)</TD -></TR -></TBODY -></TABLE -><P -></P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN3234" ->14.2. Loading modules</A -></H2 -><P ->Some subsystems in samba use different backends. These backends can be + sensitive than a normal unix <tt>/etc/passwd</tt> file.</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="modules"></a>Chapter 14. Modules</h2></div><div><div class="author"><h3 class="author">Jelmer Vernooij</h3><div class="affiliation"><span class="orgname">Samba Team<br></span><div class="address"><p><tt><<a href="mailto:jelmer@samba.org">jelmer@samba.org</a>></tt></p></div></div></div></div><div><p class="pubdate"> 19 March 2003 </p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#id2870133">Advantages</a></dt><dt><a href="#id2869868">Loading modules</a></dt><dd><dl><dt><a href="#id2869901">Static modules</a></dt><dt><a href="#id2870337">Shared modules</a></dt></dl></dd><dt><a href="#id2870365">Writing modules</a></dt><dd><dl><dt><a href="#id2870425">Static/Shared selection in configure.in</a></dt></dl></dd></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2870133"></a>Advantages</h2></div></div><p> +The new modules system has the following advantages: +</p><table class="simplelist" border="0" summary="Simple list"><tr><td>Transparent loading of static and shared modules (no need +for a subsystem to know about modules)</td></tr><tr><td>Simple selection between shared and static modules at configure time</td></tr><tr><td>"preload modules" option for increasing performance for stable modules</td></tr><tr><td>No nasty #define stuff anymore</td></tr><tr><td>All backends are available as plugin now (including pdb_ldap and pdb_tdb)</td></tr></table></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2869868"></a>Loading modules</h2></div></div><p> +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, -the passdb subsystem has: </P -><P -><PRE -CLASS="PROGRAMLISTING" ->BOOL smb_register_passdb(const char *name, pdb_init_function init, int version);</PRE -></P -><P ->This function will be called by the initialisation function of the module to -register itself. </P -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN3240" ->14.2.1. Static modules</A -></H3 -><P ->The modules system compiles a list of initialisation functions for the +the passdb subsystem has: +</p><pre class="programlisting"> +BOOL smb_register_passdb(const char *name, pdb_init_function init, int version); +</pre><p> +This function will be called by the initialisation function of the module to +register itself. +</p><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2869901"></a>Static modules</h3></div></div><p> +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 <TT -CLASS="FILENAME" ->include/config.h</TT ->): </P -><P -><PRE -CLASS="PROGRAMLISTING" ->/* Static init functions */ -#define static_init_pdb { pdb_mysql_init(); pdb_ldap_init(); pdb_smbpasswd_init(); pdb_tdbsam_init(); pdb_guest_init();}</PRE -></P -><P ->These functions should be called before the subsystem is used. That -should be done when the subsystem is initialised or first used. </P -></DIV -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN3247" ->14.2.2. Shared modules</A -></H3 -><P ->If a subsystem needs a certain backend, it should check if it has +it is here currently (from <tt>include/config.h</tt>): +</p><pre class="programlisting"> +/* Static init functions */ +#define static_init_pdb { pdb_mysql_init(); pdb_ldap_init(); pdb_smbpasswd_init(); pdb_tdbsam_init(); pdb_guest_init();} +</pre><p> +These functions should be called before the subsystem is used. That +should be done when the subsystem is initialised or first used. +</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2870337"></a>Shared modules</h3></div></div><p> +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). This function tries to load the correct module from a certain path ($LIBDIR/subsystem/backend.so). If the first character in 'backend' is a slash, smb_probe_module() tries to load the module from the -absolute path specified in 'backend'.</P -><P ->After smb_probe_module() has been executed, the subsystem -should check again if the module has been registered. </P -></DIV -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN3251" ->14.3. Writing modules</A -></H2 -><P ->Each module has an initialisation function. For modules that are -included with samba this name is '<VAR -CLASS="REPLACEABLE" ->subsystem</VAR ->_<VAR -CLASS="REPLACEABLE" ->backend</VAR ->_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:</P -><P -><PRE -CLASS="PROGRAMLISTING" ->int init_module(void);</PRE -></P -><P ->This function should call one or more +absolute path specified in 'backend'. +</p><p>After smb_probe_module() has been executed, the subsystem +should check again if the module has been registered. +</p></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2870365"></a>Writing modules</h2></div></div><p> +Each module has an initialisation function. For modules that are +included with samba this name is '<i><tt>subsystem</tt></i>_<i><tt>backend</tt></i>_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: +</p><pre class="programlisting"> +int init_module(void); +</pre><p>This function should call one or more registration functions. The function should return non-zero on success and zero on -failure.</P -><P ->For example, pdb_ldap_init() contains: </P -><P -><PRE -CLASS="PROGRAMLISTING" ->int pdb_ldap_init(void) +failure.</p><p>For example, pdb_ldap_init() contains: </p><pre class="programlisting"> +int pdb_ldap_init(void) { - smb_register_passdb("ldapsam", pdb_init_ldapsam, PASSDB_INTERFACE_VERSION); - smb_register_passdb("ldapsam_nua", pdb_init_ldapsam_nua, PASSDB_INTERFACE_VERSION); + smb_register_passdb("ldapsam", pdb_init_ldapsam, PASSDB_INTERFACE_VERSION); + smb_register_passdb("ldapsam_nua", pdb_init_ldapsam_nua, PASSDB_INTERFACE_VERSION); return TRUE; -}</PRE -></P -><DIV -CLASS="SECT2" -><HR><H3 -CLASS="SECT2" -><A -NAME="AEN3262" ->14.3.1. Static/Shared selection in configure.in</A -></H3 -><P ->Some macros in configure.in generate the various defines and substs that +} +</pre><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2870425"></a>Static/Shared selection in configure.in</h3></div></div><p> +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'. -For example, if ldap is found, pdb_ldap is added to this variable.</P -><P ->On the bottom of configure.in, SMB_MODULE() should be called -for each module and SMB_SUBSYSTEM() for each subsystem.</P -><P ->Syntax:</P -><P -><PRE -CLASS="PROGRAMLISTING" ->SMB_MODULE(<VAR -CLASS="REPLACEABLE" ->subsystem</VAR ->_<VAR -CLASS="REPLACEABLE" ->backend</VAR ->, <VAR -CLASS="REPLACEABLE" ->object files</VAR ->, <VAR -CLASS="REPLACEABLE" ->plugin name</VAR ->, <VAR -CLASS="REPLACEABLE" ->subsystem name</VAR ->, <VAR -CLASS="REPLACEABLE" ->static_action</VAR ->, <VAR -CLASS="REPLACEABLE" ->shared_action</VAR ->) -SMB_SUBSYSTEM(<VAR -CLASS="REPLACEABLE" ->subsystem</VAR ->)</PRE -></P -><P ->Also, make sure to add the correct directives to -<TT -CLASS="FILENAME" ->Makefile.in</TT ->. <VAR -CLASS="REPLACEABLE" ->@SUBSYSTEM_STATIC@</VAR -> +For example, if ldap is found, pdb_ldap is added to this variable. +</p><p> +On the bottom of configure.in, SMB_MODULE() should be called +for each module and SMB_SUBSYSTEM() for each subsystem. +</p><p>Syntax:</p><pre class="programlisting"> +SMB_MODULE(<i><tt>subsystem</tt></i>_<i><tt>backend</tt></i>, <i><tt>object files</tt></i>, <i><tt>plugin name</tt></i>, <i><tt>subsystem name</tt></i>, <i><tt>static_action</tt></i>, <i><tt>shared_action</tt></i>) +SMB_SUBSYSTEM(<i><tt>subsystem</tt></i>) +</pre><p>Also, make sure to add the correct directives to +<tt>Makefile.in</tt>. <i><tt>@SUBSYSTEM_STATIC@</tt></i> will be replaced with a list of objects files of the modules that need to -be linked in statically. <VAR -CLASS="REPLACEABLE" ->@SUBSYSTEM_MODULES@</VAR -> will -be replaced with the names of the plugins to build.</P -><P ->You must make sure all .c files that contain defines that can +be linked in statically. <i><tt>@SUBSYSTEM_MODULES@</tt></i> will +be replaced with the names of the plugins to build. +</p><p>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 <B -CLASS="COMMAND" ->static_init_subsystem;</B -> calls need to be rebuilded.</P -></DIV -></DIV -></DIV -><DIV -CLASS="CHAPTER" -><HR><H1 -><A -NAME="RPC-PLUGIN" -></A ->Chapter 15. RPC Pluggable Modules</H1 -><DIV -CLASS="SECT1" -><H2 -CLASS="SECT1" -><A -NAME="AEN3301" ->15.1. About</A -></H2 -><P ->This document describes how to make use the new RPC Pluggable Modules features +Practically, this means all c files that contain <b>static_init_subsystem;</b> calls need to be rebuilded. +</p></div></div></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="rpc-plugin"></a>Chapter 15. RPC Pluggable Modules</h2></div><div><div class="author"><h3 class="author">Anthony Liguori</h3><div class="affiliation"><span class="orgname">IBM<br></span><div class="address"><p><tt><<a href="mailto:aliguor@us.ibm.com">aliguor@us.ibm.com</a>></tt></p></div></div></div></div><div><div class="author"><h3 class="author">Jelmer Vernooij</h3><div class="affiliation"><span class="orgname">Samba Team<br></span><div class="address"><p><tt><<a href="mailto:jelmer@samba.org">jelmer@samba.org</a>></tt></p></div></div></div></div><div><p class="pubdate">January 2003</p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#id2869935">About</a></dt><dt><a href="#id2869954">General Overview</a></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2869935"></a>About</h2></div></div><p> +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.</P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN3304" ->15.2. General Overview</A -></H2 -><P ->When an RPC call is sent to smbd, smbd tries to load a shared library by the -name <TT -CLASS="FILENAME" ->librpc_<pipename>.so</TT -> to handle the call if +to Samba through plug-ins. +</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2869954"></a>General Overview</h2></div></div><p> +When an RPC call is sent to smbd, smbd tries to load a shared library by the +name <tt>librpc_<pipename>.so</tt> to handle the call if it doesn't know how to handle the call internally. For instance, LSA calls -are handled by <TT -CLASS="FILENAME" ->librpc_lsass.so</TT ->.. -These shared libraries should be located in the <TT -CLASS="FILENAME" -><sambaroot>/lib/rpc</TT ->. smbd then attempts to call the init_module function within -the shared library. Check the chapter on modules for more information.</P -><P ->In the init_module function, the library should call -rpc_pipe_register_commands(). This function takes the following arguments:</P -><P -><PRE -CLASS="PROGRAMLISTING" ->int rpc_pipe_register_commands(const char *clnt, const char *srv, - const struct api_struct *cmds, int size);</PRE -></P -><P -></P -><DIV -CLASS="VARIABLELIST" -><DL -><DT ->clnt</DT -><DD -><P ->the Client name of the named pipe</P -></DD -><DT ->srv</DT -><DD -><P ->the Server name of the named pipe</P -></DD -><DT ->cmds</DT -><DD -><P ->a list of api_structs that map RPC ordinal numbers to function calls</P -></DD -><DT ->size</DT -><DD -><P ->the number of api_structs contained in cmds</P -></DD -></DL -></DIV -><P ->See rpc_server/srv_reg.c and rpc_server/srv_reg_nt.c for a small example of -how to use this library.</P -></DIV -></DIV -><DIV -CLASS="CHAPTER" -><HR><H1 -><A -NAME="PACKAGING" -></A ->Chapter 16. Notes to packagers</H1 -><DIV -CLASS="SECT1" -><H2 -CLASS="SECT1" -><A -NAME="AEN3337" ->16.1. Versioning</A -></H2 -><P ->Please, please update the version number in -<TT -CLASS="FILENAME" ->source/include/version.h</TT -> to include the versioning of your package. This makes it easier to distinguish standard samba builds +are handled by <tt>librpc_lsass.so</tt>.. +These shared libraries should be located in the <tt><sambaroot>/lib/rpc</tt>. smbd then attempts to call the init_module function within +the shared library. Check the chapter on modules for more information. +</p><p> +In the init_module function, the library should call +rpc_pipe_register_commands(). This function takes the following arguments: +</p><pre class="programlisting"> +int rpc_pipe_register_commands(const char *clnt, const char *srv, + const struct api_struct *cmds, int size); +</pre><div class="variablelist"><dl><dt><span class="term">clnt</span></dt><dd><p>the Client name of the named pipe</p></dd><dt><span class="term">srv</span></dt><dd><p>the Server name of the named pipe</p></dd><dt><span class="term">cmds</span></dt><dd><p>a list of api_structs that map RPC ordinal numbers to function calls</p></dd><dt><span class="term">size</span></dt><dd><p>the number of api_structs contained in cmds</p></dd></dl></div><p> +See rpc_server/srv_reg.c and rpc_server/srv_reg_nt.c for a small example of +how to use this library. +</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="Packaging"></a>Chapter 16. Notes to packagers</h2></div><div><div class="author"><h3 class="author">Jelmer Vernooij</h3></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#id2870644">Versioning</a></dt><dt><a href="#id2870677">Modules</a></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2870644"></a>Versioning</h2></div></div><p>Please, please update the version number in +<tt>source/include/version.h</tt> 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: </P -><P -><PRE -CLASS="PROGRAMLISTING" ->Version 2.999+3.0.alpha21-5 for Debian</PRE -></P -></DIV -><DIV -CLASS="SECT1" -><HR><H2 -CLASS="SECT1" -><A -NAME="AEN3343" ->16.2. Modules</A -></H2 -><P ->Samba now has support for building parts of samba as plugins. This +example, a good version would be: </p><pre class="programlisting"> +Version 2.999+3.0.alpha21-5 for Debian +</pre></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2870677"></a>Modules</h2></div></div><p>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 -as a plugin, run: </P -><P -><PRE -CLASS="PROGRAMLISTING" ->./configure --with-shared-modules=rpc,vfs,auth,pdb,charset</PRE -></P -></DIV -></DIV -></DIV -></BODY -></HTML ->
\ No newline at end of file +as a plugin, run: </p><pre class="programlisting"> +./configure --with-shared-modules=rpc,vfs,auth,pdb,charset +</pre></div></div></div></body></html> |