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