@@ -782,19 +782,56 @@ def test_run_dom0_command_and_connect_vm(self):
782
782
self .client .wait ()
783
783
self .assertEqual (self .client .returncode , 0 )
784
784
785
- def test_run_dom0_service_exec (self ):
785
+ def exec_service_with_invalid_config (self , invalid_config ):
786
+ config_path = os .path .join (self .tempdir , "rpc-config" , "qubes.Service+arg" )
787
+ if invalid_config is not None :
788
+ with open (config_path , "w" ) as f :
789
+ f .write (invalid_config )
790
+ else :
791
+ os .symlink ("/dev/null/doesnotexist" , config_path )
786
792
util .make_executable_service (
787
793
self .tempdir ,
788
794
"rpc" ,
789
795
"qubes.Service" ,
790
796
"""\
791
- #!/bin/sh
792
- read input
793
- echo "arg: $1, remote domain: $QREXEC_REMOTE_DOMAIN, input: $input"
794
- """ ,
797
+ #!/bin/sh
798
+ read input
799
+ echo "arg: $1, remote domain: $QREXEC_REMOTE_DOMAIN, input: $input"
800
+ """ ,
795
801
)
802
+ self .test_run_dom0_service_failed ()
796
803
797
- cmd = "QUBESRPC qubes.Service+arg src_domain name src_domain"
804
+ def test_exec_service_with_invalid_config_1 (self ):
805
+ self .exec_service_with_invalid_config ("wait-for-session = 00\n " )
806
+
807
+ def test_exec_service_with_invalid_config_2 (self ):
808
+ self .exec_service_with_invalid_config ("wait-for-session = 01\n " )
809
+
810
+ def test_exec_service_with_invalid_config_3 (self ):
811
+ self .exec_service_with_invalid_config ("wait-for-session = \n " )
812
+
813
+ def test_exec_service_with_invalid_config_4 (self ):
814
+ self .exec_service_with_invalid_config ("wait-for-session = \" a\" \n " )
815
+
816
+ def test_exec_service_with_invalid_config_5 (self ):
817
+ self .exec_service_with_invalid_config ("wait-for-session\n " )
818
+
819
+ def test_exec_service_with_invalid_config_6 (self ):
820
+ self .exec_service_with_invalid_config (None )
821
+
822
+ def _test_run_dom0_service_exec (self , nogui ):
823
+ util .make_executable_service (
824
+ self .tempdir ,
825
+ "rpc" ,
826
+ "qubes.Service" ,
827
+ """\
828
+ #!/bin/sh
829
+ read input
830
+ echo "arg: $1, remote domain: $QREXEC_REMOTE_DOMAIN, input: $input"
831
+ """ ,
832
+ )
833
+
834
+ cmd = ("nogui:" if nogui else "" ) + "QUBESRPC qubes.Service+arg src_domain name src_domain"
798
835
source = self .connect_service_request (cmd )
799
836
800
837
source .send_message (qrexec .MSG_DATA_STDIN , b"stdin data\n " )
@@ -814,6 +851,12 @@ def test_run_dom0_service_exec(self):
814
851
self .client .wait ()
815
852
self .assertEqual (self .client .returncode , 0 )
816
853
854
+ def test_run_dom0_service_exec (self ):
855
+ self ._test_run_dom0_service_exec (False )
856
+
857
+ def test_run_dom0_service_exec_nogui (self ):
858
+ self ._test_run_dom0_service_exec (True )
859
+
817
860
def test_run_dom0_service_failed (self ):
818
861
# qubes.Service does not exist
819
862
cmd = "QUBESRPC qubes.Service+arg src_domain name src_domain"
0 commit comments