Mercurial > dropbear
annotate test/parent_dropbear_map.py @ 1921:284c3837891c
Allow user space file locations (rootless support)
Why:
Running dropbear as a user (rootless) is aided if
files and programs can be saved/removed without
needing sudo.
What:
Use the same convention as DROPBEAR_DEFAULT_CLI_AUTHKEY;
if not starting with '/', then is relative to hedge's /home/hedge:
*_PRIV_FILENAME
DROPBEAR_PIDFILE
SFTPSERVER_PATH
default_options.h commentary added.
Changes kept to a minimum, so log entry in svr_kex.c#163
is refactored.
From:
Generated hostkey is <path> ... <finger-print>
to:
Generated hostkey path is <path>
Generated hostkey fingerprint is <fp>
Otherwise the unexpanded path was reported.
Patch modified by Matt Johnston
Signed-off-by: Begley Brothers Inc <[email protected]>
author | Begley Brothers Inc <begleybrothers@gmail.com> |
---|---|
date | Thu, 09 Jul 2020 17:47:58 +1000 |
parents | 1c9215154d4a |
children |
rev | line source |
---|---|
1861 | 1 #!/usr/bin/env python3 |
2 | |
3 import os | |
4 import sys | |
5 import time | |
6 import psutil | |
7 | |
8 from pathlib import Path | |
9 | |
10 | |
11 want_name = "dropbear" | |
1874
1c9215154d4a
Handle /proc/.../maps being reordered
Matt Johnston <matt@ucc.asn.au>
parents:
1861
diff
changeset
|
12 # Walks up the parent process tree, prints a r-xp line of /proc/pid/maps when |
1861 | 13 # it finds the wanted name |
14 | |
15 def main(): | |
16 | |
17 try: | |
18 for p in psutil.Process().parents(): | |
19 print(p.pid, file=sys.stderr) | |
20 print(p.name(), file=sys.stderr) | |
21 print(p.cmdline(), file=sys.stderr) | |
22 | |
23 if want_name in p.name(): | |
24 with (Path('/proc') / str(p.pid) / "maps").open() as f: | |
1874
1c9215154d4a
Handle /proc/.../maps being reordered
Matt Johnston <matt@ucc.asn.au>
parents:
1861
diff
changeset
|
25 for i, l in enumerate(f, 1): |
1c9215154d4a
Handle /proc/.../maps being reordered
Matt Johnston <matt@ucc.asn.au>
parents:
1861
diff
changeset
|
26 if ' r-xp ' in l: |
1c9215154d4a
Handle /proc/.../maps being reordered
Matt Johnston <matt@ucc.asn.au>
parents:
1861
diff
changeset
|
27 print(l.rstrip()) |
1c9215154d4a
Handle /proc/.../maps being reordered
Matt Johnston <matt@ucc.asn.au>
parents:
1861
diff
changeset
|
28 break |
1861 | 29 return |
30 | |
31 raise RuntimeError(f"Couldn't find parent {want_name} process") | |
32 except Exception as e: | |
33 print(psutil.Process().parents()) | |
34 for p in psutil.Process().parents(): | |
35 print(p.name()) | |
36 print(e) | |
37 # time.sleep(100) | |
38 raise | |
39 | |
40 if __name__ == "__main__": | |
41 main() |