<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet type="text/xsl"
	href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
	"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY VERSION "1.0">
<!ENTITY COMMANDNAME "mandos">
]>

<refentry>
  <refentryinfo>
    <title>&COMMANDNAME;</title>
    <!-- NWalsh's docbook scripts use this to generate the footer: -->
    <productname>&COMMANDNAME;</productname>
    <productnumber>&VERSION;</productnumber>
    <authorgroup>
      <author>
	<firstname>Björn</firstname>
	<surname>Påhlsson</surname>
	<address>
	  <email>belorn@fukt.bsnet.se</email>
	</address>
      </author>
      <author>
	<firstname>Teddy</firstname>
	<surname>Hogeborn</surname>
	<address>
	  <email>teddy@fukt.bsnet.se</email>
	</address>
      </author>
    </authorgroup>
    <copyright>
      <year>2008</year>
      <holder>Teddy Hogeborn</holder>
      <holder>Björn Påhlsson</holder>
    </copyright>
    <legalnotice>
      <para>
	This manual page is free software: you can redistribute it
	and/or modify it under the terms of the GNU General Public
	License as published by the Free Software Foundation,
	either version 3 of the License, or (at your option) any
	later version.
      </para>

      <para>
	This manual page is distributed in the hope that it will
	be useful, but WITHOUT ANY WARRANTY; without even the
	implied warranty of MERCHANTABILITY or FITNESS FOR A
	PARTICULAR PURPOSE.  See the GNU General Public License
	for more details.
      </para>

      <para>
	You should have received a copy of the GNU General Public
	License along with this program; If not, see
	<ulink url="http://www.gnu.org/licenses/"/>.
      </para>
    </legalnotice>
  </refentryinfo>

  <refmeta>
    <refentrytitle>&COMMANDNAME;</refentrytitle>
    <manvolnum>8</manvolnum>
  </refmeta>
  
  <refnamediv>
    <refname><command>&COMMANDNAME;</command></refname>
    <refpurpose>
      Sends encrypted passwords to authenticated Mandos clients
    </refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <cmdsynopsis>
      <command>&COMMANDNAME;</command>
      <arg choice='opt'>--interface<arg choice='plain'>IF</arg></arg>
      <arg choice='opt'>--address<arg choice='plain'>ADDRESS</arg></arg>
      <arg choice='opt'>--port<arg choice='plain'>PORT</arg></arg>
      <arg choice='opt'>--priority<arg choice='plain'>PRIORITY</arg></arg>
      <arg choice='opt'>--servicename<arg choice='plain'>NAME</arg></arg>
      <arg choice='opt'>--configdir<arg choice='plain'>DIRECTORY</arg></arg>
      <arg choice='opt'>--debug</arg>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>&COMMANDNAME;</command>
      <arg choice='opt'>-i<arg choice='plain'>IF</arg></arg>
      <arg choice='opt'>-a<arg choice='plain'>ADDRESS</arg></arg>
      <arg choice='opt'>-p<arg choice='plain'>PORT</arg></arg>
      <arg choice='opt'>--priority<arg choice='plain'>PRIORITY</arg></arg>
      <arg choice='opt'>--servicename<arg choice='plain'>NAME</arg></arg>
      <arg choice='opt'>--configdir<arg choice='plain'>DIRECTORY</arg></arg>
      <arg choice='opt'>--debug</arg>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>&COMMANDNAME;</command>
      <arg choice='plain'>--help</arg>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>&COMMANDNAME;</command>
      <arg choice='plain'>--version</arg>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>&COMMANDNAME;</command>
      <arg choice='plain'>--check</arg>
    </cmdsynopsis>
  </refsynopsisdiv>

  <refsect1 id="description">
    <title>DESCRIPTION</title>
    <para>
      <command>&COMMANDNAME;</command> is a server daemon which
      handles incoming request for passwords for a pre-defined list of
      client host computers.  The Mandos server uses Zeroconf to
      announce itself on the local network, and uses GnuTLS to
      communicate securely with and to authenticate the clients.
      Mandos uses IPv6 link-local addresses, since the clients are
      assumed to not have any other addresses configured.  Any
      authenticated client is then given the pre-encrypted password
      for that specific client.
    </para>

  </refsect1>
  
  <refsect1 id="purpose">
    <title>PURPOSE</title>

    <para>
      The purpose of this is to enable <emphasis>remote and unattended
      rebooting</emphasis> of any client host computer with an
      <emphasis>encrypted root file system</emphasis>.  The client
      host computer should start a Mandos client in the initial RAM
      disk environment, the Mandos client program communicates with
      this server program to get an encrypted password, which is then
      decrypted and used to unlock the encrypted root file system.
      The client host computer can then continue its boot sequence
      normally.
    </para>

  </refsect1>
  
  <refsect1 id="options">
    <title>OPTIONS</title>

    <variablelist>
      <varlistentry>
	<term><literal>-h</literal>, <literal>--help</literal></term>
	<listitem>
	  <para>
	    Show a help message and exit
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term><literal>-i</literal>, <literal>--interface <replaceable>
	IF</replaceable></literal></term>
	<listitem>
	  <para>
	    Only announce the server and listen to requests on network
	    interface <replaceable>IF</replaceable>.  Default is to
	    use all available interfaces.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term><literal>-a</literal>, <literal>--address <replaceable>
	ADDRESS</replaceable></literal></term>
	<listitem>
	  <para>
	    If this option is used, the server will only listen to a
	    specific address.  This must currently be an IPv6 address;
	    an IPv4 address can be specified using the
	    <quote><literal>::FFFF:192.0.2.3</literal></quote> syntax.
	    Also, if a link-local address is specified, an interface
	    should be set, since a link-local address is only valid on
	    a single interface.  By default, the server will listen to
	    all available addresses.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term><literal>-p</literal>, <literal>--port <replaceable>
	PORT</replaceable></literal></term>
	<listitem>
	  <para>
	    If this option is used, the server to bind to that
	    port. By default, the server will listen to an arbitrary
	    port given by the operating system.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term><literal>--check</literal></term>
	<listitem>
	  <para>
	    Run the server's self-tests.  This includes any unit
	    tests, etc.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term><literal>--debug</literal></term>
	<listitem>
	  <para>
	    If the server is run in debug mode, it will run in the
	    foreground and print a lot of debugging information.  The
	    default is <emphasis>not</emphasis> to run in debug mode.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term><literal>--priority <replaceable>
	PRIORITY</replaceable></literal></term>
	<listitem>
	  <para>
	    GnuTLS priority string for the TLS handshake with the
	    clients.  See
	    <citerefentry><refentrytitle>gnutls_priority_init
	    </refentrytitle><manvolnum>3</manvolnum></citerefentry>
	    for the syntax.  The default is
	    <quote><literal>SECURE256:!CTYPE-X.509:+CTYPE-OPENPGP</literal></quote>.
	    <emphasis>Warning</emphasis>: changing this may make the
	    TLS handshake fail, making communication with clients
	    impossible.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term><literal>--servicename <replaceable>NAME</replaceable>
	</literal></term>
	<listitem>
	  <para>
	    Zeroconf service name.  The default is
	    <quote><literal>Mandos</literal></quote>.  You only need
	    to change this if you for some reason want to run more
	    than one server on the same <emphasis>host</emphasis>,
	    which would not normally be useful.  If there are name
	    collisions on the same <emphasis>network</emphasis>, the
	    newer server will automatically rename itself to
	    <quote><literal>Mandos #2</literal></quote>, and so on,
	    therefore this option is not needed in that case.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term><literal>--configdir <replaceable>DIR</replaceable>
	</literal></term>
	<listitem>
	  <para>
	    Directory to search for configuration files.  Default is
	    <quote><literal>/etc/mandos</literal></quote>.  See
	    <citerefentry><refentrytitle>mandos.conf</refentrytitle>
	    <manvolnum>5</manvolnum></citerefentry> and <citerefentry>
	    <refentrytitle>mandos-clients.conf</refentrytitle>
	    <manvolnum>5</manvolnum></citerefentry>.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term><literal>--version</literal></term>
	<listitem>
	  <para>
	    Prints the program version and exit.
	  </para>
	</listitem>
      </varlistentry>
    </variablelist>
  </refsect1>

  <refsect1 id="protocol">
    <title>NETWORK PROTOCOL</title>
    <para>
      The Mandos server announces itself as a Zeroconf service of type
      <quote><literal>_mandos._tcp</literal></quote>.  The Mandos
      client connects to the announced address and port, and sends a
      line of text where the first whitespace-separated field is the
      protocol version, which currently is
      <quote><literal>1</literal></quote>.  The client and server then
      start a TLS protocol handshake with a slight quirk: the Mandos
      server program acts as a TLS <quote>client</quote> while the
      connecting Mandos client acts as a TLS <quote>server</quote>.
      The Mandos client must supply an OpenPGP certificate, and the
      fingerprint of this certificate is used by the Mandos server to
      look up (in a list read from <filename>clients.conf</filename>
      at start time) which binary blob to give the client.  No other
      authentication or authorization is done by the server.
    </para>
    <table>
      <title>Mandos Protocol (Version 1)</title><tgroup cols="3"><thead>
      <row>
	<entry>Mandos Client</entry>
	<entry>Direction</entry>
	<entry>Mandos Server</entry>
      </row>
      </thead><tbody>
      <row>
	<entry>Connect</entry>
	<entry>-><!-- &rarr; --></entry>
      </row>
      <row>
	<entry><quote><literal>1\r\en</literal></quote></entry>
	<entry>-><!-- &rarr; --></entry>
      </row>
      <row>
	<entry>TLS handshake <emphasis>as TLS <quote>server</quote>
	</emphasis></entry>
	<entry>&lt;-><!-- &xharr; --></entry>
	<entry>TLS handshake <emphasis>as TLS <quote>client</quote>
	</emphasis></entry>
      </row>
      <row>
	<entry>OpenPGP public key (part of TLS handshake)</entry>
	<entry>-><!-- &rarr; --></entry>
      </row>
      <row>
	<entry/>
	<entry>&lt;-<!-- &larr; --></entry>
	<entry>Binary blob (client will assume OpenPGP data)</entry>
      </row>
      <row>
	<entry/>
	<entry>&lt;-<!-- &larr; --></entry>
	<entry>Close</entry>
      </row>
    </tbody></tgroup></table>
  </refsect1>

  <refsect1 id="checking">
    <title>CHECKING</title>
    <para>
      The server will, by default, continually check that the clients
      are still up.  If a client has not been confirmed as being up
      for some time, the client is assumed to be compromised and is no
      longer eligible to receive the encrypted password.  The timeout,
      checker program and interval between checks can be configured
      both globally and per client; see <citerefentry>
      <refentrytitle>mandos.conf</refentrytitle>
      <manvolnum>5</manvolnum></citerefentry> and <citerefentry>
      <refentrytitle>mandos-clients.conf</refentrytitle>
      <manvolnum>5</manvolnum></citerefentry>.
    </para>
  </refsect1>

  <refsect1 id="logging">
    <title>LOGGING</title>
    <para>
      The server will send log messaged with various severity levels
      to <filename>/dev/log</filename>.  With the
      <option>--debug</option> option, it will log even more messages,
      and also show them on the console.
    </para>
  </refsect1>

  <refsect1 id="exit_status">
    <title>EXIT STATUS</title>
    <para>
      The server will exit with a non-zero exit status only when a
      critical error is encountered.
    </para>
  </refsect1>

  <refsect1 id="file">
    <title>FILES</title>
    <para>
      Use the <option>--configdir</option> option to change where
      <command>&COMMANDNAME;</command> looks for its configurations
      files.  The default file names are listed here.
    </para>
    <variablelist>
      <varlistentry>
	<term><filename>/etc/mandos/mandos.conf</filename></term>
	<listitem>
	  <para>
	    Server-global settings.  See
	    <citerefentry><refentrytitle>mandos.conf</refentrytitle>
	    <manvolnum>5</manvolnum></citerefentry> for details.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><filename>/etc/mandos/clients.conf</filename></term>
	<listitem>
	  <para>
	    List of clients and client-specific settings.  See
	    <citerefentry><refentrytitle>mandos-clients.conf</refentrytitle>
	    <manvolnum>5</manvolnum></citerefentry> for details.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><filename>/var/run/mandos/mandos.pid</filename></term>
	<listitem>
	  <para>
	    The file containing the process id of
	    <command>&COMMANDNAME;</command>.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><filename>/dev/log</filename></term>
	<listitem>
	  <para>
	    The Unix domain socket to where local syslog messages are
	    sent.
	  </para>
	</listitem>
      </varlistentry>
    </variablelist>
  </refsect1>

  <refsect1 id="bugs">
    <title>BUGS</title>
    <para>
      This server might, on especially fatal errors, emit a Python
      backtrace.  This could be considered a feature.
    </para>
  </refsect1>

  <refsect1 id="examples">
    <title>EXAMPLES</title>
    <informalexample>
      <para>
	Normal invocation needs no options:
      </para>
      <para>
	<userinput>mandos</userinput>
      </para>
    </informalexample>
    <informalexample>
      <para>
	Run the server in debug mode and read configuration files from
	the <filename>~/mandos</filename> directory:
      </para>
      <para>

<!-- do not wrap this line -->
<userinput>mandos --debug --configdir ~/mandos --servicename Test</userinput>

      </para>
    </informalexample>
    <informalexample>
      <para>
	Run the server normally, but only listen to one interface and
	only on the link-local address on that interface:
      </para>
      <para>

<!-- do not wrap this line -->
<userinput>mandos --interface eth7 --address fe80::aede:48ff:fe71:f6f2</userinput>

      </para>
    </informalexample>
  </refsect1>

  <refsect1 id="security">
    <title>SECURITY</title>
    <refsect2>
      <title>SERVER</title>
      <para>
	Running the server should not in itself present any security
	risk to the host computer running it.
      </para>
    </refsect2>
    <refsect2>
      <title>CLIENTS</title>
      <para>
	The server only gives out its stored data to clients which
	does have the OpenPGP key of the stored fingerprint.  This is
	guaranteed by the fact that the client sends its OpenPGP
	public key in the TLS handshake; this ensures it to be
	genuine.  The server computes the fingerprint of the key
	itself and looks up the fingerprint in its list of
	clients. The <filename>clients.conf</filename> file (see
	<citerefentry><refentrytitle>mandos-clients.conf</refentrytitle>
	<manvolnum>5</manvolnum></citerefentry>) must be non-readable
	by anyone except the user running the server.
      </para>
      <para>
	For more details on client-side security, see
	<citerefentry><refentrytitle>password-request</refentrytitle>
	<manvolnum>8mandos</manvolnum></citerefentry>.
      </para>
    </refsect2>
  </refsect1>

  <refsect1 id="see_also">
    <title>SEE ALSO</title>
    <itemizedlist spacing="compact">
      <listitem><para>
	<citerefentry><refentrytitle>password-request</refentrytitle>
	<manvolnum>8mandos</manvolnum></citerefentry>
      </para></listitem>
      
      <listitem><para>
	<citerefentry><refentrytitle>plugin-runner</refentrytitle>
	<manvolnum>8mandos</manvolnum></citerefentry>
      </para></listitem>
      
      <listitem><para>
	<ulink url="http://www.zeroconf.org/">Zeroconf</ulink>
      </para></listitem>
      
      <listitem><para>
	<ulink url="http://www.avahi.org/">Avahi</ulink>
      </para></listitem>
      
      <listitem><para>
	<ulink
	    url="http://www.gnu.org/software/gnutls/">GnuTLS</ulink>
      </para></listitem>
      
      <listitem><para>
	<citation>RFC 4880: <citetitle>OpenPGP Message
	Format</citetitle></citation>
      </para></listitem>
      
      <listitem><para>
	<citation>RFC 5081: <citetitle>Using OpenPGP Keys for
	Transport Layer Security</citetitle></citation>
      </para></listitem>
      
      <listitem><para>
	<citation>RFC 4291: <citetitle>IP Version 6 Addressing
	Architecture</citetitle>, section 2.5.6, Link-Local IPv6
	Unicast Addresses</citation>
      </para></listitem>
    </itemizedlist>
  </refsect1>
</refentry>
