mbx repair script

D

David Isaac

I'm looking for a Python script to repair the mbx header
for a mail file where only the header is corrupted.

Thanks,
Alan Isaac
 
D

Donn Cave

"David Isaac said:
I'm looking for a Python script to repair the mbx header
for a mail file where only the header is corrupted.

"Repair" and "corrupted" covers a lot of territory.

In the simplest case, a Python script would just be
a nuisance. All mbx files start with a 2048 byte
header, and a valid header can be copied to another
file and still be valid. For example, if the damaged
file still has 2048 bytes of header,

1. Find or create another mbx file "spud".
2. Copy header: $ dd if=spud count=4 > newbx
3. Copy old file: $ dd if=oldbx skip=4 >> newbx
4. change ownership and permission to match oldbx.

This approach isn't perfect - for example, it doesn't
preserve user flag information, but then, user flags
can be messed up by common IMAP4 operations like copying
a message from one folder to another. It assumes you
know where message data actually starts in the file,
but I think you'd need to know that in any event.

If the damage is really just that someone edited the
file in vi and you need to restore the NUL characters,
you could probably write something. Again, you have
to be able to recognize the start of message data
(or rather, the first MBX message header line.) If
the NULs are gone, this is probably preceded by a
series of CRLF ('\r\n'.) Keep track of how much has
been written to the output file, and at this point,
write '\0'*(2048 - n).

Donn Cave, (e-mail address removed)
 
D

David Isaac

Donn Cave said:
All mbx files start with a 2048 byte
header, and a valid header can be copied to another
file and still be valid. For example, if the damaged
file still has 2048 bytes of header,

1. Find or create another mbx file "spud".
2. Copy header: $ dd if=spud count=4 > newbx
3. Copy old file: $ dd if=oldbx skip=4 >> newbx
4. change ownership and permission to match oldbx.


This did not work for me.
Should it?
I thought the header contained information tightly tied
to the rest of the content (to speed search etc) so that
e.g., byte counts could matter.

Can you point me to documentation of the mbx format?

Thanks,
Alan Isaac
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top