File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed
Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -3,17 +3,12 @@ const PAM_PREFIX_LENGTH: usize = PAM_PREFIX.len();
33const AUTH_FAILURE_MESSAGE : & str = "authentication failure" ;
44
55pub fn is_auth_failed_message ( message : & str ) -> bool {
6- let prefix_position = find_pam_prefix_end ( message) ;
7- if prefix_position. is_none ( ) {
8- return false ;
9- }
10- let ( _, after_prefix_part) = message. split_at ( prefix_position. unwrap ( ) ) ;
11- return after_prefix_part. contains ( AUTH_FAILURE_MESSAGE ) ;
12- }
13-
14- fn find_pam_prefix_end ( message : & str ) -> Option < usize > {
15- let position = message. find ( PAM_PREFIX ) ?;
16- return Some ( position + PAM_PREFIX_LENGTH ) ;
6+ return match message. find ( PAM_PREFIX ) {
7+ None => false ,
8+ Some ( pam_prefix_position) => {
9+ message[ pam_prefix_position + PAM_PREFIX_LENGTH ..] . contains ( AUTH_FAILURE_MESSAGE )
10+ }
11+ } ;
1712}
1813
1914#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments