Change moderator or admin password (random) different for each list they were an admin or moderator for

Asked by Daniel Botting

Hi,

I have been using the withlist command to delete a given administrator or moderator from all mailman 2.1 lists.

I also require to change the moderator or admin password for all lists that they have been removed from, but have it so that it is a different randomly generated password for each list they are removed from and then have this emailed to the other moderators or admins who are then left or a default address if none are left (I have managed so far that it is changed to the same password for each list they have been removed from). I am currently at the beginning of my Python learning so this is why I'm asking for help.

My script and usage so far can be found below:

Usage:

withlist --all --run script_name.change_administrator_password <email address hidden> `pwgen -sB 15 1`

The script is saved at:

/usr/sbin/

Function defined in the script:

import sha

def change_administrator_password(mlist, owner, newpasswd):
    mlist.Lock()
    try:
        if mlist.owner[mlist.owner.index(owner)]:
           mlist.password = sha.new(newpasswd).hexdigest()
           print (newpasswd)

    except:
      print("password not changed for", (mlist.real_name, owner))
    mlist.Save()
    mlist.Unlock()

This will go through all lists and change the administrator password to a randomly generated one, but as advised above it will set the same password (not what I want) I've put a print in for debugging so I can see what it was.

Thanks

Daniel

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu mailman Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said :
#1

What the script above does is: create a single password, and then start the command to go through all lists with this one password.

If you want to have a different password for each list, then you have to do the password generation inside the script, either by calling some "random" or "secrets" functions or by opening a shell (e.g. with subprocess.run) for the "pwgen -sB 15 1" command from inside python.

Revision history for this message
Daniel Botting (danmcr) said :
#2

Hi Manfred,

Thank you for your quick response the other day, appreciated.

I posted the same question as well on the mailman lists and they also
assisting me.

Thanks

Daniel

On 04/03/2021 16:11, Manfred Hampl wrote:
> Your question #695864 on mailman in Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+source/mailman/+question/695864
>
> Status: Open => Answered
>
> Manfred Hampl proposed the following answer:
> What the script above does is: create a single password, and then start
> the command to go through all lists with this one password.
>
> If you want to have a different password for each list, then you have to
> do the password generation inside the script, either by calling some
> "random" or "secrets" functions or by opening a shell (e.g. with
> subprocess.run) for the "pwgen -sB 15 1" command from inside python.
>
--
Daniel Botting
Systems Administrator
Codethink Ltd.
3rd Floor Dale House,
35 Dale Street,
Manchester, M1 2HF
United Kingdom

http://www.codethink.co.uk/
We respect your privacy. See https://www.codethink.co.uk/privacy.html

Revision history for this message
Mark Sapiro (msapiro) said :
#3

Please keep this discussion on the <email address hidden> list where it belongs. If you still have a question after reading the reply at https://<email address hidden>/message/4LHQOFAE4GM264SYQSUSHJQXHZFPOZZZ/ post your question in that thread.

Can you help with this problem?

Provide an answer of your own, or ask Daniel Botting for more information if necessary.

To post a message you must log in.