summaryrefslogtreecommitdiff
path: root/notmuch-ssh-server
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2020-03-08 22:46:45 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2020-03-08 22:46:45 +0100
commit368898379638a33578613b2169fa8c4205c44902 (patch)
tree6285ca782f83dc9fb2fe29dec1b113636b633182 /notmuch-ssh-server
parentc75b6f1cb45ccbb41af696a2c1bf8176d7bd921e (diff)
downloadutils-368898379638a33578613b2169fa8c4205c44902.tar
utils-368898379638a33578613b2169fa8c4205c44902.tar.gz
utils-368898379638a33578613b2169fa8c4205c44902.tar.bz2
utils-368898379638a33578613b2169fa8c4205c44902.tar.xz
utils-368898379638a33578613b2169fa8c4205c44902.zip
...
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)