Mercurial > dropbear
annotate test/test_aslr.py @ 1872:6b25cdad4783
Fix regression in non-symlink dropbearmulti
Introduced in recent commit for re-exec
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 01 Feb 2022 23:15:53 +0800 |
parents | d940f8007a45 |
children | 1c9215154d4a |
rev | line source |
---|---|
1861 | 1 from pathlib import Path |
2 import sys | |
3 | |
4 from test_dropbear import * | |
5 | |
6 def test_reexec(request, dropbear): | |
7 """ | |
8 Tests that two consecutive connections have different address layouts. | |
9 This indicates that re-exec makes ASLR work | |
10 """ | |
1863 | 11 map_script = (Path(request.node.fspath).parent / "parent_dropbear_map.py").resolve() |
12 # run within the same venv, for python deps | |
13 activate = own_venv_command() | |
14 cmd = f"{activate}; {map_script}" | |
15 print(cmd) | |
1861 | 16 r = dbclient(request, cmd, capture_output=True, text=True) |
17 map1 = r.stdout.rstrip() | |
18 print(r.stderr, file=sys.stderr) | |
19 r.check_returncode() | |
20 | |
21 r = dbclient(request, cmd, capture_output=True, text=True) | |
22 map2 = r.stdout.rstrip() | |
23 print(r.stderr, file=sys.stderr) | |
24 r.check_returncode() | |
25 | |
26 print(map1) | |
27 print(map2) | |
28 # expect something like | |
29 # "563174d59000-563174d5d000 r--p 00000000 00:29 4242372 /home/matt/src/dropbear/build/dropbear" | |
1865
d940f8007a45
Fix testing with dropbearmulti
Matt Johnston <matt@ucc.asn.au>
parents:
1863
diff
changeset
|
30 assert map1.endswith('/dropbear') or map1.endswith('/dropbearmulti') |
1861 | 31 assert ' r--p ' in map1 |
32 a1 = map1.split()[0] | |
33 a2 = map2.split()[0] | |
34 print(a1) | |
35 print(a2) | |
36 # relocation addresses should differ | |
37 assert a1 != a2 | |
38 |