<?xml version="1.0"?>
<!DOCTYPE book
    PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
          "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"
[
<!ENTITY os "Centos">
<!ENTITY qvcs "<acronym>QVCS</acronym>">
<!ENTITY ver "3">
<!ENTITY ossite "http://www.centos.org">
<!ENTITY osbase "http://ftp.osuosl.org/pub/centos/3/os/i386/">
<!ENTITY qvcsbase "http://mirror.mricon.com/qvcs-guide">
<!ENTITY prompt "<prompt>[root@mail root]#</prompt>">
]>

<book>
  <bookinfo>
    <!-- $Id: qvcs-guide.xml,v 1.18 2005/03/18 21:28:28 graf25 Exp $ -->
    <title>
      POP-Toaster using Qmail, Vmailmgr, Courier, and Squirrelmail
    </title>
    <authorgroup>
      <author>
        <firstname>Konstantin</firstname>
        <surname>Ryabitsev</surname>
      </author>
    </authorgroup>
    <edition>&os; &ver; Edition</edition>
    <pubdate>March 18, 2005</pubdate>
    <releaseinfo>Version: 2.3 for &os;-&ver;</releaseinfo>
    <copyright>
      <year>2001-2005</year>
      <holder>
        Konstantin Ryabitsev
      </holder>
    </copyright>    
    <legalnotice>
      <para>
        This work is licensed under the Creative Commons
        Attribution-ShareAlike License. To view a copy of this
        license, visit <ulink
        url="http://creativecommons.org/licenses/by-sa/2.0/">
        http://creativecommons.org/licenses/by-sa/2.0/</ulink> or send
        a letter to Creative Commons, 559 Nathan Abbott Way, Stanford,
        California 94305, USA.
      </para>
    </legalnotice>
    <abstract>
      <para>
        This document is useful for people who are looking to set up
        an e-mail system with an easy-to-use client webmail front end
        and support for name-based virtual domains. It proposes a
        &qvcs; tie-in as the best small to mid-class server
        solution. This document is written for &os; systems running
        &ver;.
      </para>
    </abstract>
  </bookinfo>
  
  <chapter id="intrduction">
    <title>Introduction</title>
    <para>
      Say, you are looking to start your own small-to-medium hosting
      business and you need to come up with the best solution for an
      e-mail server. The things you are looking for are:
    </para>

    <itemizedlist>
      <listitem><para>Security</para></listitem>
      <listitem><para>Reliability</para></listitem>
      <listitem><para>Lax hardware requirements</para></listitem>
      <listitem>
        <para>
          Support for many virtual hosts, all sitting on one IP address
          (name-based hosting)
        </para>
      </listitem>
      <listitem><para>SMTP relaying for your clients</para></listitem>
      <listitem><para>POP3 and IMAP mailbox access</para></listitem>
      <listitem>
        <para>A nice webmail front-end for your clients</para>
      </listitem>
    </itemizedlist>
    
    <para>
      I was facing the same problem and I have found that one of the
      best solutions would be to use &qvcs; tie-in. It is very easy to
      configure, runs very reliably, and has very good security
      features.
    </para>
    <para>
      This guide will help you configure and set up a similar system.
    </para>
    <sect1>
      <title>OSes, Packages, and Disclaimers</title>
      <para>
        There are many flavors of UN*X software out there and it's
        very hard to write a uniform document that would work for
        every distribution.  This guide is aimed at &os;, and is
        based on a set of binary packages provided with it. If you are
        running something other than &os; &ver;, or like building
        stuff from source, please consult the following document:
        <ulink url="http://megaz.arbuz.com/?p=qmail_howto">
        http://megaz.arbuz.com/?p=qmail_howto</ulink>
      </para>
      <important>
        <para>
          A special word about the binaries. <emphasis>You must
          understand, that although I have put a lot of effort into
          making and troubleshooting these packages, no guarantee
          WHATSOEVER is given that they will work for you. There is no
          warranty, no assurance, not even an implication that these
          packages are suitable for the task described in this
          document.</emphasis> Having said that (this is a standard
          disclaimer, really. :)), I am quite convinced that a lot of
          people will find these packages quite useful and suitable.
        </para>
      </important>
    </sect1>

  </chapter>
  <chapter id="install">
    <title>Installation: From Zero to 60 in 30 minutes</title>
    <para>
      This section will walk you through a generic &os; installation
      process. The system we are going to install is going to aim
      <emphasis>exclusively</emphasis> at being a mail server running
      nothing but virtual servers and webmail interface (so-called
      &quot;pop-toaster&quot;). If you are planning to use your system
      for any other services, you can still glance through this
      installation part for hints and caveats, but your install will
      differ from the one outlined below.
    </para>
    <sect1>
      <title>Considering the hardware</title>
      <para>
        This setup is aimed at low- to middle-low-end installations,
        hence we will be VERY relaxed about our hardware
        requirements. Nevertheless, there are several important things
        to consider. First of all, you need to make sure that your
        server is capable of handling peak loads, such as happen at
        times when a new outlook virus hits the Internet. Another
        thing to consider is how many clients you are planning to
        support, together with how much maximum space you are going to
        allow them to have.
      </para>
      <para>
        Overall, we are looking at three different variables -- memory
        amount, processor speed, and hard drive space. Let's consider
        a setup with <emphasis>500</emphasis> clients max and look at
        each of these three variables.
      </para>
      <sect2>
        <title>HDD space</title>
        <para>
          A sensible amount of mail quota to allow per client would be
          about 50Mb, so the amount of hard drive space you will
          require just for 500 clients worth of e-mails would be
          around 25Gb. That's not all, though, as it is also necessary
          to consider the amount of hard drive space needed for the
          mail queue.
        </para>
        <para>
          Let's imagine that you have been hit with a virus that mails
          itself to a hundred people and all of your 500 clients got
          infected one way or the other. If the virus is around 100Kb
          in size, that means that the total amount of traffic a
          single client will generate will be around 10Mb. Multiply
          that by 500, and you will arrive at a staggering 5Gb of
          traffic just to handle that virus. Since qmail will spend a
          good deal of time making connections, you will want to make
          sure that there is plenty of space to queue all of these
          requests. What this means is that you will need to allow
          around 5-7Gb of space for queuing, which brings us to
          30-35Gb of total space for the mail subsystem.
        </para>
        <para>
          The OS itself will actually require very little space -- no
          more than 1Gb for everything, including virtual web-servers,
          preferences and other miscellaneous data.
        </para>
        <para>
          After we allow about one more gigabyte for system swap
          space, we arrive at 35-40Gb overall HDD space needed for an
          installation with 500 clients. Re-calculate the requirements
          for your number of clients using the following formula:
        </para>
        <segmentedlist>
          <title>HDD considerations</title>
          <segtitle>User space</segtitle>
          <segtitle>Qmail queue</segtitle>
          <segtitle>System and swap</segtitle>
          <seglistitem>
            <seg>N*50Mb</seg>
            <seg>N*10Mb</seg>
            <seg>2GB</seg>
          </seglistitem>
        </segmentedlist>
        <para>
          Whether you decide to choose SCSI or IDE is up to you, but
          you should consider that most common HDD activity will be
          accessing and moving small files, something that high-RPM
          SCSI drives do best. Depending on how redundant you want to
          be (which generally depends on how bemused your clients can
          get at the prospect of losing email or facing a significant
          downtime), you might consider creating a RAID array to
          mirror all your data.
        </para>
        <para>
          If you do decide to go with <acronym>RAID</acronym>, then my
          advice would be to get 1 small IDE drive for the system, and
          3 SCSI drives for a RAID-1 array (1 active, 1 mirror, and 1
          spare). Granted, this setup will be more expensive, but
          believe me, you will sleep <emphasis>much</emphasis> better
          at night.
        </para>
      </sect2>
      <sect2>
        <title>RAM requirements</title>
        <para>
          The amount of RAM you will require depends on the number of
          simultaneous connections you are going to have to the
          server. This largely depends on the environment you are
          setting this up for.
        </para>
        <para>
          If you are creating this setup for your company, then it's a
          good possibility that a good chunk of these 500 will be
          accessing your system simultaneously, especially around 9am
          in the morning when people first arrive at work and check
          their e-mail. If, however, you are an ISP and your clients
          are mostly home-users, then the amount of simultaneous
          connections your server is likely to experience would be
          lower, since people will tend to check their e-mail at
          various times during the day.
        </para>
        <para>
          Let's approximate -- if you are setting up a server for your
          company, the likely peak usage would be around 90% of all
          your clients. The amount of memory each request will consume
          depends largely on what kind of connection it is --
          <application>smtp</application> and
          <application>imap</application> require very small amounts
          of memory for each connection, within a few hundred
          kilobytes each (unless you are doing email filtering and
          virus checking, in which case the only official limit to the
          amount of memory you should put into your server is how much
          the motherboard can physically take. See the advanced
          section for more info). Webmail requests, however, are very
          memory-hungry and will likely gobble up a hefty chunk of RAM
          -- around 5Mb per each request. However, the good thing
          about webmail is that each request lasts only a few seconds,
          so even if 200 people decide to connect to your server at
          around the same time, it's unlikely that there will be any
          more than 50 http processes running simultaneously.
        </para>
        <para>
          But let's be pessimistic and allow for freaky
          coincidences. Let's imagine that all of your 500 clients
          decided to connect to your server at roughly the same time,
          and our apache daemon spawned 150 processes, consuming 5Mb
          each. That brings the memory usage up to 750Mb. The system
          itself consumes about 50Mb of your memory, so at peak loads
          it will be consuming around 800Mb of RAM. If you want your
          server to be snappy at all times, you will need to have at
          least that much memory in your box, however, if you decide
          that such coincidence is not very likely and you'd rather
          save on extra memory, you can settle on 512Mb and let the
          swapping process catch the rest.
        </para>
        <para>
          On the other hand, if you are an ISP with most clients being
          home-users, you are not likely to experience more than 10%
          of your clients trying to connect at the same time. The
          memory requirement would be more relaxed, and it is likely
          that 256Mb of memory will suffice for you. Nevertheless,
          it's always better to have more memory, than less, so you
          are still encouraged to use 512Mb for 500 clients.
        </para>
        <para>
          In general, to calculate how much memory you will need use
          the following formulas:
        </para>
        <segmentedlist>
          <title>RAM considerations</title>
          <segtitle>For a company</segtitle>
          <segtitle>For an ISP with home-users</segtitle>
          <seglistitem>
            <seg>N/3*5+50</seg>
            <seg>N/10*5+50</seg>
          </seglistitem>
        </segmentedlist>
        <para>
          For 500 users these values will be 880Mb and 300Mb
          respectively. If you are going to rely on swapping, you can
          bring these values down to 512Mb and 256Mb.
        </para>
      </sect2>
      <sect2>
        <title>CPU requirements</title>
        <para>
          None of the processes are very CPU-intensive, actually, and
          you are not very likely to bottleneck at the processor
          level. Again, the only exception to this is if you are doing
          spam filtering or virus checking, which tends to tax the
          system very heavily both in terms of RAM and CPU.  Overall,
          I would recommend using something like a 1.5 GHz and above
          system for 500 users, so the calculation formula would look
          something like so:
        </para>
        <segmentedlist>
          <title>CPU Considerations</title>
          <segtitle>Lower end</segtitle>
          <segtitle>Higher end</segtitle>
          <seglistitem>
            <seg>N*1.5+800</seg>
            <seg>N*2+1000</seg>
          </seglistitem>
        </segmentedlist>
        <para>
          I'm using the +800 method simply because I think that if
          you decide to use something less than a 800Mhz system, you
          are likely to be plagued by various problems related to
          aging hardware.
        </para>
      </sect2>
      <sect2>
        <title>Other things</title>
        <para>
          I am not covering networking environment and bandwidth,
          since you will likely have to stick with what you already
          have anyway. A common 100Base-T network card will suffice in
          terms of a NIC. However, you should consider implementing
          some sort of a backup solution to make sure that you don't
          lose your job or go out of business when your server catches
          on fire and you find it reduced to cinders when you come to
          work one lovely Monday morning. I have only good words to
          say about Amanda <ulink
          url="http://www.amanda.org/">http://www.amanda.org/</ulink>,
          or you may choose some of the many alternatives.
        </para>
        <para>
          Refer to the &quot;Backup&quot; section further in the
          document for the list of directories to include in your
          backup run, and for restoring instructions.
        </para>
      </sect2>
    </sect1>
    <sect1>
      <title>Installing &os; &ver;</title>
      <para>
        There are two ways to do it. One is to get installation CDs
        and go through the installation process yourself, and another
        one is to use kickstart for a network install of a
        cookie-cutter &qvcs; system. In any case you will need the
        following information.
      </para>
      <sect2>
        <title>Partitioning</title>
        <para>
          You need to have at least 4 partitions:
          <simplelist type="inline">
            <member>/</member>
            <member>swap</member>
            <member>/var</member>
            <member>/home</member>
          </simplelist>.
        </para>
        <para>
          Use the calculations we just did in the previous section to
          come up with appropriate partition sizes, and create the
          &quot;/home&quot; partition last letting it use the rest of
          the remaining disk space. If you're making a RAID-1, utilize
          <application>Disk Druid's</application> nice RAID'ing
          features.
        </para>
        <para>
          For our example, the partitions would look like so, for a
          40Gb HDD:
        </para>
        <programlisting>
/     - 1Gb
swap  - 1024Mb
/var  - 7Gb
/home - the rest
        </programlisting>
      </sect2>
      <sect2>
        <title>Installing &os; &ver;</title>
        <tip>
          <para>
            This document uses &osbase; for the location of
            installable &os; media, but you can refer to the &ossite;
            to see the list of available mirrors if this one is too
            slow or otherwise unsuitable for you.
          </para>
        </tip>
        <para>
          This document doesn't cover the installation of &os;, but
          generally you can use several possible ways of installing:
          most commonly by installing from ISOs, or by doing it over
          the network. 
        </para>
        <sect3>
          <title>Installing from ISOs</title>
          <para>
            First you will need to download and burn the isos, which
            you can find on the <ulink url="&ossite;">Centos List of
            Mirrors</ulink>, then boot from the first binary ISO to
            start the installation process.
          </para>
        </sect3>
        <sect3>
          <title>Installing from the Network</title>
          <para>
            This installation process is similar to the previous one,
            except that you only have to download and burn a very
            small image called boot.iso. Download <ulink
            url="&osbase;/os/i386/images/">the boot.iso from the Centos
            mirror site</ulink>, burn it, and boot from it.
          </para>
        </sect3>
        <sect3>
          <title>Generic Installation Instructions</title>
          <para>
            The install process is simple enough. Just follow the
            setup screens, paying attention to the partitioning scheme
            we have discussed above. When it gets to package
            installation select &quot;Custom&quot; and then
            <emphasis>uncheck all groups in the selection
            list</emphasis>. For this installation we only want the
            core of the operating system.
          </para>
          <para>
            Once the installation is complete, reboot, login as root,
            and perform the following actions:
          </para>
          <programlisting>
&prompt; <userinput>wget &qvcsbase;/qvcs-init-centos</userinput>
&prompt; <userinput>sh qvcs-init-centos</userinput>
          </programlisting>
          <para>
            <application>Qvcs-init</application> will install the
            public keys, update your machine to the latest &os; errata
            for &ver;, download and install qmail source RPM (binary
            qmail RPMs cannot be distributed due to license
            restrictions), and then download and install &qvcs;
            related applications.
          </para>
        </sect3>
      </sect2>
    </sect1>
    <sect1>
      <title>QVCS-install</title>
      <para>
        Now, after the core of &qvcs; is installed, we need to run
        <command>qvcs-install</command> in order to configure the
        system for our purposes.
      </para>
      <programlisting>
&prompt; <userinput>qvcs-install</userinput>
      </programlisting>
      <para>
        This utility will configure the system software for some
        default settings, suitable for running the base &qvcs;
        install. The best thing about it is the fact that it will save
        backup copies of the files it overwrites into
        <filename>/var/lib/qvcs</filename> so you can always restore
        old configurations if you find it necessary.
      </para>
      <para>
        Once this step is done, you are ready to configure your system
        for actual use.
      </para>
    </sect1>
  </chapter>
  <chapter id="config-basic">
    <title>Basic Configuration</title>
    <para>
      Let's go ahead and configure your system so it's suitable for
      your purposes.
    </para>
    <note>
      <title>Examples</title>
      <para>
        For the sake of providing examples, I will be using the
        following virtual domains to make the narrative easier to
        follow:
        <simplelist type="inline">
          <member>hogwarts.jk</member>
          <member>theministry.jk</member>
          <member>quibbler.jk</member>
        </simplelist>
        (what Harry Potter addiction?).
      </para>
    </note>
    <sect1>
      <title>Creating the first virtual domain</title>
      <para>
        The first virtual domain requires some effort, but only
        relative to the others. Here is how to go about it.
      </para>
      <note>
        <para>
          If you are getting &quot;<computeroutput>command not
          found</computeroutput>&quot; errors, make sure you are
          logged in as root. If you have used <command>su</command> to
          become root, make sure you use &quot;<command>su
          -</command>&quot; to enable the root environment.
        </para>
      </note>
      <programlisting>
&prompt; <userinput>addvirt hogwarts.jk</userinput>
      </programlisting>
      <para>
        The <command>addvirt</command> script will ask you for a
        password. Remember it, as you will need it to enable the
        domain in vadmin. Make sure it's a good one, too, as it is a
        system password and though the account is marked as
        <command>/sbin/nologin</command> during creation, having poor
        passwords is one of the main reasons servers get cracked.
      </para>
      <para>
        Now you need to create the first virtual user. To do that, you
        will need to switch to the domain &quot;master user&quot; and
        use the <command>vadduser</command> command to create the
        virtual account. If you look at the output of the
        <command>addvirt</command> command, you will notice something
        to the matter of &quot;<computeroutput>Creating new domain
        user &quot;hogwarts_jk&quot;</computeroutput>. In the next
        command you will need to use the username reported by
        <command>addvirt</command> instead of &quot;hogwarts_jk&quot;
        (usually it just substitutes all dots for underscores in the
        domain name to arrive at the username). Oh, and make it
        something other than &quot;albus,&quot; of course.
      </para>
      <programlisting>
&prompt; <userinput>su -s /bin/bash - hogwarts_jk</userinput>
<prompt>[hogwarts_jk@mail hogwarts_jk]$ </prompt><userinput>vadduser albus</userinput>
<prompt>[hogwarts_jk@mail hogwarts_jk]$ </prompt><userinput>exit</userinput>
      </programlisting>
    </sect1>
    <sect1>
      <title>Editing <filename>/etc/vadmin/vadmin.conf</filename></title>
      <tip>
        <para>
          The only editor that comes with your machine is
          <command>vi</command>. If it gives you the creeps, you can
          install <command>nano</command> by using yum. Nano is a
          successor to pico and inherits all of its shortcuts.
        </para>
        <programlisting>
&prompt; <userinput>yum install nano</userinput>
        </programlisting>
        <para>
          It is useful to know that calling nano with a &quot;-w&quot;
          flag will turn off automatic line wrapping. Good for files
          where you have to type a very long line without it wrapping:
        </para>
        <programlisting>
&prompt; <userinput>nano -w filename.conf</userinput>
        </programlisting>
      </tip>
      <para>
        Open <filename>/etc/vadmin/vadmin.conf</filename> in your
        editor and locate the <varname>[auth]</varname>
        section. Change the <varname>elvis</varname> parameter to
        reflect the virtual user that you have just added.
      </para>
      <programlisting>
[auth]
    method = user
    force_https = yes
    elvis = albus@hogwarts.jk
      </programlisting>
    </sect1>
    <sect1>
      <title>Editing <filename>/etc/httpd/conf.d/vadmin.conf</filename></title>
      <para>
        This apache include file provides a secret hash string that
        will be used to encrypt your vadmin data. Right now it says
        &quot;LLAMA&quot; but go ahead and change it to something
        other than that. It can be any string of any length and
        contain any characters as long as they aren't quotes. Lines
        from your favorite songs or books are a good choice. For
        example:
      </para>
      <programlisting>
&lt;Directory "/usr/share/squirrelmail"&gt;
 SetEnv CRYPTO_HASH_LINE "Draco Dormiens Nunquam Titillandus"
 SetEnv MCRYPT_ALGO "rc4_builtin"
&lt;/Directory&gt;
      </programlisting>
      <tip>
        <para>
          You can set the <varname>MCRYPT_ALGO</varname> to something
          other than &quot;rc4_builtin&quot; if you want stronger
          encryption than rc4. &quot;Blowfish&quot; is a good fast
          algorithm, but you may choose among the following:
          <simplelist type="inline">
            <member>blowfish</member>
            <member>twofish</member>
            <member>tripledes</member>
            <member>gost</member>
            <member>serpent</member>
          </simplelist>, and others. Consult libmcrypt documentation
          for more info.
        </para>
      </tip>
    </sect1>
    <sect1>
      <title>What's in the name?</title>
      <para>
        It is useful to check whether the qmail installer set your
        hostname correctly. Go into
        <filename>/etc/qmail/control</filename> and check what the
        file &quot;<filename>me</filename>&quot; says. It may be
        empty, or it may contain the FQDN of your server. You want to
        put the official name of your server in that file,
        e.g. &quot;mail.yourisp.com&quot; -- it should not remain
        empty, as that will cause some outgoing mail to bounce.
      </para>
    </sect1>
    <sect1>
      <title>Reboot</title>
      <para>
        Well, you're done! Reboot to enable the new configurations.
      </para>
      <programlisting>
&prompt; <userinput>reboot</userinput>
      </programlisting>
    </sect1>
    <sect1>
      <title>A note on DNS</title>
      <para>
        DNS is not covered in this guide, but it would be as easy as
        pointing &quot;mail.hogwarts.jk&quot; to the IP address of
        your server. Same goes for all other mail.domainname.com
        settings -- as long as you point them at the IP address of
        your brand new &qvcs; system, you are set. Oh, and, of course,
        don't forget to <command>addvirt</command> them.
      </para>
      <tip>
        <para>
          If you are just playing around with your system and don't
          feel like mucking with DNS quite yet, you can edit the
          resolver on your local computer to point to a certain IP
          address so your browser knows where to go. In Linux/UN*X
          this would be in <filename>/etc/hosts</filename>, while for
          windows the file is somewhere in
          <filename>C:\WINDOWS\system32</filename>. Google for
          &quot;<userinput>/etc/hosts windows</userinput>&quot; for
          more information.
        </para>
      </tip>
    </sect1>
  </chapter>
  <!-- #################################################################### -->
  <chapter>
    <title>Administering your system</title>
    <sect1>
      <title>Logging in to Vadmin</title>
      <para>
        <application>Vadmin Plugin for Squirrelmail</application> is a
        tool written to simplify mundane tasks such as adding and
        deleting users, activating domains, setting quotas, etc.  To
        log in, surf to
        <userinput>https://mail.hogwarts.jk/</userinput> and log in as
        the user you have specified as <varname>elvis</varname> in
        vadmin configuration. Once you log in, click on
        &quot;options&quot; and find the &quot;Administrator
        Interface&quot; link presented somewhere on the page.
      </para>
      <para>
        The administrator interface starts with a login screen. Type
        in your mailbox password (the same password you used to log in
        to <application>Squirrelmail</application>). The next screen
        will prompt you for the domain password -- it's the one you
        used when creating the virtual domain using the
        <command>addvirt</command> command. Once you submit the
        password, it will be stored on the server in an encrypted
        format.
      </para>
    </sect1>
    <sect1>
      <title>Elvises, Admins, Cross-Admins, Oh My!</title>
      <para>
        There are three levels of admins in Vadmin. There is a
        superuser (lovingly referred to as &quot;elvis&quot;),
        cross-admins, and &quot;lowly&quot; admins. Here are the main
        differences.
      </para>
      <sect2>
        <title>Elvis</title>
        <para>
          Elvis has access to all virtual domains configured on the
          system -- it's the &quot;root&quot; in terms of system
          accounts. Elvis is also the only user who can administer
          cross-admins.
        </para>
      </sect2>
      <sect2>
        <title>Cross-admins</title>
        <para>
          Cross-admins are users who can administer more than one
          domain, just in case you have users who own
          several. Cross-admin setup tools in Vadmin allow you to set
          up who these users are and which domains they have access
          to.
        </para>
      </sect2>
      <sect2>
        <title>Lowly Admins</title>
        <para>
          This is the lowest form of administrators -- they can only
          administer one domain -- their own. You can give a user
          administrator privileges by checking &quot;<emphasis>can
          administer this domain</emphasis>&quot; in the &quot;edit
          user&quot; screen.
        </para>
      </sect2>
    </sect1>
    <sect1>
      <title>Domain Limits</title>
      <para>
        This version of Vadmin introduces the option to limit how much
        control lower admins have over certain domains. For example,
        you as elvis can specify how many mailboxes there are allowed
        in a domain, how much maximum quota a user can have, how many
        messages they are allowed to have in their inbox, etc. There
        are two levels of domain limits -- the ones set up by an
        elvis, and another set up by a cross-administrator. The latter
        cannot override the master limits as specified by the
        superuser.
      </para>
      <note>
        <para>
          If you are upgrading from an earlier version of Vadmin, note
          that domain limits do not apply retroactively. In other
          words, if you have a domain with users who have their quotas
          set to 200Mb, setting a domain-wide limit of 100Mb will not
          affect already existing accounts. Only when new accounts are
          created will the maximum quota limit be enforced.
        </para>
      </note>
    </sect1>
    <sect1>
      <title>Root Email</title>
      <para>
        We need to set up the address for root, otherwise important
        system messages will go into the bit bucket. To do this, edit
        <filename>/etc/aliases.qmail</filename> and uncomment the last
        line, changing &quot;mark&quot; to some real address. Then do
        the following:
      </para>
      <programlisting>
&prompt; <userinput>ln -s /etc/aliases.qmail /etc/aliases</userinput>
&prompt; <userinput>newaliases</userinput>
      </programlisting>
      <para>
        Remember to run <command>newaliases</command> every time you
        edit <filename>/etc/aliases</filename>, otherwise the system
        will be unaware of the changes. Also note that
        <filename>/etc/aliases</filename> can only be used for real
        users, not virtual users. Use vadmin to set up the aliases and
        forwards for the latter.
      </para>
    </sect1>
    <sect1>
      <title>Removing domains</title>
      <para>
        To remove domains, use &quot;<command>rmvirt
        domainname.com</command>&quot;. It will optionally back up
        configurations for the domain before removing it entirely.
      </para>
    </sect1>
    <sect1>
      <title>Automated Updates Using Yum</title>
      <para>
        The tool we have used for installation --
        <application>yum</application> is an automated
        installer/updater that is a free substitute for up2date. One
        of the most important aspects of running a server is keeping
        it constantly patched, so any security vulnerabilities are
        mitigated as soon as Red Hat issues fixes.
      </para>
      <para>
        If your installation is more or less a vanilla setup of
        &qvcs;, then you might consider enabling automated nightly
        updates of your system, so any errata packages are applied as
        soon as they are released. To do so, run:
      </para>
      <programlisting>
&prompt; <userinput>chkconfig yum on</userinput>
&prompt; <userinput>service yum start</userinput>
      </programlisting>
      <para>
        If you feel edgy about having an automated updater tool
        running on your system, you may leave auto-updating disabled,
        but then I would suggest putting a &quot;yum
        check-update&quot; run into your nightly cron run. The
        following will notify the root user whenever there are updates
        available for the system:
      </para>
      <programlisting>
&prompt; <userinput>echo "yum -d 0 check-update" > /etc/cron.daily/yum-check.cron</userinput>
&prompt; <userinput>chmod a+x /etc/cron.daily/yum-check.cron</userinput>
      </programlisting>
      <para>
        Evaluate any updates and apply them. Don't let your server
        become a part of the sad Internet cracking statistic.
      </para>
      <para>
        To update your system manually, run:
      </para>
      <programlisting>
&prompt; <userinput>yum update</userinput>
      </programlisting>
    </sect1>
    <sect1>
      <title>Keeping in Time</title>
      <para>
        It is important for a mailserver to have its clock set
        correctly, otherwise there may be problems with messages being
        timestamped incorrectly. This will help keep your clock in
        sync with the central network time authority. Create a file
        <filename>/etc/cron.hourly/rdate.cron</filename> and put the
        following in it:
      </para>
      <programlisting>
#!/bin/sh
# Synchronize the time with nist.gov
(/usr/bin/rdate -s time.nist.gov) &amp;&amp; (/sbin/hwclock --systohc)
      </programlisting>
      <para>
        Then set the execute permissions:
      </para>
      <programlisting>
&prompt; <userinput>chmod 755 /etc/cron.hourly/rdate.cron</userinput>
      </programlisting>
    </sect1>
    <sect1>
      <title>Virtual Users</title>
      <para>
        There are several ways your users can log in to check their
        email. All of the following forms are correct for the virtual
        user &quot;albus&quot; at the virtual domain
        &quot;hogwarts.jk&quot;:
      </para>
      <programlisting>
albus@hogwarts.jk
albus:hogwarts.jk
hogwarts_jk-albus
      </programlisting>
      <para>
        However, it is ill-advised to let your clients know of any
        other method besides the very first one. Just let them use
        their email address as the username, and you will be sure to
        avoid a lot of confusion.
      </para>
    </sect1>
    <sect1>
      <title>Backup</title>
      <para>
        There are many backup systems out there, so I will not cover
        them in this little foray. Instead, I will tell you which
        parts to back up, and it will be up to you to come up with a
        method.
      </para>
      <para>
        The following files and/or directories need to be backed up in
        a cookie-cutter &qvcs; system. If you make additions or
        modifications, you will need to make sure they are reflected
        in this list.
      </para>
      <note>
        <para>
          Some of the files in this list include the ones created or
          modified in the advanced section. If you did not add
          advanced features, your system may lack some of these
          entries.
        </para>
      </note>
      <programlisting>
/etc/passwd
/etc/shadow
/etc/group
/etc/sslcert.pem
/etc/sysconfig/spamassassin
/etc/sysconfig/iptables
/etc/hosts.*
/etc/xinetd.d/smtp
/etc/ssh/*_key*
/etc/httpd
/etc/vadmin
/etc/squirrelmail
/etc/qmail
/etc/courier-imap
/etc/vmailmgr
/var/lib/vadmin
/var/lib/squirrelmail
/var/qmail/queue
/home/dom
/root
        </programlisting>
    </sect1>
    <sect1>
      <title>Restore</title>
      <para>
        If your system has crashed and you have to reinstall
        everything from scratch, here is how you would go about it.
      </para>
      <procedure>
        <step>
          <para>
            <emphasis>Install a vanilla system</emphasis>.
            Just create a vanilla &os; &ver; setup.
          </para>
        </step>
        <step>
          <para>
            <emphasis>Restore the backup files</emphasis>.  Restore
            them over the existing tree. For example, if your backup
            is in <filename>/home/bak.tar.gz</filename>, then you
            would restore it like this:
          </para>
          <programlisting>
&prompt; <userinput>cd /</userinput>
&prompt; <userinput>tar xzvf /home/bak.tar.gz</userinput>
          </programlisting>
        </step>
        <step>
          <para>
            <emphasis>Run qvcs-init-centos</emphasis>. Refer to the
            install section of this guide. It will wordily complain
            about creating .rpmnew files, but that's exactly what you
            want.
          </para>
        </step>
        <step>
          <para>
            <emphasis>Run qvcs-install</emphasis>. However, skip all
            sections except the last two -- where it enables/disables
            services and removes sendmail.
          </para>
        </step>
      </procedure>
      <para>
        This should be it. After these steps are done, your system
        should be reinstalled.
      </para>
    </sect1>
  </chapter>
  <!-- #################################################################### -->
  <chapter>
    <title>Advanced Configuration</title>
    <para>
      At this point you have a system that provides the skeleton of a
      full email solution. However, you will probably want to take
      this further and add some features useful for a modern email
      service.
    </para>
    <sect1>
      <title>Encrypted Communication (SSL)</title>
      <para>
        You will most likely want to configure SSL on your newly
        installed machine. It is already enabled for the most part,
        but not at all configured. First thing you will need is an SSL
        certificate.
      </para>
      <para>
        Let's first of all create a test certificate to practise
        on. Perform the following actions:
      </para>
      <programlisting>
&prompt; <userinput>cd /usr/share/ssl/certs</userinput>
&prompt; <userinput>make stunnel.pem</userinput>
      </programlisting>
      <para>
        The program will ask you some questions, the most important of
        which is &quot;Common Name&quot;. That would be the host name
        of your server, but before we do that, let's have a bit of a
        segue.
      </para>
      <note>
        <title>SSL And Virtual Hosts</title>
        <para>
          Doing SSL on virtual hosts is tricky because the client
          machine will check whether the hostname of the server
          matches the &quot;common name&quot; listed in the
          certificate it provides during the &quot;SSL
          Handshake&quot;. If these two do not match, the client will
          either drop the connection, or present the user with a very
          large, very obnoxious, and very visible SSL certificate
          warning.
        </para>
        <para>
          The solution is to pick a consistent host name for your
          mailserver that would be both convenient and reflect upon
          your company as the provider of the service. I.e. if you are
          known as &quot;The Quibbler Data Express&quot;, you will
          want to make &quot;mail.quibbler.jk&quot; as the common name
          for your SSL certificate. This is the address you will give
          out to all your clients for their outgoing and incoming
          email (SSL interface for the webmail using vadmin redirects
          is discussed further down).
        </para>
        <para>
          So, once you have decided on which domain name you are going
          to use as your main SSL host, go ahead and fill out the
          &quot;Common Name&quot; field in the test certificate. I'll
          use &quot;mail.quibbler.jk&quot; for my examples.
        </para>
      </note>
      <para>
        Once you're done, you will see a
        <filename>stunnel.pem</filename> in that directory. A good
        place for it to be is in <filename>/etc/sslcert.pem</filename>
        so it can be easily backed up.
      </para>
      <programlisting>
&prompt; <userinput>mv stunnel.pem /etc/sslcert.pem</userinput>
      </programlisting>
      <sect2>
        <title>Enabling SSL in Qmail</title>
        <para>
          Qmail never runs as user root, so we will need to change the
          ownership on the ssl certificate to that of user
          &quot;qmaild&quot;:
        </para>
        <programlisting>
&prompt; <userinput>chown qmaild /etc/sslcert.pem</userinput>
&prompt; <userinput>chmod u-w /etc/sslcert.pem</userinput>
&prompt; <userinput>ln -s /etc/sslcert.pem /etc/qmail/control/servercert.pem</userinput>
&prompt; <userinput>service qmail restart</userinput>
        </programlisting>
      </sect2>
      <sect2>
        <title>Enabling SSL in Courier-IMAP</title>
        <para>
          Simple enough:
        </para>
        <programlisting>
&prompt; <userinput>ln -s /etc/sslcert.pem /etc/courier-imap/sslcert.pem</userinput>
&prompt; <userinput>service courier-imap restart</userinput>
        </programlisting>
      </sect2>
      <sect2>
        <title>Enabling SSL in Apache</title>
        <para>
          Almost the exact same set of actions for Apache.
        </para>
        <programlisting>
&prompt; <userinput>cd /etc/httpd/conf</userinput>
&prompt; <userinput>rm ssl.crt/server.crt ssl.key/server.key</userinput>
&prompt; <userinput>ln -s /etc/sslcert.pem ssl.crt/server.crt</userinput>
&prompt; <userinput>ln -s /etc/sslcert.pem ssl.key/server.key</userinput>
&prompt; <userinput>service httpd restart</userinput>
        </programlisting>
      </sect2>
      <sect2>
        <title>Vadmin And SSL Enforcement</title>
        <para>
          You may wish to enforce SSL in vadmin, so all your clients
          are redirected to an SSL site. Open
          <filename>/etc/vadmin/vadmin.conf</filename> in your editor
          and locate a commented-out section called
          &quot;<varname>[redirect]</varname>&quot;. Remove the
          semicolons and change it so it looks like so:
        </para>
        <programlisting>
[redirect]
    https = yes
    host = mail.quibbler.jk
    path = /
        </programlisting>
        <para>
          Now if you go to mail.hogwarts.jk, it will transparently
          redirect you to https://mail.quibbler.jk/, thus ensuring
          that all your communication with the server is secured.
        </para>
      </sect2>
      <sect2>
        <title>Obtaining a Real SSL Certificate</title>
        <para>
          Depending on how serious you want to be, you might want to
          go ahead and obtain a real SSL certificate, as sold by the
          Certification Authorities. Obtaining an SSL certificate is
          usually a painful and expensive process -- they run for
          about $150 per year per hostname. Several companies provide
          CA services: for more information go to <ulink
          url="http://www.whichssl.com/">www.whichssl.com</ulink>. If
          you are not worried about your clients seeing warning
          messages in their browsers about unrecognized signing
          authorities, then you may skip this part -- the self-signed
          certificate you created by running <command>make
          stunnel.pem</command> is just as secure.
        </para>
        <para>
          Trained monkeys working at the CA companies should be able
          to walk you through the process once you have decided that
          you want a real certificate and picked which company you
          want to spend money with. When you have the real certificate
          made out for the domain name that you have picked, you will
          need to make a .pem file out of the .crt and .key parts
          (unless they can give you a .pem file in the first
          place). This is done by simply concatenating the .crt and
          .key files together. E.g.:
        </para>
        <programlisting>
&prompt; <userinput>cat server.key server.crt > sslcert.pem</userinput>
        </programlisting>
        <para>
          If your key is protected by a passphrase, you will need to
          remove it before making a .pem, as otherwise every time the
          server restarts you will need to enter the passphrase
          manually, plus qmail SSL will simply not work. To remove the
          passphrase, perform the following actions:
        </para>
        <programlisting>
&prompt; <userinput>openssl rsa -in server.key -out nopass.key</userinput>
&prompt; <userinput>mv nopass.key server.key</userinput>
        </programlisting>
        <para>
          Once you have the <filename>sslcert.pem</filename> file,
          just replace our self-signed certificate in
          <filename>/etc/sslcert.pem</filename> and restart the
          services (qmail, courier-imap, httpd). Congratulations,
          you've now officially sold your soul to big business.
        </para>
      </sect2>
    </sect1>
    
    <sect1>
      <title>Selective Relaying</title>
      <para>
        Selective relaying is a method of allowing certain
        &quot;trusted&quot; incoming email messages to be sent further
        along to their final destination. You don't want
        <emphasis>ALL</emphasis> messages to be relayed, as that would
        quickly make your server the target for relaying spam, but you
        might want to enable this for your clients. If you want your
        users to be able to use your mailserver when they send
        outgoing email (not just via the webmail interface, that is),
        read this part.
      </para>
      <sect2>
        <title>Origin-based relaying</title>
        <para>
          Let's say you have a certain range of IP addresses that your
          users send email from. This range of addresses is therefore
          a &quot;trusted subnet&quot; and we can configure our
          mailserver to accept email from this origin without any
          further questioning and relay the messages to wherever they
          need to go.
        </para>
        <para>
          We will use tcp wrappers for selective relaying. Open the
          <filename>/etc/hosts.allow</filename> file in your editor: it
          should currently have the following entries:
        </para>
        <programlisting>
tcp-env: 127.0.0.1 : setenv RELAYCLIENT
tcp-env: ALL
        </programlisting>
        <para>
          Let's say that we want everyone from our trusted network to
          send their outgoing e-mail through our mailserver. If our
          trusted network is <varname>192.168.1.0/24</varname>, then
          we would change <filename>/etc/hosts.allow</filename> as
          follows:
        </para>
        <programlisting>
tcp-env: 127.0.0.1 192.168.1. : setenv RELAYCLIENT
tcp-env: ALL
        </programlisting>
        <para>
          If we only had a fraction of class C, we could change it as
          follows:
        </para>
        <programlisting>
tcp-env: 127.0.0.1 192.168.1.0/255.255.255.128 : setenv RELAYCLIENT
tcp-env: ALL
        </programlisting>
        <para>
          or, we could limit it by domain name, like so:
        </para>
        <programlisting>
tcp-env: 127.0.0.1 .hogwarts.jk : setenv RELAYCLIENT
tcp-env: ALL
        </programlisting>
        <para>
          This would mean that any host with IP address resolving to
          &quot;somehost.hogwarts.jk&quot; would be allowed to relay
          e-mail.
        </para>
        <para>
          If you have a lot of relaying rules, keeping them all on one
          line might get messy. In this case you may create a separate
          file with all the allowed hosts and networks in it. For
          example, put all your rules in the file
          <filename>/etc/relay.rules</filename>, so it contains
          something like this:
        </para>
        <programlisting>
127.0.0.1
.hogwarts.jk
192.168.1.0/255.255.255.128
rosmerta.hogsmeade.jk
        </programlisting>
        <para>
          and change <filename>/etc/hosts.allow</filename> to contain
          the following entries:
        </para>
        <programlisting>
tcp-env: /etc/relay.rules : setenv RELAYCLIENT
tcp-env: ALL
        </programlisting>
        <para>
          For more information about various patterns read the manual
          page for tcp wrappers. You can view it by executing:
        </para>
        <programlisting>
&prompt; <userinput>man hosts.allow</userinput>
        </programlisting>
      </sect2>
      <sect2>
        <title>Authenticated SMTP</title>
        <para>
          Naturally, if your clients tend to travel and bring their
          laptops with them, then specifying the allowed IP ranges is
          not going to be very useful. Authenticated SMTP allows
          relaying of email messages only for people who already have
          accounts on the server. In fact, this is the preferred way
          of relaying email these days.
        </para>
        <para>
          Open <filename>/etc/xinetd.d/smtp</filename> in your
          favorite editor and modify the server-args line so it looks
          like so (<emphasis>NOTE: The following is all on one
          line!</emphasis>):
        </para>
        <programlisting>
server_args = /var/qmail/bin/tcp-env -R /var/qmail/bin/qmail-smtpd mail.quibbler.jk /usr/bin/chk_vmauth
        </programlisting>
        <para>
          As usual, replace &quot;mail.quibbler.jk&quot; with the
          name of your mail server (the one specified in the SSL
          certificate). After you're done editing that file, run:
        </para>
        <programlisting>
&prompt; <userinput>service xinetd restart</userinput>
        </programlisting>
      </sect2>
    </sect1>
    <sect1>
      <title>Email filtering</title>
      <para>
        This seems to be a popular request, and &qvcs; is certainly
        capable of providing the infrastructure needed for
        this. However, let me start with a huge warning.
      </para>
      <warning>
        <title>Huge Warning</title>
        <para>
          Email filtering requires some <productname>BEEFY
          HARDWARE</productname>. If your mail server sees some
          significant email traffic, and I'm talking upwards of 5-10
          thousand emails a day, you will want to have some serious
          iron for hardware, especially in terms of RAM and processor
          speed. If you have less than 1G of high-speed memory, the
          server performance will degrade significantly, and anyone
          putting a less-than AMD/P4 2GHz for this will soon come to
          regret their foolishness. You have been forewarned.
        </para>
      </warning>
      <sect2>
        <title>Spamassassin</title>
        <para>
          Now let's enable spamassassin. Since you are using virtual
          users, there are certain options you will need to set in
          order for the spamd daemon not to complain. Open
          <filename>/etc/sysconfig/spamassassin</filename> in your
          editor and change the <varname>SPAMDOPTIONS</varname> line
          to be the following:
        </para>
        <programlisting>
SPAMDOPTIONS="-d -c -a -m30 -H -x -u nobody"
        </programlisting>
        <para>
          Now start it:
        </para>
        <programlisting>
&prompt; <userinput>chkconfig spamassassin on</userinput>
&prompt; <userinput>service spamassassin restart</userinput>
        </programlisting>
        <para>
          Now let's tell qmail-scanner that it can use
          spamassassin. The following command will reconfigure it --
          it will take forever to run, so don't fret if it's been
          sitting there for a while. Eventually it'll get finished.
        </para>
        <programlisting>
&prompt; <userinput>cd /usr/share/qmail-scanner</userinput>
&prompt; <userinput>./configure --batch --debug no --install</userinput>
        </programlisting>
        <para>
          Not done yet! Now you have to edit
          <filename>/etc/hosts.allow</filename> and change your
          tcp-env : ALL line as follows:
        </para>
        <programlisting>
tcp-env: ALL : setenv QMAILQUEUE /var/qmail/bin/qmail-scanner-queue.pl
        </programlisting>
        <para>
          Now you've done it!
        </para>
      </sect2>
      <sect2>
        <title>How to filter out spam</title>
        <para>
          If you now look at the headers of your email messages, you
          will see something like this:
        </para>
        <programlisting>
Received: from luna@quibbler.jk by peeves by uid 500 with qmail-scanner-1.22
     (spamassassin: 2.63. Clear:SA:0(0.4/5.0):.
     Processed in 3.495582 secs); 29 Jul 2004 02:53:49 -0000
X-Spam-Status: No, hits=0.4 required=5.0
        </programlisting>
        <para>
          The key here is the header
          <varname>X-Spam-Status</varname>. All you have to do is
          configure your email client to look for that header, and if
          it contains &quot;Yes&quot;, either move the message into
          the <emphasis>Junk</emphasis> folder, or assign it a low
          priority. Simply deleting messages marked as
          &quot;<varname>X-Spam-Status: Yes</varname>&quot; is not at
          all advised, as any automated system will have
          false-positives, meaning that you can lose important email.
        </para>
      </sect2>
      <sect2>
        <title>Virus filtering</title>
        <para>
          You can also use <application>qmail-scanner</application> to
          set up virus scanning, but that is not covered here. Feel
          free to ask around on the support lists, perhaps someone has
          done it.
        </para>
      </sect2>
    </sect1>
  </chapter>
  <chapter>
    <title>Finalizing it all</title>
    <para>
      Your mail system is set up. If you have encountered any problems
      during the install, then consult the documentation provided with
      the misbehaving component -- it will most likely tell you whom
      to contact for support. If everything is running smoothly and
      you are happy with your system, then congratulations -- you've
      got yourself one of the best solutions for a pop-toaster out
      there.
    </para>
    <sect1>
      <title>Why this is not recommended for large systems</title>
      <para>
        The only reason this is not recommended for large systems is
        because SquirrelMail is currently not very scalable -- you
        cannot easily run it on a server farm, since both SquirrelMail
        and Vadmin save their preferences onto the HDD (a trade-off
        for not requiring a database engine). However, if you decide
        not to use SquirrelMail/Vadmin, then Qmail-VmailMgr-Courier is
        definitely a strong enough solution to be run on high-demand
        servers, but this has its own set of requirements and is not
        covered under this guide.
      </para>
    </sect1>
    <sect1>
      <title>Subscribe to the mailing lists!</title>
      <para>
        No, honestly, do so. Subscribe to the following two mailing lists:
      </para>
      <itemizedlist>
        <listitem>
          <para>
            <email>qvcs-guide-rpms@lists.sourceforge.net</email>
          </para>
        </listitem>
        <listitem>
          <para>
            <email>qvcs-guide-announce@lists.sourceforge.net</email>
          </para>
        </listitem>
      </itemizedlist>
      
      <para>
        The first one will notify you when newer RPMs become
        available, and the second one will tell you of any other
        happenings. To subscribe to these lists please go to the
        qvcs-guide website, at <ulink
        url="&qvcsbase;">&qvcsbase;</ulink>.
      </para>
    </sect1>
    <sect1>
      <title>Corrections and Comments</title>
      <para>
        If you've found a mistake in this document which you would
        like to correct, or would just like to comment on something,
        please send a message to
        <email>qvcs-guide-list@lists.sourceforge.net</email> so I can
        make the correction or read your comments. You may also check
        the qvcs-guide website at <ulink
        url="&qvcsbase;">&qvcsbase;</ulink> for the latest version of
        this document.
      </para>
    </sect1>
    <sect1>
      <title>Report your success</title>
      <para>
        If you found this Guide useful, please let me know by sending
        this brief email (replacing {your locality} with the name of
        your town, state, country).
      </para>
      <programlisting>
&prompt; <userinput>echo "Greetings from {your locality}." | mail qvcs-report@mricon.com -s "Thanks"</userinput>
      </programlisting>
      <para>
        Please also consider expressing your gratitude by sending me a
        gift from my Amazon Wishlist, which you may find on the main
        website. This will help me leverage the time I put into
        maintaining this guide and the packages that come with
        it. After all, this software isn't free as in beer, but free
        as in &quot;you are free to reward the author
        accordingly.&quot; :)
      </para>
    </sect1>
  </chapter>
  <chapter>
    <title>Upgrading from Red Hat 9 to &os; &ver;</title>
    <sect1>
      <title>Using the power of yum</title>
      <para>
        Upgrading from Red Hat 9 to &os; &ver; is actually painfully
        straightforward. Use these simple instructions to get up to
        speed in no time.
      </para>
      <sect2>
        <title>Modifying yum.conf</title>
        <para>
          Modify your yum.conf to look like this:
        </para>
        <programlisting>
[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
tolerant=1

[centos-base]
name=&os; &ver; Base
baseurl=&osbase;/os/i386/
gpgcheck=1

[centos-updates]
name=&os; &ver; Updates
baseurl=&osbase;/updates/i386/
gpgcheck=1

[qvcs-guide]
name=QVCS Guide RPM Repository
baseurl=&qvcsbase;/yum/centos-&ver;/
gpgcheck=1
        </programlisting>
        <tip>
          <para>
            You can use a different &os; &ver; URL if you wish -- they
            are all yum-enabled.
          </para>
        </tip>
      </sect2>
      <sect2>
        <title>Import the GPG key</title>
        <para>
          As with Red Hat 9, it's important to use GPG checking to
          make sure that the packages you're installing haven't been
          tampered with. Import the &os; key using the following
          command:
        </para>
        <programlisting>
&prompt; <userinput>lftpget &osbase;/os/i386/RPM-GPG-KEY-CentOS-3</userinput>
&prompt; <userinput>rpm --import RPM-GPG-KEY-CentOS-3</userinput>
        </programlisting>
      </sect2>
      <sect2>
        <title>Yum upgrade</title>
        <para>
          Now run the following command to upgrade your system to
          &os; &ver;:
        </para>
        <programlisting>
&prompt; <userinput>yum upgrade</userinput>
        </programlisting>
        <para>
          The upgrade process is likely to take some time, so prepare
          to be patient.
        </para>
      </sect2>
      <sect2>
        <title>Fix yum</title>
        <para>
          The upgrade will screw up yum.conf a little, so you'll need
          to fix it back again. To do it, perform the following
          command:
        </para>
        <programlisting>
&prompt; <userinput>mv /etc/yum.conf-SAVE /etc/yum.conf</userinput>
        </programlisting>
      </sect2>
    </sect1>
    <sect1>
      <title>Rebuild QMail</title>
      <para>
        I cannot at all distribute binary packages for qmail in this
        release, so you will need to rebuild them once yum upgrade
        terminates. Use the following commands:
      </para>
      <programlisting>
&prompt; <userinput>wget &qvcsbase;/qmail.src.rpm</userinput>
&prompt; <userinput>yum -y install rpm-build gcc openssl-devel</userinput>
&prompt; <userinput>rm -f /usr/src/redhat/RPMS/i386/qmail*rpm</userinput>
&prompt; <userinput>rpmbuild --rebuild --define 'allpatches 1' qmail.src.rpm</userinput>
&prompt; <userinput>cd /usr/src/redhat/RPMS/i386</userinput>
&prompt; <userinput>rpm -Uvh qmail*rpm</userinput>
      </programlisting>
    </sect1>
    <sect1>
      <title>Vadmin DB Change</title>
      <para>
        Centos does not come with gdbm storage enabled, so you will
        need to convert the database format from gdbm to db4. To do
        it, run the following command:
      </para>
      <programlisting>
&prompt; <userinput>vadmin-convert-gdbm2db4</userinput>
      </programlisting>
      <para>
        This should convert existing databases into the new .db4
        format. Now open /etc/vadmin/vadmin.conf and edit the
        [storage] section so it looks like this:
      </para>
      <programlisting>
[storage]
    type = dba
    flavor = db4
    suffix = .db4
    dir = /var/lib/vadmin
      </programlisting>
    </sect1>
    <sect1>
      <title>Miscellaneous</title>
      <para>
        Courier-Imap relies on fam_sgi to monitor when files change,
        and in this version sgi_fam relies on the portmapper to run
        correctly, so enable portmapper in the list of services:
      </para>
      <programlisting>
&prompt; <userinput>chkconfig portmap on</userinput>
      </programlisting>
      <para>
        If you were using qmail-scanner to filter your incoming email,
        you will need to rerun the configuration program as well (and,
        just as previously, it will take forever to run):
      </para>
      <programlisting>
&prompt; <userinput>cd /usr/share/qmail-scanner</userinput>
&prompt; <userinput>./configure --batch --debug no --install</userinput>
      </programlisting>
      <note>
        <para>
          I have noticed that sometimes the upgrade process locks the
          password file, causing the upgrade for qmail-scanner to
          fail. If the configure command fails with the warning about
          user "qscand" not existing, reboot the system, then run the
          following commands (yes, the rpm -e command needs to be run
          twice):
        </para>
        <programlisting>
&prompt; <userinput>rpm -e --noscripts qmail-scanner</userinput>
&prompt; <userinput>rpm -e --noscripts qmail-scanner</userinput>
&prompt; <userinput>yum -y install qmail-scanner</userinput>
        </programlisting>
        <para>
          This should create the necessary qscand user. After that you
          can re-run the configure script for qmail-scanner.
        </para>
      </note>
    </sect1>
    <sect1>
      <title>Clean up</title>
      <para>
        This is it! To tidy up, run the following command:
      </para>
      <programlisting>
&prompt; <userinput>yum clean</userinput>
      </programlisting>
      <para>
        If you have encountered problems during the upgrade, please
        report them to the mailing list.
      </para>
    </sect1>
  </chapter>

  <!-- APPENDIXES -->
  <appendix>
    <title>Description of Packages</title>
    <para>
      Let me explain in more detail what we just installed. There
      are overall 14 packages that constitute the qvcs system:
    </para>
    <itemizedlist>
      <listitem>
        <para>
          <application>qmail</application>: This is the package with
          all main qmail binaries. Qmail is an <acronym>MTA</acronym>
          and <acronym>MDA</acronym>, which stands for &quot;Mail
          Transport Agent&quot; and &quot;Mail Delivery
          Agent&quot;. It was written with security in mind and hasn't
          had a single security exploit in many years. Moreover, the
          author of this package has set up a prize of $1000 to anyone
          who can find a security flaw in qmail -- this prize has gone
          unclaimed in years.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>qmail-initscripts</application>: This package
          contains initialization and xinetd scripts for qmail,
          written specifically for &os;.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>courier-imap</application>: Courier-Imap is a
          very well-done IMAP server which was written specifically to
          work with &quot;Maildir&quot; mail storage system used by
          qmail. It is very fast, very standards compliant, and takes
          very little space in your computer's memory.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>vmailmgr</application>: This is the Virtual
          Mail Manager for qmail -- it is also an
          <acronym>MDA</acronym> and allows you to have
          &quot;virtual&quot; e-mail users without giving said users
          shell access on your system, which can often lead to
          security compromises.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>vmailmgr-courier-imap</application>: This small
          package adds an authentication module to courier-imap which
          allows it to work with virtual users set up by vmailmgr.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>vmailmgr-daemon</application>: A small package
          containing a special binary which lets vmailmgrd communicate
          with other daemons, like perl or php in our case.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>ucspi-unix</application>: This is a support
          package for vmailmgr-daemon and allows creating UNIX sockets
          on the system for communication between daemons.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>libmcrypt</application>: This is a set of
          encryption libraries used by vadmin plugin. Vadmin can
          optionally use libmcrypt to encrypt the passwords before
          storing them on the hard drive for enhanced security. By
          default it uses a builtin rc4 function.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>libmcrypt-devel</application>: This package is
          not installed by default and is only provided for the sake
          of completeness.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>php-mcrypt</application>: A shared library file
          which ties libmcrypt to php and provides php encryption
          functions.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>squirrelmail</application>: This is a great
          IMAP-based php webmail system.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>squirrelmail-vadmin</application>: Vadmin is a
          plugin for squirrelmail which makes administering vmailmgr
          virtual domains a part of squirrelmail. It has some very
          nice features like the ability to add/remove users, set
          quotas or account expiration dates, etc.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>qmail-autoresponder</application>: This package
          allows setting up autoresponders through the squirrelmail
          (vadmin) interface.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>qvcs-helpers</application>: This package has a
          few helper scripts which come with this guide.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>bglibs</application>: This package is not
          installed by default, but is needed to build several other
          packages. Unless you rebuild some packages from source RPMs,
          you do not need this.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>maildrop</application>: Part of the qvcs-filter
          package set, it is used by qmail-scanner.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>tnef</application>: A small application that
          will unpack Microsoft-style attachments. Useful for virus
          and spam scanning. Part of the qvcs-filter set.
        </para>
      </listitem>
      <listitem>
        <para>
          <application>qmail-scanner</application>: An alternative
          qmail-queue implementation that allows invoking spamassassin
          and various virus scanners. Part of the qvcs-filter package set.
        </para>
      </listitem>
    </itemizedlist>
  </appendix>
</book>
