@@ -3328,6 +3328,51 @@ def privleapd_invalid_ascii_test(idx_str: str) -> bool:
33283328 return False
33293329
33303330
3331+ def privleapd_control_msg_mismatch_test (bogus : str ) -> bool :
3332+ """
3333+ Test how privleapd handles receiving a comm message on the control socket.
3334+ """
3335+
3336+ if bogus != "" :
3337+ return False
3338+ discard_privleapd_stderr ()
3339+ control_session : PrivleapSession = PrivleapSession (is_control_session = True )
3340+ assert control_session .backend_socket is not None
3341+ # pylint: disable=protected-access
3342+ # Same rationale as for leaprun_server_invalid_msg_seq_test
3343+ control_session ._PrivleapSession__send_msg ( # type: ignore [attr-defined]
3344+ PrivleapCommClientSignalMsg ("test-act-free" )
3345+ )
3346+ control_session .close_session ()
3347+ if not compare_privleapd_stderr (
3348+ PlTestData .privleapd_control_msg_mismatch_lines
3349+ ):
3350+ return False
3351+ return True
3352+
3353+
3354+ def privleapd_comm_msg_mismatch_test (bogus : str ) -> bool :
3355+ """
3356+ Test how privleapd handles receiving a control message on the comm socket.
3357+ """
3358+
3359+ if bogus != "" :
3360+ return False
3361+ comm_session : PrivleapSession = PrivleapSession ("privleaptestone" )
3362+ assert comm_session .backend_socket is not None
3363+ # pylint: disable=protected-access
3364+ # Same rationale as for privleapd_control_msg_mismatch_test
3365+ comm_session ._PrivleapSession__send_msg ( # type: ignore [attr-defined]
3366+ PrivleapControlClientCreateMsg ("wha" )
3367+ )
3368+ comm_session .close_session ()
3369+ if not compare_privleapd_stderr (
3370+ PlTestData .privleapd_comm_msg_mismatch_lines
3371+ ):
3372+ return False
3373+ return True
3374+
3375+
33313376def privleapd_send_random_garbage_test (bogus : str ) -> bool :
33323377 """
33333378 Test how privleapd handles a comm client that sends pseudorandom data.
@@ -4123,6 +4168,18 @@ def run_privleapd_tests() -> None:
41234168 f"Test privleapd invalid ASCII handling (iteration { i + 1 } )" ,
41244169 )
41254170 # ---
4171+ privleapd_assert_function (
4172+ privleapd_control_msg_mismatch_test ,
4173+ "" ,
4174+ "Test privleapd control message mismatch handling" ,
4175+ )
4176+ # ---
4177+ privleapd_assert_function (
4178+ privleapd_comm_msg_mismatch_test ,
4179+ "" ,
4180+ "Test privleapd comm message mismatch handling" ,
4181+ )
4182+ # ---
41264183 privleapd_assert_command (["/usr/bin/privleapd" , "-C" ], exit_code = 0 )
41274184 # ---
41284185 privleapd_assert_command (
0 commit comments