diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2020-03-08 22:46:45 +0100 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2020-03-08 22:46:45 +0100 |
| commit | 368898379638a33578613b2169fa8c4205c44902 (patch) | |
| tree | 6285ca782f83dc9fb2fe29dec1b113636b633182 /notmuch-ssh-server | |
| parent | c75b6f1cb45ccbb41af696a2c1bf8176d7bd921e (diff) | |
| download | utils-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-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) | ||
