2. Majordomo

Majordomo is, of course, the piece of code that this document revolves around; it consists of a collection of Perl scripts with the sole purpose of managing mailing lists.

2.1. Preparing to Install

Download the gzipped source distribution of the latest version of Majordomo from Great Circle Associates and uncompress it

[jarchie@majordomohowto ~]$ zcat majordomo-1.94.5.tar.gz | tar xvf -
This will create a subdirectory with all of the files necessary to install Majordomo; this directory cannot be the same directory in which Majordomo is to be installed.

Majordomo must run under a specific UID and GID so when any of the scripts are run, they will run under Majordomo's UID. Thus, it is necessary to decide what UID and GID Majordomo should run under.

Check the /etc/passwd and /etc/group files to find a UID and GID that are not taken. For this example, a UID of 16 and a GID of 16 were chosen. If you are using a shadowed password file, add entries similar to

majordom:x:16:16:Majordomo List Manager:/usr/local/majordomo:/bin/sh
to your /etc/passwd and add an appropriate entry to /etc/shadow.
majordom:*:10883:0:88888:7:::
Use the other entries in these files as a guide for exactly what should be added. These are only the values for my system. If you are not using shadowed passwords, only an entry in the /etc/passwd file is necessary.

To create a Majordomo group, add a line similar to

majordom:x:16:
to your /etc/group file.

To finish creating the majordom account, set a password for the majordom account. This will allow regular users and become Majordomo to manage mailing lists.

[root@majordomohowto majordomo-1.94.5]# passwd majordom

Now create the directory where Majordomo will reside once installed.

[jarchie@majordomohowto ~]# mkdir /usr/local/majordomo-1.94.5
[jarchie@majordomohowto ~]# chown majordom:majordom /usr/local/majordomo-1.94.5
[jarchie@majordomohowto ~]# chmod 711 /usr/local/majordomo-1.94.5/
[jarchie@majordomohowto ~]# ln -s /usr/local/majordomo-1.94.5 /usr/local/majordomo
Creating the majordomo link to majordomo-1.94.5 could ease upgrading to future versions of Majordomo. If you configure your MTA to recognize Majordomo via the majordomo link (as this HOWTO suggests), when upgrading Majordomo, you might not need to reconfigure your MTA. Instead, you might only need to point the majordomo link to the location where the new version of Majordomo resides.

2.2. Editing the Installation Files

The Makefile contains all the information needed to install Majordomo; it is usually necessary to edit lines in the Makefile that refer to system specific settings so, Majordomo will be able to install cleanly on your system. Most of the default settings are correct; however, the following settings, almost invariably, need to be changed on a per system basis.

[jarchie@majordomohowto majordomo-1.94.5]$ vi Makefile
The settings
CC = cc
W_HOME = /usr/test/majordomo-$(VERSION)
MAN = $(W_HOME)/man
W_USER = 123
W_GROUP = 45
TMPDIR = /usr/tmp
should be changed to something more appropriate for your system. For example, in my setup, the values were changed to
CC = gcc
W_HOME = /usr/local/majordomo-$(VERSION)
MAN = /usr/local/man
W_USER = 16
W_GROUP = 16
TMPDIR = /tmp
TMPDIR need only be changed if /usr/tmp/ does not exist on your system. Also, Majordomo will look for perl in /bin/. If perl is not in /bin/ on your system, you can inform Majordomo of perl's location in the Makefile. However, other scripts might look for perl in /bin/perl as well, so it is usually better to create a symbolic link from the real location of perl to /bin/perl. You can find the real location of perl on your system with the which command. For example,
[root@majordomohowto ~]# which perl
/usr/bin/perl
[root@majordomohowto ~]# ln -s /usr/bin/perl /bin/perl

Also the majordomo.cf file must be created. An easy way to create this file is to copy the provided sample.cf file to majordomo.cf and edit it.

[jarchie@majordomohowto majordomo-1.94.5]$ cp sample.cf majordomo.cf
[jarchie@majordomohowto majordomo-1.94.5]$ vi majordomo.cf
Again, most of the settings are correct by default, but the following lines might need to be changed for your system from
$whereami = "example.com";
$whoami = "Majordomo\@$whereami";
$whoami_owner = "Majordomo-Owner\@$whereami";
     $homedir = "/usr/test/majordomo";
$digest_work_dir = "/usr/local/mail/digest";
$sendmail_command = "/usr/lib/sendmail";
$TMPDIR = $ENV{'TMPDIR'} || "/usr/tmp";
to something more appropriate such as
$whereami = "majordomohowto.com";
$whoami = "majordomo\@$whereami";
$whoami_owner = "majordomo-owner\@$whereami";
     $homedir = "/usr/local/majordomo";
$digest_work_dir = "$homedir/digests";
$sendmail_command = "/usr/sbin/sendmail";
$TMPDIR = "$homedir/tmp";
$whoami and $whoami_owner do not need to be changed for Majordomo to work; however, I changed them because I like to avoid capital letters. $digest_work_dir is a temporary directory where digest files should be placed. This directory should be assigned to wherever you want digests to be stored. If you do not plan to use digested lists, do not worry about this option. $whereami, $homedir, and $sendmail_command should be changed to appropriate values for your system. I recommend changing $TMPDIR to the /usr/local/majordomo/tmp/; this directory will only be writable by majordom making it impossible for other programs to mess with Majordomo's temporary files. Unlike the options in the Makefile, the above options can always be changed after Majordomo is installed by editing majordomo.cf in the directory where Majordomo was installed. (The majordomo.cf file is simply copied during setup.)

2.3. Installing Majordomo

The next step is to compile the Majordomo wrapper. The wrapper is the only Majordomo component that needs to be compiled because all other code are perl scripts.

[jarchie@majordomohowto majordomo-1.94.5]# make wrapper
To install the Majordomo files, execute the commands
[root@majordomohowto majordomo-1.94.5]# make install
[root@majordomohowto majordomo-1.94.5]# make install-wrapper
The first command can be done as the Majordomo user (assuming majordom can create or has access to $home_dir), but the second command need be done as root so the installation script can SUID root the Majordomo wrapper. (Since, majordom was created without a login shell or password, if you want to execute the first command as majordomo, you will need to su majordomo as root in order to become majordomo.)

2.4. Becoming Majordomo

Next su majordom and create a file for a test list and a temporary directory for Majordomo.

[root@majordomohowto ~]# su majordom
[majordom@majordomohowto /root]$ cd
[majordom@majordomohowto ~]$ mkdir lists
[majordom@majordomohowto ~]$ chmod 711 lists
[majordom@majordomohowto ~]$ touch lists/test
[majordom@majordomohowto ~]$ chmod 644 lists/test
[majordom@majordomohowto ~]$ mkdir tmp
[majordom@majordomohowto ~]$ chmod 700 tmp
As majordom, edit Majordomo's aliases file (/usr/local/majordomo/majordomo.aliases) and add the aliases for Majordomo and a test list:
# Majordomo's aliases
majordom:	 majordomo
majordomo:	 "|/usr/local/majordomo/wrapper majordomo"
owner-majordomo: jarchie
majordomo-owner: owner-majordomo
discard:	 /dev/null

# test list aliases
test:	   "|/usr/local/majordomo/wrapper resend -l test test-list-XXXX,discard"
test-list-XXXX:	":include:/usr/local/majordomo/lists/test"
test-request:	"|/usr/local/majordomo/wrapper majordomo -l test"
owner-test:	jarchie
test-owner:	owner-test
test-approval:	owner-test
If you need a review of email aliasing, see
Section A.2. Note that the test-list-XXXX is a secret address; resend will redirect mail that should be sent to the list to test-list-XXXX. Anyone who discovers the test-list-XXXX address can bypass the resend script by sending mail directly to test-list-XXXX. Therefore, you should replace the XXXX portion with some string that is difficult to guess. Finally, set the permissions on Majordomo's aliases file.
[majordom@majordomohowto ~]$ chmod 644 majordomo.aliases
Majordomo should now be installed; all that need be done for Majordomo to be used is to configure your MTA to recognize Majordomo.

2.5. Testing Majordomo's Configuration

As a regular user (not as majordom or as root), run

[jarchie@majordomohowto ~]$ cd /usr/local/majordomo
[jarchie@majordomohowto jarchie]$ ./wrapper config-test
This program can detect most problems in the Majordomo installation.

2.6. Configuring your MTA

First, configure your MTA to recognize Majordomo as a trusted user. (See Section A.1.) Second, configure your MTA to recognize Majordomo's aliases. (See Section A.3.) After configuring your MTA, you might need to restart it so that it can recognize your new configuration. The last two subsections of Appendix A contain issues specific to Sendmail and Postfix; please read the appropriate section if you use one of those MTAs.

2.7. Testing Majordomo's Configuration, Again

Since the MTA is now configured to recognize Majordomo, you can test the list by actually using Majordomo. So, test the operation of the list by issuing a lists command:

[jarchie@majordomohowto jarchie]$ echo lists | mail majordomo@majordomohowto.com
It should only take a second for Majordomo to reply with a message containing all the lists which are currently set up. Next, try issuing a help command.
[jarchie@majordomohowto jarchie]$ echo help | mail majordomo@majordomohowto.com
Majordomo should reply with a list of all commands that Majordomo accepts. It might be a good idea to save the message for future reference.

To see if the aliases are working properly, try subscribing and unsubscribing yourself to the list.

[jarchie@majordomohowto jarchie]$ echo subscribe test | mail majordomo@majordomohowto.com
You will receive an email message containing instructions on how to confirm your subscription as well as a letter stating that your command was successful. After sending back your confirmation, Majordomo should send you two letters--one letter stating that your subscribe request was successful and another letter welcoming you to the test list. The owner of the list will also be sent a message stating that you have subscribed to the list.

To unsubscribe from a list, send an unsubscribe command:

[jarchie@majordomohowto jarchie]$ echo unsubscribe test | mail majordomo@majordomohowto.com
You should be sent back a letter stating that your command was successful.

2.8. Adding a List

Create a file for a new list and create aliases for that list as described in Section 2.4 for the test list.