securely overwrite files with Python

Bob Ippolito bob at redivi.com
Fri Mar 5 17:42:55 EST 2004


On 2004-03-05 16:28:55 -0500, Mathias Waack <M.Waack at gmx.de> said:

> Bart Nessux wrote:
> 
>> Is there a shred module in Python? You know, the kind that
>> overwrites files that one doesn't want others to see? I can call
>> the unix program like this:
>> 
>> x = os.popen("/usr/bin/shred -uvz NAME_OF_FILE")
>> x.read()
>> x.close()
>> 
>> But, I'd like a platform independant (portable) way of doing this
>> if possible.
> 
> First: It is not possible. Let me cite some sentences from shred(1):
> 
>        CAUTION: Note  that  shred  relies  on  a  very  important
>        assumption:  that the filesystem overwrites data in place.
>        This is the traditional way to do things, but many  modern
>        filesystem  designs  do  not satisfy this assumption.

Somewhat OT, Mac OS X 10.3 is one of the operating systems where this 
assumption is false.  Files smaller than a certain size get 
automatically moved around on the disk when it makes sense to do so in 
order to reduce fragmentation.

-bob




More information about the Python-list mailing list