listSynchro.py

What does this program do?

ListSynchro synchronizes the Mailman list membership on a Mac OS X server to match the file server group membership in Worgroup Manager. It can also be used to generate regular list membership reports.

How does it work?

The script starts by getting the name of every Mailman list. For every list we then attempt to get the members of the matching open directory group. If we find a matching group, we store all of the account names as email addresses in a temporary file, and then call the Mailman routine sync_members to add or remove anyone that is/isn't present in the open directory group.

Finally, after the lists have been synchronized, the optional membership report is generated and saved to disk (presumably to somewhere on a shared volume). Then, if selected, the synchronization report is emailed out.

Configuration

There are two files that will need to be edited. In listSynchro.py, several variables will need to be set before this script can be used:

  • kDomain: must be set to the domain that should be added to the account names.
  • kReportOnly: this is set to True by default. When ready to have the script do an actual synchronization this should be changed to False.
  • kReportSynchroPath: must be set to path of the report message template, if emailing reports out.
  • Add execute permissions for the script file w/ chmod u+x listSynchro.py or a similar cmd.

If you will be emailing out reports, you must also edit the reportMsg.txt file to contain the recipients who will be receiving the reports.

How do I use it?

After modifying the script where necessary, run via the terminal command line or with a crontab entry. The script must be run as root because Mailman's sync_members command requires it.

When run, listSynchro will output a report, which will look something like the following:

Start: Tue Oct 25 21:03:47 2005

8 lists to process

*** accounting: 4 users ***

Removed: user1@example.com

*** admin (administration): 5 users ***

Removed: user2@example.com

*** allstaff: 254 users ***

Removed: user1@example.com
Removed: user2@example.com

*** b2b: 10 users ***

Nothing to do.

*** financeandcompliance: 15 users ***

Removed: user1@example.com
Removed: user2@example.com

*** funding: 41 users ***

Nothing to do.

*** hr: 0 users ***

No matching directory group

*** management: 12 users ***

Nothing to do.

Done: Tue Oct 25 21:04:00 2005

What are the requirements for this program?

This program has been tested on Mac OS Server 10.4.2-5 with some testing done on 10.3.9.

Limitations

The directory server must be running on the same system as the script (although the dscl calls could be modified to access at a different location). To email reports Postfix must be configured sufficiently to allow email to be sent. Groups can only be nested one level deep.


Download listSynchro.py