@@ -924,7 +924,7 @@ static void send_request_to_daemon(
924
924
service_name );
925
925
if (command_size < 0 ) {
926
926
PERROR ("failed to construct request" );
927
- daemon__exit (126 );
927
+ daemon__exit (QREXEC_EXIT_PROBLEM );
928
928
}
929
929
930
930
for (int i = 0 ; i < command_size ; i += bytes_sent ) {
@@ -934,7 +934,7 @@ static void send_request_to_daemon(
934
934
if (bytes_sent < 0 ) {
935
935
assert (bytes_sent == -1 );
936
936
PERROR ("send to socket failed" );
937
- daemon__exit (126 );
937
+ daemon__exit (QREXEC_EXIT_PROBLEM );
938
938
}
939
939
}
940
940
free (command );
@@ -945,7 +945,7 @@ static _Noreturn void null_exit(void)
945
945
#ifdef COVERAGE
946
946
__gcov_dump ();
947
947
#endif
948
- _exit (126 );
948
+ _exit (QREXEC_EXIT_PROBLEM );
949
949
}
950
950
951
951
/*
@@ -970,7 +970,7 @@ static enum policy_response connect_daemon_socket(
970
970
int daemon_socket = socket (AF_UNIX , SOCK_STREAM , 0 );
971
971
if (daemon_socket < 0 ) {
972
972
PERROR ("socket creation failed" );
973
- daemon__exit (126 );
973
+ daemon__exit (QREXEC_EXIT_PROBLEM );
974
974
}
975
975
976
976
int connect_result = connect (daemon_socket ,
@@ -1001,21 +1001,21 @@ static enum policy_response connect_daemon_socket(
1001
1001
int fds [2 ];
1002
1002
if (socketpair (AF_UNIX , SOCK_STREAM | SOCK_CLOEXEC , 0 , fds )) {
1003
1003
PERROR ("socketpair()" );
1004
- daemon__exit (126 );
1004
+ daemon__exit (QREXEC_EXIT_PROBLEM );
1005
1005
}
1006
1006
daemon_socket = fds [0 ];
1007
1007
1008
1008
pid = fork ();
1009
1009
switch (pid ) {
1010
1010
case -1 :
1011
1011
LOG (ERROR , "Could not fork!" );
1012
- daemon__exit (126 );
1012
+ daemon__exit (QREXEC_EXIT_PROBLEM );
1013
1013
case 0 :
1014
1014
if (close (fds [0 ]))
1015
- _exit ( 126 );
1015
+ daemon__exit ( QREXEC_EXIT_PROBLEM );
1016
1016
if (dup2 (fds [1 ], 0 ) != 0 || dup2 (fds [1 ], 1 ) != 1 ) {
1017
1017
PERROR ("dup2()" );
1018
- daemon__exit (126 );
1018
+ daemon__exit (QREXEC_EXIT_PROBLEM );
1019
1019
}
1020
1020
if (close (fds [1 ]))
1021
1021
abort ();
@@ -1034,7 +1034,7 @@ static enum policy_response connect_daemon_socket(
1034
1034
} else {
1035
1035
PERROR ("snprintf" );
1036
1036
}
1037
- daemon__exit (126 );
1037
+ daemon__exit (QREXEC_EXIT_PROBLEM );
1038
1038
default :
1039
1039
if (close (fds [1 ]))
1040
1040
abort ();
@@ -1045,12 +1045,12 @@ static enum policy_response connect_daemon_socket(
1045
1045
do {
1046
1046
if (waitpid (pid , & status , 0 ) != pid ) {
1047
1047
PERROR ("waitpid" );
1048
- daemon__exit (126 );
1048
+ daemon__exit (QREXEC_EXIT_PROBLEM );
1049
1049
}
1050
1050
} while (!WIFEXITED (status ));
1051
1051
if (WEXITSTATUS (status ) != 0 ) {
1052
1052
LOG (ERROR , "qrexec-policy-exec failed" );
1053
- daemon__exit (126 );
1053
+ daemon__exit (QREXEC_EXIT_PROBLEM );
1054
1054
}
1055
1055
// This leaks 'result', but as the code execs later anyway this isn't a problem.
1056
1056
// 'result' cannot be freed as 'user', 'target', and 'requested_target' point into
@@ -1077,7 +1077,7 @@ static _Noreturn void do_exec(const char *prog, const char *username __attribute
1077
1077
/* if above haven't executed qubes-rpc-multiplexer, pass it to shell */
1078
1078
execl ("/bin/bash" , "bash" , "-c" , prog , NULL );
1079
1079
PERROR ("exec bash" );
1080
- _exit (126 );
1080
+ _exit (QREXEC_EXIT_PROBLEM );
1081
1081
}
1082
1082
1083
1083
_Noreturn static void handle_execute_service_child (
@@ -1098,7 +1098,7 @@ _Noreturn static void handle_execute_service_child(
1098
1098
& user , & target , & requested_target , & autostart );
1099
1099
1100
1100
if (policy_response != RESPONSE_ALLOW )
1101
- daemon__exit (126 );
1101
+ daemon__exit (QREXEC_EXIT_REQUEST_REFUSED );
1102
1102
1103
1103
/* Replace the target domain with the version normalized by the policy engine */
1104
1104
target_domain = requested_target ;
@@ -1130,7 +1130,7 @@ _Noreturn static void handle_execute_service_child(
1130
1130
remote_domain_name ,
1131
1131
type ,
1132
1132
target_domain ) <= 0 )
1133
- daemon__exit (126 );
1133
+ daemon__exit (QREXEC_EXIT_PROBLEM );
1134
1134
register_exec_func (& do_exec );
1135
1135
daemon__exit (run_qrexec_to_dom0 (request_id ,
1136
1136
remote_domain_id ,
@@ -1144,7 +1144,7 @@ _Noreturn static void handle_execute_service_child(
1144
1144
disposable = true;
1145
1145
buf = qubesd_call (target + 8 , "admin.vm.CreateDisposable" , "" , & resp_len );
1146
1146
if (!buf ) // error already printed by qubesd_call
1147
- daemon__exit (126 );
1147
+ daemon__exit (QREXEC_EXIT_PROBLEM );
1148
1148
if (memcmp (buf , "0" , 2 ) == 0 ) {
1149
1149
/* we exec later so memory leaks do not matter */
1150
1150
target = buf + 2 ;
@@ -1154,42 +1154,42 @@ _Noreturn static void handle_execute_service_child(
1154
1154
} else {
1155
1155
LOG (ERROR , "invalid response to admin.vm.CreateDisposable" );
1156
1156
}
1157
- daemon__exit (126 );
1157
+ daemon__exit (QREXEC_EXIT_PROBLEM );
1158
1158
}
1159
1159
}
1160
1160
if (asprintf (& cmd , "%s:QUBESRPC %s%s %s" ,
1161
1161
user ,
1162
1162
service_name ,
1163
1163
trailer ,
1164
1164
remote_domain_name ) <= 0 )
1165
- daemon__exit (126 );
1165
+ daemon__exit (QREXEC_EXIT_PROBLEM );
1166
1166
if (autostart ) {
1167
1167
buf = qubesd_call (target , "admin.vm.Start" , "" , & resp_len );
1168
1168
if (!buf ) // error already printed by qubesd_call
1169
- daemon__exit (126 );
1169
+ daemon__exit (QREXEC_EXIT_PROBLEM );
1170
1170
if (!((memcmp (buf , "0" , 2 ) == 0 ) ||
1171
1171
(resp_len >= 24 && memcmp (buf , "2\0QubesVMNotHaltedError" , 24 ) == 0 ))) {
1172
1172
if (memcmp (buf , "2" , 2 ) == 0 ) {
1173
1173
LOG (ERROR , "qubesd could not start VM %s: %s" , target , buf + 2 );
1174
1174
} else {
1175
1175
LOG (ERROR , "invalid response to admin.vm.Start" );
1176
1176
}
1177
- daemon__exit (126 );
1177
+ daemon__exit (QREXEC_EXIT_PROBLEM );
1178
1178
}
1179
1179
free (buf );
1180
1180
}
1181
1181
int s = connect_unix_socket (target );
1182
1182
int data_domain ;
1183
1183
int data_port ;
1184
- int rc = 126 ;
1184
+ int rc = QREXEC_EXIT_PROBLEM ;
1185
1185
if (!negotiate_connection_params (s ,
1186
1186
remote_domain_id ,
1187
1187
MSG_EXEC_CMDLINE ,
1188
1188
cmd ,
1189
1189
compute_service_length (cmd ),
1190
1190
& data_domain ,
1191
1191
& data_port ))
1192
- daemon__exit (126 );
1192
+ daemon__exit (QREXEC_EXIT_PROBLEM );
1193
1193
int wait_connection_end = -1 ;
1194
1194
if (disposable ) {
1195
1195
wait_connection_end = s ;
@@ -1237,7 +1237,7 @@ static void handle_execute_service(
1237
1237
exit (1 );
1238
1238
case 0 :
1239
1239
if (atexit (null_exit ))
1240
- _exit (126 );
1240
+ _exit (QREXEC_EXIT_PROBLEM );
1241
1241
handle_execute_service_child (remote_domain_id , remote_domain_name ,
1242
1242
target_domain , service_name , request_id );
1243
1243
abort ();
0 commit comments