569
by bwarsaw
Renamed reset_pw to reset_pw.py so that the file looks like a Python module. |
1 |
#! @PYTHON@
|
2 |
#
|
|
1779
by Mark Sapiro
Bump copyright dates. |
3 |
# Copyright (C) 2004-2018 by the Free Software Foundation, Inc.
|
569
by bwarsaw
Renamed reset_pw to reset_pw.py so that the file looks like a Python module. |
4 |
#
|
5 |
# This program is free software; you can redistribute it and/or
|
|
6 |
# modify it under the terms of the GNU General Public License
|
|
7 |
# as published by the Free Software Foundation; either version 2
|
|
8 |
# of the License, or (at your option) any later version.
|
|
9 |
#
|
|
10 |
# This program is distributed in the hope that it will be useful,
|
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
# GNU General Public License for more details.
|
|
14 |
#
|
|
15 |
# You should have received a copy of the GNU General Public License
|
|
16 |
# along with this program; if not, write to the Free Software
|
|
749
by tkikuchi
FSF office has moved to 51 Franklin Street. |
17 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
569
by bwarsaw
Renamed reset_pw to reset_pw.py so that the file looks like a Python module. |
18 |
|
19 |
# Inspired by Florian Weimer.
|
|
20 |
||
21 |
"""Reset the passwords for members of a mailing list.
|
|
22 |
||
23 |
This script resets all the passwords of a mailing list's members. It can also
|
|
24 |
be used to reset the lists of all members of all mailing lists, but it is your
|
|
25 |
responsibility to let the users know that their passwords have been changed.
|
|
26 |
||
27 |
This script is intended to be run as a bin/withlist script, i.e.
|
|
28 |
||
29 |
% bin/withlist -l -r reset_pw listname [options]
|
|
30 |
||
31 |
Options:
|
|
32 |
-v / --verbose
|
|
33 |
Print what the script is doing.
|
|
34 |
"""
|
|
35 |
||
36 |
import sys |
|
37 |
import getopt |
|
38 |
||
39 |
import paths |
|
40 |
from Mailman import Utils |
|
1619.1.2
by Yasuhito FUTATSUKI at POEM
* add option to pick up C_() texts to make potfile |
41 |
from Mailman.i18n import C_ |
569
by bwarsaw
Renamed reset_pw to reset_pw.py so that the file looks like a Python module. |
42 |
|
43 |
||
44 |
try: |
|
45 |
True, False |
|
46 |
except NameError: |
|
47 |
True = 1 |
|
48 |
False = 0 |
|
49 |
||
50 |
||
51 |
||
52 |
def usage(code, msg=''): |
|
53 |
if code: |
|
54 |
fd = sys.stderr |
|
55 |
else: |
|
56 |
fd = sys.stdout |
|
1619.1.2
by Yasuhito FUTATSUKI at POEM
* add option to pick up C_() texts to make potfile |
57 |
print >> fd, C_(__doc__.replace('%', '%%')) |
569
by bwarsaw
Renamed reset_pw to reset_pw.py so that the file looks like a Python module. |
58 |
if msg: |
59 |
print >> fd, msg |
|
60 |
sys.exit(code) |
|
61 |
||
62 |
||
63 |
||
64 |
def reset_pw(mlist, *args): |
|
65 |
try: |
|
66 |
opts, args = getopt.getopt(args, 'v', ['verbose']) |
|
67 |
except getopt.error, msg: |
|
68 |
usage(1, msg) |
|
69 |
||
70 |
verbose = False |
|
71 |
for opt, args in opts: |
|
72 |
if opt in ('-v', '--verbose'): |
|
73 |
verbose = True |
|
74 |
||
75 |
listname = mlist.internal_name() |
|
76 |
if verbose: |
|
1619.1.2
by Yasuhito FUTATSUKI at POEM
* add option to pick up C_() texts to make potfile |
77 |
print C_('Changing passwords for list: %(listname)s') |
569
by bwarsaw
Renamed reset_pw to reset_pw.py so that the file looks like a Python module. |
78 |
|
79 |
for member in mlist.getMembers(): |
|
80 |
randompw = Utils.MakeRandomPassword() |
|
81 |
mlist.setMemberPassword(member, randompw) |
|
82 |
if verbose: |
|
1619.1.2
by Yasuhito FUTATSUKI at POEM
* add option to pick up C_() texts to make potfile |
83 |
print C_('New password for member %(member)40s: %(randompw)s') |
569
by bwarsaw
Renamed reset_pw to reset_pw.py so that the file looks like a Python module. |
84 |
|
85 |
mlist.Save() |
|
86 |
||
87 |
||
88 |
||
89 |
if __name__ == '__main__': |
|
90 |
usage(0) |