<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>DomTool/ArchitectureOverview</title><revhistory><revision><revnumber>7</revnumber><date>2013-01-24 05:18:19</date><authorinitials>ClintonEbadi</authorinitials><revremark>new privs</revremark></revision><revision><revnumber>6</revnumber><date>2008-07-07 04:27:56</date><authorinitials>localhost</authorinitials><revremark>converted to 1.6 markup</revremark></revision><revision><revnumber>5</revnumber><date>2007-10-27 18:42:28</date><authorinitials>AdamChlipala</authorinitials></revision><revision><revnumber>4</revnumber><date>2006-12-16 22:00:44</date><authorinitials>AdamChlipala</authorinitials><revremark>Client/server model</revremark></revision><revision><revnumber>3</revnumber><date>2006-12-16 21:35:38</date><authorinitials>AdamChlipala</authorinitials><revremark>ACLs</revremark></revision><revision><revnumber>2</revnumber><date>2006-12-16 21:24:27</date><authorinitials>AdamChlipala</authorinitials></revision><revision><revnumber>1</revnumber><date>2006-12-16 20:08:12</date><authorinitials>AdamChlipala</authorinitials></revision></revhistory></articleinfo><para>This page describes the client/server distributed configuration architecture of <ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/DomTool#">DomTool</ulink>.  For (largely orthogonal) information on the programming language used for configuration, see <ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/DomTool/LanguageReference#">DomTool/LanguageReference</ulink>. </para><section><title>Conventions for this document</title><para>We'll use these conventions: </para><itemizedlist><listitem><para><code>$DOMTOOL</code> refers to <code>/afs/hcoop.net/common/etc/domtool</code>, the root of global <ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/DomTool#">DomTool</ulink> data </para></listitem></itemizedlist></section><section><title>Users and authentication</title><para>The principals that figure into <ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/DomTool#">DomTool</ulink> authentication are either AFS/Kerberos users (like <code>adamc</code>) or HCoop machine hostnames (like <code>mire</code>). When one of these entities connects to another with some request to make, it authenticates using SSL. </para><para>To faciliate this, we have our own SSL certificate authority (CA) living in <code>/etc/domtool</code> on <code>deleuze.hcoop.net</code>. We use this CA to sign keys belonging to <ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/DomTool#">DomTool</ulink>-related principals. The <ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/DomTool#">DomTool</ulink> tools only recognize this certificate authority, so, e.g., VeriSign can't grant any <ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/DomTool#">DomTool</ulink> privileges. </para><para>Each principal has its CA-signed certificate stored in <code>$DOMTOOL/certs/$NAME.pem</code>, where <code>$NAME</code> is the UNIX username of a user or the one-word hostname of a server. Any user is allowed to read these certificates, which are the public key halves of public key cryptography. </para><para>The private keys are stored in <code>$DOMTOOL/keys/$NAME/key.pem</code>. AFS permissions are set such that, besides admins, only the user in question has the ability to read the key data. In contrast to certificates, keys have their own directories because AFS only allows directory-level permissions. </para><para><emphasis role="strong">Meta note</emphasis>: This clearly isn't the most direct way to do authentication. I chose to do things this way initially because of that wise security mantra to implement as little as possible of your own cryptography infrastructure. By basing our authentication on that implemented in well-tested OpenAFS code, along with some help from the OpenSSL library, we avoid opportunities to introduce new bugs. But the result definitely isn't so aesthetically pleasing. --<ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/AdamChlipala#">AdamChlipala</ulink> </para></section><section><title>Access control lists</title><para>As in the cases of so many fancy systems, <ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/DomTool#">DomTool</ulink> has its own notion of access control lists relevant to the resources it controls. The ACL data is serialized to <code>$DOMTOOL/acl</code>, though it is usually accessed via in-memory data structures in the different <code>DomTool</code> tools, after they read initial values from that file. </para><para>There's nothing novel or surprising about ACLs in <ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/DomTool#">DomTool</ulink>. The ACL list is essentially a set of <emphasis role="strong">user</emphasis>/<emphasis role="strong">class</emphasis>/<emphasis role="strong">value</emphasis> triples. Users are <ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/DomTool#">DomTool</ulink> principals as discussed in the last section. <emphasis>Classes</emphasis> include things like domain configuration rights, rights to run programs as particular UNIX users, rights to use particular filesystem paths, etc.. <emphasis>Values</emphasis> are class-specific capabilities, like the name of a domain that the user may configure. </para><section><title>Standard ACL classes</title><itemizedlist><listitem><para><code>user</code>: As which UNIX users may this principal run programs? </para></listitem><listitem><para><code>group</code>: With which UNIX groups may this principal run programs? </para></listitem><listitem><para><code>path</code>: Which filesystem directories is this principal allowed to reference in his configuration? Subdirectories of these are also allowed. </para></listitem><listitem><para><code>domain</code>: Which Internet domain names may this principal configure? </para></listitem><listitem><para><code>cert</code>: Which SSL certificates may this principal use? </para></listitem><listitem><para><code>cacert</code>: Which intermediate CA certificates may this principle use? </para></listitem><listitem><para><code>priv</code>: What kinds of admin actions may this principal perform?  Useful values include: </para><itemizedlist><listitem><para><code>all</code>: Let the principal do whatever he asks. This privilege is required for administration of the ACL database itself. </para></listitem><listitem><para><code>dns</code>: The principal may configure DNS settings on servers whose DNS daemons are off-limits to normal members. </para></listitem><listitem><para><code>mail</code>: The principal may configure mail settings on servers whose mail daemons are off-limits to normal members. </para></listitem><listitem><para><code>www</code>: The principal may configure web settings on servers whose web daemons are off-limits to normal members. </para></listitem><listitem><para><code>regen</code>: The principal may run <code>domtool-admin regen</code> to reload all domain configuration from scratch. </para></listitem></itemizedlist></listitem></itemizedlist></section></section><section><title>Client/server model</title><para>Here's the anatomy of the handling of a user's configuration request. </para><orderedlist numeration="arabic"><listitem><para>A user writes his domain configuration in the form of source code in the <ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/DomTool#">DomTool</ulink> language. (See <ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/DomTool/LanguageReference#">DomTool/LanguageReference</ulink>.) The file can have any name. Ideally it is stored at the top level of the <code>.domtool</code> subdirectory of the user's AFS volume, as otherwise the corresponding configuration will be dropped if an admin triggers a  regeneration. </para></listitem><listitem><para>The user runs <code>domtool $FILENAME</code>. </para></listitem><listitem><para><code>domtool</code> parses and type-checks <code>$FILENAME</code>. The <ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/DomTool#">DomTool</ulink> language and its type system are designed to have the lovely property that type-checking implies proper adherence to access rights and general good citizenship. This means that users can check their configuration for acceptability locally, not taking up shared daemons' time until after validation. </para></listitem><listitem><para>The user opens an SSL connection to our <ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/DomTool#">DomTool</ulink> dispatcher on deleuze.hcoop.net, port 1234. </para><orderedlist numeration="arabic"><listitem><para>The dispatcher authenticates the user by way of his SSL certificate, and the user does the same for the dispatcher. This relies on the fact that only the user has permissions to read his key file in AFS. </para></listitem></orderedlist></listitem><listitem><para>The user sends the text of his configuration program to the dispatcher. </para></listitem><listitem><para>The dispatcher again parses and type-checks the program. If any errors arise, the dispatcher informs the user of this and terminates the session. </para></listitem><listitem><para>Otherwise, the dispatcher runs the program. </para><orderedlist numeration="arabic"><listitem><para>A <ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/DomTool#">DomTool</ulink> program is a purely functional expression that evaluates into a description of actions to be taken. Running the program involves executing these actions, which generally add new files to a temporary directory tree (which we'll call <code>$TMP</code> here) representing configuration. The roots of <code>$TMP</code> are HCoop server names like <code>deleuze</code> and <code>mire</code>. Each server's subdirectory contains configuration specific to its daemons. Each subdirectory has a tree structure mirroring the structure of Internet domain names. For instance, <code>$TMP/mire/net/hcoop</code> stores configuration related to <code>hcoop.net</code> on mire's daemons. <emphasis role="strong">Only domains that have been configured during this session</emphasis> will be present in any of these trees. This is part of a critical optimization to avoid reprocessing all configuration on every change. </para></listitem><listitem><para>Once the configuration program has been run, it's time to propagate the changes into the real world. The first step of doing this is to copy the modified domains from <code>$TMP</code> into the permanent configuration tree, located at <code>$DOMTOOL/nodes</code>. Not only are new/changed configuration files propagated, but old configuration files not present in <code>$TMP</code> are deleted from <code>$DOMTOOL/nodes</code>. Crucially for performance, parts of <code>$DOMTOOL/nodes</code> for domains not configured during this session are not examined or changed. </para></listitem><listitem><para>Now all the relevant configuration is in AFS and accessible to all HCoop servers. What remains is to publish it into the real daemons. The different <ulink url="https://wiki.hcoop.net/DomTool/ArchitectureOverview/DomTool#">DomTool</ulink> plugins register handlers for different filenames that might be found in <code>$DOMTOOL/nodes</code>. For instance, the Apache plugin asks to be notified of changes to files ending in <code>.vhost</code>. This handler copies these files to <code>/var/domtool/vhosts</code>. The Apache plugin also registers a post-handler to copy all files from <code>/var/domtool/vhosts</code> to <code>/etc/apache/vhosts</code> and reload Apache configuration after any <code>.vhost</code> file has changed. </para><orderedlist numeration="arabic"><listitem><para>For all files in <code>$DOMTOOL/nodes/deleuze</code> whose status changed on this invocation, the dispatcher itself runs the matching handlers. </para></listitem><listitem><para>For configuration in <code>$DOMTOOL/nodes/$NODE</code> for other values of <code>$NODE</code>, the dispatcher opens an SSL connection to a slave daemon on <code>$NODE</code> on port 1235. </para><orderedlist numeration="arabic"><listitem><para>Two-way SSL authentication proceeds in the same way as for user-dispatcher connections. </para></listitem><listitem><para>The slave server runs the appropriate file handlers locally. </para></listitem></orderedlist></listitem></orderedlist></listitem></orderedlist></listitem><listitem><para>Weather permitting, the dispatcher informs the user that the configuration has succeeded, and the session ends. </para></listitem></orderedlist></section></article>