diff options
| author | bwarsaw | 2000-10-02 20:41:40 +0000 |
|---|---|---|
| committer | bwarsaw | 2000-10-02 20:41:40 +0000 |
| commit | 0e260ba02b48f6a46d145025f91404829614520f (patch) | |
| tree | 474a9faa6c9e930a413a51c972d5f2d517b15059 /bin/mmsitepass | |
| parent | e32aecde449efe46b465f2f637ca85ffb7e84b48 (diff) | |
| download | mailman-0e260ba02b48f6a46d145025f91404829614520f.tar.gz mailman-0e260ba02b48f6a46d145025f91404829614520f.tar.zst mailman-0e260ba02b48f6a46d145025f91404829614520f.zip | |
Since we now require Python 1.5.2 and that version has getpass in it's
standard library, get rid of Mailman.pythonlib.getpass compatibility
module.
Plus, general cleanup, and use SetSiteAdminPassword(),
CheckSiteAdminPassword() from Utils instead of on a bogus MailList
object.
Diffstat (limited to 'bin/mmsitepass')
| -rwxr-xr-x | bin/mmsitepass | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/bin/mmsitepass b/bin/mmsitepass index 474f38a35..eace10989 100755 --- a/bin/mmsitepass +++ b/bin/mmsitepass @@ -19,46 +19,48 @@ """Set the site password, prompting from the terminal. The site password can be used in most if not all places that the list -administrator's password can be used, which in turn can be used in most -places that a list users password can be used.""" +administrator's password can be used, which in turn can be used in most places +that a list users password can be used. + +Usage: mmsitepass [password] + +If password is not given on the command line, it will be prompted for. + +""" import sys +import getpass + import paths -try: - import getpass -except ImportError: - # we must be in Python 1.5, which didn't have the getpass module - from Mailman.pythonlib import getpass -from Mailman import MailList +from Mailman import Utils -def main(argv): +def main(): if len(sys.argv) > 2: - print "Usage: mmsitepass [ password ]" - raise SystemExit, 1 + print __doc__ + sys.exit(1) elif len(sys.argv) == 2: - pw = sys.argv[1] + pw1 = sys.argv[1] else: try: - pw = getpass.getpass("New Password: ") - confirm = getpass.getpass("Again to confirm password: ") - if pw != confirm: - print "Mismatch - password not changed." - raise SystemExit, 1 + pw1 = getpass.getpass("New Password: ") + pw2 = getpass.getpass("Again to confirm password: ") + if pw1 <> pw2: + print 'Passwords do not match; no changes made.' + sys.exit(1) except KeyboardInterrupt: print "Interrupted..." - raise SystemExit, 1 - l = MailList.MailList() - l.SetSiteAdminPassword(pw) - if l.CheckSiteAdminPassword(pw): - print "Password changed." - raise SystemExit, 0 + sys.exit(0) + # Set the site password by writing it to a local file. Make sure the + # permissions don't allow other+read. + Utils.SetSiteAdminPassword(pw1) + if Utils.CheckSiteAdminPassword(pw1): + print 'Password changed.' else: - print "Password change failed." - raise SystemExit, 1 + print 'Password change failed.' if __name__ == '__main__': - main(sys.argv) + main() |
