Exemple #1
0
def driveIsEncrypted(self):
    NSLog(u"Checking on FileVault Status")
    if os.path.exists(fdesetupExec):
        try:
            fv_status = subprocess.Popen([fdesetupExec,'status'], stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0]
            if re.match(r'FileVault is On.|Encryption in progress:*',fv_status):
                FVAlerts.quit_if_encrypted(self)
                return True
            elif re.match(r'Decryption in progress:|FileVault is Off, but needs to be restarted to finish.',fv_status):
                FVAlerts.quit_if_decrypting(self)
                return True
            else:
                NSLog(u"FileVault Not Enabled, launching Crypt")
                return False
        except expat.ExpatError as e:
            return False

    elif os.path.exists(diskutilExec):
        try:
            lv_family = plistlib.readPlistFromString(subprocess.Popen([diskutilExec,'cs','info','-plist','/'], stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0]).get('MemberOfCoreStorageLogicalVolumeFamily')
           
            the_command=diskutilExec+" cs list "+lv_family
            stdout = subprocess.Popen(the_command,shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0]
            FVproperty=''
            FVstatus=''
            for line in stdout.splitlines():
                try:
                    try:FVproperty, FVstatus = line.split(':', 2)
                    except:pass
                    if re.search(r'Conversion Status', FVproperty):
                        lvf_status = FVstatus
                    elif re.search(r'Conversion Direction', FVproperty):
                        lvf_direction = FVstatus
                    elif re.search(r'Fully Secure', FVproperty):
                        lvf_secure = FVstatus
                except:
                    NSLog(u"something went wrong!")

   
            if re.search(r'Yes',lvf_secure):
                FVAlerts.quit_if_encrypted(self)
                return True
            elif re.search(r'No',lvf_secure):
                if re.search(r'Converting',lvf_status):
                    NSLog(u"Drive is Currenlty in the process of Converting....")

                    if re.search(r'forward',lvf_direction):
                        FVAlerts.quit_if_encrypted(self)
                        return True
                        
                    elif re.search(r'backward',lvf_direction):
                        FVAlerts.quit_if_decrypting(self)
                        return True
                else:
                    NSLog(u"FileVault Not Enabled, launching Crypt")
                    return False                    
        except expat.ExpatError as e:
            print False
Exemple #2
0
    def encrypt_(self,sender):
        fvprefspath = "/Library/Preferences/FVServer.plist"
        the_command = "ioreg -c \"IOPlatformExpertDevice\" | awk -F '\"' '/IOPlatformSerialNumber/ {print $4}'"
        serial = subprocess.Popen(the_command,shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0]
        serial = re.sub(r'\s', '', serial)
        serverURL = FVUtils.pref("ServerURL")
        NSLog(u"%s" % serverURL)
        if serverURL == "":
            self.errorField.setStringValue_("ServerURL isn't configured")
            self.userName.setEnabled_(False)
            self.password.setEnabled_(False)
            self.encryptButton.setEnabled_(False)
        username_value = self.userName.stringValue()
        password_value = self.password.stringValue()
        self.userName.setEnabled_(False)
        self.password.setEnabled_(False)
        self.encryptButton.setEnabled_(False)
        
        def enable_inputs(self):
            self.userName.setEnabled_(True)
            self.password.setEnabled_(True)
            self.encryptButton.setEnabled_(True)
        
        if username_value == "" or password_value == "":
            self.errorField.setStringValue_("You need to enter your username and password")
            self.userName.setEnabled_(True)
            self.password.setEnabled_(True)
            self.encryptButton.setEnabled_(True)

        if username_value != "" and password_value !="":
            self.userName.setEnabled_(False)
            self.password.setEnabled_(False)
            self.encryptButton.setEnabled_(False)
            
            #NSLog(u"csfde results: %s" % fv_status)
            recovery_key, encrypt_error = FVUtils.encryptDrive(password_value, username_value)
            if encrypt_error:
                FVAlerts.crypt_error(self,encrypt_error)
                ##write the key to a plist
                ##load a launch daemon - touch a file maybe?
                ##submit the key
                
            if recovery_key:
                FVUtils.escrowKey(recovery_key, username_value, 'initial')