~mailman-coders/mailman/2.1

1 by
This commit was manufactured by cvs2svn to create branch
1
#! @PYTHON@
2
#
1779 by Mark Sapiro
Bump copyright dates.
3
# Copyright (C) 1998-2018 by the Free Software Foundation, Inc.
1 by
This commit was manufactured by cvs2svn to create branch
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.
1 by
This commit was manufactured by cvs2svn to create branch
18
19
"""Set the site password, prompting from the terminal.
20
21
The site password can be used in most if not all places that the list
22
administrator's password can be used, which in turn can be used in most places
23
that a list users password can be used.
24
25
Usage: %(PROGRAM)s [options] [password]
26
27
Options:
28
29
    -c/--listcreator
30
        Set the list creator password instead of the site password.  The list
31
        creator is authorized to create and remove lists, but does not have
32
        the total power of the site administrator.
33
34
    -h/--help
35
        Print this help message and exit.
36
37
If password is not given on the command line, it will be prompted for.
38
"""
39
40
import sys
41
import getpass
42
import getopt
43
44
import paths
45
from Mailman import Utils
1619.1.1 by Yasuhito FUTATSUKI at POEM
Importing locale patch for command line utils, from RHEL6 rpm source
46
from Mailman.i18n import C_
1 by
This commit was manufactured by cvs2svn to create branch
47
48
PROGRAM = sys.argv[0]
49
50
51

52
def usage(code, msg=''):
53
    if code:
54
        fd = sys.stderr
55
    else:
56
        fd = sys.stdout
1619.1.1 by Yasuhito FUTATSUKI at POEM
Importing locale patch for command line utils, from RHEL6 rpm source
57
    print >> fd, C_(__doc__)
1 by
This commit was manufactured by cvs2svn to create branch
58
    if msg:
59
        print >> fd, msg
60
    sys.exit(code)
61
62
63

64
def main():
65
    try:
66
        opts, args = getopt.getopt(sys.argv[1:], 'ch',
67
                                   ['listcreator', 'help'])
68
    except getopt.error, msg:
69
        usage(1, msg)
70
71
    # Defaults
72
    siteadmin = 1
1619.1.1 by Yasuhito FUTATSUKI at POEM
Importing locale patch for command line utils, from RHEL6 rpm source
73
    pwdesc = C_('site')
1 by
This commit was manufactured by cvs2svn to create branch
74
75
    for opt, arg in opts:
76
        if opt in ('-h', '--help'):
77
            usage(0)
78
        elif opt in ('-c', '--listcreator'):
79
            siteadmin = 0
1619.1.1 by Yasuhito FUTATSUKI at POEM
Importing locale patch for command line utils, from RHEL6 rpm source
80
            pwdesc = C_('list creator')
1 by
This commit was manufactured by cvs2svn to create branch
81
82
    if len(args) == 1:
83
        pw1 = args[0]
84
    else:
85
        try:
1619.1.1 by Yasuhito FUTATSUKI at POEM
Importing locale patch for command line utils, from RHEL6 rpm source
86
            pw1 = getpass.getpass(C_('New %(pwdesc)s password: '))
87
            pw2 = getpass.getpass(C_('Again to confirm password: '))
1 by
This commit was manufactured by cvs2svn to create branch
88
            if pw1 <> pw2:
1619.1.1 by Yasuhito FUTATSUKI at POEM
Importing locale patch for command line utils, from RHEL6 rpm source
89
                print C_('Passwords do not match; no changes made.')
1 by
This commit was manufactured by cvs2svn to create branch
90
                sys.exit(1)
91
        except KeyboardInterrupt:
1619.1.1 by Yasuhito FUTATSUKI at POEM
Importing locale patch for command line utils, from RHEL6 rpm source
92
            print C_('Interrupted...')
1 by
This commit was manufactured by cvs2svn to create branch
93
            sys.exit(0)
94
    # Set the site password by writing it to a local file.  Make sure the
95
    # permissions don't allow other+read.
96
    Utils.set_global_password(pw1, siteadmin)
97
    if Utils.check_global_password(pw1, siteadmin):
1619.1.1 by Yasuhito FUTATSUKI at POEM
Importing locale patch for command line utils, from RHEL6 rpm source
98
        print C_('Password changed.')
1 by
This commit was manufactured by cvs2svn to create branch
99
    else:
1619.1.1 by Yasuhito FUTATSUKI at POEM
Importing locale patch for command line utils, from RHEL6 rpm source
100
        print C_('Password change failed.')
1 by
This commit was manufactured by cvs2svn to create branch
101
102
103

104
if __name__ == '__main__':
105
    main()