diff options
author | Matt Johnston <matt@ucc.asn.au> | 2022-02-03 22:13:06 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2022-02-03 22:13:06 +0800 |
commit | e0464ab77a141e3b1cbe0ef38f72c11183a1be0a (patch) | |
tree | 0f2af20ade6ca5ae04a0148ee3ed39ef19e4e54a /test | |
parent | ad40339570c267bec5a88fafe30a9de2237d23e5 (diff) | |
download | dropbear-e0464ab77a141e3b1cbe0ef38f72c11183a1be0a.tar.gz |
Handle /proc/.../maps being reordered
We now search for the first r-xp line in the file
Diffstat (limited to 'test')
-rwxr-xr-x | test/parent_dropbear_map.py | 8 | ||||
-rw-r--r-- | test/test_aslr.py | 1 |
2 files changed, 5 insertions, 4 deletions
diff --git a/test/parent_dropbear_map.py b/test/parent_dropbear_map.py index 34a8b9f..479222b 100755 --- a/test/parent_dropbear_map.py +++ b/test/parent_dropbear_map.py @@ -9,7 +9,7 @@ from pathlib import Path want_name = "dropbear" -# Walks up the parent process tree, prints the first line of /proc/pid/maps when +# Walks up the parent process tree, prints a r-xp line of /proc/pid/maps when # it finds the wanted name def main(): @@ -22,8 +22,10 @@ def main(): if want_name in p.name(): with (Path('/proc') / str(p.pid) / "maps").open() as f: - map0 = f.readline().rstrip() - print(map0) + for i, l in enumerate(f, 1): + if ' r-xp ' in l: + print(l.rstrip()) + break return raise RuntimeError(f"Couldn't find parent {want_name} process") diff --git a/test/test_aslr.py b/test/test_aslr.py index ddc8fa5..ec38844 100644 --- a/test/test_aslr.py +++ b/test/test_aslr.py @@ -28,7 +28,6 @@ def test_reexec(request, dropbear): # expect something like # "563174d59000-563174d5d000 r--p 00000000 00:29 4242372 /home/matt/src/dropbear/build/dropbear" assert map1.endswith('/dropbear') or map1.endswith('/dropbearmulti') - assert ' r--p ' in map1 a1 = map1.split()[0] a2 = map2.split()[0] print(a1) |