Ejemplo n.º 1
0
 def testOutOfOrder(self):
     self.mox.StubOutWithMock(util, 'Exec')
     util.Exec(('/sbin/mount')).AndReturn(
         (0, MOUNT_OUTPUT_OUT_OF_ORDER, ''))
     self.mox.ReplayAll()
     self.assertEquals('/dev/disk0s2', util.GetRootDisk())
     self.mox.VerifyAll()
Ejemplo n.º 2
0
 def _GetCommand(self):
     return (self.PATH, util.GetRootDisk(), self._username, '-')
Ejemplo n.º 3
0
    def testOutOfOrder(self, exec_mock):
        self.assertEquals('/dev/disk0s2', util.GetRootDisk())

        exec_mock.assert_called_once_with('/sbin/mount')
Ejemplo n.º 4
0
class OptionError(Error):
    """Base class for all errors raised by options."""


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))

    root_disk = util.GetRootDisk()
    try:
        csfde_plist = util.GetPlistFromExec(
            (CSFDE_PATH, root_disk, username, '-'), stdin=password)
    except util.ExecError, e:
        if e.returncode == CSFDE_RETURN_AUTH_FAIL:
            raise InputError(
                'Authentication problem with local account.  Drive NOT encrypted.'
            )
        elif e.returncode != 0:
            logging.error('csfde failed with stderr:\n%s', e.stderr)
            raise Error('Problem running csfde (exit status = %d)' %
                        e.returncode)
        else:
            logging.exception('Problem running csfde.')
            raise Error('Problem running csfde', e)