|
29 | 29 | #include <sys/socket.h>
|
30 | 30 | #include <netinet/in.h>
|
31 | 31 | #include <arpa/inet.h>
|
32 |
| -#include <err.h> |
33 | 32 |
|
34 | 33 | /* For X509_NAME_add_entry_by_txt */
|
35 | 34 | #pragma GCC diagnostic ignored "-Wpointer-sign"
|
@@ -69,6 +68,17 @@ static const char *cipher_list;
|
69 | 68 | /* How much K to transfer between client and server. */
|
70 | 69 | #define KTRANSFER (1 * 1024)
|
71 | 70 |
|
| 71 | +static void err(int eval, const char *fmt, ...) |
| 72 | +{ |
| 73 | + va_list ap; |
| 74 | + |
| 75 | + va_start(ap, fmt); |
| 76 | + vprintf(fmt, ap); |
| 77 | + va_end(ap); |
| 78 | + printf(": %s\n", strerror(errno)); |
| 79 | + exit(eval); |
| 80 | +} |
| 81 | + |
72 | 82 | /*
|
73 | 83 | * Simple TLS Server code is based on
|
74 | 84 | * https://wiki.openssl.org/index.php/Simple_TLS_Server
|
@@ -274,7 +284,7 @@ int test(const char *algname, const char *paramset)
|
274 | 284 | ck = certgen(algname, paramset);
|
275 | 285 |
|
276 | 286 | int sockfd[2];
|
277 |
| - if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sockfd) == -1) |
| 287 | + if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockfd) == -1) |
278 | 288 | err(1, "socketpair");
|
279 | 289 |
|
280 | 290 | setpgid(0, 0);
|
@@ -307,22 +317,22 @@ int test(const char *algname, const char *paramset)
|
307 | 317 | ret = (WIFEXITED(status) && WEXITSTATUS(status)) ||
|
308 | 318 | (WIFSIGNALED(status) && WTERMSIG(status));
|
309 | 319 | if (ret) {
|
310 |
| - warnx(cRED "%s child %s with %d %s" cNORM, |
| 320 | + fprintf(stderr, cRED "%s child %s with %d %s" cNORM, |
311 | 321 | exited_pid == server_pid? "server" : "client",
|
312 | 322 | WIFSIGNALED(status)? "killed" : "exited",
|
313 | 323 | WIFSIGNALED(status)? WTERMSIG(status) : WEXITSTATUS(status),
|
314 | 324 | WIFSIGNALED(status)? strsignal(WTERMSIG(status)) : "");
|
315 | 325 |
|
316 | 326 | /* If first child exited with error, kill other. */
|
317 |
| - warnx("terminating %s by force", |
| 327 | + fprintf(stderr, "terminating %s by force", |
318 | 328 | exited_pid == server_pid? "client" : "server");
|
319 | 329 | kill(exited_pid == server_pid? client_pid : server_pid, SIGTERM);
|
320 | 330 | }
|
321 | 331 |
|
322 | 332 | exited_pid = wait(&status);
|
323 | 333 | /* Report error unless we killed it. */
|
324 | 334 | if (!ret && (!WIFEXITED(status) || WEXITSTATUS(status)))
|
325 |
| - warnx(cRED "%s child %s with %d %s" cNORM, |
| 335 | + fprintf(stderr, cRED "%s child %s with %d %s" cNORM, |
326 | 336 | exited_pid == server_pid? "server" : "client",
|
327 | 337 | WIFSIGNALED(status)? "killed" : "exited",
|
328 | 338 | WIFSIGNALED(status)? WTERMSIG(status) : WEXITSTATUS(status),
|
|
0 commit comments