old-www/LDP/solrhe/Securing-Optimizing-Linux-R.../chap23sec188.html

896 lines
15 KiB
HTML

<HTML
><HEAD
><TITLE
>Configure and Compile</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.60"><LINK
REL="HOME"
TITLE="Securing and Optimizing Linux"
HREF="index.html"><LINK
REL="UP"
TITLE="Linux IMAP & POP Server"
HREF="imapop.html"><LINK
REL="PREVIOUS"
TITLE="Linux IMAP & POP Server"
HREF="imapop.html"><LINK
REL="NEXT"
TITLE="Configure to tweak"
HREF="chap23sec189.html"></HEAD
><BODY
CLASS="section"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Securing and Optimizing Linux: RedHat Edition -A Hands on Guide</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="imapop.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 23. Linux <SPAN
CLASS="acronym"
>IMAP</SPAN
> &#38; <SPAN
CLASS="acronym"
>POP</SPAN
> Server</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="chap23sec189.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="pr6ch23sc1ip"
>23.1. Configure and Compile</A
></H1
><P
>&#13; With <SPAN
CLASS="acronym"
>IMAP</SPAN
> &#38; <SPAN
CLASS="acronym"
>POP</SPAN
> software, a remote <TT
CLASS="literal"
>client</TT
> email program can access message stores on the Linux mail server as if they were local. For example, email received and
stored on an <SPAN
CLASS="acronym"
>IMAP</SPAN
> server for a user can be manipulated from his/her computer at home, office, etc, without the need to transfer messages or files back and forth between these computers.
</P
><P
>&#13; <SPAN
CLASS="acronym"
>POP</SPAN
> stands for <TT
CLASS="literal"
>Post Office Protocol</TT
> and simply allows you to list messages, retrieve them, and delete them. <SPAN
CLASS="acronym"
>IMAP</SPAN
> is <SPAN
CLASS="acronym"
>POP</SPAN
> on steroids. It allows you to
easily maintain multiple accounts, have multiple people access one account, leave mail on the server, just download the headers, or bodies, no attachments, and so on. <SPAN
CLASS="acronym"
>IMAP</SPAN
> is ideal for anyone on the go, or
with serious email needs. The default <SPAN
CLASS="acronym"
>POP</SPAN
> and <SPAN
CLASS="acronym"
>IMAP</SPAN
> servers that most distributions ship fulfill most needs.
<DIV
CLASS="mediaobject"
><P
><IMG
SRC="./images/IMAP-Client-Schema.gif"
ALT="IMAP client"
></IMG
></P
></DIV
>
</P
><P
>&#13; These installation instructions assume:
<P
></P
><UL
><LI
><P
>&#13; Commands are Unix-compatible.
</P
></LI
><LI
><P
>&#13; The source path is <TT
CLASS="filename"
>/var/tmp</TT
> -<EM
>other paths are possible</EM
>.
</P
></LI
><LI
><P
>&#13; Installations were tested on Red Hat Linux 6.1 and 6.2.
</P
></LI
><LI
><P
>&#13; All steps in the installation will happen in super-user account root.
</P
></LI
><LI
><P
>&#13; <SPAN
CLASS="acronym"
>IMAP</SPAN
> version number is 4.7c
</P
></LI
></UL
>
</P
><P
>&#13; These are the Package(s) needed and should be available here:
<P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>&#13; <SPAN
CLASS="acronym"
>IMAP</SPAN
>/<SPAN
CLASS="acronym"
>POP</SPAN
> Homepage: <A
HREF="appendixa.html#prtinxfp20"
>http://www.washington.edu/imap/</A
>
</TD
></TR
><TR
><TD
>&#13; <SPAN
CLASS="acronym"
>IMAP</SPAN
>/<SPAN
CLASS="acronym"
>POP</SPAN
> FTP Site: <A
HREF="appendixa.html#prtinxfp20"
>140.142.3.227</A
> or <A
HREF="appendixa.html#prtinxfp20"
>140.142.4.227</A
>
</TD
></TR
><TR
><TD
>&#13; You must be sure to download: imap.tar.Z
</TD
></TR
></TBODY
></TABLE
><P
></P
>
</P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
><SPAN
CLASS="inlinemediaobject"
><IMG
SRC="./images/Note.gif"
ALT="Note"
></IMG
></SPAN
>: </B
>
These are a few Prerequisites you have to keep in mind, sendmail server should be already installed on your system to be able to use <SPAN
CLASS="acronym"
>IMAP</SPAN
> &#38; <SPAN
CLASS="acronym"
>POP</SPAN
> software.
For more information on the required software, see the related chapters in this book.
</P
></BLOCKQUOTE
></DIV
><P
>&#13; You need to decompress the tarballs to compile, so it is a good idea to make a list of files on the system before you install Imap, and one afterwards, and then compare them using diff to find out what
file it placed where. Simply run <B
CLASS="command"
>find</B
> <TT
CLASS="userinput"
><B
>/* &#62; Imap1</B
></TT
> before and <B
CLASS="command"
>find</B
> <TT
CLASS="userinput"
><B
>/* &#62; Imap2</B
></TT
> after you install the software, and
use <B
CLASS="command"
>diff</B
> <TT
CLASS="userinput"
><B
>Imap1 Imap2 &#62; Imap-Installed</B
></TT
> to get a list of what changed.
</P
><P
>&#13; Before Compilation you need to decompress the tarball (tar.Z).:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="screen"
>&#13; [root@deep] /# <B
CLASS="command"
>cp</B
> imap.tar.Z /var/tmp
[root@deep] /# <B
CLASS="command"
>cd</B
> /var/tmp
[root@deep ]/tmp# <B
CLASS="command"
>tar</B
> xzpf imap.tar.Z
</PRE
></TD
></TR
></TABLE
>
</P
><P
>&#13; Optimize before you Compile, move into the new <SPAN
CLASS="acronym"
>IMAP</SPAN
>/<SPAN
CLASS="acronym"
>POP</SPAN
> directory and edit the <TT
CLASS="filename"
>Makefile</TT
> file <B
CLASS="command"
>vi</B
> <TT
CLASS="filename"
>src/osdep/unix/Makefile</TT
>
and change these lines:</P
><DIV
CLASS="procedure"
><OL
TYPE="1"
><LI
><P
>
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13; sh -c '(test -f /usr/include/sys/statvfs.h -a $(OS) != sc5 -a $(OS) != sco) &#38;&#38; $(LN) flocksun.c flockbsd.c || $(LN) flocksv4.c flockbsd.c'
</PRE
></TD
></TR
></TABLE
>
To read:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13; sh -c '(test -f /usr/include/sys/statvfs.h -a $(OS) != sc5 -a $(OS) != sco -a $(OS) != lnx) &#38;&#38; $(LN) flocksun.c flockbsd.c || $(LN) flocksv4.c flockbsd.c'
</PRE
></TD
></TR
></TABLE
>
This modification will change the <TT
CLASS="filename"
>sys/stavfs</TT
> file. This file, with the new glibc 2.1 of Linux, is different from what is available on Sun.
</P
></LI
><LI
><P
>
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13; BASECFLAGS="-g -fno-omit-frame-pointer -O6 -DNFSKLUDGE" \
</PRE
></TD
></TR
></TABLE
>
To read:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13; BASECFLAGS="-g -fno-omit-frame-pointer -O9 -funroll-loops -ffast-math -malign-double -mcpu=pentiumpro -march=pentiumpro -fomit-frame-pointer -fno-exceptions -DNFSKLUDGE" \
</PRE
></TD
></TR
></TABLE
>
These are our optimization flags for the compilation of <SPAN
CLASS="acronym"
>IMAP</SPAN
>/<SPAN
CLASS="acronym"
>POP</SPAN
> software on the server.
</P
></LI
><LI
><P
>
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13; ACTIVEFILE=/usr/lib/news/active
</PRE
></TD
></TR
></TABLE
>
To read:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13; ACTIVEFILE=/var/lib/news/active
</PRE
></TD
></TR
></TABLE
>
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13; SPOOLDIR=/usr/spool
</PRE
></TD
></TR
></TABLE
>
To read:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13; SPOOLDIR=/var/spool
</PRE
></TD
></TR
></TABLE
>
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13; RSHPATH=/usr/ucb/rsh
</PRE
></TD
></TR
></TABLE
>
To read:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13; RSHPATH=/usr/bin/rsh
</PRE
></TD
></TR
></TABLE
>
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13; LOCKPGM=/etc/mlock
</PRE
></TD
></TR
></TABLE
>
To read:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13; #LOCKPGM=/etc/mlock
</PRE
></TD
></TR
></TABLE
>
The <TT
CLASS="envar"
>ACTIVEFILE=</TT
> line specifies the path of the <TT
CLASS="filename"
>active</TT
> directory for <SPAN
CLASS="acronym"
>IMAP</SPAN
>/<SPAN
CLASS="acronym"
>POP</SPAN
>, the <TT
CLASS="envar"
>SPOOLDIR=</TT
> is where we put
the <TT
CLASS="filename"
>spool</TT
> directory of Linux <SPAN
CLASS="acronym"
>IMAP</SPAN
>/<SPAN
CLASS="acronym"
>POP</SPAN
>, and the <TT
CLASS="envar"
>RSHPATH=</TT
> specify the path of <TT
CLASS="filename"
>rsh</TT
> directory
on our system. It's important to note that we don't use rsh services on our server, but even so, we specify the right directory to <TT
CLASS="filename"
>rsh</TT
>.
</P
></LI
><LI
><P
>&#13; <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13; CC=cc
</PRE
></TD
></TR
></TABLE
>
To read:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13; CC=egcs
</PRE
></TD
></TR
></TABLE
>
This line represents the name of our <SPAN
CLASS="acronym"
>GCC</SPAN
> compiler we will use to compile <SPAN
CLASS="acronym"
>IMAP</SPAN
>/<SPAN
CLASS="acronym"
>POP</SPAN
> software, in our case, egcs).
</P
></LI
></OL
></DIV
><P
>&#13; Now, we must compile and <B
CLASS="command"
>install</B
> <SPAN
CLASS="acronym"
>IMAP</SPAN
> &#38; <SPAN
CLASS="acronym"
>POP</SPAN
> on the Mail Server:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="screen"
>&#13; [root@deep ]/imap-4.7c# <B
CLASS="command"
>make</B
> lnp
[root@deep ]/imap-4.7c# <B
CLASS="command"
>install</B
> -m 644 ./src/ipopd/ipopd.8c /usr/man/man8/ipopd.8c
[root@deep ]/imap-4.7c# <B
CLASS="command"
>install</B
> -m 644 ./src/imapd/imapd.8c /usr/man/man8/imapd.8c
[root@deep ]/imap-4.7c# <B
CLASS="command"
>install</B
> -s -m 755 ./ipopd/ipop2d /usr/sbin
[root@deep ]/imap-4.7c# <B
CLASS="command"
>install</B
> -s -m 755 ./ipopd/ipop3d /usr/sbin
[root@deep ]/imap-4.7c# <B
CLASS="command"
>install</B
> -s -m 755 ./imapd/imapd /usr/sbin
[root@deep ]/imap-4.7c# <B
CLASS="command"
>install</B
> -m 644 ./c-client/c-client.a /usr/lib
[root@deep ]/imap-4.7c# <B
CLASS="command"
>ln</B
> -fs /usr/lib/c-client.a /usr/lib/libimap.a
[root@deep ]/imap-4.7c# <B
CLASS="command"
>mkdir</B
> -p /usr/include/imap
[root@deep ]/imap-4.7c# <B
CLASS="command"
>install</B
> -m 644 ./c-client/*.h /usr/include/imap
[root@deep ]/imap-4.7c# <B
CLASS="command"
>install</B
> -m 644 ./src/osdep/tops-20/shortsym.h /usr/include/imap
[root@deep ]/imap-4.7c# <B
CLASS="command"
>chown</B
> root.mail /usr/sbin/ipop2d
[root@deep ]/imap-4.7c# <B
CLASS="command"
>chown</B
> root.mail /usr/sbin/ipop3d
[root@deep ]/imap-4.7c# <B
CLASS="command"
>chown</B
> root.mail /usr/sbin/imapd
</PRE
></TD
></TR
></TABLE
>
</P
><P
>&#13; The above commands will configure the software to ensure your system has the necessary functionality and libraries to successfully compile the package, compile all source files into executable binaries, and
then <B
CLASS="command"
>install</B
> the binaries and any supporting files into the appropriate locations.
<P
></P
><UL
><LI
><P
>&#13; Note that the <B
CLASS="command"
>make lnp</B
> command above will configure your Linux system with Pluggable Authentication Modules -<SPAN
CLASS="acronym"
>PAM</SPAN
> capability for better security.
</P
></LI
><LI
><P
>&#13; The <B
CLASS="command"
>mkdir</B
> command will create a new directory named <TT
CLASS="filename"
>imap</TT
> under <TT
CLASS="filename"
>/usr/include</TT
>. This new directory <TT
CLASS="filename"
>imap</TT
>
will keep all header files related to the imapd program <TT
CLASS="filename"
>c-client/*</TT
>, and <TT
CLASS="filename"
>shortsym.h</TT
> files.
</P
></LI
><LI
><P
>&#13; The <B
CLASS="command"
>chown</B
> command will change the ownership of the binary programs ipop2d, ipop3d, and imapd to be owned by the super-user <TT
CLASS="literal"
>root</TT
>, be group owner by the user <TT
CLASS="literal"
>mail</TT
>.
</P
></LI
><LI
><P
>&#13; The <B
CLASS="command"
>ln</B
> -fs command would create a symbolic link from <TT
CLASS="filename"
>c-client.a</TT
> file to <TT
CLASS="filename"
>libimap.a</TT
> link which may be require by some third party program you may install in the future.
</P
></LI
></UL
>
</P
><DIV
CLASS="important"
><BLOCKQUOTE
CLASS="important"
><P
><B
><SPAN
CLASS="inlinemediaobject"
><IMG
SRC="./images/Important.gif"
ALT="Important"
></IMG
></SPAN
>: </B
>
For security reasons, if you use only imapd services, remove the ipop2d and ipop3d binaries from your mail server. The same applies for ipopd; if you use only ipopd services, remove the imapd binary from your mail server. If you intend to
use imapd and ipopd services then keep both binaries.
</P
></BLOCKQUOTE
></DIV
><P
>&#13; Please do cleanup later:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="screen"
>&#13; [root@deep] /# <B
CLASS="command"
>cd</B
> /var/tmp
[root@deep ]/tmp# <B
CLASS="command"
>rm</B
> -rf imap-version/ imap.tar.Z
</PRE
></TD
></TR
></TABLE
>
The <B
CLASS="command"
>rm</B
> command as used above will remove all the source files we have used to compile and install <SPAN
CLASS="acronym"
>IMAP</SPAN
>/<SPAN
CLASS="acronym"
>POP</SPAN
>. It will also remove the <SPAN
CLASS="acronym"
>IMAP</SPAN
>/<SPAN
CLASS="acronym"
>POP</SPAN
>
compressed archive from the <TT
CLASS="filename"
>/var/tmp</TT
> directory.
</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="imapop.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="chap23sec189.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Linux <SPAN
CLASS="acronym"
>IMAP</SPAN
> &#38; <SPAN
CLASS="acronym"
>POP</SPAN
> Server</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="imapop.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Configure to tweak</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>