def ApplyEncryption(fvclient, username, password): """Turn encryption on.""" # Supply entropy to the system before csfde uses /dev/random. try: entropy = util.RetrieveEntropy() util.SupplyEntropy(entropy) except util.EntropyError, e: raise Error('Entropy operations failed: %s' % str(e))
def testRetrieveEntropy(self, exec_mock): rc = 0 stdout = 'HIDIdleTime=100\nWhateverOtherCrap\n' stderr = '' expected_entropy = 'HIDIdleTime=100' exec_mock.return_value = (rc, stdout, stderr) self.assertEqual(expected_entropy, util.RetrieveEntropy()) exec_mock.assert_called_once_with(['/usr/sbin/ioreg', '-l'])
def testRetrieveEntropy(self): self.mox.StubOutWithMock(util, 'Exec') rc = 0 stdout = 'HIDIdleTime=100\nWhateverOtherCrap\n' stderr = '' expected_entropy = 'HIDIdleTime=100' util.Exec(['/usr/sbin/ioreg', '-l']).AndReturn((rc, stdout, stderr)) self.mox.ReplayAll() self.assertEqual(expected_entropy, util.RetrieveEntropy()) self.mox.VerifyAll()
def ApplyEncryption(fvclient, username, password): """Turn encryption on.""" # Supply entropy to the system. try: entropy = util.RetrieveEntropy() util.SupplyEntropy(entropy) except util.EntropyError as e: raise Error('Entropy operations failed: %s' % str(e)) # Use "fdesetup" on Mac OS 10.8+ (Mountain Lion). logging.debug('Using fdesetup to enable FileVault') tool = FullDiskEncryptionSetup(username, password) volume_uuid, recovery_token = tool.EnableEncryption() fvclient.SetOwner(username) return volume_uuid, recovery_token
def ApplyEncryption(fvclient, username, password): """Turn encryption on.""" # Supply entropy to the system before csfde uses /dev/random. try: entropy = util.RetrieveEntropy() util.SupplyEntropy(entropy) except util.EntropyError as e: raise Error('Entropy operations failed: %s' % str(e)) if os.path.exists(FullDiskEncryptionSetup.PATH): # Use "fdesetup" on Mac OS 10.8+ (Mountain Lion). logging.debug('Using fdesetup to enable FileVault') tool = FullDiskEncryptionSetup(username, password) else: # Fall back on "csfde" for Mac OS 10.7 (Lion) and below. logging.debug('Using csfde to enable FileVault') tool = CoreStorageFullDiskEncryption(username, password) volume_uuid, recovery_token = tool.EnableEncryption() fvclient.SetOwner(username) return volume_uuid, recovery_token