Skip to content

Commit 0ef4740

Browse files
committed
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.
1 parent cf8a23a commit 0ef4740

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

common/encfstools.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,41 @@ def _mount(self):
8383
.format(command=' '.join(encfs)),
8484
output))
8585

86+
def init_backend(self):
87+
"""
88+
init the cipher path
89+
"""
90+
if self.password is None:
91+
self.password = self.config.password(self.parent, self.profile_id, self.mode)
92+
logger.debug('Provide password through temp FIFO', self)
93+
thread = TempPasswordThread(self.password)
94+
env = os.environ.copy()
95+
env['ASKPASS_TEMP'] = thread.temp_file
96+
97+
with thread.starter():
98+
encfs = [self.mountproc, '--extpass=backintime-askpass']
99+
if self.reverse:
100+
encfs += ['--reverse']
101+
encfs += ['--standard']
102+
encfs += [self.path, self.currentMountpoint]
103+
logger.debug(
104+
'Call command to create EncFS config file: %s'
105+
%' '.join(encfs),
106+
self
107+
)
108+
109+
proc = subprocess.Popen(encfs, env = env,
110+
stdout = subprocess.PIPE,
111+
stderr = subprocess.STDOUT,
112+
universal_newlines = True)
113+
output = proc.communicate()[0]
114+
self.backupConfig()
115+
if proc.returncode:
116+
raise MountException(
117+
_("Can't init encrypted path '{command}':\n\n{error}")
118+
.format(command=' '.join(encfs), error=output)
119+
)
120+
86121
def preMountCheck(self, first_run=False):
87122
"""Check what ever conditions must be given for the mount.
88123

0 commit comments

Comments
 (0)