[Mailman-Users] feature request: rules on new mailing list names?

Jon Carnes jonc at nc.rr.com
Tue Dec 9 04:14:26 CET 2003


On Mon, 2003-12-08 at 20:43, James Ralston wrote:
> I've skimmed the FAQ and the mailing list archives, but I didn't see
> this subject come up...
> 
> I'm using Mailman 2.1.1.  I really need to be able to prevent people
> who are using the "list creator" role from being able to create
> mailing lists with certain names.
> 
> I'd like to be able to specify a list of regular expressions to
> consider "bad", like so:
> 
>     ^postmaster$
>     ^abuse$
>     ^news$
>     -request$
>     ^owner-
> 
> Ideally, I'd also like to be able to enforce a rule that all mailing
> list names must match a certain regular expression.  E.g.:
> 
>     ^[:alpha:][:alnum:]*(-[:alnum:]+)*$
> 
> A new list name would only be permitted if it didn't match any of the
> "bad" regular expressions *and* matched the "good" regular expression.
> 
> While I'm not very familiar with Python, from a cursory examination of
> the code, it would appear that Mailman doesn't offer this feature.  Am
> I mistaken?
> 
> Assuming I'm not mistaken, would there be any resistance to adding
> this feature?  And what would be the best mechanism to do so?
> 
> Regards,

This is almost trivial.

Modify the file ~mailman/Mailman/Utils.py

The first defined function therein is "list_exists" which is used when
creating a new list to determine if the list can be created.

def list_exists(listname):
    """Return true iff list `listname' exists."""
    # The existance of any of the following file proves the list exists
    # <wink>: config.pck, config.pck.last, config.db, config.db.last
    #
    # The former two are for 2.1alpha3 and beyond, while the latter
    # two are for all earlier versions.
    basepath = Site.get_listpath(listname)
    for ext in ('.pck', '.pck.last', '.db', '.db.last'):
        dbfile = os.path.join(basepath, 'config' + ext)
        if os.path.exists(dbfile):
            return 1
    return 0

You could simply add your restrictions in here (but be sure to read up
on how Regular Expressions work in Python - they are different than what
your used to in shell expansions)... 

Alternately, as the code points out, you could simply create a
directory  under ~mailman/lists/ and then "touch config.db" in that
directory:
  mkdir ~mailman/lists/postmaster
  touch ~mailman/lists/postmaster/config.db

Viola! Now no user can create a list called "postmaster".

HtH - Jon Carnes





More information about the Mailman-Users mailing list