예제 #1
0
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))
예제 #2
0
    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'])
예제 #3
0
    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()
예제 #4
0
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
예제 #5
0
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