Question on outputting all lists and list owners and a process for batch disabling of lists without an owner
![](https://secure.gravatar.com/avatar/9acc110746bb8ca851798064d7c07321.jpg?s=120&d=mm&r=g)
Howdy!
To start with, a belated thank you is in order for Mark Sapiro –I leveraged your suggestion for batch changing list owners (in our case, changing list owner from owner “a” to owner “b” for 700 lists) from your post here:
https://answers.launchpad.net/mailman/+question/111591 😊
Our security department has asked me to canvas all of our lists (4,237!)—and if a list owner value is not defined they want me to disable the list.
- Can I combine the list_lists and list_owners commands to output both (hopefully linked) values as a .csv?
- Is there a script that any of you have leveraged to batch disable lists without a defined owner?
Thanks in advance for the assistance, I really appreciate this community as I don’t have much Linux Fu and the GNU resources and assistance have been invaluable!
Best,
John
![](https://secure.gravatar.com/avatar/56f108518d7ee2544412cc80978e3182.jpg?s=120&d=mm&r=g)
On 5/27/22 10:22, John Lake wrote:
list_owners -w
will list the owners by list name. If a list has no
owners, only the list name will be output for that list. You could then
process that file to identify the lists with no owners.
What do you mean by disable
?
A withlist script like
def no_owner(mlist)
if len mlist.owner == 0:
if not mlist.Locked:
mlist.Lock
print('List %s has no owners, disabling.' % mlist.real_name)
<code here to disable list. I could provide it if I knew what
that meant>
mlist.Save()
mlist.Unlock()
saved as no_owner.py in Mailman's bin/ directory and run via
bin/withlist -a -r no_owner
You could omit the code
if not mlist.Locked:
mlist.Lock
<code here to disable list. I could provide it if I knew what
that meant>
mlist.Save()
mlist.Unlock()
I.e., just leave the print statement in the if len mlist.owner == 0:
clause to just print the names of lists with no owner.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/91d4ad5d2d8c192b3d6d683f40eb80e8.jpg?s=120&d=mm&r=g)
Well some guy named Mark supported one method in the past 8-) (which I found googling ‘how to disable a mailman 2 list’ because I’d like to know how, too, since we do occasionally have need to do this.)
https://mail.python.org/pipermail/mailman-users/2010-September/070283.html
Since he appears to have shell access using the script you gave would let him move the list directory to someplace like /path/to/mailman/lists/[listname] to /path/to/mailman/disabled lists/[listname]
That would let him re-enable the list without having to recreate everything.
On May 27, 2022, at 11:49 AM, Mark Sapiro <mark@msapiro.net<mailto:mark@msapiro.net>> wrote:
On 5/27/22 10:22, John Lake wrote: Our security department has asked me to canvas all of our lists (4,237!)—and if a list owner value is not defined they want me to disable the list.
- Can I combine the list_lists and list_owners commands to output both (hopefully linked) values as a .csv?
list_owners -w
will list the owners by list name. If a list has no owners, only the list name will be output for that list. You could then process that file to identify the lists with no owners.
- Is there a script that any of you have leveraged to batch disable lists without a defined owner?
What do you mean by disable
?
A withlist script like
def no_owner(mlist)
if len mlist.owner == 0:
if not mlist.Locked:
mlist.Lock
print('List %s has no owners, disabling.' % mlist.real_name)
<code here to disable list. I could provide it if I knew what that meant>
mlist.Save()
mlist.Unlock()
saved as no_owner.py in Mailman's bin/ directory and run via
bin/withlist -a -r no_owner
You could omit the code
if not mlist.Locked:
mlist.Lock
<code here to disable list. I could provide it if I knew what that meant>
mlist.Save()
mlist.Unlock()
I.e., just leave the print statement in the if len mlist.owner == 0:
clause to just print the names of lists with no owner.
-- Mark Sapiro <mark@msapiro.net<mailto:mark@msapiro.net>> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Mailman-Users mailing list -- mailman-users@python.org<mailto:mailman-users@python.org> To unsubscribe send an email to mailman-users-leave@python.org<mailto:mailman-users-leave@python.org> https://mail.python.org/mailman3/lists/mailman-users.python.org/ Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: https://www.mail-archive.com/mailman-users@python.org/ https://mail.python.org/archives/list/mailman-users@python.org/
-- Bruce Johnson University of Arizona College of Pharmacy Information Technology Group
Institutions do not have opinions, merely customs
![](https://secure.gravatar.com/avatar/56f108518d7ee2544412cc80978e3182.jpg?s=120&d=mm&r=g)
On 5/27/22 12:47, Bruce Johnson via Mailman-Users wrote:
Well some guy named Mark supported one method in the past 8-) (which I found googling ‘how to disable a mailman 2 list’ because I’d like to know how, too, since we do occasionally have need to do this.)
https://mail.python.org/pipermail/mailman-users/2010-September/070283.html
The method in that thread is simply moving the lists/<listname> aside. That is one way to disable a list, but there are others depending on what you actually want. For that, this withlist script will do it.
import os
from Mailman import Site
BACKUP_DIR = 'path to a mailman writable directory'
def no_owner(mlist)
if len mlist.owner == 0:
print('List %s has no owners, disabling.' % mlist.real_name)
src = Site.get_listpath(mlist.internal_name())
dst = os.path.join(BACKUP_DIR, mlist.internal_name())
os.rename(src, dst)
BACKUP_DIR is set to the full path of the directory in which to save the list configurations. To avoid potential issues with os.rename, BACKUP_DIR should be on the same file system as Mailman's lists/ directory.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/9acc110746bb8ca851798064d7c07321.jpg?s=120&d=mm&r=g)
Thanks very much Bruce and Mark!
Much appreciated,
John
On 5/27/22, 1:53 PM, "Mark Sapiro" <mark@msapiro.net> wrote:
On 5/27/22 12:47, Bruce Johnson via Mailman-Users wrote:
> Well some guy named Mark supported one method in the past 8-) (which I found googling ‘how to disable a mailman 2 list’ because I’d like to know how, too, since we do occasionally have need to do this.)
>
> https://urldefense.com/v3/__https://mail.python.org/pipermail/mailman-users/2010-September/070283.html__;!!C5qS4YX3!AJcsaCQavpDgwaaIVqilPzNAu0rJ_NfoDw_GIKESav0V0oT2bK06YElcB7px4bxmW9JrUvOMkdrHNRxH$
The method in that thread is simply moving the lists/<listname> aside.
That is one way to disable a list, but there are others depending on
what you actually want. For that, this withlist script will do it.
```
import os
from Mailman import Site
BACKUP_DIR = 'path to a mailman writable directory'
def no_owner(mlist)
if len mlist.owner == 0:
print('List %s has no owners, disabling.' % mlist.real_name)
src = Site.get_listpath(mlist.internal_name())
dst = os.path.join(BACKUP_DIR, mlist.internal_name())
os.rename(src, dst)
```
BACKUP_DIR is set to the full path of the directory in which to save the
list configurations. To avoid potential issues with os.rename,
BACKUP_DIR should be on the same file system as Mailman's lists/ directory.
--
Mark Sapiro <mark@msapiro.net> The highway is for gamblers,
San Francisco Bay Area, California better use your sense - B. Dylan
------------------------------------------------------
Mailman-Users mailing list -- mailman-users@python.org
To unsubscribe send an email to mailman-users-leave@python.org
https://urldefense.com/v3/__https://mail.python.org/mailman3/lists/mailman-users.python.org/__;!!C5qS4YX3!AJcsaCQavpDgwaaIVqilPzNAu0rJ_NfoDw_GIKESav0V0oT2bK06YElcB7px4bxmW9JrUvOMkcv2vDVU$
Mailman FAQ: https://urldefense.com/v3/__http://wiki.list.org/x/AgA3__;!!C5qS4YX3!AJcsaCQavpDgwaaIVqilPzNAu0rJ_NfoDw_GIKESav0V0oT2bK06YElcB7px4bxmW9JrUvOMkdThkNA2$
Security Policy: https://urldefense.com/v3/__http://wiki.list.org/x/QIA9__;!!C5qS4YX3!AJcsaCQavpDgwaaIVqilPzNAu0rJ_NfoDw_GIKESav0V0oT2bK06YElcB7px4bxmW9JrUvOMkW3OTXfV$
Searchable Archives: mailman-users@python.org <https://urldefense.com/v3/__https://www.mail-archive.com/<a href=>/__;!!C5qS4YX3!AJcsaCQavpDgwaaIVqilPzNAu0rJ_NfoDw_GIKESav0V0oT2bK06YElcB7px4bxmW9JrUvOMkRS9z4yU$">https://urldefense.com/v3/__https://www.mail-archive.com/mailman-users@python.org/__;!!C5qS4YX3!AJcsaCQavpDgwaaIVqilPzNAu0rJ_NfoDw_GIKESav0V0oT2bK06YElcB7px4bxmW9JrUvOMkRS9z4yU$
mailman-users@python.org <https://urldefense.com/v3/__https://mail.python.org/archives/list/<a href=>/__;!!C5qS4YX3!AJcsaCQavpDgwaaIVqilPzNAu0rJ_NfoDw_GIKESav0V0oT2bK06YElcB7px4bxmW9JrUvOMke2Nwy1w$">https://urldefense.com/v3/__https://mail.python.org/archives/list/mailman-users@python.org/__;!!C5qS4YX3!AJcsaCQavpDgwaaIVqilPzNAu0rJ_NfoDw_GIKESav0V0oT2bK06YElcB7px4bxmW9JrUvOMke2Nwy1w$
![](https://secure.gravatar.com/avatar/6b50c17f55d7174b281928faf6e87a4d.jpg?s=120&d=mm&r=g)
...which I found googling ‘how to disable a mailman 2 list’ because I’d like to know how, too, since we do occasionally have need to do this.)
The method in that thread is simply moving the lists/<listname> aside. That is one way to disable a list, but there are others depending on what you actually want. ...
To disable a list:
chmod 000 $PATH/lists/<LISTNAME>
And to re-enable it:
chmod 2775 $PATH/lists/<LISTNAME>
![](https://secure.gravatar.com/avatar/56f108518d7ee2544412cc80978e3182.jpg?s=120&d=mm&r=g)
On 5/27/22 10:22, John Lake wrote:
list_owners -w
will list the owners by list name. If a list has no
owners, only the list name will be output for that list. You could then
process that file to identify the lists with no owners.
What do you mean by disable
?
A withlist script like
def no_owner(mlist)
if len mlist.owner == 0:
if not mlist.Locked:
mlist.Lock
print('List %s has no owners, disabling.' % mlist.real_name)
<code here to disable list. I could provide it if I knew what
that meant>
mlist.Save()
mlist.Unlock()
saved as no_owner.py in Mailman's bin/ directory and run via
bin/withlist -a -r no_owner
You could omit the code
if not mlist.Locked:
mlist.Lock
<code here to disable list. I could provide it if I knew what
that meant>
mlist.Save()
mlist.Unlock()
I.e., just leave the print statement in the if len mlist.owner == 0:
clause to just print the names of lists with no owner.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/91d4ad5d2d8c192b3d6d683f40eb80e8.jpg?s=120&d=mm&r=g)
Well some guy named Mark supported one method in the past 8-) (which I found googling ‘how to disable a mailman 2 list’ because I’d like to know how, too, since we do occasionally have need to do this.)
https://mail.python.org/pipermail/mailman-users/2010-September/070283.html
Since he appears to have shell access using the script you gave would let him move the list directory to someplace like /path/to/mailman/lists/[listname] to /path/to/mailman/disabled lists/[listname]
That would let him re-enable the list without having to recreate everything.
On May 27, 2022, at 11:49 AM, Mark Sapiro <mark@msapiro.net<mailto:mark@msapiro.net>> wrote:
On 5/27/22 10:22, John Lake wrote: Our security department has asked me to canvas all of our lists (4,237!)—and if a list owner value is not defined they want me to disable the list.
- Can I combine the list_lists and list_owners commands to output both (hopefully linked) values as a .csv?
list_owners -w
will list the owners by list name. If a list has no owners, only the list name will be output for that list. You could then process that file to identify the lists with no owners.
- Is there a script that any of you have leveraged to batch disable lists without a defined owner?
What do you mean by disable
?
A withlist script like
def no_owner(mlist)
if len mlist.owner == 0:
if not mlist.Locked:
mlist.Lock
print('List %s has no owners, disabling.' % mlist.real_name)
<code here to disable list. I could provide it if I knew what that meant>
mlist.Save()
mlist.Unlock()
saved as no_owner.py in Mailman's bin/ directory and run via
bin/withlist -a -r no_owner
You could omit the code
if not mlist.Locked:
mlist.Lock
<code here to disable list. I could provide it if I knew what that meant>
mlist.Save()
mlist.Unlock()
I.e., just leave the print statement in the if len mlist.owner == 0:
clause to just print the names of lists with no owner.
-- Mark Sapiro <mark@msapiro.net<mailto:mark@msapiro.net>> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Mailman-Users mailing list -- mailman-users@python.org<mailto:mailman-users@python.org> To unsubscribe send an email to mailman-users-leave@python.org<mailto:mailman-users-leave@python.org> https://mail.python.org/mailman3/lists/mailman-users.python.org/ Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: https://www.mail-archive.com/mailman-users@python.org/ https://mail.python.org/archives/list/mailman-users@python.org/
-- Bruce Johnson University of Arizona College of Pharmacy Information Technology Group
Institutions do not have opinions, merely customs
![](https://secure.gravatar.com/avatar/56f108518d7ee2544412cc80978e3182.jpg?s=120&d=mm&r=g)
On 5/27/22 12:47, Bruce Johnson via Mailman-Users wrote:
Well some guy named Mark supported one method in the past 8-) (which I found googling ‘how to disable a mailman 2 list’ because I’d like to know how, too, since we do occasionally have need to do this.)
https://mail.python.org/pipermail/mailman-users/2010-September/070283.html
The method in that thread is simply moving the lists/<listname> aside. That is one way to disable a list, but there are others depending on what you actually want. For that, this withlist script will do it.
import os
from Mailman import Site
BACKUP_DIR = 'path to a mailman writable directory'
def no_owner(mlist)
if len mlist.owner == 0:
print('List %s has no owners, disabling.' % mlist.real_name)
src = Site.get_listpath(mlist.internal_name())
dst = os.path.join(BACKUP_DIR, mlist.internal_name())
os.rename(src, dst)
BACKUP_DIR is set to the full path of the directory in which to save the list configurations. To avoid potential issues with os.rename, BACKUP_DIR should be on the same file system as Mailman's lists/ directory.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/9acc110746bb8ca851798064d7c07321.jpg?s=120&d=mm&r=g)
Thanks very much Bruce and Mark!
Much appreciated,
John
On 5/27/22, 1:53 PM, "Mark Sapiro" <mark@msapiro.net> wrote:
On 5/27/22 12:47, Bruce Johnson via Mailman-Users wrote:
> Well some guy named Mark supported one method in the past 8-) (which I found googling ‘how to disable a mailman 2 list’ because I’d like to know how, too, since we do occasionally have need to do this.)
>
> https://urldefense.com/v3/__https://mail.python.org/pipermail/mailman-users/2010-September/070283.html__;!!C5qS4YX3!AJcsaCQavpDgwaaIVqilPzNAu0rJ_NfoDw_GIKESav0V0oT2bK06YElcB7px4bxmW9JrUvOMkdrHNRxH$
The method in that thread is simply moving the lists/<listname> aside.
That is one way to disable a list, but there are others depending on
what you actually want. For that, this withlist script will do it.
```
import os
from Mailman import Site
BACKUP_DIR = 'path to a mailman writable directory'
def no_owner(mlist)
if len mlist.owner == 0:
print('List %s has no owners, disabling.' % mlist.real_name)
src = Site.get_listpath(mlist.internal_name())
dst = os.path.join(BACKUP_DIR, mlist.internal_name())
os.rename(src, dst)
```
BACKUP_DIR is set to the full path of the directory in which to save the
list configurations. To avoid potential issues with os.rename,
BACKUP_DIR should be on the same file system as Mailman's lists/ directory.
--
Mark Sapiro <mark@msapiro.net> The highway is for gamblers,
San Francisco Bay Area, California better use your sense - B. Dylan
------------------------------------------------------
Mailman-Users mailing list -- mailman-users@python.org
To unsubscribe send an email to mailman-users-leave@python.org
https://urldefense.com/v3/__https://mail.python.org/mailman3/lists/mailman-users.python.org/__;!!C5qS4YX3!AJcsaCQavpDgwaaIVqilPzNAu0rJ_NfoDw_GIKESav0V0oT2bK06YElcB7px4bxmW9JrUvOMkcv2vDVU$
Mailman FAQ: https://urldefense.com/v3/__http://wiki.list.org/x/AgA3__;!!C5qS4YX3!AJcsaCQavpDgwaaIVqilPzNAu0rJ_NfoDw_GIKESav0V0oT2bK06YElcB7px4bxmW9JrUvOMkdThkNA2$
Security Policy: https://urldefense.com/v3/__http://wiki.list.org/x/QIA9__;!!C5qS4YX3!AJcsaCQavpDgwaaIVqilPzNAu0rJ_NfoDw_GIKESav0V0oT2bK06YElcB7px4bxmW9JrUvOMkW3OTXfV$
Searchable Archives: mailman-users@python.org <https://urldefense.com/v3/__https://www.mail-archive.com/<a href=>/__;!!C5qS4YX3!AJcsaCQavpDgwaaIVqilPzNAu0rJ_NfoDw_GIKESav0V0oT2bK06YElcB7px4bxmW9JrUvOMkRS9z4yU$">https://urldefense.com/v3/__https://www.mail-archive.com/mailman-users@python.org/__;!!C5qS4YX3!AJcsaCQavpDgwaaIVqilPzNAu0rJ_NfoDw_GIKESav0V0oT2bK06YElcB7px4bxmW9JrUvOMkRS9z4yU$
mailman-users@python.org <https://urldefense.com/v3/__https://mail.python.org/archives/list/<a href=>/__;!!C5qS4YX3!AJcsaCQavpDgwaaIVqilPzNAu0rJ_NfoDw_GIKESav0V0oT2bK06YElcB7px4bxmW9JrUvOMke2Nwy1w$">https://urldefense.com/v3/__https://mail.python.org/archives/list/mailman-users@python.org/__;!!C5qS4YX3!AJcsaCQavpDgwaaIVqilPzNAu0rJ_NfoDw_GIKESav0V0oT2bK06YElcB7px4bxmW9JrUvOMke2Nwy1w$
![](https://secure.gravatar.com/avatar/6b50c17f55d7174b281928faf6e87a4d.jpg?s=120&d=mm&r=g)
...which I found googling ‘how to disable a mailman 2 list’ because I’d like to know how, too, since we do occasionally have need to do this.)
The method in that thread is simply moving the lists/<listname> aside. That is one way to disable a list, but there are others depending on what you actually want. ...
To disable a list:
chmod 000 $PATH/lists/<LISTNAME>
And to re-enable it:
chmod 2775 $PATH/lists/<LISTNAME>
participants (4)
-
Bruce Johnson
-
John Lake
-
Mark Dale
-
Mark Sapiro