#!/usr/bin/python

###
###  Simple script which uses the mailman_admin_cmd_handler to change
###  a user's password for a given email list; this is also used by
###  sync-list-passwords.py utility script.
###
###  Anthony R. Thompson, June 2010
###  Contact: put @ between art and sigilservices.com
###
###  Copyright (C) 1998-2010 by the Free Software Foundation, Inc.
###
###  This program is free software; you can redistribute it and/or
###  modify it under the terms of the GNU General Public License
###  as published by the Free Software Foundation; either version 2
###  of the License, or (at your option) any later version.
###
###  This program is distributed in the hope that it will be useful,
###  but WITHOUT ANY WARRANTY; without even the implied warranty of
###  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
###  GNU General Public License for more details.
###
###  You should have received a copy of the GNU General Public License
###  along with this program; if not, write to the Free Software
###  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
###  02110-1301, USA. http://www.fsf.org/licensing/licenses/gpl.html
###

import sys
import mailman_admin_cmd_handler

SITE_PASS = 'YOURSITEPASSWORD'  # INSTALL, as set by mmsitepass bin script

if (len(sys.argv) < 4):
    print 'Usage: ' + sys.argv[0] + ' listname useremail newpass'
    sys.exit(1)
listname = sys.argv[1]
username = sys.argv[2]
password = sys.argv[3]

args = ['password', listname, SITE_PASS, username, password]
mlist = mailman_admin_cmd_handler.get_list_unlocked(listname)
print mailman_admin_cmd_handler.password(mlist, args)
