1<HTML> 2<HEAD> 3<TITLE> 4[Chapter 6] Users, Security, and Domains </title><META NAME="DC.title" CONTENT=""><META NAME="DC.creator" CONTENT=""><META NAME="DC.publisher" CONTENT="O'Reilly & Associates, Inc."><META NAME="DC.date" CONTENT="1999-11-05T21:33:28Z"><META NAME="DC.type" CONTENT="Text.Monograph"><META NAME="DC.format" CONTENT="text/html" SCHEME="MIME"><META NAME="DC.source" CONTENT="" SCHEME="ISBN"><META NAME="DC.language" CONTENT="en-US"><META NAME="generator" CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"></head> 5<BODY BGCOLOR="#FFFFFF" TEXT="#000000" link="#990000" vlink="#0000CC"> 6<table BORDER="0" CELLPADDING="0" CELLSPACING="0" width="90%"> 7<tr> 8<td width="25%" valign="TOP"> 9<img hspace=10 vspace=10 src="gifs/samba.s.gif" 10alt="Using Samba" align=left valign=top border=0> 11</td> 12<td height="105" valign="TOP"> 13<br> 14<H2>Using Samba</H2> 15<font size="-1"> 16Robert Eckstein, David Collier-Brown, Peter Kelly 17<br>1st Edition November 1999 18<br>1-56592-449-5, Order Number: 4495 19<br>416 pages, $34.95 20</font> 21<p> <a href="http://www.oreilly.com/catalog/samba/">Buy the hardcopy</a> 22<p><a href="index.html">Table of Contents</a> 23</td> 24</tr> 25</table> 26<hr size=1 noshade> 27<!--sample chapter begins --> 28 29<center> 30<DIV CLASS="htmlnav"> 31<TABLE WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0"> 32<TR> 33<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 34<A CLASS="sect1" HREF="ch05_05.html" TITLE="5.5 Locks and Oplocks"> 35<IMG SRC="gifs/txtpreva.gif" ALT="Previous: 5.5 Locks and Oplocks" BORDER="0"></a></td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 36<B> 37<FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1"> 38Chapter 6</font></b></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 39<A CLASS="sect1" HREF="ch06_02.html" TITLE="6.2 Controlling Access to Shares"> 40<IMG SRC="gifs/txtnexta.gif" ALT="Next: 6.2 Controlling Access to Shares" BORDER="0"></a></td></tr></table> <hr noshade size=1></center> 41</div> 42<blockquote> 43<div class="samplechapter"> 44<H1 CLASS="chapter"> 45<A CLASS="title" NAME="ch06-88749"> 466. Users, Security, and Domains </a></h1><DIV CLASS="htmltoc"> 47<P> 48<B> 49Contents:</b><br> 50<A CLASS="sect1" HREF="#ch06-92902" TITLE="6.1 Users and Groups"> 51Users and Groups</a><br> 52<A CLASS="sect1" HREF="ch06_02.html" TITLE="6.2 Controlling Access to Shares"> 53Controlling Access to Shares</a><br> 54<A CLASS="sect1" HREF="ch06_03.html" TITLE="6.3 Authentication Security"> 55Authentication Security</a><br> 56<A CLASS="sect1" HREF="ch06_04.html" TITLE="6.4 Passwords"> 57Passwords</a><br> 58<A CLASS="sect1" HREF="ch06_05.html" TITLE="6.5 Windows Domains"> 59Windows Domains</a><br> 60<A CLASS="sect1" HREF="ch06_06.html" TITLE="6.6 Logon Scripts"> 61Logon Scripts</a></p><P> 62</p></div><P CLASS="para"> 63This chapter discusses how to configure users with the Samba server. This topic may seem straightforward at first, but you'll soon discover that there are several ancillary problems that can crop up. One issue that Samba administrators have difficulty with is user authentication - password and security problems are by far the most common support questions on the Samba mailing lists. Learning why various authentication mechanisms work on certain architectures (and don't on others) can save you a tremendous amount of time testing and debugging Samba users in the future.</p><DIV CLASS="sect1"> 64<H2 CLASS="sect1"> 65<A CLASS="title" NAME="s1"></a> 66<A CLASS="title" NAME="ch06-92902"> 676.1 Users and Groups</a></h2><P CLASS="para">Before we start, we need to warn you up front that if you are connecting to Samba with a Windows 98 or NT 4.0 Workstation SP3, you need to configure your server for encrypted passwords before you can make a connection; otherwise, the clients will refuse to connect to the Samba server. This is because each of those Windows clients sends encrypted passwords, and Samba needs to be configured to expect and decrypt them. We'll show you how to set up Samba for this task later in the chapter, assuming you haven't already tackled this problem in <a href="ch02_01.html"><b>Chapter 2, <CITE CLASS="chapter">Installing Samba on a Unix System</cite></b></a>.</p><P CLASS="para">Let's start with a single user. The easiest way to set up a client user is to create a Unix account (and home directory) for that individual on the server, and notify Samba of the user's existence. You can do the latter by creating a disk share that maps to the user's home directory in the Samba configuration file, and restricting access to that user with the <CODE CLASS="literal"> 68valid</code> <CODE CLASS="literal"> 69users</code> option. For example:</p><PRE CLASS="programlisting"> 70[dave] 71 path = /home/dave 72 comment = Dave's home directory 73 writeable = yes<B CLASS="emphasis.bold"> 74 valid users = dave</b></pre><P CLASS="para"> 75The <CODE CLASS="literal"> 76valid</code> <CODE CLASS="literal"> 77users</code> option lists the users that will be allowed to access the share. In this case, only the user <CODE CLASS="literal"> 78dave</code> is allowed to access the share. In the previous chapters, we specified that any user could access a disk share using the <CODE CLASS="literal"> 79guest</code> <CODE CLASS="literal"> 80ok</code> parameter. Because we don't wish to allow guest access, that option is absent here. We could grant both authenticated users and guest users access to a specific share if we wanted to. The difference between the two typically involves access rights for each of the files. </p><P CLASS="para"> 81Remember that you can abbreviate the user's home directory by using the <CODE CLASS="literal"> 82%H</code> variable. In addition, you can use the Unix username variable <CODE CLASS="literal"> 83%u</code> and/or the client username variable <CODE CLASS="literal"> 84%U</code> in your options as well. For example<EM CLASS="emphasis"></em>:</p><PRE CLASS="programlisting"> 85[dave] 86 comment = %U home directory 87 writeable = yes 88 valid users = dave 89 path = %H</pre><P CLASS="para"> 90Both of these examples work as long as the Unix user that Samba uses to represent the client has read/write access to the directory referenced by the <CODE CLASS="literal"> 91path</code> option. In other words, a client must first pass Samba's security mechanisms (e.g., encrypted passwords, the <CODE CLASS="literal"> 92valid users</code> option, etc.) as well as the normal Unix file and directory permissions of its Unix-side user <EM CLASS="emphasis"> 93before</em> it can gain read/write access to a share.</p><P CLASS="para"> 94With a single user accessing a home directory, access permissions are taken care of when the operating system creates the user account. However, if you're creating a shared directory for group access, there are a few more steps you need to perform. Let's take a stab at a group share for the accounting department in the <EM CLASS="emphasis"> 95smb.conf</em> file:</p><PRE CLASS="programlisting"> 96[accounting] 97 comment = Accounting Department Directory 98 writeable = yes 99 valid users = @account 100 path = /home/samba/accounting 101 create mode = 0660 102 directory mode = 0770</pre><P CLASS="para"> 103The first thing that you might notice we did differently is to specify <CODE CLASS="literal"> 104@account</code> as the valid user instead of one or more individual usernames. This is shorthand for saying that the valid users are represented by the Unix group <CODE CLASS="literal"> 105account</code>. These users will need to be added to the group entry <CODE CLASS="literal"> 106account</code> in the system group file (<I CLASS="filename">/etc/group</i> or equivalent) to be recognized as part of the group. Once they are, Samba will recognize those users as valid users for the share.</p><P CLASS="para"> 107In addition, you will need to create a shared directory that the members of the group can access, which is pointed to by the <CODE CLASS="literal"> 108path</code> configuration option. Here are the Unix commands that create the shared directory for the accounting department (assuming <EM CLASS="emphasis"> 109/home/samba</em> already exists):</p><PRE CLASS="programlisting"><B CLASS="emphasis.bold"><CODE CLASS="literal">#</code> mkdir /home/samba/accounting</b><B CLASS="emphasis.bold"> 110<CODE CLASS="literal">#</code> chgrp account /home/samba/accounting</b><B CLASS="emphasis.bold"> 111<CODE CLASS="literal">#</code> chmod 770 /home/samba/accounting</b></pre><P CLASS="para"> 112There are two other options in this <I CLASS="filename"> 113smb.conf</i> example, both of which we saw in the previous chapter. These options are <CODE CLASS="literal"> 114create</code> <CODE CLASS="literal"> 115mode</code> and <CODE CLASS="literal"> 116directory</code> <CODE CLASS="literal"> 117mode</code>. These options set the maximum file and directory permissions that a new file or directory can have. In this case, we have denied all world access to the contents of this share. (This is reinforced by the <EM CLASS="emphasis"> 118chmod</em> command, shown earlier.).</p><DIV CLASS="sect2"> 119<H3 CLASS="sect2"> 120<A CLASS="title" NAME="ch06-pgfId-968835"> 1216.1.1 The [homes] Share</a></h3><P CLASS="para"> 122Let's return to user shares for a moment. If we have several users to set up home directory shares for, we probably want to use the special <CODE CLASS="literal"> 123[homes]</code> share that we introduced in <a href="ch05_01.html"><b>Chapter 5, <CITE CLASS="chapter">Browsing and Advanced Disk Shares</cite></b></a>. With the <CODE CLASS="literal"> 124[homes]</code> share, all we need to say is: </p><PRE CLASS="programlisting"> 125[homes] 126<CODE CLASS="literal"> 127 </code>browsable = no 128 writable = yes</pre><P CLASS="para"> 129The <CODE CLASS="literal"> 130[homes]</code> share is a special section of the Samba configuration file. If a user attempts to connect to an ordinary share that doesn't appear in the <I CLASS="filename"> 131smb.conf</i> file (such as specifying it with a UNC in Windows Explorer), Samba will search for a <CODE CLASS="literal"> 132[homes]</code> share. If one exists, the incoming share name is assumed to be a username and is queried as such in the password database (<I CLASS="filename">/etc/passwd</i> or equivalent) file of the Samba server. If it appears, Samba assumes the client is a Unix user trying to connect to his or her home directory.</p><P CLASS="para"> 133As an illustration, let's assume that <CODE CLASS="literal"> 134sofia</code> is attempting to connect to a share called [<CODE CLASS="literal">sofia]</code> on the Samba server. There is no share by that name in the configuration file, but a <CODE CLASS="literal"> 135[homes]</code> share exists and user <CODE CLASS="literal"> 136sofia</code> is present in the password database, so Samba takes the following steps:</p><OL CLASS="orderedlist"> 137<LI CLASS="listitem"> 138<P CLASS="para"> 139<A CLASS="listitem" NAME="ch06-pgfId-957527"> 140</a>Samba creates a new disk share called <CODE CLASS="literal"> 141[sofia]</code> with the <CODE CLASS="literal"> 142path</code> specified in the <CODE CLASS="literal"> 143[homes]</code> section. If there is no <CODE CLASS="literal"> 144path</code> option specified in <CODE CLASS="literal"> 145[homes]</code>, Samba initializes it to her home directory.</p></li><LI CLASS="listitem"> 146<P CLASS="para"> 147<A CLASS="listitem" NAME="ch06-pgfId-957528"> 148</a>Samba initializes the new share's options from the defaults in <CODE CLASS="literal"> 149[globals]</code>, and any overriding options in <CODE CLASS="literal"> 150[homes]</code> with the exception of <CODE CLASS="literal"> 151browseable</code>.</p></li><LI CLASS="listitem"> 152<P CLASS="para"> 153<A CLASS="listitem" NAME="ch06-pgfId-957529"> 154</a>Samba connects <CODE CLASS="literal"> 155sofia</code>'s client to that share.</p></li></ol><P CLASS="para"> 156The <CODE CLASS="literal"> 157[homes]</code> share is a fast, painless way to create shares for your user community without having to duplicate the information from the password database file in the <I CLASS="filename"> 158smb.conf</i> file. It does have some peculiarities, however, that we need to point out:</p><UL CLASS="itemizedlist"> 159<LI CLASS="listitem"> 160<P CLASS="para"> 161<A CLASS="listitem" NAME="ch06-pgfId-957531"> 162</a>The <CODE CLASS="literal"> 163[homes]</code> section can represent any account on the machine, which isn't always desirable. For example, it can potentially create a share for <EM CLASS="emphasis"> 164root</em>, <EM CLASS="emphasis"> 165bin</em>, <EM CLASS="emphasis"> 166sys</em>, <EM CLASS="emphasis"> 167uucp</em>, and the like. (You can set a global <CODE CLASS="literal"> 168invalid</code> <CODE CLASS="literal"> 169users</code> option to protect against this.)</p></li><LI CLASS="listitem"> 170<P CLASS="para"> 171<A CLASS="listitem" NAME="ch06-pgfId-957533"> 172</a>The meaning of the <CODE CLASS="literal"> 173browseable</code> configuration option is different from other shares; it indicates only that a <CODE CLASS="literal"> 174[homes]</code> section won't show up in the local browse list, not that the <CODE CLASS="literal"> 175[alice]</code> share won't. When the <CODE CLASS="literal"> 176[alice]</code> section is created (after the initial connection), it will use the browsable value from the <CODE CLASS="literal"> 177[globals]</code> section for that share, not the value from <CODE CLASS="literal"> 178[homes]</code>.</p></li></ul><P CLASS="para"> 179As we mentioned, there is no need for a path statement in <CODE CLASS="literal"> 180[homes]</code> if the users have Unix home directories in the server's <I CLASS="filename"> 181/etc/passwd</i> file. You should ensure that a valid home directory does exist, however, as Samba will not automatically create a home directory for a user, and will refuse a tree connect if the user's directory does not exist or is not accessible. </p></div></div></div></blockquote> 182<div> 183<center> 184<hr noshade size=1><TABLE WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0"> 185<TR> 186<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 187<A CLASS="sect1" HREF="ch05_05.html" TITLE="5.5 Locks and Oplocks"> 188<IMG SRC="gifs/txtpreva.gif" ALT="Previous: 5.5 Locks and Oplocks" BORDER="0"></a></td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 189<A CLASS="book" HREF="index.html" TITLE=""> 190<IMG SRC="gifs/txthome.gif" ALT="" BORDER="0"></a></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 191<A CLASS="sect1" HREF="ch06_02.html" TITLE="6.2 Controlling Access to Shares"> 192<IMG SRC="gifs/txtnexta.gif" ALT="Next: 6.2 Controlling Access to Shares" BORDER="0"></a></td></tr><TR> 193<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 1945.5 Locks and Oplocks</td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 195<A CLASS="index" HREF="inx.html" TITLE="Book Index"> 196<IMG SRC="gifs/index.gif" ALT="Book Index" BORDER="0"></a></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 1976.2 Controlling Access to Shares</td></tr></table><hr noshade size=1></center> 198</div> 199 200<!-- End of sample chapter --> 201<CENTER> 202<FONT SIZE="1" FACE="Verdana, Arial, Helvetica"> 203<A HREF="http://www.oreilly.com/"> 204<B>O'Reilly Home</B></A> <B> | </B> 205<A HREF="http://www.oreilly.com/sales/bookstores"> 206<B>O'Reilly Bookstores</B></A> <B> | </B> 207<A HREF="http://www.oreilly.com/order_new/"> 208<B>How to Order</B></A> <B> | </B> 209<A HREF="http://www.oreilly.com/oreilly/contact.html"> 210<B>O'Reilly Contacts<BR></B></A> 211<A HREF="http://www.oreilly.com/international/"> 212<B>International</B></A> <B> | </B> 213<A HREF="http://www.oreilly.com/oreilly/about.html"> 214<B>About O'Reilly</B></A> <B> | </B> 215<A HREF="http://www.oreilly.com/affiliates.html"> 216<B>Affiliated Companies</B></A><p> 217<EM>© 1999, O'Reilly & Associates, Inc.</EM> 218</FONT> 219</CENTER> 220</BODY> 221</html> 222