diff options
Diffstat (limited to 'notmuch-ssh-server')
-rw-r--r-- | notmuch-ssh-server | 30 |
1 files changed, 30 insertions, 0 deletions
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 @@ | |||
1 | #!@python@/bin/python | ||
2 | |||
3 | import os | ||
4 | import sys | ||
5 | import shlex | ||
6 | from xdg import BaseDirectory | ||
7 | from pathlib import Path | ||
8 | from configparser import ConfigParser | ||
9 | |||
10 | |||
11 | config = ConfigParser() | ||
12 | config_file = BaseDirectory.load_first_config('notmuch-ssh') | ||
13 | if config_file is not None: | ||
14 | config.read(config_file) | ||
15 | |||
16 | original_command = os.environ.get('SSH_ORIGINAL_COMMAND') | ||
17 | |||
18 | if original_command is None: | ||
19 | sys.exit(os.EX_USAGE) | ||
20 | |||
21 | original_command = shlex.split(original_command, comments = True) | ||
22 | |||
23 | if len(original_command) < 1: | ||
24 | sys.exit(os.EX_USAGE) | ||
25 | |||
26 | config_section = original_command[0] | ||
27 | |||
28 | command_environment = config.items(config_section) if config.has_section(config_section) else config.items(config.default_section) | ||
29 | |||
30 | os.execvpe('@notmuch@/bin/notmuch', original_command[1:], command_environment) | ||