From 0ef47409aeb47f37e786932ea9255965d3cb65c5 Mon Sep 17 00:00:00 2001 From: David Wales Date: Wed, 15 Jan 2025 23:13:28 +1100 Subject: [PATCH] Add init_backend method to match gocryptfs updates We are rebasing previous gocryptfs work from 2017. This work added an `init_backend` method which separates the concerns of first-time initialisation vs subsequent use. --- common/encfstools.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/common/encfstools.py b/common/encfstools.py index 2a1206cca..c112004a5 100644 --- a/common/encfstools.py +++ b/common/encfstools.py @@ -83,6 +83,41 @@ def _mount(self): .format(command=' '.join(encfs)), output)) + def init_backend(self): + """ + init the cipher path + """ + if self.password is None: + self.password = self.config.password(self.parent, self.profile_id, self.mode) + logger.debug('Provide password through temp FIFO', self) + thread = TempPasswordThread(self.password) + env = os.environ.copy() + env['ASKPASS_TEMP'] = thread.temp_file + + with thread.starter(): + encfs = [self.mountproc, '--extpass=backintime-askpass'] + if self.reverse: + encfs += ['--reverse'] + encfs += ['--standard'] + encfs += [self.path, self.currentMountpoint] + logger.debug( + 'Call command to create EncFS config file: %s' + %' '.join(encfs), + self + ) + + proc = subprocess.Popen(encfs, env = env, + stdout = subprocess.PIPE, + stderr = subprocess.STDOUT, + universal_newlines = True) + output = proc.communicate()[0] + self.backupConfig() + if proc.returncode: + raise MountException( + _("Can't init encrypted path '{command}':\n\n{error}") + .format(command=' '.join(encfs), error=output) + ) + def preMountCheck(self, first_run=False): """Check what ever conditions must be given for the mount.