Ejemplo n.º 1
0
 def crypt_open(self):
     if self.configuration.get('encrypted_key', None):
         try:
             sh.cryptsetup('luksOpen', '-d',
                           self.configuration['encrypted_key'],
                           self.configuration['device'],
                           self.configuration['encrypted_map'])
         except sh.ErrorReturnCode_4:
             self.logger.debug("Device unavailable")
             quit()
         self.logger.debug("Opened encrypted device")
         self.crypt_is_open = True
         self.configuration['crypt_device'] = self.configuration['device']
         self.configuration['device'] = os.path.join(
             '/dev', 'mapper', self.configuration['encrypted_map'])
Ejemplo n.º 2
0
	def OpenCrypt(self, filepath):
		self.logger.info('Opening encrypted container on loopback device [{0}] for file [{1}]'.format(self.containers[filepath].loop_dev, filepath))
		container = self.containers[filepath]
		self.logger.info('Mapping to device [{0}]'.format(container.mapped_name))
		sh.cryptsetup('open', self.containers[filepath].loop_dev, container.mapped_name, _tty_in=True, _err_to_out=True, _out_bufsize=0, _out=interactive_handler_std_getpass).wait()
		self.logger.info('Opened encrypted container on loopback device [{0}] for file [{1}] on mapped device [{2}]'.format(self.containers[filepath].loop_dev, filepath, self.containers[filepath].mapped_device))
Ejemplo n.º 3
0
	def SetupCrypt(self, filepath):
		self.logger.info('Setting up encrypted container on loopback device [{0}] for file [{1}]'.format(self.containers[filepath].loop_dev, filepath))
		sh.cryptsetup( '-v', 'luksFormat', self.containers[filepath].loop_dev,  _tty_in=True, _err_to_out=True, _out_bufsize=0, _out=interactive_handler_std_getpass).wait()
		self.logger.info('Done setting up encrypted container on loopback device [{0}] for file [{1}]'.format(self.containers[filepath].loop_dev, filepath))
Ejemplo n.º 4
0
 def crypt_close(self):
     if self.crypt_is_open:
         sh.cryptsetup('luksClose', self.configuration['encrypted_map'])
         self.logger.debug("Closed encrypted device")
         self.crypt_is_open = False
         self.configuration['device'] = self.configuration['crypt_device']