File tree Expand file tree Collapse file tree 4 files changed +49
-6
lines changed
sudo-compliance-tests/src/sudo Expand file tree Collapse file tree 4 files changed +49
-6
lines changed Original file line number Diff line number Diff line change 42
42
43
43
- name : Run all E2E tests
44
44
working-directory : test-framework
45
- run : cargo test -p e2e-tests
45
+ run : cargo test -p e2e-tests --features apparmor
46
46
47
47
- name : prevent the cache from growing too large
48
48
run : |
Original file line number Diff line number Diff line change @@ -6,3 +6,6 @@ version = "0.0.0"
6
6
7
7
[dependencies ]
8
8
sudo-test.path = " ../sudo-test"
9
+
10
+ [features ]
11
+ apparmor = [" sudo-test/apparmor" ]
Original file line number Diff line number Diff line change @@ -13,3 +13,48 @@ fn sanity_check() {
13
13
"you must set `SUDO_UNDER_TEST=ours` when running this test suite"
14
14
) ;
15
15
}
16
+
17
+ #[ test]
18
+ #[ cfg( feature = "apparmor" ) ]
19
+ fn dlopen_apparmor_ignores_ld_library_path ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
20
+ use sudo_test:: { Command , Env } ;
21
+
22
+ let env = Env ( "foo ALL=(ALL:ALL) APPARMOR_PROFILE=docker-default NOPASSWD: ALL" )
23
+ . file (
24
+ "/tmp/crash_me.c" ,
25
+ "#include <stdlib.h>
26
+
27
+ void __attribute__((constructor)) do_not_load() {
28
+ abort();
29
+ }
30
+ " ,
31
+ )
32
+ . user ( "foo" )
33
+ . apparmor ( "unconfined" )
34
+ . build ( ) ;
35
+
36
+ Command :: new ( "gcc" )
37
+ . args ( [ "/tmp/crash_me.c" , "-shared" , "-o" , "/tmp/libapparmor.so.1" ] )
38
+ . output ( & env)
39
+ . assert_success ( ) ;
40
+
41
+ let output = Command :: new ( "sh" )
42
+ . args ( [
43
+ "-c" ,
44
+ "LD_LIBRARY_PATH=/tmp sudo -s cat /proc/\\ $\\ $/attr/current" ,
45
+ ] )
46
+ . as_user ( "foo" )
47
+ . output ( & env) ;
48
+
49
+ output. assert_success ( ) ;
50
+ assert_eq ! ( output. stdout( ) , "docker-default (enforce)" ) ;
51
+
52
+ let output = Command :: new ( "sh" )
53
+ . args ( [ "-c" , "LD_PRELOAD=/tmp/libapparmor.so.1 ls" ] )
54
+ . output ( & env) ;
55
+
56
+ output. assert_exit_code ( 134 ) ; // SIGABRT
57
+ assert_eq ! ( output. stderr( ) , "Aborted (core dumped)" ) ;
58
+
59
+ Ok ( ( ) )
60
+ }
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ fn can_switch_the_apparmor_profile() -> Result<()> {
11
11
let output = Command :: new ( "sudo" )
12
12
. args ( [ "-s" , "cat" , "/proc/$$/attr/current" ] )
13
13
. output ( & env) ;
14
- dbg ! ( & output) ;
15
14
16
15
output. assert_success ( ) ;
17
16
assert_eq ! ( output. stdout( ) , "docker-default (enforce)" ) ;
@@ -25,8 +24,6 @@ fn cannot_switch_to_nonexisting_profile() -> Result<()> {
25
24
26
25
let output = Command :: new ( "sudo" ) . arg ( "true" ) . output ( & env) ;
27
26
28
- dbg ! ( & output) ;
29
-
30
27
output. assert_exit_code ( 1 ) ;
31
28
assert_contains ! ( output. stderr( ) , "unable to change AppArmor profile" ) ;
32
29
@@ -44,7 +41,6 @@ Defaults apparmor_profile=docker-default
44
41
let output = Command :: new ( "sudo" )
45
42
. args ( [ "-s" , "cat" , "/proc/$$/attr/current" ] )
46
43
. output ( & env) ;
47
- dbg ! ( & output) ;
48
44
49
45
output. assert_success ( ) ;
50
46
assert_eq ! ( output. stdout( ) , "docker-default (enforce)" ) ;
@@ -63,7 +59,6 @@ Defaults apparmor_profile=docker-default
63
59
let output = Command :: new ( "sudo" )
64
60
. args ( [ "-s" , "cat" , "/proc/$$/attr/current" ] )
65
61
. output ( & env) ;
66
- dbg ! ( & output) ;
67
62
68
63
output. assert_success ( ) ;
69
64
assert_eq ! ( output. stdout( ) , "unconfined" ) ;
You can’t perform that action at this time.
0 commit comments