[Mailman-Users] Hey Jon, here's something for your FAQ entry for Mailman..

Glenn Sieb ges at wingfoot.org
Mon Oct 14 07:28:33 CEST 2002


Hey Jon--

First--thank you for pointing me to your entry in the FAQ--it was exactly 
what I was looking for!! :)

Now, I'd like to give back .. :)

I have a suggested addition for that entry: FAQ # 3.7, Setting up Web 
access using MM list passwords - for Apache...

Here's a Perl script that creates a Makefile that you can call in your 
crontab to rebuild htpasswd files for all of your lists... I figured since 
you pointed me towards this FAQ, I'd share what I did with it so far.. :)

I hope you find this useful.. it's my first perl script!

I'm sure this can be made even better... but this is what I have so far.. 
:) Suggestions/etc are always welcomed and encouraged!

Thanks again!
Glenn

Suggested addendum for FAQ Entry 3.7:

To automate this procedure, I first made a wrapper for Mailman's newlist 
that consists of:

#!/bin/sh
/etc/mailman/bin/newlist
/adm/bin/mm_make_htaccess.pl
--

So whenever you create a new mailing list, it will recreate the Makefile 
which will keep your htaccess passwords for your lists up to date. Put in 
whatever output options you usually use for newlist.

Here is a perl script that creates the Makefile to do all the work for you:

#!/usr/bin/perl
###############
##
## mm_make_htaccess.pl
##
## Create $file_dir/Makefile for Mailman use.
## version 1.0
## by ges, 10/12/2002
##
## This script is designed to take the directory names
## from ~mailman/lists and put them into a Makefile
## which, when run, will create htpasswd files for
## all your mailman lists, for use in Apache.
##
###############
##
## First we define where Mailman lists reside.
##
## Then we define what directory the Makefile
## lives in, as well as where the htpasswd files
## will live.
##
## Then we will set a variable to change for
## admins using Mailman 2.1 or 2.0
##
## Change $configext to be db for 2.0
## or pck for 2.1
##
$list_dir="/etc/mailman/lists";
$file_dir="/etc/httpd";
$configext="pck";
##
## First let's open the list directory!
## Once that's done, we'll read the filenames into @names
## for later use!
##
opendir(LISTDIR,$list_dir) || die("Cannot Open $list_dir!");
@lists = readdir(LISTDIR);
closedir(LISTDIR);
##
## Now we open the makefile
##
open(MAKEFILE,">$file_dir/Makefile") || die("Cannot Open File");
         print MAKEFILE "\n\nall: mailmanstuff\n\n";
         print MAKEFILE "mailmanstuff: ";
                 foreach $list (@lists)
                 {
                         next if ($list eq ".");
                         next if ($list eq "..");
                         print MAKEFILE "$file_dir/htpasswd.$list ";
                         next;
                 }
         $list="";
         print MAKEFILE "\n\n";
                 foreach $list (@lists)
                 {
                         next if ($list eq ".");
                         next if ($list eq "..");
                         print MAKEFILE "$file_dir/htpasswd.$list: ";
                         print MAKEFILE "$list_dir/$list/config.$configext\n";
                         print MAKEFILE "\t/home/adm/bin/mm_htaccess 
$list\n\n";
                         next;
                 }
close(MAKEFILE)
--
Change the variables at the beginning of the script to match your 
installation of Mailman (I put a symlink in /etc to make it easier for me 
to get to).

Now we create a small shell script:

#!/bin/sh
cd /etc/httpd
make
--

Change /etc/httpd to match $file_dir from the perl script. Put this shell 
script into your crontab to run every 10 minutes or so--remember--it's a 
Makefile, so it won't actually do anything if the files haven't changed!

Now, just run your wrapper when you make new lists on Mailman, and every 10 
minutes the htpasswd files will be created using Jon Carnes' mm_htaccess 
script!

--ges 10/13/02
ges at wingfoot.org


---
The original portions of this message are the copyright of the author
(c)1998-2002 Glenn E. Sieb.    ICQ UIN: 300395    IRC Nick: Rainbear
"Religion is for those who do what they are told regardless of what is right.
Spirituality is for those who do what is right regardless of what
they are told." -- unattributed






More information about the Mailman-Users mailing list