mirror of
https://codeberg.org/gaschz/passff-host.git
synced 2025-06-06 18:08:46 +02:00
Allow error code extraction from GPG by including debug output (#65)
* Don't filter GPG debug outputs, but send everything to PassFF --------- Co-authored-by: Thomas Vogt <tuxor1337@users.noreply.github.com> Co-authored-by: Thomas Vogt <acc-framagit@tovotu.de>
This commit is contained in:
parent
91ae64fd5f
commit
bfabb222dd
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
import shlex
|
||||||
import struct
|
import struct
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@ -52,6 +54,24 @@ def sendMessage(encodedMessage):
|
|||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
|
||||||
|
def setPassGpgOpts(env, opts_dict):
|
||||||
|
""" Add arguments to PASSWORD_STORE_GPG_OPTS. """
|
||||||
|
opts = env.get('PASSWORD_STORE_GPG_OPTS', '')
|
||||||
|
for opt, value in opts_dict.items():
|
||||||
|
re_opt = new_opt = opt
|
||||||
|
if value is not None:
|
||||||
|
re_opt = rf"{opt}(?:=|\s+)\S*"
|
||||||
|
new_opt = (
|
||||||
|
f"{opt}={shlex.quote(value)}"
|
||||||
|
if opt.startswith("--") else
|
||||||
|
f"{opt} {shlex.quote(value)}"
|
||||||
|
)
|
||||||
|
# If the user's environment sets this opt, remove it.
|
||||||
|
opts = re.sub(re_opt, '', opts)
|
||||||
|
opts = f"{new_opt} {opts}"
|
||||||
|
env['PASSWORD_STORE_GPG_OPTS'] = opts.strip()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Read message from standard input
|
# Read message from standard input
|
||||||
receivedMessage = getMessage()
|
receivedMessage = getMessage()
|
||||||
@ -93,6 +113,7 @@ if __name__ == "__main__":
|
|||||||
env["HOME"] = os.path.expanduser('~')
|
env["HOME"] = os.path.expanduser('~')
|
||||||
for key, val in COMMAND_ENV.items():
|
for key, val in COMMAND_ENV.items():
|
||||||
env[key] = val
|
env[key] = val
|
||||||
|
setPassGpgOpts(env, {'--status-fd': '2', '--debug': 'ipc'})
|
||||||
|
|
||||||
# Set up subprocess params
|
# Set up subprocess params
|
||||||
cmd = [COMMAND] + opt_args + ['--'] + pos_args
|
cmd = [COMMAND] + opt_args + ['--'] + pos_args
|
||||||
|
Loading…
x
Reference in New Issue
Block a user