Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(20)  |  Call(13)  |  Derive(0)  |  Import(7)
Given a list of filenames, removes the contents of all of those
files, from the disk, 'securely'.  If blocking=1, does not
return until the remove is complete.  If blocking=0, returns
immediately, and continues removing the files in the background.

Securely deleting files only does so much good.  Metadata on
the file system, such as atime and dtime, can still be used to
reconstruct information about message timings.  To be more
safe, we could use a loopback device and shred _that_ from time
to time.  But since many filesystems relocate data underneath(more...)

        def secureDelete(fnames, blocking=0):
    """Given a list of filenames, removes the contents of all of those
       files, from the disk, 'securely'.  If blocking=1, does not
       return until the remove is complete.  If blocking=0, returns
       immediately, and continues removing the files in the background.

       Securely deleting files only does so much good.  Metadata on
       the file system, such as atime and dtime, can still be used to
       reconstruct information about message timings.  To be more
       safe, we could use a loopback device and shred _that_ from time
       to time.  But since many filesystems relocate data underneath
       you, you can't trust loopback devices: a separate shreddable
       partition is necessary.  But even then, HD controllers and
       drives sometimes relocate blocks to avoid bad blocks: then
       there's no way to overwrite the old locations!  The only
       heavy-duty solution is to use an encrypted filesystem and swap
       partition from the get-go... or to physically destroy and
       replace your hard drive every so often.)

       So we don't even bother trying to make the data 'physically
       irretrievable.'  We just zero it out, which should be good
       enough to stymie root for most purposes, and totally inadequate
       against a well-funded adversary with access to your hard drive
       and a bunch of sensitive magnetic equipment.

       XXXX Currently, we use shred from GNU fileutils.  Shred's 'unlink'
       XXXX operation has the regrettable property that two shred commands
       XXXX running in the same directory can sometimes get into a race.
       XXXX The source to shred.c seems to imply that this is harmless, but
       XXXX let's try to avoid that, to be on the safe side.
    """
    if _SHRED_CMD == "---":
        configureShredCommand(None)

    if fnames == []:
        return

    if isinstance(fnames, StringType):
        fnames = [fnames]

    if not _SHRED_CMD:
        for f in fnames:
            _overwriteFile(f)
            os.unlink(f)
        return None

    # Some systems are unhappy when you call them with too many options.
    for i in xrange(0, len(fnames), 250-len(_SHRED_OPTS)):
        files = fnames[i:i+250-len(_SHRED_OPTS)]
        try:
            #XXXX008 if blocking, we should just call this with P_WAIT.
            pid = os.spawnl(os.P_NOWAIT,
                            _SHRED_CMD, _SHRED_CMD, *(_SHRED_OPTS+files))
        except OSError, e:
            if e.errno not in (errno.EAGAIN, errno.ENOMEM):
                raise
            LOG.warn("Transient error while shredding files: %s",e)
            for f in files:
                if os.path.exists(f):
                    _overwriteFile(f)
                    os.unlink(f)
        else:
            if blocking:
                try:
                    os.waitpid(pid, 0)
                except OSError:
                    # sigchild handler might get to the pid first.
                    pass
        


src/m/i/mixminion-HEAD/lib/mixminion/server/ServerKeys.py   mixminion(Download)
from mixminion.ServerInfo import ServerInfo, PACKET_KEY_BYTES, MMTP_KEY_BYTES,\
     signServerInfo
from mixminion.Common import AtomicFile, LOG, MixError, MixFatalError, \
     ceilDiv, createPrivateDir, checkPrivateFile, englishSequence, \
     formatBase64, formatDate, formatTime, previousMidnight, readFile, \
            time.sleep(10)
            LOG.warn("Removing identity key")
            secureDelete([fn], blocking=1)
 
        if os.path.exists(self.dhFile):
            LOG.info("Removing diffie-helman parameters file")
            secureDelete([self.dhFile], blocking=1)
        self.certFile = os.path.join(keydir, "mmtp.cert")
        if os.path.exists(self.mmtpKeyFile):
            secureDelete(self.mmtpKeyFile)
        if os.path.exists(self.certFile):
            secureDelete(self.certFile)

src/m/i/mixminion-HEAD/lib/mixminion/Filestore.py   mixminion(Download)
import whichdb
 
from mixminion.Common import MixError, MixFatalError, secureDelete, LOG, \
     createPrivateDir, readFile, replaceFile, tryUnlink, writePickled
from mixminion.Crypto import getCommonPRNG
           is true, removes any incomplete or invalidated messages from the
           store."""
        secureDelete([]) # Make sure secureDelete is configured. HACK!
 
        self._lock = threading.RLock()
            secureDeleteFn(rmv)
        else:
            secureDelete(rmv, blocking=1)
 
    def _changeState(self, handle, s1, s2):
                secureDeleteFn(rmv)
            else:
                secureDelete(rmv, blocking=1)
 
    def loadAllMetadata(self, newDataFn):

src/m/i/mixminion-HEAD/lib/mixminion/server/ServerMain.py   mixminion(Download)
 
from bisect import insort
from mixminion.Common import LOG, LogStream, MixError, MixFatalError,\
     UIError, ceilDiv, createPrivateDir, disp64, formatTime, \
     installSIGCHLDHandler, Lockfile, LockfileLocked, readFile, secureDelete, \
                        LOG.warn("Delete thread didn't find file %s",fn)
 
                secureDelete(delNames, blocking=1)
 
            LOG.info("Cleanup thread shutting down.")
        files = os.listdir(qd)
        print "   (Deleting %s files from %s.)" %(len(files),qd)
        secureDelete([os.path.join(qd,f) for f in files])
 
    print "Homedir is upgraded"

src/m/i/mixminion-HEAD/lib/mixminion/server/HashLog.py   mixminion(Download)
import threading
import mixminion.Filestore
from mixminion.Common import MixFatalError, LOG, secureDelete
from mixminion.Packet import DIGEST_LEN
 
                    remove.append(os.path.join(parent, fn))
        remove = [f for f in remove if os.path.exists(f)]
        secureDelete(remove, blocking=1)
    finally:
        _HASHLOG_DICT_LOCK.release()

src/m/i/mixminion-HEAD/lib/mixminion/benchmark.py   mixminion(Download)
from mixminion.BuildMessage import _buildHeader, buildForwardPacket, \
     compressData, uncompressData, encodeMessage, decodePayload
from mixminion.Common import secureDelete, installSIGCHLDHandler, \
     waitForChildren, formatBase64, Lockfile
from mixminion.Crypto import *
    lst = [os.path.join(dname,str(i)) for i in range(100) ]
    t1 = time()
    secureDelete(lst)
    t = time()-t1
    print "secureDelete (100x32)", timestr(t)
    t1 = time()
    for fname in lst:
        secureDelete(fname)
    t = time()-t1
    print "secureDelete (1)", timestr(t/100)

src/m/i/mixminion-HEAD/lib/mixminion/server/Pinger.py   mixminion(Download)
import mixminion.server.MMTPServer
 
from mixminion.Common import MixError, AtomicFile, ceilDiv, createPrivateDir, \
     floorDiv, formatBase64, formatFnameDate, formatTime, IntervalSet, LOG, \
     parseFnameDate, previousMidnight, readPickled, secureDelete, \

src/m/i/mixminion-HEAD/lib/mixminion/server/ServerQueue.py   mixminion(Download)
import mixminion.Filestore
 
from mixminion.Common import MixError, MixFatalError, secureDelete, LOG, \
     createPrivateDir, readPickled, writePickled, formatTime, readFile, \
     ceilDiv