[Mailman-Developers] PHP Wrappers?

Joshua Ginsberg jag at fsf.org
Thu Nov 17 18:46:43 CET 2005


Well, it's pretty much about as vanilla of an XMLRPC interface as we
could generate... I'm not a PHP programmer, so I don't know exactly how
the XMLRPC bindings work on PHP, but the Readers' Digest version of
XMLRPC goes like this...

XMLRPC is a request-response based remote procedure call mechanism over
HTTP. The client initiates a request to the XMLRPC "listener" and posts
an XML document that represents a request. For example, let's say I wrap
the function multiply(x, y) which multiplies two numbers together.
First, I need to give the function an XMLRPC methodname, so we'll call
it "foo.multiply". A request might look like:

<?xml version="1.0"?>
<methodCall>
  <methodName>foo.multiply</methodName>
  <params>
    <param><i4><value>2</value></i4></param>
    <param><i4><value>5</value></i4></param>
  </params.
</methodCall>

which the "listener" would parse and dispatch to multiply(x, y) and get
back 10. Which it would then send as a response to the client.

<?xml version="1.0"?>
<methodResponse>
  <params>
    <param><i4><value>10</value></i4></param>
  </params>
</methodResponse>

and so your XMLRPC client would return 10.

There are a handful of standard "system" methods, so for example you can
execute system.listMethods() to see what methods are implemented; or
system.methodHelp(methodName) to see documentation on a method. Also, if
errors occur, they are raised as "faults" with a fault code and a fault
string.

Fortunately most programming languages wrap the details of all of this
up for you to make it easy. In Python, you instantiate an object that
represents a connection to an XMLRPC listener. Then all methods
implemented by that listener become attributes of that object. So in
Python:

>>> import xmlrpclib
>>> sp = xmlrpclib.ServerProxy('http://lists.mysite.com/mailman/RPC2')
>>> sp.system.listMethods()
['Mailman.addMember', 'Mailman.changeMemberAddress',
'Mailman.createList', 'Mailman.deleteList', 'Mailman.deleteMember',
'Mailman.getDigestMembers', 'Mailman.getMembers', 'Mailman.getOptions',
'Mailman.getRegularMembers', 'Mailman.listAdvertisedLists',
'Mailman.listAllLists', 'Mailman.resetListPassword',
'Mailman.setOptions', 'system.listMethods', 'system.methodHelp',
'system.methodSignature']

So these are the methods exported by the Mailman RPC listener. So how do
they work?

>>> print sp.system.methodHelp('Mailman.addMember')
"add_member(listname, admin_pw, address, fullname, password, digest, now):

Subscribes the email address provided to the mailing list.

listname -- the name of the list to configure
admin_pw -- the list or site administrator password
address -- the email address to add
fullname -- the user's full name
password -- the password the user would like to have, leave blank to
    generate a random password
digest -- True or False implying if they wish to receive batched digest
    delivery
now -- True or False implying whether to bypass normal mailing list rules
    about confirmation/approval

Returns True if everything succeeded; raises Fault -32501 if the user needs
to confirm their subscription; raises Fault -32502 if the list administrator
needs to approve their subscription"

So I could execute Mailman.addMember('whatifnet-announce', 'f00bar',
'jag at fsf.org', 'jagpass', False, True) to add myself to the list
whatifnet-announce with regular delivery and without having to confirm
my email address. The method would return True if everything succeeded.
In Python, I'd do:

>>> sp.Mailman.addMember('whatifnet-announce', 'f00bar', 'jag at fsf.org',
'jagpass', False, True)

There are some pretty good references for how PHP's XMLRPC client works,
so I'd refer to those to figure out how to write a PHP client for this
interface.

Does that answer your questions somewhat?

-jag

On Thu, 2005-11-17 at 09:55 -0500, Adrian Wells wrote:
> Jag,
> 
> Thank you for the reply.  I had briefly looked over this XMLRPC patch
> before posting to the mailing list, but I do not understand how it
> would provide the desired functionality.  However, having received
> your message, I want to learn more and understand how this might
> work.  Do you have some examples, documentation, or other resources
> that I might be able to review to learn more?
> 
> In the meantime, I'll look at the patch more closely to try to
> understand how it works and how to interface with it.
> 
> Thank you,
> -Adrian
> 
> Joshua Ginsberg <jag at fsf.org> on Wednesday, November 16, 2005 at 3:01
> PM +0000 wrote:
> This would be something that could take advantage of the XMLRPC patch
> under review:
> http://www.lnk4.com/?437B8F9B45D7
> See also:
> http://www.lnk4.com/?437B900345F7
> http://www.lnk4.com/?437B901745F9
> -jag
> On Wed, 2005-11-16 at 13:12 -0400, Adrian Wells wrote:
> > Hello.  How might one configure Mailman (version 2.1.6) list
> settings
> > using PHP scripts?  The goal is to configure Mailman list settings
> such as
> > domain name of list, non-digest footer, set welcome/goodbye
> messages, etc.
> >  An approach that comes to mind is to use bin/config_list.  This
> would
> > require writing/reading files and using bin/config_list to process
> them. 
> > Is there another recommended or preferred way to accomplish this?
> > 
> > There was a post about "PHP Wrappers" which suggested, "...just use
> a
> > setuid mailman wrapper script that does caller-checking to see if
> it's
> > called correctly, by the right user, and with 'safe' values"
> >
> <http://mail.python.org/pipermail/mailman-developers/2001-March/008421.html>.
> >  This was recommended over simply adding the www user to the mailman
> group.
> > 
> > I do not completely understand how one creates a setuid mailman
> wrapper
> > script.  Is this a matter of creating something similar to
> mail-wrapper.c?
> > 
> > If someone has written a wrapper script or has some good resources
> further
> > explaining this to share and is willing to do so, I would appreciate
> it. 
> > Thank you,
> > -Adrian
> > 
> > _______________________________________________
> > Mailman-Developers mailing list
> > Mailman-Developers at python.org
> > http://mail.python.org/mailman/listinfo/mailman-developers
> > Mailman FAQ: http://www.python.org/cgi-bin/faqw-mm.py
> > Searchable Archives: http://www.mail-archive.com/mailman-users%
> 40python.org/
> > Unsubscribe:
> http://mail.python.org/mailman/options/mailman-developers/jag%
> 40fsf.org
> > 
> > Security Policy:
> http://www.python.org/cgi-bin/faqw-mm.py?req=show&file=faq01.027.htp
> > 
> -- 
> Joshua Ginsberg <jag at fsf.org>
> Free Software Foundation - Senior Systems Administrator
-- 
Joshua Ginsberg <jag at fsf.org>
Free Software Foundation - Senior Systems Administrator
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/mailman-developers/attachments/20051117/a4fafdd2/attachment.pgp


More information about the Mailman-Developers mailing list