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