]> arthur.barton.de Git - netatalk.git/blob - doc/manual/configuration.xml
0054a0c0328ba4f10a46e251624a8a181e0e1e65
[netatalk.git] / doc / manual / configuration.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <chapter id="configuration">
3   <title>Setting up Netatalk</title>
4
5   <sect1>
6     <title>File Services<indexterm>
7         <primary>File Services</primary>
8
9         <secondary>Netatalk's File Services</secondary>
10       </indexterm></title>
11
12     <para>Netatalk supplies AFP<indexterm>
13         <primary>AFP</primary>
14
15         <secondary>Apple Filing Protocol</secondary>
16       </indexterm> services.</para>
17
18     <sect2>
19       <title>Setting up the AFP file server</title>
20
21       <para>AFP (the Apple Filing Protocol) is the protocol Apple Macintoshes
22       use for file services. The protocol has evolved over the years. The
23       latest changes to the protocol, called "AFP 3.3", were added with the
24       release of Snow Leopard<indexterm>
25           <primary>Snow Leopard</primary>
26
27           <secondary>Mac OS X 10.6</secondary>
28         </indexterm> (Mac OS X 10.6).</para>
29
30       <para>The afpd daemon offers the fileservices to Apple clients. The only
31       configuration file is <filename>afp.conf</filename>. It uses a ini style
32       configuration syntax.</para>
33
34       <para>Mac OS X 10.5 (Leopard) added support for Time Machine backups
35       over AFP. Two new functions ensure that backups are written to spinning
36       disk, not just in the server's cache. Different host operating systems
37       honour this cache flushing differently. To make a volume a Time Machine
38       target use the volume option "<option>time machine =
39       yes</option>".</para>
40
41       <para>Starting with Netatalk 2.1 UNIX symlinks<indexterm>
42           <primary>symlink</primary>
43
44           <secondary>UNIX symlink</secondary>
45         </indexterm> can be used on the server. Semantics are the same as for
46       eg NFS, ie they are not resolved on the server side but instead it's
47       completely up to the client to resolve them, resulting in links that
48       point somewhere inside the clients filesystem view.</para>
49
50       <para>Support for <link linkend="spotlight">Spotlight</link> has been
51       added in Netatalk 3.1. See this <link
52       linkend="spotlight_compile">section</link> for information on how to
53       compile Netatalk with Spotlight support.</para>
54
55       <sect3>
56         <title>afp.conf</title>
57
58         <para><filename>afp.conf</filename> is the configuration file used by
59         afpd to determine the behaviour and configuration of the AFP file
60         serverand the AFP volume that it provides.</para>
61
62         <para>The <filename>afp.conf</filename> is divided into several
63         sections:<variablelist>
64             <varlistentry>
65               <term>[Global]</term>
66
67               <listitem>
68                 <para>The global section defines general server options</para>
69               </listitem>
70             </varlistentry>
71
72             <varlistentry>
73               <term>[Homes]</term>
74
75               <listitem>
76                 <para>The homes section defines user home volumes</para>
77               </listitem>
78             </varlistentry>
79           </variablelist>Any section not called <option>Global</option> or
80         <option>Homes</option> is interpreted as an AFP volume.</para>
81
82         <para>For sharing user homes by defining a <option>Homes</option>
83         section you must specify the option <option>basedir regex</option>
84         which can be a simple string with the path to the parent directory of
85         all user homes or a regular expression.</para>
86
87         <para>Example:</para>
88
89         <para><programlisting>[Homes]
90 basedir regex = /home
91 </programlisting></para>
92
93         <para>Now any user logging into the AFP server will have a user volume
94         available whos path is <filename>/home/NAME</filename>.</para>
95
96         <para>A more complex setup would be a server with a large amount of
97         user homes which are split across eg two different
98         filesystems:<itemizedlist>
99             <listitem>
100               <para>/RAID1/homes</para>
101             </listitem>
102
103             <listitem>
104               <para>/RAID2/morehomes</para>
105             </listitem>
106           </itemizedlist>The following configuration is
107         required:<programlisting>[Homes]
108 basedir regex = /RAID./.*homes
109 </programlisting></para>
110
111         <para>If <option>basedir regex</option> contains symlink, set the
112         canonicalized absolute path. When <filename>/home</filename> links to
113         <filename>/usr/home</filename>: <programlisting>[Homes]
114 basedir regex = /usr/home</programlisting></para>
115
116         <para>For a more detailed explanation of the available options, please
117         refer to the <citerefentry>
118             <refentrytitle>afp.conf</refentrytitle>
119
120             <manvolnum>5</manvolnum>
121           </citerefentry> man page.</para>
122       </sect3>
123     </sect2>
124
125     <sect2>
126       <title id="spotlight">Spotlight<indexterm>
127           <primary>Spotlight</primary>
128         </indexterm></title>
129
130       <para>Netatalk uses Tracker as the metadata backend. Recent Linux
131       distributions will provide the libtracker-sparql library which is
132       available since Tracker version 0.7. This version is referred to as
133       Tracker SPARQL.</para>
134
135       <para>Other system like FreeBSD, Solaris and systems derived from
136       Solaris will only ship Tracker version 0.6 which only offers a much more
137       restrcited feature set. We refer to this version as Tracker RDF. Solaris
138       users are advised to install Tracker from OpenCSW as this is at least
139       version 0.15 and thus supports SPARQL</para>
140
141       <para>To enable Spotlight put this in your afp.conf:</para>
142
143       <screen>[Global]
144 ...
145 spotlight = yes
146 ...</screen>
147
148       <para>This will enable Spotlight functionality. For Solaris with Tracker
149       from OpenCSW also add:<screen>dbus daemon = /opt/csw/bin/dbus-daemon</screen></para>
150
151       <sect3>
152         <title>Tracker SPARQL</title>
153
154         <para>Next you must enbale Spotlight indexing on a per volume
155         basis:</para>
156
157         <screen>[foo]
158 path = /bar
159 spotlight = yes
160 ...</screen>
161
162         <para>Only volumes with a setting of spotlight = yes will be
163         searchable with Spotlight.</para>
164
165         <warning>
166           <para>All other volumes won't be searchable at all</para>
167         </warning>
168       </sect3>
169
170       <sect3>
171         <title>Tracker RDF</title>
172
173         <para>Add all volume paths that should be searchable to
174         $sysconfdir/tracker/tracker.cfg:<screen>...
175 [Watches]
176 # List of directory roots to index and watch (separator=;)
177 WatchDirectoryRoots=/foo/bar;/another/volume
178 ...</screen></para>
179       </sect3>
180
181       <sect3>
182         <title>Limitations and notes</title>
183
184         <itemizedlist>
185           <listitem>
186             <para>Large filesystems</para>
187
188             <para>Tracker on Linux uses the inotify Kernel filesystem change
189             event API for tracking filesystem changes. On large filesystems
190             this may be problematic since the inotify API doesn't offer
191             recursive directory watches but instead requires that for every
192             subdirectoy watches must be added individually.</para>
193
194             <para>On Solaris the FEN file event notification system is used.
195             It is unkown which limitations and ressource consumption this
196             Solaris subsystem has,</para>
197           </listitem>
198
199           <listitem>
200             <para>Tracker RDF</para>
201
202             <para>The mapping of certain simple and of complex Spotlight to
203             Tracker RDF queries is imperfect. Also, Tracker RDF filename
204             searches are case sensitive! As a result there are two noticable
205             restrictions:</para>
206
207             <orderedlist>
208               <listitem>
209                 <para>On a Mac, a query entered in the Spotlight search menu
210                 or in a Finder search toolbar is meant to express "search any
211                 metadata field, file name or content for this string". With
212                 Netatalk and Tracker RDF only filenames will be
213                 searched.</para>
214               </listitem>
215
216               <listitem>
217                 <para>Searching files content must be done through explicitly
218                 adding a "<emphasis>Contents</emphasis> contains ..."
219                 filter.</para>
220               </listitem>
221             </orderedlist>
222
223             <screenshot>
224               <screeninfo>Case sensivity</screeninfo>
225
226               <mediaobject>
227                 <imageobject>
228                   <imagedata fileref="http://netatalk.sourceforge.net/wiki/images/2/2a/Toolbar_search_is_name_search.png" />
229                 </imageobject>
230               </mediaobject>
231             </screenshot>
232
233             <screenshot>
234               <screeninfo>Searching metadata</screeninfo>
235
236               <mediaobject>
237                 <imageobject>
238                   <imagedata fileref="http://netatalk.sourceforge.net/wiki/images/0/01/Searching_for_content.png" />
239                 </imageobject>
240               </mediaobject>
241             </screenshot>
242           </listitem>
243         </itemizedlist>
244       </sect3>
245
246       <sect3>
247         <title>Supported metadata attributes</title>
248
249         <para>The following list is the complete set of supported metadata
250         attributes in Tracker SPARQL search queries</para>
251
252         <table>
253           <title>Tracker SPARQL</title>
254
255           <tgroup cols="2">
256             <thead>
257               <row>
258                 <entry align="center">Description</entry>
259
260                 <entry align="center">Spotlight Key </entry>
261               </row>
262             </thead>
263
264             <tbody>
265               <row>
266                 <entry>Name</entry>
267
268                 <entry>kMDItemDisplayName, kMDItemFSName</entry>
269               </row>
270
271               <row>
272                 <entry>Document content (full text search)</entry>
273
274                 <entry>kMDItemTextContent</entry>
275               </row>
276
277               <row>
278                 <entry>File type</entry>
279
280                 <entry>_kMDItemGroupId, kMDItemContentTypeTree</entry>
281               </row>
282
283               <row>
284                 <entry>File modification date</entry>
285
286                 <entry>kMDItemFSContentChangeDate,
287                 kMDItemContentModificationDate,
288                 kMDItemAttributeChangeDate</entry>
289               </row>
290
291               <row>
292                 <entry>Content Creation date</entry>
293
294                 <entry>kMDItemContentCreationDate</entry>
295               </row>
296
297               <row>
298                 <entry>The author, or authors, of the contents of the
299                 file</entry>
300
301                 <entry>kMDItemAuthors, kMDItemCreator</entry>
302               </row>
303
304               <row>
305                 <entry>The name of the country where the item was
306                 created</entry>
307
308                 <entry>kMDItemCountry</entry>
309               </row>
310
311               <row>
312                 <entry>Duration</entry>
313
314                 <entry>kMDItemDurationSeconds</entry>
315               </row>
316
317               <row>
318                 <entry>Number of pages</entry>
319
320                 <entry>kMDItemNumberOfPages</entry>
321               </row>
322
323               <row>
324                 <entry>Document title</entry>
325
326                 <entry>kMDItemTitle</entry>
327               </row>
328
329               <row>
330                 <entry>The width, in pixels, of the contents. For example, the
331                 image width or the video frame width</entry>
332
333                 <entry>kMDItemPixelWidth</entry>
334               </row>
335
336               <row>
337                 <entry>The height, in pixels, of the contents. For example,
338                 the image height or the video frame height</entry>
339
340                 <entry>kMDItemPixelHeight</entry>
341               </row>
342
343               <row>
344                 <entry>The color space model used by the document
345                 contents</entry>
346
347                 <entry>kMDItemColorSpace</entry>
348               </row>
349
350               <row>
351                 <entry>The number of bits per sample</entry>
352
353                 <entry>kMDItemBitsPerSample</entry>
354               </row>
355
356               <row>
357                 <entry>Focal length of the lens, in millimeters</entry>
358
359                 <entry>kMDItemFocalLength</entry>
360               </row>
361
362               <row>
363                 <entry>ISO speed</entry>
364
365                 <entry>kMDItemISOSpeed</entry>
366               </row>
367
368               <row>
369                 <entry>Orientation of the document. Possible values are 0
370                 (landscape) and 1 (portrait)</entry>
371
372                 <entry>kMDItemOrientation</entry>
373               </row>
374
375               <row>
376                 <entry>Resolution width, in DPI</entry>
377
378                 <entry>kMDItemResolutionWidthDPI</entry>
379               </row>
380
381               <row>
382                 <entry>Resolution height, in DPI</entry>
383
384                 <entry>kMDItemResolutionHeightDPI</entry>
385               </row>
386
387               <row>
388                 <entry>Exposure time, in seconds</entry>
389
390                 <entry>kMDItemExposureTimeSeconds</entry>
391               </row>
392
393               <row>
394                 <entry>The composer of the music contained in the audio
395                 file</entry>
396
397                 <entry>kMDItemComposer</entry>
398               </row>
399
400               <row>
401                 <entry>The musical genre of the song or composition</entry>
402
403                 <entry>kMDItemMusicalGenre</entry>
404               </row>
405             </tbody>
406           </tgroup>
407         </table>
408
409         <para>The following list is the complete set of supported metadata
410         attributes in Tracker RDF search queries:<table>
411             <title>Tracker RDF</title>
412
413             <tgroup cols="2">
414               <thead>
415                 <row>
416                   <entry align="center">Description</entry>
417
418                   <entry align="center">Spotlight Key</entry>
419                 </row>
420               </thead>
421
422               <tbody>
423                 <row>
424                   <entry>Name</entry>
425
426                   <entry>kMDItemDisplayName, kMDItemFSName</entry>
427                 </row>
428
429                 <row>
430                   <entry>Document content (full text search)</entry>
431
432                   <entry>kMDItemTextContent</entry>
433                 </row>
434
435                 <row>
436                   <entry>File type</entry>
437
438                   <entry>_kMDItemGroupId, kMDItemContentTypeTree</entry>
439                 </row>
440
441                 <row>
442                   <entry>File modification date</entry>
443
444                   <entry>kMDItemFSContentChangeDate,
445                   kMDItemContentModificationDate,
446                   kMDItemAttributeChangeDate</entry>
447                 </row>
448
449                 <row>
450                   <entry>Content Creation date</entry>
451
452                   <entry>kMDItemContentCreationDate</entry>
453                 </row>
454
455                 <row>
456                   <entry>The author, or authors, of the contents of the
457                   file</entry>
458
459                   <entry>kMDItemAuthors, kMDItemCreator</entry>
460                 </row>
461
462                 <row>
463                   <entry>The name of the country where the item was
464                   created</entry>
465
466                   <entry>kMDItemCountry</entry>
467                 </row>
468
469                 <row>
470                   <entry>Duration</entry>
471
472                   <entry>kMDItemDurationSeconds</entry>
473                 </row>
474
475                 <row>
476                   <entry>Number of pages</entry>
477
478                   <entry>kMDItemNumberOfPages</entry>
479                 </row>
480
481                 <row>
482                   <entry>Document title</entry>
483
484                   <entry>kMDItemTitle</entry>
485                 </row>
486
487                 <row>
488                   <entry>The width, in pixels, of the contents. For example,
489                   the image width or the video frame width</entry>
490
491                   <entry>kMDItemPixelWidth</entry>
492                 </row>
493
494                 <row>
495                   <entry>The height, in pixels, of the contents. For example,
496                   the image height or the video frame height</entry>
497
498                   <entry>kMDItemPixelHeight</entry>
499                 </row>
500
501                 <row>
502                   <entry>Focal length of the lens, in millimeters</entry>
503
504                   <entry>kMDItemFocalLength</entry>
505                 </row>
506
507                 <row>
508                   <entry>ISO speed</entry>
509
510                   <entry>kMDItemISOSpeed</entry>
511                 </row>
512
513                 <row>
514                   <entry>Orientation of the document. Possible values are 0
515                   (landscape) and 1 (portrait)</entry>
516
517                   <entry>kMDItemOrientation</entry>
518                 </row>
519
520                 <row>
521                   <entry>Exposure time, in seconds</entry>
522
523                   <entry>kMDItemExposureTimeSeconds</entry>
524                 </row>
525
526                 <row>
527                   <entry>The musical genre of the song or composition</entry>
528
529                   <entry>kMDItemMusicalGenre</entry>
530                 </row>
531               </tbody>
532             </tgroup>
533           </table></para>
534       </sect3>
535
536       <sect3>
537         <title>Using Tracker commandline tools on the server</title>
538
539         <para>Netatalk must be running. Then setup relevant environment
540         variables, adjust the prefix /usr/local/netatalk to match your
541         configured paths:<screen>$ su
542 ****
543 # cat trackerenv.sh 
544 export DBUS_SESSION_BUS_ADDRESS="unix:path=/tmp/spotlight.ipc"
545 export XDG_DATA_HOME=/usr/local/netatalk/var/netatalk
546 export XDG_CACHE_HOME=/usr/local/netatalk/var/netatalk
547 export XDG_CONFIG_HOME=/usr/local/netatalk/etc
548 # . trackerenv.sh
549 #</screen></para>
550
551         <para>Tracker SPARQL:<screen># tracker-search QUERY
552 ...
553 # tracker-info PATH
554 ...</screen></para>
555
556         <para>Tracker RDF<screen># cat file.rdf
557 &lt;rdfq:Condition&gt;
558     &lt;rdfq:and&gt;
559         &lt;rdfq:contains&gt;
560             &lt;rdfq:Property name="File:Name" /&gt;
561             &lt;rdf:String&gt;SEARCHSTRING&lt;/rdf:String&gt;
562         &lt;/rdfq:contains&gt;
563     &lt;/rdfq:and&gt;
564 &lt;/rdfq:Condition&gt;
565 # tracker-query -p file.rdf File:Name
566 ...
567 # tracker-info -m File:Mime PATH
568 ...</screen></para>
569       </sect3>
570
571       <sect3>
572         <title>References</title>
573
574         <orderedlist>
575           <listitem>
576             <para><ulink
577             url="https://developer.apple.com/library/mac/#documentation/Carbon/Reference/MDItemRef/Reference/reference.html">MDItem</ulink></para>
578           </listitem>
579
580           <listitem>
581             <para><ulink
582             url="https://live.gnome.org/Tracker/Documentation">Tracker</ulink></para>
583           </listitem>
584         </orderedlist>
585       </sect3>
586     </sect2>
587
588     <sect2 id="CNID-backends">
589       <title>CNID<indexterm>
590           <primary>CNID</primary>
591
592           <secondary>Catalog Node ID</secondary>
593         </indexterm> backends<indexterm>
594           <primary>Backend</primary>
595
596           <secondary>CNID backend</secondary>
597         </indexterm></title>
598
599       <para>Unlike other protocols like SMB or NFS, the AFP protocol mostly
600       refers to files and directories by ID and not by a path (the IDs are
601       also called CNID, that means Catalog Node ID). A typical AFP request
602       uses a directory ID<indexterm>
603           <primary>DID</primary>
604
605           <secondary>Directory ID</secondary>
606         </indexterm> and a filename, something like <phrase>"server, please
607       open the file named 'Test' in the directory with id 167"</phrase>. For
608       example "Aliases" on the Mac basically work by ID (with a fallback to
609       the absolute path in more recent AFP clients. But this applies only to
610       Finder, not to applications).</para>
611
612       <para>Every file in an AFP volume has to have a unique file ID<indexterm>
613           <primary>FID</primary>
614
615           <secondary>File ID</secondary>
616         </indexterm>, IDs must, according to the specs, never be reused, and
617       IDs are 32 bit numbers (Directory IDs use the same ID pool). So, after
618       ~4 billion files/folders have been written to an AFP volume, the ID pool
619       is depleted and no new file can be written to the volume. No whining
620       please :-)</para>
621
622       <para>Netatalk needs to map IDs to files and folders in the host
623       filesystem. To achieve this, several different CNID backends<indexterm>
624           <primary>CNID backend</primary>
625         </indexterm> are available and can be choosed by the <option>cnid
626       scheme</option><indexterm>
627           <primary>cnidscheme</primary>
628
629           <secondary>specifying a CNID backend</secondary>
630         </indexterm> option in the <citerefentry>
631           <refentrytitle>afp.conf</refentrytitle>
632
633           <manvolnum>5</manvolnum>
634         </citerefentry> configuration file. A CNID backend is basically a
635       database storing ID &lt;-&gt; name mappings.</para>
636
637       <para>The CNID Databases are by default located in
638       <filename>/var/netatalk/CNID</filename>.</para>
639
640       <para>There is a command line utility called <command>dbd</command>
641       available which can be used to verify, repair and rebuild the CNID
642       database.</para>
643
644       <note>
645         <para>There are some CNID related things you should keep in mind when
646         working with netatalk:</para>
647
648         <itemizedlist>
649           <listitem>
650             <para>Don't nest volumes<indexterm>
651                 <primary>Nested volumes</primary>
652               </indexterm>.</para>
653           </listitem>
654
655           <listitem>
656             <para>CNID backends are databases, so they turn afpd into a file
657             server/database mix.</para>
658           </listitem>
659
660           <listitem>
661             <para>If there's no more space on the filesystem left, the
662             database will get corrupted. You can work around this by either
663             using the <option>vol dbpath</option> option and put the database
664             files into another location or, if you use quotas, make sure the
665             CNID database folder is owned by a user/group without a
666             quota<indexterm>
667                 <primary>Quotas</primary>
668
669                 <secondary>Disk usage quotas</secondary>
670               </indexterm>.</para>
671           </listitem>
672
673           <listitem>
674             <para>Be careful with CNID databases for volumes that are mounted
675             via NFS. That is a pretty audacious decision to make anyway, but
676             putting a database there as well is really asking for trouble,
677             i.e. database corruption. Use the <option>vol dbpath</option>
678             directive to put the databases onto a local disk if you must use
679             NFS<indexterm>
680                 <primary>NFS</primary>
681
682                 <secondary>Network File System</secondary>
683               </indexterm> mounted volumes.</para>
684           </listitem>
685         </itemizedlist>
686       </note>
687
688       <sect3>
689         <title>cdb<indexterm>
690             <primary>CDB</primary>
691
692             <secondary>"cdb" CNID backend</secondary>
693           </indexterm></title>
694
695         <para>The "concurrent database" backend is based on Berkeley DB. With
696         this backend, several afpd daemons access the CNID database directly.
697         Berkeley DB locking is used to synchronize access, if more than one
698         afpd process is active for a volume. The drawback is, that the crash
699         of a single afpd process might corrupt the database. cdb should only
700         be used when sharing home directories for a larger number of users
701         <emphasis>and</emphasis> it has been determined that a large number of
702         <command>cnid_dbd</command> processes is problematic.</para>
703       </sect3>
704
705       <sect3>
706         <title>dbd<indexterm>
707             <primary>DBD</primary>
708
709             <secondary>"dbd" CNID backend</secondary>
710           </indexterm></title>
711
712         <para>Access to the CNID database is restricted to the cnid_dbd daemon
713         process. afpd processes communicate with the daemon for database reads
714         and updates. The probability for database corruption is practically
715         zero.</para>
716
717         <para>This is the default backend since Netatalk 2.1.</para>
718       </sect3>
719
720       <sect3>
721         <title>tdb<indexterm>
722             <primary>tdb</primary>
723
724             <secondary>"tdb" CNID backend</secondary>
725           </indexterm></title>
726
727         <para><abbrev>tdb</abbrev> is another persistent CNID database, it's
728         Samba's <emphasis>Trivial Database</emphasis>. It could be used
729         instead of <abbrev>cdb</abbrev> for user volumes.<important>
730             <para>Only ever use it for volumes that are
731             <emphasis>not</emphasis> shared and accessed by multiple clients
732             at once !</para>
733           </important>This backend is also used internally (as in-memory CNID
734         database) as a fallback in case opening the primary database can't be
735         opened, because <abbrev>tdb</abbrev> can work as in-memory database.
736         This of course means upon restart the CNIDs are gone.</para>
737       </sect3>
738
739       <sect3>
740         <title>last<indexterm>
741             <primary>Last</primary>
742
743             <secondary>"last" CNID backend</secondary>
744           </indexterm></title>
745
746         <para>The last backend is a in-memory tdb database. It is not
747         persistent. Starting with netatalk 3.0, it becomes the <emphasis> read
748         only mode</emphasis> automatically. This is useful e.g. for
749         CD-ROMs.</para>
750       </sect3>
751     </sect2>
752
753     <sect2 id="charsets">
754       <title>Charsets<indexterm>
755           <primary>Charset</primary>
756
757           <secondary>character set</secondary>
758         </indexterm>/Unicode<indexterm>
759           <primary>Unicode</primary>
760         </indexterm></title>
761
762       <para></para>
763
764       <sect3>
765         <title>Why Unicode?</title>
766
767         <para>Internally, computers don't know anything about characters and
768         texts, they only know numbers. Therefore, each letter is assigned a
769         number. A character set, often referred to as
770         <emphasis>charset</emphasis> or
771         <emphasis>codepage</emphasis><indexterm>
772             <primary>Codepage</primary>
773           </indexterm>, defines the mappings between numbers and
774         letters.</para>
775
776         <para>If two or more computer systems need to communicate with each
777         other, the have to use the same character set. In the 1960s the
778         ASCII<indexterm>
779             <primary>ASCII</primary>
780
781             <secondary>American Standard Code for Information
782             Interchange</secondary>
783           </indexterm> (American Standard Code for Information Interchange)
784         character set was defined by the American Standards Association. The
785         original form of ASCII represented 128 characters, more than enough to
786         cover the English alphabet and numerals. Up to date, ASCII has been
787         the normative character scheme used by computers.</para>
788
789         <para>Later versions defined 256 characters to produce a more
790         international fluency and to include some slightly esoteric graphical
791         characters. Using this mode of encoding each character takes exactly
792         one byte. Obviously, 256 characters still wasn't enough to map all the
793         characters used in the various languages into one character
794         set.</para>
795
796         <para>As a result localized character sets were defined later, e.g the
797         ISO-8859 character sets. Most operating system vendors introduced
798         their own characters sets to satisfy their needs, e.g. IBM defined the
799         <emphasis>codepage 437 (DOSLatinUS)</emphasis>, Apple introduced the
800         <emphasis>MacRoman</emphasis><indexterm>
801             <primary>MacRoman</primary>
802
803             <secondary>MacRoman charset</secondary>
804           </indexterm> codepage and so on. The characters that were assigned
805         number larger than 127 were referred to as
806         <emphasis>extended</emphasis> characters. These character sets
807         conflict with another, as they use the same number for different
808         characters, or vice versa.</para>
809
810         <para>Almost all of those characters sets defined 256 characters,
811         where the first 128 (0-127) character mappings are identical to ASCII.
812         As a result, communication between systems using different codepages
813         was effectively limited to the ASCII charset.</para>
814
815         <para>To solve this problem new, larger character sets were defined.
816         To make room for more character mappings, these character sets use at
817         least 2 bytes to store a character. They are therefore referred to as
818         <emphasis>multibyte</emphasis> character sets.</para>
819
820         <para>One standardized multibyte charset encoding scheme is known as
821         <ulink url="http://www.unicode.org/">unicode</ulink>. A big advantage
822         of using a multibyte charset is that you only need one. There is no
823         need to make sure two computers use the same charset when they are
824         communicating.</para>
825       </sect3>
826
827       <sect3>
828         <title>character sets used by Apple</title>
829
830         <para>In the past, Apple clients used single-byte charsets to
831         communicate over the network. Over the years Apple defined a number of
832         codepages, western users will most likely be using the
833         <emphasis>MacRoman</emphasis> codepage.</para>
834
835         <para>Codepages defined by Apple include:</para>
836
837         <itemizedlist>
838           <listitem>
839             <para>MacArabic, MacFarsi</para>
840           </listitem>
841
842           <listitem>
843             <para>MacCentralEurope</para>
844           </listitem>
845
846           <listitem>
847             <para>MacChineseSimple</para>
848           </listitem>
849
850           <listitem>
851             <para>MacChineseTraditional</para>
852           </listitem>
853
854           <listitem>
855             <para>MacCroation</para>
856           </listitem>
857
858           <listitem>
859             <para>MacCyrillic</para>
860           </listitem>
861
862           <listitem>
863             <para>MacDevanagari</para>
864           </listitem>
865
866           <listitem>
867             <para>MacGreek</para>
868           </listitem>
869
870           <listitem>
871             <para>MacHebrew</para>
872           </listitem>
873
874           <listitem>
875             <para>MacIcelandic</para>
876           </listitem>
877
878           <listitem>
879             <para>MacJapanese</para>
880           </listitem>
881
882           <listitem>
883             <para>MacKorean</para>
884           </listitem>
885
886           <listitem>
887             <para>MacRoman</para>
888           </listitem>
889
890           <listitem>
891             <para>MacRomanian</para>
892           </listitem>
893
894           <listitem>
895             <para>MacThai</para>
896           </listitem>
897
898           <listitem>
899             <para>MacTurkish</para>
900           </listitem>
901         </itemizedlist>
902
903         <para>Starting with Mac OS X and AFP3, <ulink
904         url="http://www.utf-8.com/">UTF-8</ulink> is used. UTF-8 encodes
905         Unicode characters in an ASCII compatible way, each Unicode character
906         is encoded into 1-6 ASCII characters. UTF-8 is therefore not really a
907         charset itself, it's an encoding of the Unicode charset.</para>
908
909         <para>To complicate things, Unicode defines several <emphasis> <ulink
910         url="http://www.unicode.org/reports/tr15/index.html">normalization</ulink>
911         </emphasis> forms. While <ulink
912         url="http://www.samba.org">samba</ulink><indexterm>
913             <primary>Samba</primary>
914           </indexterm> uses <emphasis>precomposed</emphasis><indexterm>
915             <primary>Precomposed</primary>
916
917             <secondary>Precomposed Unicode normalization</secondary>
918           </indexterm> Unicode, which most Unix tools prefer as well, Apple
919         decided to use the <emphasis>decomposed</emphasis><indexterm>
920             <primary>Decomposed</primary>
921
922             <secondary>Decomposed Unicode normalization</secondary>
923           </indexterm> normalization.</para>
924
925         <para>For example lets take the German character
926         '<keycode>ä</keycode>'. Using the precomposed normalization, Unicode
927         maps this character to 0xE4. In decomposed normalization, 'ä' is
928         actually mapped to two characters, 0x61 and 0x308. 0x61 is the mapping
929         for an 'a', 0x308 is the mapping for a <emphasis>COMBINING
930         DIAERESIS</emphasis>.</para>
931
932         <para>Netatalk refers to precomposed UTF-8 as
933         <emphasis>UTF8</emphasis><indexterm>
934             <primary>UTF8</primary>
935
936             <secondary>Netatalk's precomposed UTF-8 encoding</secondary>
937           </indexterm> and to decomposed UTF-8 as
938         <emphasis>UTF8-MAC</emphasis><indexterm>
939             <primary>UTF8-MAC</primary>
940
941             <secondary>Netatalk's decomposed UTF-8 encoding</secondary>
942           </indexterm>.</para>
943       </sect3>
944
945       <sect3>
946         <title>afpd and character sets</title>
947
948         <para>To support new AFP 3.x and older AFP 2.x clients at the same
949         time, afpd needs to be able to convert between the various charsets
950         used. AFP 3.x clients always use UTF8-MAC, AFP 2.x clients use one of
951         the Apple codepages.</para>
952
953         <para>At the time of this writing, netatalk supports the following
954         Apple codepages:</para>
955
956         <itemizedlist>
957           <listitem>
958             <para>MAC_CENTRALEUROPE</para>
959           </listitem>
960
961           <listitem>
962             <para>MAC_CHINESE_SIMP</para>
963           </listitem>
964
965           <listitem>
966             <para>MAC_CHINESE_TRAD</para>
967           </listitem>
968
969           <listitem>
970             <para>MAC_CYRILLIC</para>
971           </listitem>
972
973           <listitem>
974             <para>MAC_GREEK</para>
975           </listitem>
976
977           <listitem>
978             <para>MAC_HEBREW</para>
979           </listitem>
980
981           <listitem>
982             <para>MAC_JAPANESE</para>
983           </listitem>
984
985           <listitem>
986             <para>MAC_KOREAN</para>
987           </listitem>
988
989           <listitem>
990             <para>MAC_ROMAN</para>
991           </listitem>
992
993           <listitem>
994             <para>MAC_TURKISH</para>
995           </listitem>
996         </itemizedlist>
997
998         <para>afpd handles three different character set options:</para>
999
1000         <variablelist>
1001           <varlistentry>
1002             <term>unix charset<indexterm>
1003                 <primary>unix charset</primary>
1004
1005                 <secondary>afpd's unix charset setting</secondary>
1006               </indexterm></term>
1007
1008             <listitem>
1009               <para>This is the codepage used internally by your operating
1010               system. If not specified, it defaults to <option>UTF8</option>.
1011               If <option>LOCALE</option> is specified and your system support
1012               Unix locales, afpd tries to detect the codepage. afpd uses this
1013               codepage to read its configuration files, so you can use
1014               extended characters for volume names, login messages, etc. see
1015               <citerefentry>
1016                   <refentrytitle>afp.conf</refentrytitle>
1017
1018                   <manvolnum>5</manvolnum>
1019                 </citerefentry>.</para>
1020             </listitem>
1021           </varlistentry>
1022
1023           <varlistentry>
1024             <term>mac charset<indexterm>
1025                 <primary>mac charset</primary>
1026
1027                 <secondary>afpd's mac charset setting</secondary>
1028               </indexterm></term>
1029
1030             <listitem>
1031               <para>As already mentioned, older Mac OS clients (up to AFP 2.2)
1032               use codepages to communicate with afpd. However, there is no
1033               support for negotiating the codepage used by the client in the
1034               AFP protocol. If not specified otherwise, afpd assumes the
1035               <emphasis>MacRoman</emphasis> codepage is used. In case you're
1036               clients use another codepage, e.g.
1037               <emphasis>MacCyrillic</emphasis>, you'll <emphasis
1038               role="bold">have</emphasis> to explicitly configure this. see
1039               <citerefentry>
1040                   <refentrytitle>afp.conf</refentrytitle>
1041
1042                   <manvolnum>5</manvolnum>
1043                 </citerefentry>.</para>
1044             </listitem>
1045           </varlistentry>
1046
1047           <varlistentry>
1048             <term>vol charset<indexterm>
1049                 <primary>vol charset</primary>
1050
1051                 <secondary>afpd's vol charset setting</secondary>
1052               </indexterm></term>
1053
1054             <listitem>
1055               <para>This defines the charset afpd should use for filenames on
1056               disk. By default, it is the same as <option>unix
1057               charset</option>. If you have <ulink
1058               url="http://www.gnu.org/software/libiconv/">iconv</ulink><indexterm>
1059                   <primary>Iconv</primary>
1060
1061                   <secondary>iconv encoding conversion engine</secondary>
1062                 </indexterm> installed, you can use any iconv provided charset
1063               as well.</para>
1064
1065               <para>afpd needs a way to preserve extended macintosh
1066               characters, or characters illegal in unix filenames, when saving
1067               files on a unix filesystem. Earlier versions used the the so
1068               called CAP encoding<indexterm>
1069                   <primary>CAP encoding</primary>
1070
1071                   <secondary>CAP style character encoding</secondary>
1072                 </indexterm>. An extended character (&gt;0x7F) would be
1073               converted to a :xx hex sequence, e.g. the Apple Logo (MacRoman:
1074               0xF0) was saved as :f0. Some special characters will be
1075               converted as to :xx notation as well. '/' will be encoded to
1076               :2f, if <option>usedots</option> was not specified, a leading
1077               dot '.' will be encoded as :2e.</para>
1078
1079               <para>Even though this version now uses <option>UTF8</option> as
1080               the default encoding for filenames, '/' will be converted to
1081               ':'. For western users another useful setting could be
1082               <option>vol charset = ISO-8859-15</option>.</para>
1083
1084               <para>If a character cannot be converted from the <option>mac
1085               charset</option> to the selected <option>vol charset</option>,
1086               afpd will save it as a CAP encoded character. For AFP3 clients,
1087               afpd will convert the UTF8 character to <option>mac
1088               charset</option> first. If this conversion fails, you'll receive
1089               a -50 error on the mac. <emphasis>Note</emphasis>: Whenever you
1090               can, please stick with the default UTF8 volume format. see
1091               <citerefentry>
1092                   <refentrytitle>afp.conf</refentrytitle>
1093
1094                   <manvolnum>5</manvolnum>
1095                 </citerefentry>.</para>
1096             </listitem>
1097           </varlistentry>
1098         </variablelist>
1099       </sect3>
1100     </sect2>
1101
1102     <sect2 id="authentication">
1103       <title>Authentication<indexterm>
1104           <primary>Authentication</primary>
1105
1106           <secondary>between AFP client and server</secondary>
1107         </indexterm></title>
1108
1109       <sect3>
1110         <title>AFP authentication basics</title>
1111
1112         <para>Apple chose a flexible model called "User Authentication
1113         Modules"<indexterm>
1114             <primary>UAM</primary>
1115
1116             <secondary>User Authentication Module</secondary>
1117           </indexterm> (UAMs) for authentication purposes between AFP client
1118         and server. An AFP client initially connecting to an AFP server will
1119         ask for the list of UAMs which the server provides, and will choose
1120         the one with strongest encryption that the client supports.</para>
1121
1122         <para>Several UAMs have been developed by Apple over the time, some by
1123         3rd-party developers.</para>
1124       </sect3>
1125
1126       <sect3>
1127         <title>UAMs supported by Netatalk</title>
1128
1129         <para>Netatalk supports the following ones by default:</para>
1130
1131         <itemizedlist>
1132           <listitem>
1133             <para>"No User Authent"<indexterm>
1134                 <primary>No User Authent</primary>
1135
1136                 <secondary>"No User Authent" UAM (guest access)</secondary>
1137               </indexterm> UAM (guest access without authentication)</para>
1138           </listitem>
1139
1140           <listitem>
1141             <para>"Cleartxt Passwrd"<indexterm>
1142                 <primary>Cleartxt Passwrd</primary>
1143
1144                 <secondary>"Cleartxt Passwrd" UAM</secondary>
1145               </indexterm> UAM (no password encryption)</para>
1146           </listitem>
1147
1148           <listitem>
1149             <para>"Randnum exchange"<indexterm>
1150                 <primary>Randnum exchange</primary>
1151
1152                 <secondary>"Randnum exchange" UAM</secondary>
1153               </indexterm>/"2-Way Randnum exchange"<indexterm>
1154                 <primary>2-Way Randnum exchange</primary>
1155
1156                 <secondary>"2-Way Randnum exchange" UAM</secondary>
1157               </indexterm> UAMs (weak password encryption, separate password
1158             storage)</para>
1159           </listitem>
1160
1161           <listitem>
1162             <para>"DHCAST128"<indexterm>
1163                 <primary>DHCAST128</primary>
1164
1165                 <secondary>"DHCAST128" UAM</secondary>
1166               </indexterm> UAM (stronger password encryption)</para>
1167           </listitem>
1168
1169           <listitem>
1170             <para>"DHX2"<indexterm>
1171                 <primary>DHX2</primary>
1172
1173                 <secondary>"DHX2" UAM</secondary>
1174               </indexterm> UAM (successor of DHCAST128)</para>
1175           </listitem>
1176         </itemizedlist>
1177
1178         <para>There exist other optional UAMs as well:</para>
1179
1180         <itemizedlist>
1181           <listitem>
1182             <para>"PGPuam 1.0"<indexterm>
1183                 <primary>PGPuam 1.0</primary>
1184
1185                 <secondary>"PGPuam 1.0" UAM</secondary>
1186               </indexterm><indexterm>
1187                 <primary>uams_pgp.so</primary>
1188
1189                 <secondary>"PGPuam 1.0" UAM</secondary>
1190               </indexterm> UAM (PGP-based authentication for pre-Mac OS X
1191             clients. You'll also need the <ulink
1192             url="http://www.vmeng.com/vinnie/papers/pgpuam.html">PGPuam
1193             client</ulink> to let this work)</para>
1194
1195             <para>You'll have to add <filename>"--enable-pgp-uam"</filename>
1196             to your configure switches to have this UAM available.</para>
1197           </listitem>
1198
1199           <listitem>
1200             <para>"Kerberos IV"<indexterm>
1201                 <primary>Kerberos IV</primary>
1202
1203                 <secondary>"Kerberos IV" UAM</secondary>
1204               </indexterm><indexterm>
1205                 <primary>uams_krb4.so</primary>
1206
1207                 <secondary>"Kerberos IV" UAM</secondary>
1208               </indexterm>/"AFS Kerberos"<indexterm>
1209                 <primary>AFS Kerberos</primary>
1210
1211                 <secondary>"AFS Kerberos" UAM (Kerberos IV)</secondary>
1212               </indexterm> UAMs (suitable to use <ulink
1213             url="http://web.mit.edu/macdev/KfM/Common/Documentation/faq.html">Kerberos
1214             v4 based authentication</ulink> and AFS file servers)</para>
1215
1216             <para>Use <filename>"--enable-krb4-uam"</filename> at compile time
1217             to activate the build of this UAM.</para>
1218           </listitem>
1219
1220           <listitem>
1221             <para>"Client Krb v2"<indexterm>
1222                 <primary>Client Krb v2</primary>
1223
1224                 <secondary>"Client Krb v2" UAM (Kerberos V)</secondary>
1225               </indexterm> UAM (Kerberos V, suitable for "Single Sign On"
1226             Scenarios with OS X clients -- see below)</para>
1227
1228             <para><filename>"--enable-krbV-uam"</filename> will provide you
1229             with the ability to use this UAM.</para>
1230           </listitem>
1231         </itemizedlist>
1232
1233         <para>You can configure which UAMs should be activated by defining
1234         "<option>uam list</option>" in <option>Global</option> section.
1235         <command>afpd</command> will log which UAMs it's using and if problems
1236         occur while activating them in either
1237         <filename>netatalk.log</filename> or syslog at startup time.
1238         <citerefentry>
1239             <refentrytitle>asip-status.pl</refentrytitle>
1240
1241             <manvolnum>1</manvolnum>
1242           </citerefentry> can be used to query the available UAMs of AFP
1243         servers as well.</para>
1244
1245         <para>Having a specific UAM available at the server does not
1246         automatically mean that a client can use it. Client-side support is
1247         also necessary. For older Macintoshes running Mac OS &lt; X DHCAST128
1248         support exists since AppleShare client 3.8.x.</para>
1249
1250         <para>On OS X, there exist some client-side techniques to make the
1251         AFP-client more verbose, so one can have a look what's happening while
1252         negotiating the UAMs to use. Compare with this <ulink
1253         url="http://article.gmane.org/gmane.network.netatalk.devel/7383/">hint</ulink>.</para>
1254       </sect3>
1255
1256       <sect3>
1257         <title>Which UAMs to activate?</title>
1258
1259         <para>It depends primarily on your needs and on the kind of Mac OS
1260         versions you have to support. Basically one should try to use
1261         DHCAST128 and DHX2 where possible because of its strength of password
1262         encryption.</para>
1263
1264         <itemizedlist>
1265           <listitem>
1266             <para>Unless you really have to supply guest access to your
1267             server's volumes ensure that you disable "No User Authent" since
1268             it might lead accidentally to unauthorized access. In case you
1269             must enable guest access take care that you enforce this on a per
1270             volume base using the access controls.</para>
1271           </listitem>
1272
1273           <listitem>
1274             <para>The "ClearTxt Passwrd" UAM is as bad as it sounds since
1275             passwords go unencrypted over the wire. Try to avoid it at both
1276             the server's side as well as on the client's. Note: If you want to
1277             provide Mac OS 8/9 clients with NetBoot-services then you need
1278             uams_cleartext.so since the AFP-client integrated into the Mac's
1279             firmware can only deal with this basic form of
1280             authentication.</para>
1281           </listitem>
1282
1283           <listitem>
1284             <para>Since "Randnum exchange"/"2-Way Randnum exchange" uses only
1285             56 bit DES for encryption it should be avoided as well. Another
1286             disadvantage is the fact that the passwords have to be stored in
1287             cleartext on the server and that it doesn't integrate into both
1288             PAM scenarios or classic /etc/shadow (you have to administrate
1289             passwords separately by using the <citerefentry>
1290                 <refentrytitle>afppasswd</refentrytitle>
1291
1292                 <manvolnum>1</manvolnum>
1293               </citerefentry> utility, if clients should use these
1294             UAMs)</para>
1295           </listitem>
1296
1297           <listitem>
1298             <para>"DHCAST128" or "DHX2" should be a good compromise for most
1299             people since it combines stronger encryption with PAM
1300             integration.</para>
1301           </listitem>
1302
1303           <listitem>
1304             <para>Using the Kerberos V<indexterm>
1305                 <primary>Kerberos V</primary>
1306
1307                 <secondary>"Client Krb v2" UAM</secondary>
1308               </indexterm> ("Client Krb v2") UAM, it's possible to implement
1309             real single sign on scenarios using Kerberos tickets. The password
1310             is not sent over the network. Instead, the user password is used
1311             to decrypt a service ticket for the appleshare server. The service
1312             ticket contains an encryption key for the client and some
1313             encrypted data (which only the appleshare server can decrypt). The
1314             encrypted portion of the service ticket is sent to the server and
1315             used to authenticate the user. Because of the way that the afpd
1316             service principal detection is implemented, this authentication
1317             method is vulnerable to man-in-the-middle attacks.</para>
1318           </listitem>
1319         </itemizedlist>
1320
1321         <para>For a more detailed overview over the technical implications of
1322         the different UAMs, please have a look at Apple's <ulink
1323         url="http://developer.apple.com/library/mac/#documentation/Networking/Conceptual/AFP/AFPSecurity/AFPSecurity.html#//apple_ref/doc/uid/TP40000854-CH232-SW1">File
1324         Server Security</ulink> pages.</para>
1325       </sect3>
1326
1327       <sect3>
1328         <title>Using different authentication sources with specific
1329         UAMs</title>
1330
1331         <para>Some UAMs provide the ability to use different authentication
1332         "backends", namely <filename>uams_cleartext.so</filename>,
1333         <filename>uams_dhx.so</filename> and
1334         <filename>uams_dhx2.so</filename>. They can use either classic Unix
1335         passwords from <filename>/etc/passwd</filename>
1336         (<filename>/etc/shadow</filename>) or PAM if the system supports that.
1337         <filename>uams_cleartext.so</filename> can be symlinked to either
1338         <filename>uams_passwd.so</filename> or
1339         <filename>uams_pam.so</filename>, <filename>uams_dhx.so</filename> to
1340         <filename>uams_dhx_passwd.so</filename> or
1341         <filename>uams_dhx_pam.so</filename> and
1342         <filename>uams_dhx2.so</filename> to
1343         <filename>uams_dhx2_passwd.so</filename> or
1344         <filename>uams_dhx2_pam.so</filename>.</para>
1345
1346         <para>So, if it looks like this in Netatalk's UAMs folder (per default
1347         <filename>/etc/netatalk/uams/</filename>):<programlisting>uams_clrtxt.so -&gt; uams_pam.so
1348 uams_dhx.so -&gt; uams_dhx_pam.so
1349 uams_dhx2.so -&gt; uams_dhx2_pam.so</programlisting> then you're using PAM,
1350         otherwise classic Unix passwords. The main advantage of using PAM is
1351         that one can integrate Netatalk in centralized authentication
1352         scenarios, eg. via LDAP, NIS and the like. Please always keep in mind
1353         that the protection of your user's login credentials in such scenarios
1354         also depends on the strength of encryption that the UAM in question
1355         supplies. So think about eliminating weak UAMs like "ClearTxt Passwrd"
1356         and "Randnum exchange" completely from your network.</para>
1357       </sect3>
1358
1359       <sect3>
1360         <title>Netatalk UAM overview table</title>
1361
1362         <para>A small overview of the most common used UAMs.</para>
1363
1364         <table orient="land">
1365           <title>Netatalk UAM overview</title>
1366
1367           <tgroup align="center" cols="7">
1368             <colspec colname="col1" colnum="1" colwidth="0.5*" />
1369
1370             <colspec colname="uam_guest" colnum="2" colwidth="1*" />
1371
1372             <colspec colname="uam_clrtxt" colnum="3" colwidth="1*" />
1373
1374             <colspec colname="uam_randnum" colnum="4" colwidth="1*" />
1375
1376             <colspec colname="uam_dhx" colnum="5" colwidth="1*" />
1377
1378             <colspec colname="uam_dhx2" colnum="6" colwidth="1*" />
1379
1380             <colspec colname="uam_gss" colnum="7" colwidth="1*" />
1381
1382             <tbody>
1383               <row>
1384                 <entry align="center" rotate="0" valign="middle">UAM</entry>
1385
1386                 <entry>No User Authent<indexterm>
1387                     <primary>uams_guest.so</primary>
1388
1389                     <secondary>"No User Authent" UAM (guest
1390                     access)</secondary>
1391                   </indexterm></entry>
1392
1393                 <entry>Cleartxt Passwrd<indexterm>
1394                     <primary>uams_cleartxt.so</primary>
1395
1396                     <secondary>"Cleartxt Passwrd" UAM</secondary>
1397                   </indexterm></entry>
1398
1399                 <entry>(2-Way) Randnum exchange<indexterm>
1400                     <primary>uams_randnum.so</primary>
1401
1402                     <secondary>"(2-Way) Randnum exchange" UAM</secondary>
1403                   </indexterm></entry>
1404
1405                 <entry>DHCAST128<indexterm>
1406                     <primary>uams_dhx.so</primary>
1407
1408                     <secondary>"DHCAST128" UAM</secondary>
1409                   </indexterm></entry>
1410
1411                 <entry>DHX2<indexterm>
1412                     <primary>uams_dhx2.so</primary>
1413
1414                     <secondary>"DHX2" UAM</secondary>
1415                   </indexterm></entry>
1416
1417                 <entry>Client Krb v2<indexterm>
1418                     <primary>uams_gss.so</primary>
1419
1420                     <secondary>"Client Krb v2" UAM (Kerberos V)</secondary>
1421                   </indexterm></entry>
1422               </row>
1423
1424               <row>
1425                 <entry align="center" rotate="0" valign="middle">pssword
1426                 length</entry>
1427
1428                 <entry>guest access</entry>
1429
1430                 <entry>max. 8 characters</entry>
1431
1432                 <entry>max. 8 characters</entry>
1433
1434                 <entry>max. 64 characters</entry>
1435
1436                 <entry>max. 256 characters</entry>
1437
1438                 <entry>Kerberos tickets</entry>
1439               </row>
1440
1441               <row>
1442                 <entry align="center" rotate="0" valign="middle">Client
1443                 support</entry>
1444
1445                 <entry>built-in into all Mac OS versions</entry>
1446
1447                 <entry>built-in in all Mac OS versions except 10.0. Has to be
1448                 activated explicitly in recent Mac OS X versions</entry>
1449
1450                 <entry>built-in into almost all Mac OS versions</entry>
1451
1452                 <entry>built-in since AppleShare client 3.8.4, available as a
1453                 plug-in for 3.8.3, integrated in Mac OS X' AFP client</entry>
1454
1455                 <entry>built-in since Mac OS X 10.2</entry>
1456
1457                 <entry>built-in since Mac OS X 10.2</entry>
1458               </row>
1459
1460               <row>
1461                 <entry align="center" rotate="0"
1462                 valign="middle">Encryption</entry>
1463
1464                 <entry>Enables guest access without authentication between
1465                 client and server.</entry>
1466
1467                 <entry>Password will be sent in cleartext over the wire. Just
1468                 as bad as it sounds, therefore avoid at all if possible (note:
1469                 providing NetBoot services requires the ClearTxt UAM)</entry>
1470
1471                 <entry>8-byte random numbers are sent over the wire,
1472                 comparable with DES, 56 bits. Vulnerable to offline dictionary
1473                 attack. Requires passwords in clear on the server.</entry>
1474
1475                 <entry>Password will be encrypted with 128 bit SSL, user will
1476                 be authenticated against the server but not vice versa.
1477                 Therefor weak against man-in-the-middle attacks.</entry>
1478
1479                 <entry>Password will be encrypted using libgcrypt with CAST
1480                 128 in CBC mode. User will be authenticated against the server
1481                 but not vice versa. Therefor weak against man-in-the-middle
1482                 attacks.</entry>
1483
1484                 <entry>Password is not sent over the network. Due to the
1485                 service principal detection method, this authentication method
1486                 is vulnerable to man-in-the-middle attacks.</entry>
1487               </row>
1488
1489               <row>
1490                 <entry align="center" rotate="0" valign="middle">Server
1491                 support</entry>
1492
1493                 <entry align="center" valign="middle">uams_guest.so</entry>
1494
1495                 <entry align="center" valign="middle">uams_cleartxt.so</entry>
1496
1497                 <entry align="center" valign="middle">uams_randnum.so</entry>
1498
1499                 <entry align="center" valign="middle">uams_dhx.so</entry>
1500
1501                 <entry align="center" valign="middle">uams_dhx2.so</entry>
1502
1503                 <entry align="center" valign="middle">uams_gss.so</entry>
1504               </row>
1505
1506               <row>
1507                 <entry align="center" rotate="0" valign="middle">Password
1508                 storage method</entry>
1509
1510                 <entry align="center" valign="middle">None</entry>
1511
1512                 <entry align="center" valign="middle">Either /etc/passwd
1513                 (/etc/shadow) or PAM</entry>
1514
1515                 <entry align="center" valign="middle">Passwords stored in
1516                 clear text in a separate text file</entry>
1517
1518                 <entry align="center" valign="middle">Either /etc/passwd
1519                 (/etc/shadow) or PAM</entry>
1520
1521                 <entry align="center" valign="middle">Either /etc/passwd
1522                 (/etc/shadow) or PAM</entry>
1523
1524                 <entry align="center" valign="middle">At the Kerberos Key
1525                 Distribution Center*</entry>
1526               </row>
1527             </tbody>
1528           </tgroup>
1529         </table>
1530
1531         <para>* Have a look at this <ulink
1532         url="http://cryptnet.net/fdp/admin/kerby-infra/en/kerby-infra.html">Kerberos
1533         overview</ulink></para>
1534       </sect3>
1535
1536       <sect3 id="sshtunnel">
1537         <title>SSH tunneling</title>
1538
1539         <para>Tunneling and all sort of VPN stuff has nothing to do with AFP
1540         authentication and UAMs in general. But since Apple introduced an
1541         option called "Allow Secure Connections Using SSH" and many people
1542         tend to confuse both things, we'll speak about that here too.</para>
1543
1544         <sect4 id="manualsshtunnel">
1545           <title>Manually tunneling an AFP session</title>
1546
1547           <para>This works since the first AFP servers that spoke "AFP over
1548           TCP" appeared in networks. One simply tunnels the remote server's
1549           AFP port to a local port different than 548 and connects locally to
1550           this port afterwards. On OS X this can be done by</para>
1551
1552           <programlisting>ssh -l $USER $SERVER -L 10548:127.0.0.1:548 sleep 3000</programlisting>
1553
1554           <para>After establishing the tunnel one will use
1555           <filename>"afp://127.0.0.1:10548"</filename> in the "Connect to
1556           server" dialog. All AFP traffic including the initial connection
1557           attempts will be sent encrypted over the wire since the local AFP
1558           client will connect to the Mac's local port 10548 which will be
1559           forwarded to the remote server's AFP port (we used the default 548)
1560           over SSH.</para>
1561
1562           <para>These sorts of tunnels are an ideal solution if you've to
1563           access an AFP server providing weak authentications mechanisms
1564           through the Internet without having the ability to use a "real" VPN.
1565           Note that you can let <command>ssh</command> compress the data by
1566           using its "-C" switch and that the tunnel endpoints can be different
1567           from both AFP client and server (compare with the SSH documentation
1568           for details).</para>
1569         </sect4>
1570
1571         <sect4 id="autosshtunnel">
1572           <title>Automatically establishing a tunneled AFP connection</title>
1573
1574           <para>From Mac OS X 10.2 to 10.4, Apple added an "Allow Secure
1575           Connections Using SSH" checkbox to the "Connect to Server" dialog.
1576           The idea behind: When the server signals that it can be contacted by
1577           SSH then Mac OS X' AFP client tries to establish the tunnel and
1578           automagically sends all AFP traffic through it.</para>
1579
1580           <para>But it took until the release of Mac OS X 10.3 that this
1581           feature worked the first time... partly. In case, the SSH tunnel
1582           can't be established the AFP client <emphasis
1583           role="strong">silently</emphasis> fell back to an unencrypted AFP
1584           connection attempt.</para>
1585
1586           <para>Netatalk's afpd will report that it is capable of handling SSH
1587           tunneled AFP requests, when both "<option>advertise ssh</option>"
1588           and "<option>fqdn</option>" options are set in
1589           <option>Global</option> section (double check with <citerefentry>
1590               <refentrytitle>asip-status.pl</refentrytitle>
1591
1592               <manvolnum>1</manvolnum>
1593             </citerefentry> after you restarted afpd when you made changes to
1594           the settings). But there are a couple of reasons why you don't want
1595           to use this option at all:</para>
1596
1597           <itemizedlist>
1598             <listitem>
1599               <para>Tunneling TCP over TCP (as SSH does) is not the best idea.
1600               There exist better solutions like VPNs based on the IP
1601               layer.</para>
1602             </listitem>
1603
1604             <listitem>
1605               <para>Since this SSH kludge isn't a normal UAM that integrates
1606               directly into the AFP authentication mechanisms but instead uses
1607               a single flag signalling clients whether they can <emphasis
1608               role="strong">try</emphasis> to establish a tunnel or not, it
1609               makes life harder to see what's happening when things go
1610               wrong.</para>
1611             </listitem>
1612
1613             <listitem>
1614               <para>You cannot control which machines are logged on by
1615               Netatalk tools like a <command>macusers</command> since all
1616               connection attempts seem to be made from localhost.</para>
1617             </listitem>
1618
1619             <listitem>
1620               <para>On the other side you've to limit access to afpd to
1621               localhost only (TCP wrappers) when you want to ensure that all
1622               AFP sessions are SSH encrypted or...</para>
1623             </listitem>
1624
1625             <listitem>
1626               <para>...when you're using 10.2 - 10.3.3 then you get the
1627               opposite of what you'd expect: potentially unencrypted AFP
1628               communication (including logon credentials) on the network
1629               without a single notification that establishing the tunnel
1630               failed. Apple fixed that not until Mac OS X 10.3.4.</para>
1631             </listitem>
1632
1633             <listitem>
1634               <para>Encrypting all AFP sessions via SSH can lead to a
1635               significantly higher load on the Netatalk server</para>
1636             </listitem>
1637           </itemizedlist>
1638         </sect4>
1639       </sect3>
1640     </sect2>
1641
1642     <sect2 id="acls">
1643       <title>ACL Support<indexterm>
1644           <primary>ACLs</primary>
1645         </indexterm></title>
1646
1647       <para>ACL support for AFP is implemented for ZFS ACLs on Solaris and
1648       derived platforms and for POSIX 1e ACLs on Linux.</para>
1649
1650       <sect3>
1651         <title>Configuration</title>
1652
1653         <para>For a basic mode of operation there's nothing to configure.
1654         Netatalk reads ACLs on the fly and calculates effective permissions
1655         which are then send to the AFP client via the so called
1656         UARights<indexterm>
1657             <primary>UARights</primary>
1658           </indexterm> permission bits. On a Mac, the Finder uses these bits
1659         to adjust permission in Finder windows. For example folder whos UNIX
1660         mode would only result in in read-only permissions for a user will not
1661         be displayed with a read-only icon and the user will be able to write
1662         to the folder given the folder has an ACL giving the user write
1663         access.</para>
1664
1665         <para>By default, the effective permission of the authenticated user
1666         are only mapped to the mentioned UARights<indexterm>
1667             <primary>UARights</primary>
1668           </indexterm>permission structure, not the UNIX mode. You can adjust
1669         this behaviour with the configuration option <link
1670         linkend="map_acls">map acls</link>.</para>
1671
1672         <para>However, neither in Finder "Get Info" windows nor in Terminal
1673         will you be able to see the ACLs, that's a result of how ACLs in OS X
1674         are designed. If you want to be able to display ACLs on the client,
1675         things get more involved as you must then setup both client and server
1676         to be part on a authentication domain (directory service, eg LDAP,
1677         OpenDirectory). The reason is, that in OS X ACLs are bound to UUIDs,
1678         not just uid's or gid's. Therefor afpd must be able to map every
1679         filesystem uid and gid to a UUID so that it can return the server side
1680         ACLs which are bound to UNIX uid and gid mapped to OS X UUIDs.</para>
1681
1682         <para>Netatalk can query a directory server using LDAP queries. Either
1683         the directory server already provides an UUID attribute for user and
1684         groups (Active Directory, Open Directory) or you reuse an unused
1685         attribute (or add a new one) to you directory server (eg
1686         OpenLDAP).</para>
1687
1688         <para>In detail:</para>
1689
1690         <orderedlist>
1691           <listitem>
1692             <para>For Solaris/ZFS: ZFS Volumes</para>
1693
1694             <para>You should configure a ZFS ACL know for any volume you want
1695             to use with Netatalk:</para>
1696
1697             <screen>aclinherit = passthrough
1698 aclmode = passthrough</screen>
1699
1700             <para>For an explanation of what this knob does and how to apply
1701             it, check your hosts ZFS documentation (eg man zfs).</para>
1702           </listitem>
1703
1704           <listitem>
1705             <para>Authentication Domain</para>
1706
1707             <para>Your server and the clients must be part of a security
1708             association where identity data is coming from a common source.
1709             ACLs in Darwin are based on UUIDs and so is the ACL specification
1710             in AFP 3.2. Therefor your source of identity data has to provide
1711             an attribute for every user and group where a UUID is stored as a
1712             ASCII string. In other words:</para>
1713
1714             <itemizedlist>
1715               <listitem>
1716                 <para>you need an Open Directory Server or an LDAP server
1717                 where you store UUIDs in some attribute</para>
1718               </listitem>
1719
1720               <listitem>
1721                 <para>your clients must be configured to use this
1722                 server</para>
1723               </listitem>
1724
1725               <listitem>
1726                 <para>your server should be configured to use this server via
1727                 nsswitch and PAM</para>
1728               </listitem>
1729
1730               <listitem>
1731                 <para>configure Netatalk via the special <link
1732                 linkend="acl_options">LDAP options for ACLs</link> in <link
1733                 linkend="afp.conf.5">afp.conf</link> so that Netatalk is able
1734                 to retrieve the UUID for users and groups via LDAP search
1735                 queries</para>
1736               </listitem>
1737             </itemizedlist>
1738           </listitem>
1739         </orderedlist>
1740       </sect3>
1741
1742       <sect3>
1743         <title>OS X ACLs</title>
1744
1745         <para>With Access Control Lists (ACLs) Mac OS X offers a powerful
1746         extension of the traditional UNIX permissions model. An ACL is an
1747         ordered list of Access Control Entries (ACEs) explicitly granting or
1748         denying a set of permissions to a given user or group.</para>
1749
1750         <para>Unlike UNIX permissions, which are bound to user or group IDs,
1751         ACLs are tied to UUIDs. For this reason accessing an object's ACL
1752         requires server and client to use a common directory service which
1753         translates between UUIDs and user/group IDs.</para>
1754
1755         <para>ACLs and UNIX permissions interact in a rather simple way. As
1756         ACLs are optional UNIX permissions act as a default mechanism for
1757         access control. Changing an objects's UNIX permissions will leave it's
1758         ACL intact and modifying an ACL will never change the object's UNIX
1759         permissions. While doing access checks, OS X first examines an
1760         object's ACL evaluating ACEs in order until all requested rights have
1761         been granted, a requested right has been explicitly denied by an ACE
1762         or the end of the list has been reached. In case there is no ACL or
1763         the permissions granted by the ACL are not sufficient to fulfill the
1764         request, OS X next evaluates the object's UNIX permissions. Therefore
1765         ACLs always have precedence over UNIX permissions.</para>
1766       </sect3>
1767
1768       <sect3>
1769         <title>ZFS ACLs</title>
1770
1771         <para>ZFS ACLs closely match OS X ACLs. Both offer mostly identical
1772         fine grained permissions and inheritance settings.</para>
1773       </sect3>
1774
1775       <sect3>
1776         <title>POSIX ACLs</title>
1777
1778         <sect4>
1779           <title>Overview</title>
1780
1781           <para>Compared to OS X or NFSv4 ACLs, Posix ACLs represent a
1782           different, less versatile approach to overcome the limitations of
1783           the traditional UNIX permissions. Implementations are based on the
1784           withdrawn Posix 1003.1e standard.</para>
1785
1786           <para>The standard defines two types of ACLs. Files and directories
1787           can have access ACLs which are consulted for access checks.
1788           Directories can also have default ACLs irrelevant to access checks.
1789           When a new object is created inside a directory with a default ACL,
1790           the default ACL is applied to the new object as it's access ACL.
1791           Subdirectories inherit default ACLs from their parent. There are no
1792           further mechanisms of inheritance control.</para>
1793
1794           <para>Architectural differences between Posix ACLs and OS X ACLs
1795           especially involve:</para>
1796
1797           <para><itemizedlist>
1798               <listitem>
1799                 <para>No fine-granular permissions model. Like UNIX
1800                 permissions Posix ACLs only differentiate between read, write
1801                 and execute permissions.</para>
1802               </listitem>
1803
1804               <listitem>
1805                 <para>Entries within an ACL are unordered.</para>
1806               </listitem>
1807
1808               <listitem>
1809                 <para>Posix ACLs can only grant rights. There is no way to
1810                 explicitly deny rights by an entry.</para>
1811               </listitem>
1812
1813               <listitem>
1814                 <para>UNIX permissions are integrated into an ACL as special
1815                 entries.</para>
1816               </listitem>
1817             </itemizedlist></para>
1818
1819           <para>Posix 1003.1e defines 6 different types of ACL entries. The
1820           first three types are used to integrate standard UNIX permissions.
1821           They form a minimal ACL, their presence is mandatory and only one
1822           entry of each type is allowed within an ACL.</para>
1823
1824           <para><itemizedlist>
1825               <listitem>
1826                 <para>ACL_USER_OBJ: the owner's access rights.</para>
1827               </listitem>
1828
1829               <listitem>
1830                 <para>ACL_GROUP_OBJ: the owning group's access rights.</para>
1831               </listitem>
1832
1833               <listitem>
1834                 <para>ACL_OTHER: everybody's access rights.</para>
1835               </listitem>
1836             </itemizedlist></para>
1837
1838           <para>The remaining entry types expand the traditional permissions
1839           model:</para>
1840
1841           <para><itemizedlist>
1842               <listitem>
1843                 <para>ACL_USER: grants access rights to a certain user.</para>
1844               </listitem>
1845
1846               <listitem>
1847                 <para>ACL_GROUP: grants access rights to a certain
1848                 group.</para>
1849               </listitem>
1850
1851               <listitem>
1852                 <para>ACL_MASK: limits the maximum access rights which can be
1853                 granted by entries of type ACL_GROUP_OBJ, ACL_USER and
1854                 ACL_GROUP. As the name suggests, this entry acts as a mask.
1855                 Only one ACL_MASK entry is allowed per ACL. If an ACL contains
1856                 ACL_USER or ACL_GROUP entries, an ACL_MASK entry must be
1857                 present too, otherwise it is optional.</para>
1858               </listitem>
1859             </itemizedlist></para>
1860
1861           <para>In order to maintain compatibility with applications not aware
1862           of ACLs, Posix 1003.1e changes the semantics of system calls and
1863           utilities which retrieve or manipulate an objects UNIX permissions.
1864           In case an object only has a minimal ACL, the group permissions bits
1865           of the UNIX permissions correspond to the value of the ACL_GROUP_OBJ
1866           entry.</para>
1867
1868           <para>However, if the ACL also contains an ACL_MASK entry, the
1869           behavior of those system calls and utilities is different. The group
1870           permissions bits of the UNIX permissions correspond to the value of
1871           the ACL_MASK entry, i. e. calling "chmod g-w" will not only revoke
1872           write access for the group, but for all entities which have been
1873           granted write access by ACL_USER or ACL_GROUP entries.</para>
1874         </sect4>
1875
1876         <sect4>
1877           <title>Mapping POSIX ACLs to OS X ACLs</title>
1878
1879           <para>When a client wants to read an object's ACL, afpd maps it's
1880           Posix ACL onto an equivalent OS X ACL. Writing an object's ACL
1881           requires afpd to map an OS X ACL onto a Posix ACL. Due to
1882           architectural restrictions of Posix ACLs, it is usually impossible
1883           to find an exact mapping so that the result of the mapping process
1884           will be an approximation of the original ACL's semantic.</para>
1885
1886           <para><itemizedlist>
1887               <listitem>
1888                 <para>afpd silently discard entries which deny a set of
1889                 permissions because they they can't be represented within the
1890                 Posix architecture.</para>
1891               </listitem>
1892
1893               <listitem>
1894                 <para>As entries within Posix ACLs are unordered, it is
1895                 impossible to preserve order.</para>
1896               </listitem>
1897
1898               <listitem>
1899                 <para>Inheritance control is subject to severe limitations as
1900                 well:<itemizedlist>
1901                     <listitem>
1902                       <para>Entries with the only_inherit flag set will only
1903                       become part of the directory's default ACL.</para>
1904                     </listitem>
1905
1906                     <listitem>
1907                       <para>Entries with at least one of the flags
1908                       file_inherit, directory_inherit or limit_inherit set,
1909                       will become part of the directory's access and default
1910                       ACL, but the restrictions they impose on inheritance
1911                       will be ignored.</para>
1912                     </listitem>
1913                   </itemizedlist></para>
1914               </listitem>
1915
1916               <listitem>
1917                 <para>The lack of a fine-granular permission model on the
1918                 Posix side will normally result in an increase of granted
1919                 permissions.</para>
1920               </listitem>
1921             </itemizedlist></para>
1922
1923           <para>As OS X clients aren't aware of the Posix 1003.1e specific
1924           relationship between UNIX permissions and ACL_MASK, afpd does not
1925           expose this feature to the client to avoid compatibility issues and
1926           handles *unix permissions and ACLs the same way as Apple's reference
1927           implementation of AFP does. When an object's UNIX permissions are
1928           requested, afpd calculates proper group rights and returns the
1929           result together with the owner's and everybody's access rights to
1930           the caller via "permissions" and "ua_permissions" members of the
1931           FPUnixPrivs structure (see Apple Filing Protocol Reference, page
1932           181). Changing an object's permissions, afpd always updates
1933           ACL_USER_OBJ, ACL_GROUP_OBJ and ACL_OTHERS. If an ACL_MASK entry is
1934           present too, afpd recalculates it's value so that the new group
1935           rights become effective and existing entries of type ACL_USER or
1936           ACL_GROUP stay intact.</para>
1937         </sect4>
1938       </sect3>
1939     </sect2>
1940
1941     <sect2 id="fce">
1942       <title>Filesystem Change Events<indexterm>
1943           <primary>FCE</primary>
1944         </indexterm></title>
1945
1946       <para>Netatalk includes a nifty filesystem change event mechanism where
1947       afpd processes notfiy interested listeners about certain filesystem
1948       event by UDP network datagrams.</para>
1949
1950       <para>For the format of the UDP packets and for an example C application
1951       that demonstrates how to use these in a listener, take a look at the
1952       Netatalk sourcefile <filename>bin/misc/fce.c</filename>.</para>
1953
1954       <para>The currently supported FCE events are<itemizedlist>
1955           <listitem>
1956             <para>file modification (fmod)</para>
1957           </listitem>
1958
1959           <listitem>
1960             <para>file deletion (fdel)</para>
1961           </listitem>
1962
1963           <listitem>
1964             <para>directory deletion (ddel)</para>
1965           </listitem>
1966
1967           <listitem>
1968             <para>file creation (fcre)</para>
1969           </listitem>
1970
1971           <listitem>
1972             <para>directory deletion (ddel)</para>
1973           </listitem>
1974         </itemizedlist></para>
1975
1976       <para>For details on the available simple configuration options take a
1977       look at <filename><link
1978       linkend="fceconf">afp.conf</link></filename>.</para>
1979     </sect2>
1980   </sect1>
1981
1982   <sect1>
1983     <title>Starting and stopping Netatalk</title>
1984
1985     <para>The Netatalk distribution comes with several operating system
1986     specific startup script templates that are tailored according to the
1987     options given to the "configure" script before compiling. Currently,
1988     templates are provided for RedHat (sysv style), RedHat (systemd style),
1989     SUSE (sysv style), SUSE (systemd style), Gentoo, NetBSD, Debian and
1990     Solaris. You can select to install the generated startup script(s)
1991     <indexterm>
1992         <primary>Startscript</primary>
1993
1994         <secondary>startup script</secondary>
1995       </indexterm> by specifying a system type to "configure". To
1996     automatically install startup scripts give one of the available
1997     <option>--with-init-style</option> option to "configure".</para>
1998
1999     <para>Since new releases of Linux distributions appear all the time and
2000     the startup procedure for the other systems mentioned above might change
2001     as well, it is probably a good idea to not blindly install a startup
2002     script but to look at it first to see if it will work on your system. If
2003     you use Netatalk as part of a fixed setup, like a Linux distribution, an
2004     RPM or a BSD package, things will probably have been arranged properly for
2005     you. The following therefore applies mostly for people who have compiled
2006     Netatalk themselves.</para>
2007
2008     <para>The following daemon need to be started by whatever startup script
2009     mechanism is used:</para>
2010
2011     <itemizedlist>
2012       <listitem>
2013         <para>netatalk<indexterm>
2014             <primary>netatalk</primary>
2015           </indexterm></para>
2016       </listitem>
2017     </itemizedlist>
2018
2019     <para>Additionally, make sure that the configuration file
2020     <filename>afp.conf</filename> is in the right place.</para>
2021   </sect1>
2022 </chapter>