[Mailman-Users] Re: Make List Function

Kevin McCann kmccann at bellanet.org
Wed Mar 28 15:29:17 CEST 2001


Mitchell,

There are a few steps to do what you want. Maybe there are better ways, but 
I use the "sudo" program to allow the web user ("nobody" on most systems) 
to issue the "newlist" mailman command as root. It also allows "nobody" to 
append to /etc/aliases and issue the "newaliases" command.

First, you can create a php form like so:

------------------------
form_newlist.php:
-------------------------
<?
         print ' <P>
         <TABLE BORDER=0>
         <TR>
         <TD COLSPAN=2 ALIGN="middle">
         <FONT FACE="Arial, Helvetica"><B>Add a List</B></FONT>
         </TD></TR>
         <FORM ACTION="act_newlist.php" METHOD="post">
         <TR>
         <TD>List name:</TD><TD><INPUT TYPE="text" NAME="listname" 
SIZE="50"></TD>
         </TR>
         <TR>
         <TD>Admin Email</TD><TD><INPUT TYPE="text" NAME="adminemail" 
SIZE="50"></TD>
         </TR>
         <TR>
         <TD>Admin Password</TD><TD><INPUT TYPE="password" NAME="adminpass" 
SIZE="50"></TD>
         </TR>
         </TABLE>
         <INPUT TYPE="submit" VALUE="submit">
         </FORM> ';
?>
---

The above form, when submitted, will execute the script below:

-----------------------
act_newlist.php:
-----------------------
<?
// Issue newlist command, append output to /etc/aliases
$newlist = exec("/usr/local/bin/sudo  /home/mailman/bin/newlist --quiet 
--output=/etc/aliases$listname $adminemail $adminpass
",$alloutput,$returnvalue);

// Issue newaliases command
$newaliases = exec("/usr/local/bin/sudo  /usr/bin/newaliases");
print "List created.\n";
?>
-----

Notice that both the "newlist" and "newaliases" commands are prepended with 
the /usr/local/bin/sudo command.

To get sudo, go to http://www.courtesan.com/sudo

Once you have downloaded and installed it, create your sudoers file which 
will look like this:

-------------------
/etc/sudoers:
-------------------
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL
nobody ALL = NOPASSWD: /home/mailman/bin/newlist
nobody ALL = NOPASSWD: /usr/bin/newaliases

--------

If you want to create other forms to, say,  add members, delete lists, 
etc., just do the same kind of thing and remember to add the new commands 
to the sudoers file.

Be very careful about how you set up sudo. It's a great program but can be 
harmful if misused.

Hope this helps.

- Kevin





More information about the Mailman-Users mailing list