@@ -60,12 +60,12 @@ pub fn deserialize_binary<R: Read>(
60
60
}
61
61
62
62
/// Filter installation errors.
63
- #[ derive( Debug , PartialEq , Eq , thiserror:: Error , displaydoc:: Display ) ]
63
+ #[ derive( Debug , thiserror:: Error , displaydoc:: Display ) ]
64
64
pub enum InstallationError {
65
65
/// Filter length exceeds the maximum size of {BPF_MAX_LEN:} instructions
66
66
FilterTooLarge ,
67
67
/// prctl` syscall failed with error code: {0}
68
- Prctl ( i32 ) ,
68
+ Prctl ( std :: io :: Error ) ,
69
69
}
70
70
71
71
/// The maximum seccomp-BPF program length allowed by the linux kernel.
@@ -101,7 +101,7 @@ pub fn apply_filter(bpf_filter: BpfProgramRef) -> Result<(), InstallationError>
101
101
{
102
102
let rc = libc:: prctl ( libc:: PR_SET_NO_NEW_PRIVS , 1 , 0 , 0 , 0 ) ;
103
103
if rc != 0 {
104
- return Err ( InstallationError :: Prctl ( * libc :: __errno_location ( ) ) ) ;
104
+ return Err ( InstallationError :: Prctl ( std :: io :: Error :: last_os_error ( ) ) ) ;
105
105
}
106
106
}
107
107
@@ -118,7 +118,7 @@ pub fn apply_filter(bpf_filter: BpfProgramRef) -> Result<(), InstallationError>
118
118
bpf_prog_ptr,
119
119
) ;
120
120
if rc != 0 {
121
- return Err ( InstallationError :: Prctl ( * libc :: __errno_location ( ) ) ) ;
121
+ return Err ( InstallationError :: Prctl ( std :: io :: Error :: last_os_error ( ) ) ) ;
122
122
}
123
123
}
124
124
}
@@ -191,10 +191,10 @@ mod tests {
191
191
let filter: BpfProgram = vec ! [ 0 ; 5000 ] ;
192
192
193
193
// Apply seccomp filter.
194
- assert_eq ! (
194
+ assert ! ( matches !(
195
195
apply_filter( & filter) . unwrap_err( ) ,
196
196
InstallationError :: FilterTooLarge
197
- ) ;
197
+ ) ) ;
198
198
} )
199
199
. join ( )
200
200
. unwrap ( ) ;
@@ -224,10 +224,10 @@ mod tests {
224
224
let seccomp_level = unsafe { libc:: prctl ( libc:: PR_GET_SECCOMP ) } ;
225
225
assert_eq ! ( seccomp_level, 0 ) ;
226
226
227
- assert_eq ! (
227
+ assert ! ( matches !(
228
228
apply_filter( & filter) . unwrap_err( ) ,
229
- InstallationError :: Prctl ( 22 )
230
- ) ;
229
+ InstallationError :: Prctl ( _ )
230
+ ) ) ;
231
231
232
232
// test that seccomp level remains 0 on failure.
233
233
let seccomp_level = unsafe { libc:: prctl ( libc:: PR_GET_SECCOMP ) } ;
0 commit comments