From 368898379638a33578613b2169fa8c4205c44902 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 8 Mar 2020 22:46:45 +0100 Subject: ... --- notmuch-ssh-server | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 notmuch-ssh-server (limited to 'notmuch-ssh-server') diff --git a/notmuch-ssh-server b/notmuch-ssh-server new file mode 100644 index 0000000..6a7a2ed --- /dev/null +++ b/notmuch-ssh-server @@ -0,0 +1,30 @@ +#!@python@/bin/python + +import os +import sys +import shlex +from xdg import BaseDirectory +from pathlib import Path +from configparser import ConfigParser + + +config = ConfigParser() +config_file = BaseDirectory.load_first_config('notmuch-ssh') +if config_file is not None: + config.read(config_file) + +original_command = os.environ.get('SSH_ORIGINAL_COMMAND') + +if original_command is None: + sys.exit(os.EX_USAGE) + +original_command = shlex.split(original_command, comments = True) + +if len(original_command) < 1: + sys.exit(os.EX_USAGE) + +config_section = original_command[0] + +command_environment = config.items(config_section) if config.has_section(config_section) else config.items(config.default_section) + +os.execvpe('@notmuch@/bin/notmuch', original_command[1:], command_environment) -- cgit v1.2.3