Update of /cvsroot/mailman/mailman/Mailman/Cgi
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8128/Mailman/Cgi

Modified Files:
        admin.py admindb.py confirm.py create.py edithtml.py 
        listinfo.py options.py private.py 
Log Message:
back porting from 2.1.6


Index: admin.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Cgi/admin.py,v
retrieving revision 2.90
retrieving revision 2.91
diff -u -d -r2.90 -r2.91
--- admin.py    27 Aug 2005 01:54:02 -0000      2.90
+++ admin.py    28 Aug 2005 05:31:26 -0000      2.91
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2004 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
@@ -14,9 +14,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA.
 
-"""Process and produce the list-administration options forms.
-
-"""
+"""Process and produce the list-administration options forms."""
 
 # For Python 2.1.x compatibility
 from __future__ import nested_scopes
@@ -51,6 +49,12 @@
 NL = '\n'
 OPTCOLUMNS = 11
 
+try:
+    True, False
+except NameError:
+    True = 1
+    False = 0
+
 
 
 def main():
@@ -232,8 +236,9 @@
                 # List is for different identity of this host - skip it.
                 continue
             else:
-                advertised.append(mlist)
-
+                advertised.append((mlist.GetScriptURL('admin'),
+                                   mlist.real_name,
+                                   mlist.description))
     # Greeting depends on whether there was an error or not
     if msg:
         greeting = FontAttr(msg, color="ff5060", size="+1")
@@ -283,10 +288,10 @@
                       Bold(FontAttr(_('Description'), size='+2'))
                       ])
         highlight = 1
-        for mlist in advertised:
+        for url, real_name, description in advertised:
             table.AddRow(
-                [Link(mlist.GetScriptURL('admin'), Bold(mlist.real_name)),
-                 mlist.description or Italic(_('[no description available]'))])
+                [Link(url, Bold(real_name)),
+                      description or Italic(_('[no description available]'))])
             if highlight and mm_cfg.WEB_HIGHLIGHT_COLOR:
                 table.AddRowInfo(table.GetCurrentRowIndex(),
                                  bgcolor=mm_cfg.WEB_HIGHLIGHT_COLOR)
@@ -406,7 +411,7 @@
     otherlinks.AddItem(Link(mlist.GetScriptURL('listinfo'),
                             _('Go to the general list information page')))
     otherlinks.AddItem(Link(mlist.GetScriptURL('edithtml'),
-                            _('Edit the public HTML pages')))
+                            _('Edit the public HTML pages and text files')))
     otherlinks.AddItem(Link(mlist.GetBaseArchiveURL(),
                             _('Go to list archives')).Format() +
                        '<br>&nbsp;<br>')
@@ -678,7 +683,7 @@
         # and a delete button.  Yeesh!  params are ignored.
         table = Table(border=0)
         # This adds the html for the entry widget
-        def makebox(i, name, pattern, desc, empty=0, table=table):
+        def makebox(i, name, pattern, desc, empty=False, table=table):
             deltag   = 'topic_delete_%02d' % i
             boxtag   = 'topic_box_%02d' % i
             reboxtag = 'topic_rebox_%02d' % i
@@ -718,7 +723,71 @@
         # Add one more non-deleteable widget as the first blank entry, but
         # only if there are no real entries.
         if i == 1:
-            makebox(i, '', '', '', empty=1)
+            makebox(i, '', '', '', empty=True)
+        return table
+    elif kind == mm_cfg.HeaderFilter:
+        # A complex and specialized widget type that allows for setting of a
+        # spam filter rule including, a mark button, a regexp text box, an
+        # "add after mark", up and down buttons, and a delete button.  Yeesh!
+        # params are ignored.
+        table = Table(border=0)
+        # This adds the html for the entry widget
+        def makebox(i, pattern, action, empty=False, table=table):
+            deltag    = 'hdrfilter_delete_%02d' % i
+            reboxtag  = 'hdrfilter_rebox_%02d' % i
+            actiontag = 'hdrfilter_action_%02d' % i
+            wheretag  = 'hdrfilter_where_%02d' % i
+            addtag    = 'hdrfilter_add_%02d' % i
+            newtag    = 'hdrfilter_new_%02d' % i
+            uptag     = 'hdrfilter_up_%02d' % i
+            downtag   = 'hdrfilter_down_%02d' % i
+            if empty:
+                table.AddRow([Center(Bold(_('Spam Filter Rule %(i)d'))),
+                              Hidden(newtag)])
+            else:
+                table.AddRow([Center(Bold(_('Spam Filter Rule %(i)d'))),
+                              SubmitButton(deltag, _('Delete'))])
+            table.AddRow([Label(_('Spam Filter Regexp:')),
+                          TextArea(reboxtag, text=pattern,
+                                   rows=4, cols=30, wrap='off')])
+            values = [mm_cfg.DEFER, mm_cfg.HOLD, mm_cfg.REJECT,
+                      mm_cfg.DISCARD, mm_cfg.ACCEPT]
+            try:
+                checked = values.index(action)
+            except ValueError:
+                checked = 0
+            radio = RadioButtonArray(
+                actiontag,
+                (_('Defer'), _('Hold'), _('Reject'),
+                 _('Discard'), _('Accept')),
+                values=values,
+                checked=checked).Format()
+            table.AddRow([Label(_('Action:')), radio])
+            if not empty:
+                table.AddRow([SubmitButton(addtag, _('Add new item...')),
+                              SelectOptions(wheretag, ('before', 'after'),
+                                            (_('...before this one.'),
+                                             _('...after this one.')),
+                                            selected=1),
+                              ])
+                # BAW: IWBNI we could disable the up and down buttons for the
+                # first and last item respectively, but it's not easy to know
+                # which is the last item, so let's not worry about that for
+                # now.
+                table.AddRow([SubmitButton(uptag, _('Move rule up')),
+                              SubmitButton(downtag, _('Move rule down'))])
+            table.AddRow(['<hr>'])
+            table.AddCellInfo(table.GetCurrentRowIndex(), 0, colspan=2)
+        # Now for each element in the existing data, create a widget
+        i = 1
+        data = getattr(mlist, varname)
+        for pattern, action, empty in data:
+            makebox(i, pattern, action, empty)
+            i += 1
+        # Add one more non-deleteable widget as the first blank entry, but
+        # only if there are no real entries.
+        if i == 1:
+            makebox(i, '', mm_cfg.DEFER, empty=True)
         return table
     elif kind == mm_cfg.Checkbox:
         return CheckBoxArray(varname, *params)
@@ -1262,7 +1331,8 @@
                         mlist.InviteNewMember(userdesc, invitation)
                 else:
                     mlist.ApprovedAddMember(userdesc, send_welcome_msg,
-                                            send_admin_notif, invitation)
+                                            send_admin_notif, invitation,
+                                            whence='admin mass sub')
             except Errors.MMAlreadyAMember:
                 subscribe_errors.append((entry, _('Already a member')))
             except Errors.MMBadEmailError:
@@ -1353,7 +1423,7 @@
         for user in users:
             if cgidata.has_key('%s_unsub' % user):
                 try:
-                    mlist.ApprovedDeleteMember(user)
+                    mlist.ApprovedDeleteMember(user, whence='member mgt page')
                     removes.append(user)
                 except Errors.NotAMemberError:
                     errors.append((user, _('Not subscribed')))

Index: admindb.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Cgi/admindb.py,v
retrieving revision 2.48
retrieving revision 2.49
diff -u -d -r2.48 -r2.49
--- admindb.py  27 Aug 2005 01:54:02 -0000      2.48
+++ admindb.py  28 Aug 2005 05:31:26 -0000      2.49
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2004 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
@@ -155,7 +155,7 @@
         realname = mlist.real_name
         if not cgidata.keys():
             # If this is not a form submission (i.e. there are no keys in the
-            # form), then all we don't need to do much special.
+            # form), then we don't need to do much special.
             doc.SetTitle(_('%(realname)s Administrative Database'))
         elif not details:
             # This is a form submission
@@ -179,7 +179,7 @@
         admindburl = mlist.GetScriptURL('admindb', absolute=1)
         form = Form(admindburl)
         # Add the instructions template
-        if details:
+        if details == 'instructions':
             doc.AddItem(Header(
                 2, _('Detailed instructions for the administrative database')))
         else:
@@ -187,8 +187,14 @@
                 2,
                 _('Administrative requests for mailing list:')
                 + ' <em>%s</em>' % mlist.real_name))
-        if not details:
+        if details <> 'instructions':
             form.AddItem(Center(SubmitButton('submit', _('Submit All Data'))))
+        if not (sender or msgid):
+            form.AddItem(Center(
+                CheckBox('discardalldefersp', 0).Format() +
+                '&nbsp;' +
+                _('Discard all messages marked <em>Defer</em>')
+                ))
         # Add a link back to the overview, if we're not viewing the overview!
         adminurl = mlist.GetScriptURL('admin', absolute=1)
         d = {'listname'  : mlist.real_name,
@@ -231,6 +237,12 @@
         if addform:
             doc.AddItem(form)
             form.AddItem('<hr>')
+            if not (sender or msgid):
+                form.AddItem(Center(
+                    CheckBox('discardalldefersp', 0).Format() +
+                    '&nbsp;' +
+                    _('Discard all messages marked <em>Defer</em>')
+                    ))
             form.AddItem(Center(SubmitButton('submit', _('Submit All Data'))))
         doc.AddItem(mlist.GetMailmanFooter())
         print doc.Format()
@@ -298,7 +310,9 @@
         if addr not in mlist.ban_list:
             radio += '<br>' + CheckBox('ban-%d' % id, 1).Format() + \
                      '&nbsp;' + _('Permanently ban from this list')
-        table.AddRow(['%s<br><em>%s</em>' % (addr, fullname),
+        # While the address may be a unicode, it must be ascii
+        paddr = addr.encode('us-ascii', 'replace')
+        table.AddRow(['%s<br><em>%s</em>' % (paddr, fullname),
                       radio,
                       TextBox('comment-%d' % id, size=40)
                       ])
@@ -470,10 +484,12 @@
                 # handled by the time we got here.
                 mlist.HandleRequest(id, mm_cfg.DISCARD)
                 continue
+            dispsubj = Utils.oneline(
+                subject, Utils.GetCharSet(mlist.preferred_language))
             t = Table(border=0)
             t.AddRow([Link(admindburl + '?msgid=%d' % id, '[%d]' % counter),
                       Bold(_('Subject:')),
-                      Utils.websafe(subject)
+                      Utils.websafe(dispsubj)
                       ])
             t.AddRow(['&nbsp;', Bold(_('Size:')), str(size) + _(' bytes')])
             if reason:
@@ -589,6 +605,14 @@
         body = EMPTYSTRING.join(lines)[:mm_cfg.ADMINDB_PAGE_TEXT_LIMIT]
     else:
         body = EMPTYSTRING.join(lines)
+    # Get message charset and try encode in list charset
+    mcset = msg.get_param('charset', 'us-ascii').lower()
+    lcset = Utils.GetCharSet(mlist.preferred_language)
+    if mcset <> lcset:
+        try:
+            body = unicode(body, mcset).encode(lcset)
+        except (LookupError, UnicodeError, ValueError):
+            pass
     hdrtxt = NL.join(['%s: %s' % (k, v) for k, v in msg.items()])
     hdrtxt = Utils.websafe(hdrtxt)
     # Okay, we've reconstituted the message just fine.  Now for the fun part!
@@ -596,7 +620,8 @@
     t.AddRow([Bold(_('From:')), sender])
     row, col = t.GetCurrentRowIndex(), t.GetCurrentCellIndex()
     t.AddCellInfo(row, col-1, align='right')
-    t.AddRow([Bold(_('Subject:')), Utils.websafe(subject)])
+    t.AddRow([Bold(_('Subject:')),
+              Utils.websafe(Utils.oneline(subject, lcset))])
     t.AddCellInfo(row+1, col-1, align='right')
     t.AddRow([Bold(_('Reason:')), _(reason)])
     t.AddCellInfo(row+2, col-1, align='right')
@@ -661,6 +686,11 @@
                 sender = unquote_plus(k[len(prefix):])
                 value = cgidata.getvalue(k)
                 senderactions.setdefault(sender, {})[action] = value
+    # discard-all-defers
+    try:
+       discardalldefersp = cgidata.getvalue('discardalldefersp', 0)
+    except ValueError:
+       discardalldefersp = 0
     for sender in senderactions.keys():
         actions = senderactions[sender]
         # Handle what to do about all this sender's held messages
@@ -668,6 +698,8 @@
             action = int(actions.get('senderaction', mm_cfg.DEFER))
         except ValueError:
             action = mm_cfg.DEFER
+       if action == mm_cfg.DEFER and discardalldefersp:
+           action = mm_cfg.DISCARD
         if action in (mm_cfg.DEFER, mm_cfg.APPROVE,
                       mm_cfg.REJECT, mm_cfg.DISCARD):
             preserve = actions.get('senderpreserve', 0)

Index: confirm.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Cgi/confirm.py,v
retrieving revision 2.34
retrieving revision 2.35
diff -u -d -r2.34 -r2.35
--- confirm.py  27 Aug 2005 01:54:02 -0000      2.34
+++ confirm.py  28 Aug 2005 05:31:26 -0000      2.35
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2004 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
@@ -33,6 +33,12 @@
 _ = i18n._
 i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE)
 
+try:
+    True, False
+except NameError:
+    True = 1
+    False = 0
+
 
 
 def main():
@@ -95,7 +101,7 @@
     Otherwise, <a href="%(confirmurl)s">re-enter</a> your confirmation
     string.''')
 
-    content = Pending.confirm(cookie, expunge=0)
+    content = mlist.pend_confirm(cookie, expunge=False)
     if content is None:
         bad_confirmation(doc, badconfirmstr)
         doc.AddItem(mlist.GetMailmanFooter())
@@ -122,8 +128,8 @@
                 doc.addError(_("""The address requesting unsubscription is not
                 a member of the mailing list.  Perhaps you have already been
                 unsubscribed, e.g. by the list administrator?"""))
-                # And get rid of this confirmation cookie
-                Pending.confirm(cookie)
+                # Expunge this record from the pending database.
+                expunge(mlist, cookie)
         elif content[0] == Pending.CHANGE_OF_ADDRESS:
             if cgidata.getvalue('cancel'):
                 addrchange_cancel(mlist, doc, cookie)
@@ -138,7 +144,8 @@
                     doc.addError(_("""The address requesting to be changed has
                     been subsequently unsubscribed.  This request has been
                     cancelled."""))
-                    Pending.confirm(cookie, expunge=1)
+                    # Expunge this record from the pending database.
+                    expunge(mlist, cookie)
         elif content[0] == Pending.HELD_MESSAGE:
             if cgidata.getvalue('cancel'):
                 heldmsg_cancel(mlist, doc, cookie)
@@ -170,6 +177,17 @@
     doc.AddItem(extra)
 
 
+def expunge(mlist, cookie):
+    # Expunge this record from the list's pending database.  This requires
+    # that the list lock be acquired, however the list doesn't need to be
+    # saved because this operation doesn't touch the config.pck file.
+    mlist.Lock()
+    try:
+        mlist.pend_confirm(cookie, expunge=True)
+    finally:
+        mlist.Unlock()
+
+
 
 def ask_for_cookie(mlist, doc, extra=''):
     title = _('Enter confirmation cookie')
@@ -235,8 +253,8 @@
     <p>Note: your password will be emailed to you once your subscription is
     confirmed.  You can change it by visiting your personal options page.
 
-    <p>Or hit <em>Cancel and discard</em> to cancel this subscription
-    request.""") + '<p><hr>'
+    <p>Or hit <em>Cancel my subscription request</em> if you no longer want to
+    subscribe to this list.""") + '<p><hr>'
     if mlist.subscribe_policy in (2, 3):
         # Confirmation is required
         result = _("""Your confirmation is required in order to continue with
@@ -290,8 +308,12 @@
 
 
 def subscription_cancel(mlist, doc, cookie):
-    # Discard this cookie
-    userdesc = Pending.confirm(cookie, expunge=1)[1]
+    mlist.Lock()
+    try:
+        # Discard this cookie
+        userdesc = mlist.pend_confirm(cookie)[1]
+    finally:
+        mlist.Unlock()
     lang = userdesc.language
     i18n.set_language(lang)
     doc.set_language(lang)
@@ -324,7 +346,7 @@
                     digest = None
             else:
                 digest = None
-            userdesc = Pending.confirm(cookie, expunge=0)[1]
+            userdesc = mlist.pend_confirm(cookie, expunge=False)[1]
             fullname = cgidata.getvalue('realname', None)
             if fullname is not None:
                 fullname = Utils.canonstr(fullname, lang)
@@ -379,8 +401,8 @@
 
 
 def unsubscription_cancel(mlist, doc, cookie):
-    # Discard this cookie
-    Pending.confirm(cookie, expunge=1)
+    # Expunge this record from the pending database
+    expunge(mlist, cookie)
     doc.AddItem(_('You have canceled your unsubscription request.'))
 
 
@@ -397,7 +419,7 @@
         try:
             # Do this in two steps so we can get the preferred language for
             # the user who is unsubscribing.
-            op, addr = Pending.confirm(cookie, expunge=0)
+            op, addr = mlist.pend_confirm(cookie, expunge=False)
             lang = mlist.getMemberLanguage(addr)
             i18n.set_language(lang)
             doc.set_language(lang)
@@ -467,8 +489,8 @@
 
 
 def addrchange_cancel(mlist, doc, cookie):
-    # Discard this cookie
-    Pending.confirm(cookie, expunge=1)
+    # Expunge this record from the pending database
+    expunge(mlist, cookie)
     doc.AddItem(_('You have canceled your change of address request.'))
 
 
@@ -485,7 +507,8 @@
         try:
             # Do this in two steps so we can get the preferred language for
             # the user who is unsubscribing.
-            op, oldaddr, newaddr, globally = Pending.confirm(cookie, expunge=0)
+            op, oldaddr, newaddr, globally = mlist.pend_confirm(
+                cookie, expunge=False)
             lang = mlist.getMemberLanguage(oldaddr)
             i18n.set_language(lang)
             doc.set_language(lang)
@@ -565,14 +588,14 @@
 
 
 def heldmsg_cancel(mlist, doc, cookie):
-    # Discard this cookie
     title = _('Continue awaiting approval')
     doc.SetTitle(title)
     table = Table(border=0, width='100%')
     table.AddRow([Center(Bold(FontAttr(title, size='+1')))])
     table.AddCellInfo(table.GetCurrentRowIndex(), 0,
                       bgcolor=mm_cfg.WEB_HEADER_COLOR)
-    Pending.confirm(cookie, expunge=1)
+    # Expunge this record from the pending database.
+    expunge(mlist, cookie)
     table.AddRow([_('''Okay, the list moderator will still have the
     opportunity to approve or reject this message.''')])
     doc.AddItem(table)
@@ -591,7 +614,7 @@
         try:
             # Do this in two steps so we can get the preferred language for
             # the user who posted the message.
-            op, id = Pending.confirm(cookie, expunge=1)
+            op, id = mlist.pend_confirm(cookie)
             ign, sender, msgsubject, ign, ign, ign = mlist.GetRecord(id)
             subject = Utils.websafe(msgsubject)
             lang = mlist.getMemberLanguage(sender)
@@ -708,7 +731,7 @@
         try:
             # Do this in two steps so we can get the preferred language for
             # the user who is unsubscribing.
-            op, listname, addr = Pending.confirm(cookie, expunge=0)
+            op, listname, addr = mlist.pend_confirm(cookie, expunge=False)
             lang = mlist.getMemberLanguage(addr)
             i18n.set_language(lang)
             doc.set_language(lang)
@@ -758,7 +781,8 @@
         <a href="%(listinfourl)s">list information page</a>.""")])
         return
 
-    date = time.strftime('%A, %B %d, %Y', info.date + (0,) * 6)
+    date = time.strftime('%A, %B %d, %Y', 
+                         time.localtime(time.mktime(info.date + (0,)*6)))
     daysleft = int(info.noticesleft *
                    mlist.bounce_you_are_disabled_warnings_interval /
                    mm_cfg.days(1))

Index: create.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Cgi/create.py,v
retrieving revision 2.23
retrieving revision 2.24
diff -u -d -r2.23 -r2.24
--- create.py   27 Aug 2005 01:54:02 -0000      2.23
+++ create.py   28 Aug 2005 05:31:26 -0000      2.24
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2004 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
@@ -93,7 +93,7 @@
     auth     = cgidata.getvalue('auth', '').strip()
     langs    = cgidata.getvalue('langs', [mm_cfg.DEFAULT_SERVER_LANGUAGE])
 
-    if type(langs) <> ListType:
+    if not isinstance(langs, ListType):
         langs = [langs]
     # Sanity check
     safelistname = Utils.websafe(listname)
@@ -125,7 +125,8 @@
                 blank if you want Mailman to autogenerate the list
                 passwords.'''))
             return
-        password = confirm = Utils.MakeRandomPassword(length=8)
+        password = confirm = Utils.MakeRandomPassword(
+            mm_cfg.ADMIN_PASSWORD_LENGTH)
     else:
         if password <> confirm:
             request_creation(doc, cgidata,
@@ -152,6 +153,15 @@
             doc, cgidata,
             _('You are not authorized to create new mailing lists'))
         return
+    # Make sure the web hostname matches one of our virtual domains
+    hostname = Utils.get_domain()
+    if mm_cfg.VIRTUAL_HOST_OVERVIEW and \
+           not mm_cfg.VIRTUAL_HOSTS.has_key(hostname):
+        safehostname = Utils.websafe(hostname)
+        request_creation(doc, cgidata,
+                         _('Unknown virtual host: %(safehostname)s'))
+        return
+    emailhost = mm_cfg.VIRTUAL_HOSTS.get(hostname, mm_cfg.DEFAULT_EMAIL_HOST)
     # We've got all the data we need, so go ahead and try to create the list
     # See admin.py for why we need to set up the signal handler.
     mlist = MailList.MailList()
@@ -175,10 +185,10 @@
         oldmask = os.umask(002)
         try:
             try:
-                mlist.Create(listname, owner, pw, langs)
+                mlist.Create(listname, owner, pw, langs, emailhost)
             finally:
                 os.umask(oldmask)
-        except Errors.MMBadEmailError, s:
+        except Errors.EmailAddressError, s:
             request_creation(doc, cgidata,
                              _('Bad owner email address: %(s)s'))
             return
@@ -199,11 +209,9 @@
 
         # Initialize the host_name and web_page_url attributes, based on
         # virtual hosting settings and the request environment variables.
-        hostname = Utils.get_domain()
         mlist.default_member_moderation = moderate
         mlist.web_page_url = mm_cfg.DEFAULT_URL_PATTERN % hostname
-        mlist.host_name = mm_cfg.VIRTUAL_HOSTS.get(
-            hostname, mm_cfg.DEFAULT_EMAIL_HOST)
+        mlist.host_name = emailhost
         mlist.Save()
     finally:
         # Now be sure to unlock the list.  It's okay if we get a signal here
@@ -220,7 +228,7 @@
 
     # And send the notice to the list owner.
     if notify:
-        siteadmin = Utils.get_site_email(mlist.host_name, 'admin')
+        siteowner = Utils.get_site_email(mlist.host_name, 'owner')
         text = Utils.maketext(
             'newlist.txt',
             {'listname'    : listname,
@@ -228,10 +236,10 @@
              'admin_url'   : mlist.GetScriptURL('admin', absolute=1),
              'listinfo_url': mlist.GetScriptURL('listinfo', absolute=1),
              'requestaddr' : mlist.GetRequestEmail(),
-             'siteowner'   : siteadmin,
+             'siteowner'   : siteowner,
              }, mlist=mlist)
         msg = Message.UserNotification(
-            owner, siteadmin,
+            owner, siteowner,
             _('Your new mailing list: %(listname)s'),
             text, mlist.preferred_language)
         msg.send(mlist)

Index: edithtml.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Cgi/edithtml.py,v
retrieving revision 2.17
retrieving revision 2.18
diff -u -d -r2.17 -r2.18
--- edithtml.py 27 Aug 2005 01:54:02 -0000      2.17
+++ edithtml.py 28 Aug 2005 05:31:26 -0000      2.18
@@ -1,17 +1,17 @@
-# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2005 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 
+# along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA.
 
 """Script which implements admin editing of the list's html templates."""
@@ -43,6 +43,7 @@
         ('listinfo.html',    _('General list information page')),
         ('subscribe.html',   _('Subscribe results page')),
         ('options.html',     _('User specific options page')),
+        ('subscribeack.txt', _('Welcome email text file')),
         )
 
     _ = i18n._
@@ -157,10 +158,14 @@
     code = cgi_info['html_code'].value
     langdir = os.path.join(mlist.fullpath(), mlist.preferred_language)
     # Make sure the directory exists
+    omask = os.umask(0)
     try:
-        os.mkdir(langdir, 02775)
-    except OSError, e:
-        if e.errno <> errno.EEXIST: raise
+        try:
+            os.mkdir(langdir, 02775)
+        except OSError, e:
+            if e.errno <> errno.EEXIST: raise
+    finally:
+        os.umask(omask)
     fp = open(os.path.join(langdir, template_name), 'w')
     try:
         fp.write(code)

Index: listinfo.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Cgi/listinfo.py,v
retrieving revision 2.27
retrieving revision 2.28
diff -u -d -r2.27 -r2.28
--- listinfo.py 27 Aug 2005 01:54:02 -0000      2.27
+++ listinfo.py 28 Aug 2005 05:31:26 -0000      2.28
@@ -91,8 +91,9 @@
                 # List is for different identity of this host - skip it.
                 continue
             else:
-                advertised.append(mlist)
-
+                advertised.append((mlist.GetScriptURL('listinfo'),
+                                   mlist.real_name,
+                                   mlist.description))
     if msg:
         greeting = FontAttr(msg, color="ff5060", size="+1")
     else:
@@ -135,10 +136,10 @@
                       Bold(FontAttr(_('Description'), size='+2'))
                       ])
         highlight = 1
-        for mlist in advertised:
+        for url, real_name, description in advertised:
             table.AddRow(
-                [Link(mlist.GetScriptURL('listinfo'), Bold(mlist.real_name)),
-                 mlist.description or Italic(_('[no description available]'))])
+                [Link(url, Bold(real_name)),
+                      description or Italic(_('[no description available]'))])
             if highlight and mm_cfg.WEB_HIGHLIGHT_COLOR:
                 table.AddRowInfo(table.GetCurrentRowIndex(),
                                  bgcolor=mm_cfg.WEB_HIGHLIGHT_COLOR)

Index: options.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Cgi/options.py,v
retrieving revision 2.44
retrieving revision 2.45
diff -u -d -r2.44 -r2.45
--- options.py  27 Aug 2005 01:54:02 -0000      2.44
+++ options.py  28 Aug 2005 05:31:26 -0000      2.45
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2004 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
@@ -39,6 +39,12 @@
 _ = i18n._
 i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE)
 
+try:
+    True, False
+except NameError:
+    True = 1
+    False = 0
+
 
 
 def main():
@@ -157,8 +163,23 @@
         # Because they can't supply a password for unsubscribing, we'll need
         # to do the confirmation dance.
         if mlist.isMember(user):
-            mlist.ConfirmUnsubscription(user, userlang)
-            doc.addError(_('The confirmation email has been sent.'), tag='')
+            # We must acquire the list lock in order to pend a request.
+            try:
+                mlist.Lock()
+                # If unsubs require admin approval, then this request has to
+                # be held.  Otherwise, send a confirmation.
+                if mlist.unsubscribe_policy:
+                    mlist.HoldUnsubscription(user)
+                    doc.addError(_("""Your unsubscription request has been
+                    forwarded to the list administrator for approval."""),
+                                 tag='')
+                else:
+                    mlist.ConfirmUnsubscription(user, userlang)
+                    doc.addError(_('The confirmation email has been sent.'),
+                                 tag='')
+                mlist.Save()
+            finally:
+                mlist.Unlock()
         else:
             # Not a member
             if mlist.private_roster == 0:
@@ -199,7 +220,6 @@
 
     # Authenticate, possibly using the password supplied in the login page
     password = cgidata.getvalue('password', '').strip()
-
     if not mlist.WebAuthenticate((mm_cfg.AuthUser,
                                   mm_cfg.AuthListAdmin,
                                   mm_cfg.AuthSiteAdmin),
@@ -416,13 +436,13 @@
         # list admin?) is informed of the removal.
         signal.signal(signal.SIGTERM, sigterm_handler)
         mlist.Lock()
-        needapproval = 0
+        needapproval = False
         try:
             try:
                 mlist.DeleteMember(
                     user, 'via the member options page', userack=1)
             except Errors.MMNeedApproval:
-                needapproval = 1
+                needapproval = True
             mlist.Save()
         finally:
             mlist.Unlock()
@@ -609,7 +629,10 @@
         print doc.Format()
         return
 
-    options_page(mlist, doc, user, cpuser, userlang)
+    if mlist.isMember(user):
+        options_page(mlist, doc, user, cpuser, userlang)
+    else:
+        loginpage(mlist, doc, user, userlang)
     print doc.Format()
 
 

Index: private.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Cgi/private.py,v
retrieving revision 2.19
retrieving revision 2.20
diff -u -d -r2.19 -r2.20
--- private.py  27 Aug 2005 01:54:02 -0000      2.19
+++ private.py  28 Aug 2005 05:31:26 -0000      2.20
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2005 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
@@ -35,13 +35,16 @@
 _ = i18n._
 i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE)
 
+SLASH = '/'
+
 
 
 def true_path(path):
     "Ensure that the path is safe by removing .."
-    path = path.replace('../', '')
-    path = path.replace('./', '')
-    return path[1:]
+    # Workaround for path traverse vulnerability.  Unsuccessful attempts will
+    # be logged in logs/error.
+    parts = [x for x in path.split(SLASH) if x not in ('.', '..')]
+    return SLASH.join(parts)[1:]
 
 
 

_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to