Skip to content

Commit

Permalink
Add init_backend method to match gocryptfs updates
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
daviewales committed Jan 16, 2025
1 parent cf8a23a commit 0ef4740
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions common/encfstools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0ef4740

Please sign in to comment.