@@ -60,12 +60,12 @@ pub fn deserialize_binary<R: Read>(
6060}
6161
6262/// Filter installation errors.
63- #[ derive( Debug , PartialEq , Eq , thiserror:: Error , displaydoc:: Display ) ]
63+ #[ derive( Debug , thiserror:: Error , displaydoc:: Display ) ]
6464pub enum InstallationError {
6565 /// Filter length exceeds the maximum size of {BPF_MAX_LEN:} instructions
6666 FilterTooLarge ,
6767 /// prctl` syscall failed with error code: {0}
68- Prctl ( i32 ) ,
68+ Prctl ( std :: io :: Error ) ,
6969}
7070
7171/// The maximum seccomp-BPF program length allowed by the linux kernel.
@@ -101,7 +101,7 @@ pub fn apply_filter(bpf_filter: BpfProgramRef) -> Result<(), InstallationError>
101101 {
102102 let rc = libc:: prctl ( libc:: PR_SET_NO_NEW_PRIVS , 1 , 0 , 0 , 0 ) ;
103103 if rc != 0 {
104- return Err ( InstallationError :: Prctl ( * libc :: __errno_location ( ) ) ) ;
104+ return Err ( InstallationError :: Prctl ( std :: io :: Error :: last_os_error ( ) ) ) ;
105105 }
106106 }
107107
@@ -118,7 +118,7 @@ pub fn apply_filter(bpf_filter: BpfProgramRef) -> Result<(), InstallationError>
118118 bpf_prog_ptr,
119119 ) ;
120120 if rc != 0 {
121- return Err ( InstallationError :: Prctl ( * libc :: __errno_location ( ) ) ) ;
121+ return Err ( InstallationError :: Prctl ( std :: io :: Error :: last_os_error ( ) ) ) ;
122122 }
123123 }
124124 }
@@ -191,10 +191,10 @@ mod tests {
191191 let filter: BpfProgram = vec ! [ 0 ; 5000 ] ;
192192
193193 // Apply seccomp filter.
194- assert_eq ! (
194+ assert ! ( matches !(
195195 apply_filter( & filter) . unwrap_err( ) ,
196196 InstallationError :: FilterTooLarge
197- ) ;
197+ ) ) ;
198198 } )
199199 . join ( )
200200 . unwrap ( ) ;
@@ -224,10 +224,10 @@ mod tests {
224224 let seccomp_level = unsafe { libc:: prctl ( libc:: PR_GET_SECCOMP ) } ;
225225 assert_eq ! ( seccomp_level, 0 ) ;
226226
227- assert_eq ! (
227+ assert ! ( matches !(
228228 apply_filter( & filter) . unwrap_err( ) ,
229- InstallationError :: Prctl ( 22 )
230- ) ;
229+ InstallationError :: Prctl ( _ )
230+ ) ) ;
231231
232232 // test that seccomp level remains 0 on failure.
233233 let seccomp_level = unsafe { libc:: prctl ( libc:: PR_GET_SECCOMP ) } ;
0 commit comments