Skip to content

Commit 9059ef6

Browse files
committed
update
1 parent 4d86ca6 commit 9059ef6

4 files changed

Lines changed: 69 additions & 61 deletions

File tree

Mailman/Cgi/admin.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,18 @@ def main():
152152
csrf_checked = True
153153
try:
154154
mailman_log('debug', 'Calling WebAuthenticate')
155+
mailman_log('debug', 'Authentication contexts: %s', str((mm_cfg.AuthListAdmin, mm_cfg.AuthSiteAdmin)))
156+
mailman_log('debug', 'Password provided: %s', 'Yes' if cgidata.get('adminpw', [''])[0] else 'No')
157+
mailman_log('debug', 'Cookie present: %s', 'Yes' if os.environ.get('HTTP_COOKIE') else 'No')
155158
auth_result = mlist.WebAuthenticate((mm_cfg.AuthListAdmin,
156159
mm_cfg.AuthSiteAdmin),
157160
cgidata.get('adminpw', [''])[0])
158161
mailman_log('debug', 'WebAuthenticate result: %s', str(auth_result))
162+
if not auth_result:
163+
mailman_log('debug', 'Authentication failed - checking auth contexts')
164+
for context in (mm_cfg.AuthListAdmin, mm_cfg.AuthSiteAdmin):
165+
mailman_log('debug', 'Checking context %s: %s',
166+
context, str(mlist.AuthContextInfo(context)))
159167
except Exception as e:
160168
mailman_log('error', 'admin: Exception during WebAuthenticate: %s\n%s', str(e), traceback.format_exc())
161169
mailman_log('debug', 'Exception during WebAuthenticate')

Mailman/Handlers/Hold.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def hold_for_approval(mlist, msg, msgdata, exc):
260260
finally:
261261
mlist.Unlock()
262262
else:
263-
cookie = mlist.pend_new(Pending.HELD_MESSAGE, id)
263+
cookie = mlist.pend_new(Pending.HELD_MESSAGE, id)
264264

265265
if not fromusenet and ackp(msg) and mlist.respond_to_post_requests and \
266266
mlist.autorespondToSender(sender, mlist.getMemberLanguage(sender)):

Mailman/Handlers/ToOutgoing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import traceback
2727
from Mailman.Logging.Syslog import mailman_log
2828

29-
29+
3030
def process(mlist, msg, msgdata):
3131
"""Process the message by moving it to the outgoing queue."""
3232
msgid = msg.get('message-id', 'n/a')

Mailman/Queue/Switchboard.py

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def recover_backup_files(self):
501501
try:
502502
# First try to validate the backup file
503503
with open(src, 'rb') as fp:
504-
try:
504+
try:
505505
# Try to read the entire file first to check for EOF
506506
content = fp.read()
507507
if not content:
@@ -511,86 +511,86 @@ def recover_backup_files(self):
511511
from io import BytesIO
512512
fp = BytesIO(content)
513513

514-
try:
515-
msg = pickle.load(fp, fix_imports=True, encoding='latin1')
516-
data_pos = fp.tell()
517-
data = pickle.load(fp, fix_imports=True, encoding='latin1')
514+
try:
515+
msg = pickle.load(fp, fix_imports=True, encoding='latin1')
516+
data_pos = fp.tell()
517+
data = pickle.load(fp, fix_imports=True, encoding='latin1')
518518
except (EOFError, pickle.UnpicklingError) as e:
519519
mailman_log('error', 'Corrupted backup file %s: %s\nTraceback:\n%s',
520520
filebase, str(e), traceback.format_exc())
521-
self.finish(filebase, preserve=True)
522-
continue
523-
521+
self.finish(filebase, preserve=True)
522+
continue
523+
524524
# Validate the unpickled data
525525
if not isinstance(data, dict):
526526
raise TypeError('Invalid data format in backup file')
527527

528528
# Update metadata
529-
data['_bak_count'] = data.setdefault('_bak_count', 0) + 1
530-
data['_last_attempt'] = time.time()
531-
if '_error_history' not in data:
532-
data['_error_history'] = []
533-
if '_traceback' in data:
534-
data['_error_history'].append({
535-
'error': data.get('_last_error', 'unknown'),
536-
'traceback': data.get('_traceback', 'none'),
537-
'time': data.get('_last_attempt', 0)
538-
})
529+
data['_bak_count'] = data.setdefault('_bak_count', 0) + 1
530+
data['_last_attempt'] = time.time()
531+
if '_error_history' not in data:
532+
data['_error_history'] = []
533+
if '_traceback' in data:
534+
data['_error_history'].append({
535+
'error': data.get('_last_error', 'unknown'),
536+
'traceback': data.get('_traceback', 'none'),
537+
'time': data.get('_last_attempt', 0)
538+
})
539539

540540
# Write the updated data back
541541
with open(src, 'wb') as out_fp:
542-
if data.get('_parsemsg'):
543-
protocol = 0
544-
else:
545-
protocol = 1
542+
if data.get('_parsemsg'):
543+
protocol = 0
544+
else:
545+
protocol = 1
546546
pickle.dump(data, out_fp, protocol=4, fix_imports=True)
547547
out_fp.flush()
548548
if hasattr(os, 'fsync'):
549549
os.fsync(out_fp.fileno())
550-
551-
# Log detailed information about the retry
552-
mailman_log('warning',
553-
'Message retry attempt %d/%d: %s (queue: %s, '
554-
'message-id: %s, listname: %s, recipients: %s, '
555-
'error: %s, last attempt: %s, traceback: %s)',
556-
data['_bak_count'],
550+
551+
# Log detailed information about the retry
552+
mailman_log('warning',
553+
'Message retry attempt %d/%d: %s (queue: %s, '
554+
'message-id: %s, listname: %s, recipients: %s, '
555+
'error: %s, last attempt: %s, traceback: %s)',
556+
data['_bak_count'],
557+
MAX_BAK_COUNT,
558+
filebase,
559+
self.__whichq,
560+
data.get('message-id', 'unknown'),
561+
data.get('listname', 'unknown'),
562+
data.get('recips', 'unknown'),
563+
data.get('_last_error', 'unknown'),
564+
time.ctime(data.get('_last_attempt', 0)),
565+
data.get('_traceback', 'none'))
566+
567+
if data['_bak_count'] >= MAX_BAK_COUNT:
568+
mailman_log('error',
569+
'Backup file exceeded maximum retry count (%d). '
570+
'Moving to shunt queue: %s (original queue: %s, '
571+
'retry count: %d, last error: %s, '
572+
'message-id: %s, listname: %s, '
573+
'recipients: %s, error history: %s, '
574+
'last traceback: %s, full path: %s)',
557575
MAX_BAK_COUNT,
558576
filebase,
559577
self.__whichq,
578+
data['_bak_count'],
579+
data.get('_last_error', 'unknown'),
560580
data.get('message-id', 'unknown'),
561581
data.get('listname', 'unknown'),
562582
data.get('recips', 'unknown'),
563-
data.get('_last_error', 'unknown'),
564-
time.ctime(data.get('_last_attempt', 0)),
565-
data.get('_traceback', 'none'))
566-
567-
if data['_bak_count'] >= MAX_BAK_COUNT:
568-
mailman_log('error',
569-
'Backup file exceeded maximum retry count (%d). '
570-
'Moving to shunt queue: %s (original queue: %s, '
571-
'retry count: %d, last error: %s, '
572-
'message-id: %s, listname: %s, '
573-
'recipients: %s, error history: %s, '
574-
'last traceback: %s, full path: %s)',
575-
MAX_BAK_COUNT,
576-
filebase,
577-
self.__whichq,
578-
data['_bak_count'],
579-
data.get('_last_error', 'unknown'),
580-
data.get('message-id', 'unknown'),
581-
data.get('listname', 'unknown'),
582-
data.get('recips', 'unknown'),
583-
data.get('_error_history', 'unknown'),
584-
data.get('_traceback', 'none'),
585-
os.path.join(self.__whichq, filebase + '.bak'))
583+
data.get('_error_history', 'unknown'),
584+
data.get('_traceback', 'none'),
585+
os.path.join(self.__whichq, filebase + '.bak'))
586+
self.finish(filebase, preserve=True)
587+
else:
588+
try:
589+
os.rename(src, dst)
590+
except OSError as e:
591+
mailman_log('error', 'Failed to rename backup file %s (full paths: %s -> %s): %s\nTraceback:\n%s',
592+
filebase, os.path.join(self.__whichq, filebase + '.bak'), os.path.join(self.__whichq, filebase + '.pck'), str(e), traceback.format_exc())
586593
self.finish(filebase, preserve=True)
587-
else:
588-
try:
589-
os.rename(src, dst)
590-
except OSError as e:
591-
mailman_log('error', 'Failed to rename backup file %s (full paths: %s -> %s): %s\nTraceback:\n%s',
592-
filebase, os.path.join(self.__whichq, filebase + '.bak'), os.path.join(self.__whichq, filebase + '.pck'), str(e), traceback.format_exc())
593-
self.finish(filebase, preserve=True)
594594

595595
except Exception as e:
596596
mailman_log('error', 'Failed to process backup file %s (full path: %s): %s\nTraceback:\n%s',

0 commit comments

Comments
 (0)