# HG changeset patch # User Matt Johnston # Date 1643897586 -28800 # Node ID 1c9215154d4a6f0e9d895d5ce444a461c3d0433e # Parent 2c9d635a1c043d99dc264d7e3dbaf01a08c89dfe Handle /proc/.../maps being reordered We now search for the first r-xp line in the file diff -r 2c9d635a1c04 -r 1c9215154d4a test/parent_dropbear_map.py --- a/test/parent_dropbear_map.py Thu Feb 03 22:12:11 2022 +0800 +++ b/test/parent_dropbear_map.py Thu Feb 03 22:13:06 2022 +0800 @@ -9,7 +9,7 @@ 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 @@ 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 -r 2c9d635a1c04 -r 1c9215154d4a test/test_aslr.py --- a/test/test_aslr.py Thu Feb 03 22:12:11 2022 +0800 +++ b/test/test_aslr.py Thu Feb 03 22:13:06 2022 +0800 @@ -28,7 +28,6 @@ # 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)