@@ -85,6 +85,7 @@ static const char *fork_server_path = QREXEC_FORK_SERVER_SOCKET;
85
85
static void handle_server_exec_request_do (int type , int connect_domain , int connect_port ,
86
86
struct qrexec_parsed_command * cmd ,
87
87
char * cmdline );
88
+ static void terminate_connection (uint32_t domain , uint32_t port );
88
89
89
90
const bool qrexec_is_fork_server = false;
90
91
@@ -587,14 +588,16 @@ static void handle_server_exec_request_init(struct msg_header *hdr)
587
588
cmd = parse_qubes_rpc_command (buf , true);
588
589
if (cmd == NULL ) {
589
590
LOG (ERROR , "Could not parse command line: %s" , buf );
590
- return ;
591
+ goto doit ;
591
592
}
592
593
593
594
/* load service config only for service requests */
594
595
if (cmd -> service_descriptor ) {
595
596
if (load_service_config_v2 (cmd ) < 0 ) {
596
597
LOG (ERROR , "Could not load config for command %s" , buf );
597
- return ;
598
+ destroy_qrexec_parsed_command (cmd );
599
+ cmd = NULL ;
600
+ goto doit ;
598
601
}
599
602
600
603
/* "nogui:" prefix has priority */
@@ -620,6 +623,7 @@ static void handle_server_exec_request_init(struct msg_header *hdr)
620
623
}
621
624
}
622
625
626
+ doit :
623
627
handle_server_exec_request_do (hdr -> type , params .connect_domain , params .connect_port , cmd , buf );
624
628
destroy_qrexec_parsed_command (cmd );
625
629
free (buf );
@@ -663,7 +667,7 @@ static void handle_server_exec_request_do(int type,
663
667
return ;
664
668
}
665
669
666
- if (!cmd -> nogui ) {
670
+ if (cmd != NULL && !cmd -> nogui ) {
667
671
/* try fork server */
668
672
int child_socket = try_fork_server (type ,
669
673
params .connect_domain , params .connect_port ,
@@ -757,20 +761,29 @@ static int find_connection(int pid)
757
761
}
758
762
759
763
static void release_connection (int id ) {
760
- struct msg_header hdr ;
761
- struct exec_params params ;
762
-
763
- hdr .type = MSG_CONNECTION_TERMINATED ;
764
- hdr .len = sizeof (struct exec_params );
765
- params .connect_domain = connection_info [id ].connect_domain ;
766
- params .connect_port = connection_info [id ].connect_port ;
767
- if (libvchan_send (ctrl_vchan , & hdr , sizeof (hdr )) != sizeof (hdr ))
768
- handle_vchan_error ("send (MSG_CONNECTION_TERMINATED hdr)" );
769
- if (libvchan_send (ctrl_vchan , & params , sizeof (params )) != sizeof (params ))
770
- handle_vchan_error ("send (MSG_CONNECTION_TERMINATED data)" );
764
+ terminate_connection (connection_info [id ].connect_domain ,
765
+ connection_info [id ].connect_port );
771
766
connection_info [id ].pid = 0 ;
772
767
}
773
768
769
+ static void terminate_connection (uint32_t domain , uint32_t port ) {
770
+ struct {
771
+ struct msg_header hdr ;
772
+ struct exec_params params ;
773
+ } data = {
774
+ .hdr = {
775
+ .type = MSG_CONNECTION_TERMINATED ,
776
+ .len = sizeof (struct exec_params ),
777
+ },
778
+ .params = {
779
+ .connect_domain = domain ,
780
+ .connect_port = port ,
781
+ },
782
+ };
783
+ if (libvchan_send (ctrl_vchan , & data , sizeof (data )) != sizeof (data ))
784
+ handle_vchan_error ("send (MSG_CONNECTION_TERMINATED)" );
785
+ }
786
+
774
787
static void reap_children (void )
775
788
{
776
789
int status ;
0 commit comments