Removed debug information
This commit is contained in:
parent
af1e240611
commit
8239c96278
|
|
@ -223,11 +223,8 @@ class SysCommandWorker:
|
|||
"""
|
||||
assert type(key) == bytes
|
||||
|
||||
with open('./debug.txt', 'a') as silent_output:
|
||||
silent_output.write(f"Checking for {[key]} in {[self._trace_log]} as position {self._trace_log_pos}\n")
|
||||
if (contains := key in self._trace_log[self._trace_log_pos:]):
|
||||
silent_output.write(f" -Found it ({[contains]}) at {self._trace_log.find(key, self._trace_log_pos)}\n")
|
||||
self._trace_log_pos += self._trace_log.find(key, self._trace_log_pos) + len(key)
|
||||
if (contains := key in self._trace_log[self._trace_log_pos:]):
|
||||
self._trace_log_pos += self._trace_log.find(key, self._trace_log_pos) + len(key)
|
||||
|
||||
return contains
|
||||
|
||||
|
|
@ -284,16 +281,12 @@ class SysCommandWorker:
|
|||
|
||||
self.make_sure_we_are_executing()
|
||||
|
||||
with open('debug_write.txt', 'a') as silent_output:
|
||||
if self.child_fd:
|
||||
data = data + (b'\n' if line_ending else b'')
|
||||
written_data = os.write(self.child_fd, data)
|
||||
written_data = os.write(self.child_fd, data + (b'\n' if line_ending else b''))
|
||||
|
||||
sys.stdout.flush()
|
||||
# sys.stdout.flush() # <- Doesn't help
|
||||
# os.fsync(self.child_fd) # <-- Will generate OSError: [Error 22] Invalid argument
|
||||
|
||||
silent_output.write(f"Wrote {written_data}: {[data]}\n")
|
||||
|
||||
return written_data
|
||||
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -103,16 +103,15 @@ class luks2:
|
|||
])
|
||||
|
||||
# print(f"Looking for phrase: 'Enter passphrase for {partition.path}'")
|
||||
cryptworker = SysCommandWorker(cryptsetup_args, peak_output=True)
|
||||
cryptworker = SysCommandWorker(cryptsetup_args)
|
||||
|
||||
pw_given = False
|
||||
while cryptworker.is_alive():
|
||||
with open('debug_outer.txt', 'a') as silent_output:
|
||||
found = bytes(f'Enter passphrase for {partition.path}', 'UTF-8') in cryptworker
|
||||
silent_output.write(f"Found string in worker: {found} / {pw_given}")
|
||||
if found and pw_given is False:
|
||||
cryptworker.write(password + b'\r\n', line_ending=False)
|
||||
pw_given = True
|
||||
if bytes(f'Enter passphrase for {partition.path}', 'UTF-8') in cryptworker and pw_given is False:
|
||||
# cryptworker.write(password)
|
||||
# TODO: Workaround, as cryptsetup doesn't appear to accept any input via os.write(child_cd, data)
|
||||
print(password.decode())
|
||||
pw_given = True
|
||||
|
||||
if cryptworker.exit_code == 256:
|
||||
log(f'{partition} is being used, trying to unmount and crypt-close the device and running one more attempt at encrypting the device: {cryptworker}', level=logging.INFO)
|
||||
|
|
@ -185,12 +184,14 @@ class luks2:
|
|||
os.path.basename(mountpoint) # TODO: Raise exception instead?
|
||||
|
||||
# print(f"Looking for phrase: 'Enter passphrase for {partition.path}'")
|
||||
cryptworker = SysCommandWorker(f'/usr/bin/cryptsetup open {partition.path} {mountpoint} --type luks2', peak_output=True)
|
||||
cryptworker = SysCommandWorker(f'/usr/bin/cryptsetup open {partition.path} {mountpoint} --type luks2')
|
||||
|
||||
pw_given = False
|
||||
while cryptworker.is_alive():
|
||||
if bytes(f'Enter passphrase for {partition.path}', 'UTF-8') in cryptworker and pw_given is False:
|
||||
cryptworker.write(password)
|
||||
# cryptworker.write(password)
|
||||
# TODO: Workaround, as cryptsetup doesn't appear to accept any input via os.write(child_cd, data)
|
||||
print(password.decode())
|
||||
pw_given = True
|
||||
|
||||
if not cryptworker.exit_code == 0:
|
||||
|
|
|
|||
Loading…
Reference in New Issue