diff options
author | David Lehman <dlehman@redhat.com> | 2008-10-30 15:45:16 -0500 |
---|---|---|
committer | David Lehman <dlehman@redhat.com> | 2008-10-30 15:45:23 -0500 |
commit | 1e5bbb5fd61160ebac5f917662f05a2a07fb3627 (patch) | |
tree | f8929e8e399464e0477fe37df8343ef36948cec1 | |
parent | 55833649b14b1118dabb050a8629aa767e58a8e4 (diff) | |
download | anaconda-1e5bbb5fd61160ebac5f917662f05a2a07fb3627.tar.gz anaconda-1e5bbb5fd61160ebac5f917662f05a2a07fb3627.tar.xz anaconda-1e5bbb5fd61160ebac5f917662f05a2a07fb3627.zip |
Write zeros to remove metadata before running luksFormat. (#469177)
This should be fixed in cryptsetup for RHEL5.4 (#468910).
-rw-r--r-- | cryptodev.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/cryptodev.py b/cryptodev.py index 3dac057ca..cde919a3b 100644 --- a/cryptodev.py +++ b/cryptodev.py @@ -163,6 +163,20 @@ class LUKSDevice: if not device: raise ValueError, "Cannot open mapping without a device." + # zero out the 1MB at the beginning and end of the device in the + # hope that it will wipe any metadata from filesystems that + # previously occupied this device + log.debug("zeroing out beginning and end of %s..." % device) + try: + fd = os.open("%s/%s" % (devPrefix, device), os.O_RDWR) + buf = '\0' * 1024 * 1024 + os.write(fd, buf) + os.lseek(fd, -1024 * 1024, 2) + os.write(fd, buf) + os.close(fd) + except Exception, e: + log.error("error zeroing out %s/%s: %s" % (devPrefix, device, e)) + log.info("formatting %s as %s" % (device, self.getScheme())) p = os.pipe() os.write(p[1], "%s\n" % (self.passphrase,)) |