Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 1 | /** |
| 2 | * \file test_server_thread.c |
| 3 | * \author Michal Vasko <mvasko@cesnet.cz> |
| 4 | * \brief libnetconf2 tests - thread-safety of all server functions |
| 5 | * |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 6 | * Copyright (c) 2017 CESNET, z.s.p.o. |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 7 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 8 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 9 | * You may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
Michal Vasko | ad1cc6a | 2016-02-26 15:06:06 +0100 | [diff] [blame] | 11 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 12 | * https://opensource.org/licenses/BSD-3-Clause |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #include <pthread.h> |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 16 | #include <stdio.h> |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 17 | #include <stdlib.h> |
Michal Vasko | a28be9a | 2016-03-01 15:20:47 +0100 | [diff] [blame] | 18 | #include <string.h> |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 19 | #include <sys/types.h> |
| 20 | #include <sys/wait.h> |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 21 | #include <unistd.h> |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 22 | |
| 23 | #include <libyang/libyang.h> |
| 24 | |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 25 | #include <log.h> |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 26 | #include <session_client.h> |
| 27 | #include <session_server.h> |
Jan Kundrát | cf15d6c | 2017-10-26 18:07:56 +0200 | [diff] [blame] | 28 | #include "tests/config.h" |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 29 | |
| 30 | /* millisec */ |
Michal Vasko | 15592cc | 2016-02-09 09:52:43 +0100 | [diff] [blame] | 31 | #define NC_ACCEPT_TIMEOUT 5000 |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 32 | /* millisec */ |
Michal Vasko | 15592cc | 2016-02-09 09:52:43 +0100 | [diff] [blame] | 33 | #define NC_PS_POLL_TIMEOUT 5000 |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 34 | /* sec */ |
Michal Vasko | 15592cc | 2016-02-09 09:52:43 +0100 | [diff] [blame] | 35 | #define CLIENT_SSH_AUTH_TIMEOUT 10 |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 36 | |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 37 | #define nc_assert(cond) if (!(cond)) { fprintf(stderr, "assert failed (%s:%d)\n", __FILE__, __LINE__); exit(1); } |
| 38 | |
Claus Klein | 2209191 | 2020-01-20 13:45:47 +0100 | [diff] [blame] | 39 | #if _POSIX_BARRIERS >= 200112L |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 40 | pthread_barrier_t barrier; |
| 41 | |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 42 | #if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS) |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 43 | |
Michal Vasko | 9322407 | 2021-11-09 12:14:28 +0100 | [diff] [blame] | 44 | struct ly_ctx *ctx; |
| 45 | |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 46 | static void * |
| 47 | server_thread(void *arg) |
| 48 | { |
| 49 | (void)arg; |
Michal Vasko | 71090fc | 2016-05-24 16:37:28 +0200 | [diff] [blame] | 50 | NC_MSG_TYPE msgtype; |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 51 | int ret; |
| 52 | struct nc_pollsession *ps; |
| 53 | struct nc_session *session; |
| 54 | |
| 55 | ps = nc_ps_new(); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 56 | nc_assert(ps); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 57 | |
| 58 | pthread_barrier_wait(&barrier); |
| 59 | |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 60 | #if defined (NC_ENABLED_SSH) && defined (NC_ENABLED_TLS) |
Michal Vasko | 9322407 | 2021-11-09 12:14:28 +0100 | [diff] [blame] | 61 | msgtype = nc_accept(NC_ACCEPT_TIMEOUT, ctx, &session); |
Michal Vasko | 71090fc | 2016-05-24 16:37:28 +0200 | [diff] [blame] | 62 | nc_assert(msgtype == NC_MSG_HELLO); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 63 | |
| 64 | nc_ps_add_session(ps, session); |
Michal Vasko | 71090fc | 2016-05-24 16:37:28 +0200 | [diff] [blame] | 65 | ret = nc_ps_poll(ps, NC_PS_POLL_TIMEOUT, NULL); |
| 66 | nc_assert(ret & NC_PSPOLL_RPC); |
Michal Vasko | 7893907 | 2022-12-12 07:43:18 +0100 | [diff] [blame] | 67 | ret = nc_ps_poll(ps, NC_PS_POLL_TIMEOUT, NULL); |
| 68 | nc_assert(ret & NC_PSPOLL_RPC); |
Michal Vasko | 81f9e05 | 2022-12-12 07:53:32 +0100 | [diff] [blame^] | 69 | nc_ps_clear(ps, 1, NULL); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 70 | #endif |
| 71 | |
Michal Vasko | 9322407 | 2021-11-09 12:14:28 +0100 | [diff] [blame] | 72 | msgtype = nc_accept(NC_ACCEPT_TIMEOUT, ctx, &session); |
Michal Vasko | 71090fc | 2016-05-24 16:37:28 +0200 | [diff] [blame] | 73 | nc_assert(msgtype == NC_MSG_HELLO); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 74 | |
| 75 | nc_ps_add_session(ps, session); |
Michal Vasko | 71090fc | 2016-05-24 16:37:28 +0200 | [diff] [blame] | 76 | ret = nc_ps_poll(ps, NC_PS_POLL_TIMEOUT, NULL); |
| 77 | nc_assert(ret & NC_PSPOLL_RPC); |
Michal Vasko | 7893907 | 2022-12-12 07:43:18 +0100 | [diff] [blame] | 78 | ret = nc_ps_poll(ps, NC_PS_POLL_TIMEOUT, NULL); |
| 79 | nc_assert(ret & NC_PSPOLL_RPC); |
Michal Vasko | 81f9e05 | 2022-12-12 07:53:32 +0100 | [diff] [blame^] | 80 | nc_ps_clear(ps, 1, NULL); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 81 | |
| 82 | nc_ps_free(ps); |
| 83 | |
| 84 | nc_thread_destroy(); |
| 85 | return NULL; |
| 86 | } |
| 87 | |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 88 | #endif /* NC_ENABLED_SSH || NC_ENABLED_TLS */ |
| 89 | |
| 90 | #ifdef NC_ENABLED_SSH |
| 91 | |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 92 | static int |
| 93 | clb_hostkeys(const char *name, void *UNUSED(user_data), char **privkey_path, char **UNUSED(privkey_data), |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 94 | NC_SSH_KEY_TYPE *UNUSED(privkey_type)) |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 95 | { |
| 96 | if (!strcmp(name, "key_rsa")) { |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 97 | *privkey_path = strdup(TESTS_DIR "/data/key_rsa"); |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 98 | return 0; |
Michal Vasko | 7a4213f | 2022-09-08 11:02:34 +0200 | [diff] [blame] | 99 | } else if (!strcmp(name, "key_ecdsa")) { |
| 100 | *privkey_path = strdup(TESTS_DIR "/data/key_ecdsa"); |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | return 1; |
| 105 | } |
| 106 | |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 107 | static void * |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 108 | add_endpt_thread(void *arg) |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 109 | { |
| 110 | (void)arg; |
| 111 | int ret; |
| 112 | |
| 113 | pthread_barrier_wait(&barrier); |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 114 | ret = nc_server_add_endpt("tertiary", NC_TI_LIBSSH); |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 115 | nc_assert(!ret); |
| 116 | |
| 117 | return NULL; |
| 118 | } |
| 119 | |
| 120 | static void * |
| 121 | del_endpt_thread(void *arg) |
| 122 | { |
| 123 | (void)arg; |
| 124 | int ret; |
| 125 | |
| 126 | pthread_barrier_wait(&barrier); |
| 127 | |
Michal Vasko | 5905037 | 2016-11-22 14:33:55 +0100 | [diff] [blame] | 128 | ret = nc_server_del_endpt("secondary", 0); |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 129 | nc_assert(!ret); |
| 130 | |
| 131 | return NULL; |
| 132 | } |
| 133 | |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 134 | static void * |
| 135 | ssh_endpt_set_hostkey_thread(void *arg) |
| 136 | { |
| 137 | (void)arg; |
| 138 | int ret; |
| 139 | |
| 140 | pthread_barrier_wait(&barrier); |
| 141 | |
Michal Vasko | 7a4213f | 2022-09-08 11:02:34 +0200 | [diff] [blame] | 142 | ret = nc_server_ssh_endpt_add_hostkey("main_ssh", "key_ecdsa", -1); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 143 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 144 | |
| 145 | return NULL; |
| 146 | } |
| 147 | |
| 148 | static void * |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 149 | ssh_endpt_set_auth_methods_thread(void *arg) |
| 150 | { |
| 151 | (void)arg; |
| 152 | int ret; |
| 153 | |
| 154 | pthread_barrier_wait(&barrier); |
| 155 | |
roman | 41a11e4 | 2022-06-22 09:27:08 +0200 | [diff] [blame] | 156 | ret = nc_server_ssh_endpt_set_auth_methods("main_ssh", NC_SSH_AUTH_PUBLICKEY | NC_SSH_AUTH_PASSWORD); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 157 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 158 | |
| 159 | return NULL; |
| 160 | } |
| 161 | |
| 162 | static void * |
| 163 | ssh_endpt_set_auth_attempts_thread(void *arg) |
| 164 | { |
| 165 | (void)arg; |
| 166 | int ret; |
| 167 | |
| 168 | pthread_barrier_wait(&barrier); |
| 169 | |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 170 | ret = nc_server_ssh_endpt_set_auth_attempts("main_ssh", 2); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 171 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 172 | |
| 173 | return NULL; |
| 174 | } |
| 175 | |
| 176 | static void * |
| 177 | ssh_endpt_set_auth_timeout_thread(void *arg) |
| 178 | { |
| 179 | (void)arg; |
| 180 | int ret; |
| 181 | |
| 182 | pthread_barrier_wait(&barrier); |
| 183 | |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 184 | ret = nc_server_ssh_endpt_set_auth_timeout("main_ssh", 5); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 185 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 186 | |
| 187 | return NULL; |
| 188 | } |
| 189 | |
| 190 | static void * |
| 191 | ssh_endpt_add_authkey_thread(void *arg) |
| 192 | { |
| 193 | (void)arg; |
| 194 | int ret; |
| 195 | |
| 196 | pthread_barrier_wait(&barrier); |
| 197 | |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 198 | ret = nc_server_ssh_add_authkey_path(TESTS_DIR "/data/key_rsa.pub", "test3"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 199 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 200 | |
| 201 | return NULL; |
| 202 | } |
| 203 | |
| 204 | static void * |
| 205 | ssh_endpt_del_authkey_thread(void *arg) |
| 206 | { |
| 207 | (void)arg; |
| 208 | int ret; |
| 209 | |
| 210 | pthread_barrier_wait(&barrier); |
| 211 | |
Michal Vasko | 7a4213f | 2022-09-08 11:02:34 +0200 | [diff] [blame] | 212 | ret = nc_server_ssh_del_authkey(TESTS_DIR "/data/key_ecdsa.pub", NULL, 0, "test2"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 213 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 214 | |
| 215 | return NULL; |
| 216 | } |
| 217 | |
Michal Vasko | 693eb11 | 2016-02-18 13:28:49 +0100 | [diff] [blame] | 218 | static int |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 219 | ssh_hostkey_check_clb(const char *hostname, ssh_session session, void *priv) |
Michal Vasko | 693eb11 | 2016-02-18 13:28:49 +0100 | [diff] [blame] | 220 | { |
| 221 | (void)hostname; |
| 222 | (void)session; |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 223 | (void)priv; |
Michal Vasko | 693eb11 | 2016-02-18 13:28:49 +0100 | [diff] [blame] | 224 | |
| 225 | return 0; |
| 226 | } |
| 227 | |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 228 | static void * |
| 229 | ssh_client_thread(void *arg) |
| 230 | { |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 231 | int ret, read_pipe = *(int *)arg; |
| 232 | char buf[9]; |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 233 | struct nc_session *session; |
| 234 | |
Michal Vasko | 5a44647 | 2020-05-06 12:43:42 +0200 | [diff] [blame] | 235 | fprintf(stdout, "SSH client start.\n"); |
| 236 | |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 237 | ret = read(read_pipe, buf, 9); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 238 | nc_assert(ret == 9); |
| 239 | nc_assert(!strncmp(buf, "ssh_ready", 9)); |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 240 | |
Michal Vasko | 693eb11 | 2016-02-18 13:28:49 +0100 | [diff] [blame] | 241 | /* skip the knownhost check */ |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 242 | nc_client_ssh_set_auth_hostkey_check_clb(ssh_hostkey_check_clb, NULL); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 243 | |
Michal Vasko | 693eb11 | 2016-02-18 13:28:49 +0100 | [diff] [blame] | 244 | ret = nc_client_ssh_set_username("test"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 245 | nc_assert(!ret); |
Michal Vasko | 693eb11 | 2016-02-18 13:28:49 +0100 | [diff] [blame] | 246 | |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 247 | ret = nc_client_ssh_add_keypair(TESTS_DIR "/data/key_ecdsa.pub", TESTS_DIR "/data/key_ecdsa"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 248 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 249 | |
| 250 | nc_client_ssh_set_auth_pref(NC_SSH_AUTH_PUBLICKEY, 1); |
| 251 | nc_client_ssh_set_auth_pref(NC_SSH_AUTH_PASSWORD, -1); |
| 252 | nc_client_ssh_set_auth_pref(NC_SSH_AUTH_INTERACTIVE, -1); |
| 253 | |
Michal Vasko | 693eb11 | 2016-02-18 13:28:49 +0100 | [diff] [blame] | 254 | session = nc_connect_ssh("127.0.0.1", 6001, NULL); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 255 | nc_assert(session); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 256 | |
Michal Vasko | e1a64ec | 2016-03-01 12:21:58 +0100 | [diff] [blame] | 257 | nc_session_free(session, NULL); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 258 | |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 259 | fprintf(stdout, "SSH client finished.\n"); |
| 260 | |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 261 | nc_thread_destroy(); |
| 262 | return NULL; |
| 263 | } |
| 264 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 265 | #endif /* NC_ENABLED_SSH */ |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 266 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 267 | #ifdef NC_ENABLED_TLS |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 268 | |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 269 | static int |
| 270 | clb_server_cert(const char *name, void *UNUSED(user_data), char **cert_path, char **cert_data, char **privkey_path, |
Michal Vasko | e49a15f | 2019-05-27 14:18:36 +0200 | [diff] [blame] | 271 | char **privkey_data, NC_SSH_KEY_TYPE *privkey_type) |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 272 | { |
| 273 | if (!strcmp(name, "server_cert1")) { |
Michal Vasko | 346ac56 | 2018-11-05 08:47:18 +0100 | [diff] [blame] | 274 | *cert_data = strdup("MIIEQDCCAygCCQCV65JgDvfWkTANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJD\n" |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 275 | "WjETMBEGA1UECAwKU29tZS1TdGF0ZTENMAsGA1UEBwwEQnJubzEPMA0GA1UECgwG\n" |
| 276 | "Q0VTTkVUMQwwCgYDVQQLDANUTUMxETAPBgNVBAMMCHNlcnZlcmNhMB4XDTE4MTEw\n" |
| 277 | "NTA3MzExMFoXDTI4MTEwMjA3MzExMFowYTELMAkGA1UEBhMCQ1oxEzARBgNVBAgM\n" |
| 278 | "ClNvbWUtU3RhdGUxDTALBgNVBAcMBEJybm8xDzANBgNVBAoMBkNFU05FVDEMMAoG\n" |
| 279 | "A1UECwwDVE1DMQ8wDQYDVQQDDAZzZXJ2ZXIwggIiMA0GCSqGSIb3DQEBAQUAA4IC\n" |
| 280 | "DwAwggIKAoICAQDqiO2N8Oa/JA/VmQjAGmv3t4oO55u+miCVEdF29W5Ol/+BTVUC\n" |
| 281 | "sBCbAaHTmLqWbxORWXWegyUjEskNxayVp5WforK+xfQeGxC1fCo+rCRrlQK/pqXB\n" |
| 282 | "/+K8C9w2lxfWPS3+4gYIjh1KIqfNALJ/QVOKvNCSOsNlR3eZ4OE1BOu4JqUZXiB8\n" |
| 283 | "1Yird7Wga7ACfW0uW72hOsTgfMymBs0RTrA2axKqnAbFSFguhJoztvR0uao/5lzN\n" |
| 284 | "JLRRpzQ8U2R6EZDYJghPzR/nzSjhca2gsJRQaSnpgJMvhnYJ4ERokAFaMMgMf50p\n" |
| 285 | "ghQGpSnPhOHXaBcA/6H7eojr716ml4et+vMBEOx8uPBQ3FAmx7VBICuMDK1/QUq0\n" |
| 286 | "Yes5FztbROIIW9HTNqhQ0tMqTt6dOJFD2t9Zk4C7jh9S88JpcMTrNdd5pWCgoKjh\n" |
| 287 | "UeWGjfp6tRyOUQEz6OTbwjKRtka0FvqKAq9hrW09KB5ib/MmgVWNByevXi5yL9+3\n" |
| 288 | "X41r6E4gSgQSIrFwA+TZva8Eo2VEhbtYsne7tmK5AQlM2br7dwTj6V/BoEIGoFOg\n" |
| 289 | "T52nO+hRegzIUVF5QV3U7lrG7h9eC3TSMxo5DGYTS/06ZH+kv89Yh+VUXhnPnJU4\n" |
| 290 | "1hoNVzuX695jSgRmu4Q8nSGUSDG4LMutwyGO5+XaoTZDt9Ahpq//U2oFWQIDAQAB\n" |
| 291 | "MA0GCSqGSIb3DQEBCwUAA4IBAQAXWHf/MG8RPCyA0rC3RwxmM70ndyKPIJoL4ggU\n" |
| 292 | "VgkN66BdpsE4UlWdlp0XL3aauMPxzLn9rq1yRtoHWT4/ucL9iEa6B295JBNjkgW+\n" |
| 293 | "ct9/y8060P9BUhY1DTv5DLzitsA4bjRaraIevjATDPfsbHFx9DTNrS5pXHIFbRcz\n" |
| 294 | "y3WniYXTKhpfM6m+1X8ogImE968DG8RqAW5YZZtrZW0VF/dhlQp20jEX/8Rv33Bp\n" |
| 295 | "RhNEIhPnYAquKCesMMclUtPW+5n2z8rgj5t/ETv4wc5QegpyPfdHNq09bGKB10Sy\n" |
| 296 | "sGvC6hP9GKU3R2Jhxih/t88O3WoisFQ8+Tf9s2LuSxUV0bzp"); |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 297 | *privkey_data = strdup("MIIJKAIBAAKCAgEA6ojtjfDmvyQP1ZkIwBpr97eKDuebvpoglRHRdvVuTpf/gU1V\n" |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 298 | "ArAQmwGh05i6lm8TkVl1noMlIxLJDcWslaeVn6KyvsX0HhsQtXwqPqwka5UCv6al\n" |
| 299 | "wf/ivAvcNpcX1j0t/uIGCI4dSiKnzQCyf0FTirzQkjrDZUd3meDhNQTruCalGV4g\n" |
| 300 | "fNWIq3e1oGuwAn1tLlu9oTrE4HzMpgbNEU6wNmsSqpwGxUhYLoSaM7b0dLmqP+Zc\n" |
| 301 | "zSS0Uac0PFNkehGQ2CYIT80f580o4XGtoLCUUGkp6YCTL4Z2CeBEaJABWjDIDH+d\n" |
| 302 | "KYIUBqUpz4Th12gXAP+h+3qI6+9eppeHrfrzARDsfLjwUNxQJse1QSArjAytf0FK\n" |
| 303 | "tGHrORc7W0TiCFvR0zaoUNLTKk7enTiRQ9rfWZOAu44fUvPCaXDE6zXXeaVgoKCo\n" |
| 304 | "4VHlho36erUcjlEBM+jk28IykbZGtBb6igKvYa1tPSgeYm/zJoFVjQcnr14uci/f\n" |
| 305 | "t1+Na+hOIEoEEiKxcAPk2b2vBKNlRIW7WLJ3u7ZiuQEJTNm6+3cE4+lfwaBCBqBT\n" |
| 306 | "oE+dpzvoUXoMyFFReUFd1O5axu4fXgt00jMaOQxmE0v9OmR/pL/PWIflVF4Zz5yV\n" |
| 307 | "ONYaDVc7l+veY0oEZruEPJ0hlEgxuCzLrcMhjufl2qE2Q7fQIaav/1NqBVkCAwEA\n" |
| 308 | "AQKCAgAeRZw75Oszoqj0jfMmMILdD3Cfad+dY3FvLESYESeyt0XAX8XoOed6ymQj\n" |
| 309 | "1qPGxQGGkkBvPEgv1b3jrC8Rhfb3Ct39Z7mRpTar5iHhwwBUboBTUmQ0vR173iAH\n" |
| 310 | "X8sw2Oa17mCO/CDlr8Fu4Xcom7r3vlVBepo72VSjpPYMjN0MANjwhEi3NCyWzTXB\n" |
| 311 | "RgUK3TuZbzfzto0w2Irlpx0S7dAqxfk70jXBgwv2vSDWKfg1lL1X0BkMVX98xpMk\n" |
| 312 | "cjMW2muSqp4KBtTma4GqT6z0f7Y1Bs3lGLZmvPlBXxQVVvkFtiQsENCtSd/h17Gk\n" |
| 313 | "2mb4EbReaaBzwCYqJdRWtlpJ54kzy8U00co+Yn//ZS7sbbIDkqHPnXkpdIr+0rED\n" |
| 314 | "MlOw2Y3vRZCxqZFqfWCW0uzhwKqk2VoYqtDL+ORKG/aG/KTBQ4Y71Uh+7aabPwj5\n" |
| 315 | "R+NaVMjbqmrVeH70eKjoNVgcNYY1C9rGVF1d+LQEm7UsqS0DPp4wN9QKLAqIfuar\n" |
| 316 | "AhQBhZy1R7Sj1r5macD9DsGxsurM4mHZV0LNmYLZiFHjTUb6iRSPD5RBFW80vcNt\n" |
| 317 | "xZ0cxmkLtxrj/DVyExV11Cl0SbZLLa9mScYvxdl/qZutXt3PQyab0NiYxGzCD2Rn\n" |
| 318 | "LkCyxkh1vuHHjhvIWYfbd2VgZB/qGr+o9T07FGfMCu23//fugQKCAQEA9UH38glH\n" |
| 319 | "/rAjZ431sv6ryUEFY8I2FyLTijtvoj9CNGcQn8vJQAHvUPfMdyqDoum6wgcTmG+U\n" |
| 320 | "XA6mZzpGQCiY8JW5CoItgXRoYgNzpvVVe2aLf51QGtNLLEFpNDMpCtI+I+COpAmG\n" |
| 321 | "vWAukku0pZfRjm9eb1ydvTpHlFC9+VhVUsLzw3VtSC5PVW6r65mZcYcB6SFVPap+\n" |
| 322 | "31ENP/9jOMFoymh57lSMZJMxTEA5b0l2miFb9Rp906Zqiud5zv2jIqF6gL70giW3\n" |
| 323 | "ovVxR7LGKKTKIa9pxawHwB6Ithygs7YoJkjF2dm8pZTMZKsQN92K70XGj07SmYRL\n" |
| 324 | "ZpkVD7i+cqbbKQKCAQEA9M6580Rcw6W0twfcy0/iB4U5ZS52EcCjW8vHlL+MpUo7\n" |
| 325 | "YvXadSgV1ZaM28zW/ZGk3wE0zy1YT5s30SQkm0NiWN3t/J0l19ccAOxlPWfjhF7v\n" |
| 326 | "IQZr7XMo5HeaK0Ak5+68J6bx6KgcXmlJOup7INaE8DyGXB6vd4K6957IXyqs3/bf\n" |
| 327 | "JAUmz49hnveCfLFdTVVT/Uq4IoPKfQSbSZc0BvPBsnBCF164l4jllGBaWS302dhg\n" |
| 328 | "W4cgxzG0SZGgNwow4AhB+ygiiS8yvOa7UcHfUObVrzWeeq9mYSQ1PkvUTjkWR2/Y\n" |
| 329 | "8xy7WP0TRBdJOVSs90H51lerEDGNQWvQvI97S9ZOsQKCAQB59u9lpuXtqwxAQCFy\n" |
| 330 | "fSFSuQoEHR2nDcOjF4GhbtHum15yCPaw5QVs/33nuPWze4ZLXReKk9p0mTh5V0p+\n" |
| 331 | "N3IvGlXl+uzEVu5d55eI7LIw5sLymHmwjWjxvimiMtrzLbCHSPHGc5JU9NLUH9/b\n" |
| 332 | "BY/JxGpy+NzcsHHOOQTwTdRIjviIOAo7fgQn2RyX0k+zXE8/7zqjqvji9zyemdNu\n" |
| 333 | "8we4uJICSntyvJwkbj/hrufTKEnBrwXpzfVn1EsH+6w32ZPBGLUhT75txJ8r56SR\n" |
| 334 | "q7l1XPU9vxovmT+lSMFF/Y0j1MbHWnds5H1shoFPNtYTvWBL/gfPHjIc+H23zsiu\n" |
| 335 | "3XlZAoIBAC2xB/Pnpoi9vOUMiqFH36AXtYa1DURy+AqCFlYlClMvb7YgvQ1w1eJv\n" |
| 336 | "nwrHSLk7HdKhnwGsLPduuRRH8q0n/osnoOutSQroE0n41UyIv2ZNccRwNmSzQcai\n" |
| 337 | "rBu2dSz02hlsh2otNl5IuGpOqXyPjXBpW4qGD6n2tH7THALnLC0BHtTSQVQsJsRM\n" |
| 338 | "3gX39LoiWvLDp2qJvplm6rTpi8Rgap6rZSqHe1yNKIxxD2vlr/WY9SMgLXYASO4S\n" |
| 339 | "SBz9wfGOmQIPk6KXNJkdV4kC7nNjIi75iwLLCgjHgUiHTrDq5sWekpeNnUoWsinb\n" |
| 340 | "Tsdsjnv3zHG9GyiClyLGxMbs4M5eyYECggEBAKuC8ZMpdIrjk6tERYB6g0LnQ7mW\n" |
| 341 | "8XYbDFAmLYMLs9yfG2jcjVbsW9Kugsr+3poUUv/q+hNO3jfY4HazhZDa0MalgNPo\n" |
| 342 | "Swr/VNRnkck40x2ovFb989J7yl++zTrnIrax9XRH1V0cNu+Kj7OMwZ2RRfbNv5JB\n" |
| 343 | "dOZPvkfqyIKFmbQgYbtD66rHuzNOfJpzqr/WVLO57/zzW8245NKG2B6B0oXkei/K\n" |
| 344 | "qDY0DAbHR3i3EOj1NPtVI1FC/xX8R9BREaid458bqoHJKuInrGcBjaUI9Cvymv8T\n" |
| 345 | "bstUgD6NPbJR4Sm6vrLeUqzjWZP3t1+Z6DjXmnpR2vvhMU/FWb//21p/88o="); |
Michal Vasko | e49a15f | 2019-05-27 14:18:36 +0200 | [diff] [blame] | 346 | *privkey_type = NC_SSH_KEY_RSA; |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 347 | return 0; |
| 348 | } else if (!strcmp(name, "main_cert")) { |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 349 | *cert_path = strdup(TESTS_DIR "/data/server.crt"); |
| 350 | *privkey_path = strdup(TESTS_DIR "/data/server.key"); |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 351 | return 0; |
| 352 | } |
| 353 | |
| 354 | return 1; |
| 355 | } |
| 356 | |
| 357 | static int |
| 358 | clb_trusted_cert_lists(const char *name, void *UNUSED(user_data), char ***cert_paths, int *cert_path_count, |
Michal Vasko | e49a15f | 2019-05-27 14:18:36 +0200 | [diff] [blame] | 359 | char ***cert_data, int *cert_data_count) |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 360 | { |
| 361 | if (!strcmp(name, "trusted_cert_list1")) { |
Michal Vasko | ad0bcb5 | 2017-03-22 11:55:47 +0100 | [diff] [blame] | 362 | *cert_data = malloc(sizeof **cert_data); |
Michal Vasko | 346ac56 | 2018-11-05 08:47:18 +0100 | [diff] [blame] | 363 | (*cert_data)[0] = strdup("MIIDnDCCAoSgAwIBAgIJAIjf7UNx4uabMA0GCSqGSIb3DQEBCwUAMGMxCzAJBgNV\n" |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 364 | "BAYTAkNaMRMwEQYDVQQIDApTb21lLVN0YXRlMQ0wCwYDVQQHDARCcm5vMQ8wDQYD\n" |
| 365 | "VQQKDAZDRVNORVQxDDAKBgNVBAsMA1RNQzERMA8GA1UEAwwIc2VydmVyY2EwHhcN\n" |
| 366 | "MTgxMTA1MDcyNjM5WhcNMjgxMTAyMDcyNjM5WjBjMQswCQYDVQQGEwJDWjETMBEG\n" |
| 367 | "A1UECAwKU29tZS1TdGF0ZTENMAsGA1UEBwwEQnJubzEPMA0GA1UECgwGQ0VTTkVU\n" |
| 368 | "MQwwCgYDVQQLDANUTUMxETAPBgNVBAMMCHNlcnZlcmNhMIIBIjANBgkqhkiG9w0B\n" |
| 369 | "AQEFAAOCAQ8AMIIBCgKCAQEAyMrKraqraFGklO2itRIEWxfuzWo1IwxZ22aJmeXD\n" |
| 370 | "Leomt6893NXelMLaC3swQ+hu49JjiIY81DXvbVgmIgLm7cAz5tHTHuJbfdI4Q6gy\n" |
| 371 | "ic4aOpy2s3s1/vYz+1TvEUFCiPXEsJrH72he/z9nBxL8vY6Eg8U8EG8NvKp9zyCK\n" |
| 372 | "A7vmNSgQOtuyF18fesYHAnvQjNXO5q6diPXdHOr2bjTRUvARGbWlv4Rvf81RwUkR\n" |
| 373 | "sWoF/0pglV/TxnW2MoHnn3apxb/kmH92CQ+GWKxq5SkhvbkYePlA87kgKnDtXl4w\n" |
| 374 | "EXIhYwM51kafRhhlAKN+qYeV9teBqGpjsZRYesrh3mXHlQIDAQABo1MwUTAdBgNV\n" |
| 375 | "HQ4EFgQU60nJ4q3ItcfaOOBjJSqadAPiMg8wHwYDVR0jBBgwFoAU60nJ4q3Itcfa\n" |
| 376 | "OOBjJSqadAPiMg8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEA\n" |
| 377 | "xIqIQ5SCXnKslZfrXiAEbB5dglxVOSa8me5a/70uHK/27JZ6veeIgRqZ4VgPHnBC\n" |
| 378 | "a3m6EHr+mnTjjqSUcGIUiKV3g2Dumw8paqZC+Qv+Ib/NKquS1lO2Ry1wHBtXzn5K\n" |
| 379 | "KHHyM1bWMDaDszirw2+pp22VdRrPZNA9NWXheEDYOLyQekyL2CfidhxhaXvUZyWg\n" |
| 380 | "alLyF2XRZ5/jAT+NjfWw39EmWPUGk13Jm83OaFc1VdrXNCiD0sGCQ+BTCllDinQv\n" |
| 381 | "R08yzd4fzA3YXthvX1dBu1SvqQAGOS7gssRCyv9uWI6MXta25X91eY1ZMz1euJ04\n" |
| 382 | "mB8EdyYiZc0kzrb9dv5d0g=="); |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 383 | *cert_data_count = 1; |
| 384 | return 0; |
| 385 | } else if (!strcmp(name, "client_cert_list")) { |
Michal Vasko | 75ff74b | 2017-03-21 15:34:34 +0100 | [diff] [blame] | 386 | *cert_paths = malloc(sizeof **cert_paths); |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 387 | (*cert_paths)[0] = strdup(TESTS_DIR "/data/client.crt"); |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 388 | *cert_path_count = 1; |
| 389 | return 0; |
| 390 | } |
| 391 | |
| 392 | return 1; |
| 393 | } |
| 394 | |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 395 | static void * |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 396 | endpt_set_address_thread(void *arg) |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 397 | { |
| 398 | (void)arg; |
| 399 | int ret; |
| 400 | |
| 401 | pthread_barrier_wait(&barrier); |
| 402 | |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 403 | ret = nc_server_endpt_set_address("quaternary", "0.0.0.0"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 404 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 405 | |
| 406 | return NULL; |
| 407 | } |
| 408 | |
| 409 | static void * |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 410 | endpt_set_port_thread(void *arg) |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 411 | { |
| 412 | (void)arg; |
| 413 | int ret; |
| 414 | |
| 415 | pthread_barrier_wait(&barrier); |
| 416 | |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 417 | ret = nc_server_endpt_set_port("quaternary", 6003); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 418 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 419 | |
| 420 | return NULL; |
| 421 | } |
| 422 | |
| 423 | static void * |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 424 | tls_endpt_set_server_cert_thread(void *arg) |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 425 | { |
| 426 | (void)arg; |
| 427 | int ret; |
| 428 | |
| 429 | pthread_barrier_wait(&barrier); |
| 430 | |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 431 | ret = nc_server_tls_endpt_set_server_cert("quaternary", "server_cert1"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 432 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 433 | |
| 434 | nc_thread_destroy(); |
| 435 | return NULL; |
| 436 | } |
| 437 | |
| 438 | static void * |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 439 | tls_endpt_add_trusted_cert_list_thread(void *arg) |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 440 | { |
| 441 | (void)arg; |
| 442 | int ret; |
| 443 | |
| 444 | pthread_barrier_wait(&barrier); |
| 445 | |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 446 | ret = nc_server_tls_endpt_add_trusted_cert_list("quaternary", "trusted_cert_list1"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 447 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 448 | |
| 449 | nc_thread_destroy(); |
| 450 | return NULL; |
| 451 | } |
| 452 | |
| 453 | static void * |
| 454 | tls_endpt_set_trusted_ca_paths_thread(void *arg) |
| 455 | { |
| 456 | (void)arg; |
| 457 | int ret; |
| 458 | |
| 459 | pthread_barrier_wait(&barrier); |
| 460 | |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 461 | ret = nc_server_tls_endpt_set_trusted_ca_paths("quaternary", TESTS_DIR "/data/serverca.pem", "data"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 462 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 463 | |
| 464 | nc_thread_destroy(); |
| 465 | return NULL; |
| 466 | } |
| 467 | |
| 468 | static void * |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 469 | tls_endpt_del_trusted_cert_list_thread(void *arg) |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 470 | { |
| 471 | (void)arg; |
| 472 | |
| 473 | pthread_barrier_wait(&barrier); |
| 474 | |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 475 | nc_server_tls_endpt_del_trusted_cert_list("quaternary", "trusted_cert_list1"); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 476 | |
| 477 | return NULL; |
| 478 | } |
| 479 | |
| 480 | static void * |
| 481 | tls_endpt_set_crl_paths_thread(void *arg) |
| 482 | { |
| 483 | (void)arg; |
| 484 | int ret; |
| 485 | |
| 486 | pthread_barrier_wait(&barrier); |
| 487 | |
| 488 | ret = nc_server_tls_endpt_set_crl_paths("quaternary", NULL, "data"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 489 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 490 | |
| 491 | nc_thread_destroy(); |
| 492 | return NULL; |
| 493 | } |
| 494 | |
| 495 | static void * |
| 496 | tls_endpt_clear_crls_thread(void *arg) |
| 497 | { |
| 498 | (void)arg; |
| 499 | |
| 500 | pthread_barrier_wait(&barrier); |
| 501 | |
| 502 | nc_server_tls_endpt_clear_crls("quaternary"); |
| 503 | |
| 504 | return NULL; |
| 505 | } |
| 506 | |
| 507 | static void * |
| 508 | tls_endpt_add_ctn_thread(void *arg) |
| 509 | { |
| 510 | (void)arg; |
| 511 | int ret; |
| 512 | |
| 513 | pthread_barrier_wait(&barrier); |
| 514 | |
Michal Vasko | 3cf4aaa | 2017-02-01 15:03:36 +0100 | [diff] [blame] | 515 | ret = nc_server_tls_endpt_add_ctn("main_tls", 2, "02:F0:F1:F2:F3:F4:F5:F6:F7:F8:F9:10:11:12:EE:FF:A0:A1:A2:A3", |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 516 | NC_TLS_CTN_SAN_IP_ADDRESS, NULL); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 517 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 518 | |
| 519 | return NULL; |
| 520 | } |
| 521 | |
| 522 | static void * |
| 523 | tls_endpt_del_ctn_thread(void *arg) |
| 524 | { |
| 525 | (void)arg; |
| 526 | int ret; |
| 527 | |
| 528 | pthread_barrier_wait(&barrier); |
| 529 | |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 530 | ret = nc_server_tls_endpt_del_ctn("main_tls", -1, NULL, NC_TLS_CTN_SAN_ANY, NULL); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 531 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 532 | |
| 533 | return NULL; |
| 534 | } |
| 535 | |
| 536 | static void * |
| 537 | tls_client_thread(void *arg) |
| 538 | { |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 539 | int ret, read_pipe = *(int *)arg; |
| 540 | char buf[9]; |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 541 | struct nc_session *session; |
| 542 | |
Michal Vasko | 5a44647 | 2020-05-06 12:43:42 +0200 | [diff] [blame] | 543 | fprintf(stdout, "TLS client start.\n"); |
| 544 | |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 545 | ret = read(read_pipe, buf, 9); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 546 | nc_assert(ret == 9); |
| 547 | nc_assert(!strncmp(buf, "tls_ready", 9)); |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 548 | |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 549 | ret = nc_client_tls_set_cert_key_paths(TESTS_DIR "/data/client.crt", TESTS_DIR "/data/client.key"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 550 | nc_assert(!ret); |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 551 | ret = nc_client_tls_set_trusted_ca_paths(NULL, TESTS_DIR "/data"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 552 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 553 | |
| 554 | session = nc_connect_tls("127.0.0.1", 6501, NULL); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 555 | nc_assert(session); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 556 | |
Frank Rimpler | cb9274f | 2019-03-13 16:40:34 +0000 | [diff] [blame] | 557 | /* verify some capabilities */ |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 558 | nc_assert(nc_session_cpblt(session, "urn:jmu:params:xml:ns:yang:module-a?module=module-a&deviations=module-a-dv,module-a-dv2")); |
Frank Rimpler | cb9274f | 2019-03-13 16:40:34 +0000 | [diff] [blame] | 559 | |
Michal Vasko | e1a64ec | 2016-03-01 12:21:58 +0100 | [diff] [blame] | 560 | nc_session_free(session, NULL); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 561 | |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 562 | fprintf(stdout, "TLS client finished.\n"); |
| 563 | |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 564 | nc_thread_destroy(); |
| 565 | return NULL; |
| 566 | } |
| 567 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 568 | #endif /* NC_ENABLED_TLS */ |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 569 | |
| 570 | static void *(*thread_funcs[])(void *) = { |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 571 | #if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS) |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 572 | server_thread, |
| 573 | #endif |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 574 | #ifdef NC_ENABLED_SSH |
Michal Vasko | 8727e43 | 2016-10-13 15:44:10 +0200 | [diff] [blame] | 575 | add_endpt_thread, |
| 576 | del_endpt_thread, |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 577 | ssh_endpt_set_hostkey_thread, |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 578 | ssh_endpt_set_auth_methods_thread, |
| 579 | ssh_endpt_set_auth_attempts_thread, |
| 580 | ssh_endpt_set_auth_timeout_thread, |
| 581 | ssh_endpt_add_authkey_thread, |
| 582 | ssh_endpt_del_authkey_thread, |
| 583 | #endif |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 584 | #ifdef NC_ENABLED_TLS |
Michal Vasko | 8727e43 | 2016-10-13 15:44:10 +0200 | [diff] [blame] | 585 | endpt_set_address_thread, |
| 586 | endpt_set_port_thread, |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 587 | tls_endpt_set_server_cert_thread, |
| 588 | tls_endpt_add_trusted_cert_list_thread, |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 589 | tls_endpt_set_trusted_ca_paths_thread, |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 590 | tls_endpt_del_trusted_cert_list_thread, |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 591 | tls_endpt_set_crl_paths_thread, |
| 592 | tls_endpt_clear_crls_thread, |
| 593 | tls_endpt_add_ctn_thread, |
| 594 | tls_endpt_del_ctn_thread, |
| 595 | #endif |
| 596 | }; |
| 597 | |
| 598 | const int thread_count = sizeof thread_funcs / sizeof *thread_funcs; |
| 599 | |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 600 | #if defined (NC_ENABLED_SSH) && defined (NC_ENABLED_TLS) |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 601 | const int client_count = 2; |
| 602 | pid_t pids[2]; |
| 603 | int pipes[4]; |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 604 | #else |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 605 | const int client_count = 1; |
| 606 | pid_t pids[1]; |
| 607 | int pipes[2]; |
| 608 | #endif |
| 609 | |
| 610 | static void |
| 611 | client_fork(void) |
| 612 | { |
| 613 | int ret, clients = 0; |
| 614 | |
| 615 | #ifdef NC_ENABLED_SSH |
Jan Kundrát | 5cec3c2 | 2021-10-08 19:54:39 +0200 | [diff] [blame] | 616 | nc_assert(pipe(pipes + clients * 2) == 0); |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 617 | |
| 618 | if (!(pids[clients] = fork())) { |
| 619 | nc_client_init(); |
| 620 | |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 621 | ret = nc_client_set_schema_searchpath(TESTS_DIR "/data/modules"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 622 | nc_assert(!ret); |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 623 | |
| 624 | /* close write */ |
| 625 | close(pipes[clients * 2 + 1]); |
| 626 | ssh_client_thread(&pipes[clients * 2]); |
| 627 | close(pipes[clients * 2]); |
| 628 | nc_client_destroy(); |
| 629 | exit(0); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 630 | } |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 631 | /* close read */ |
| 632 | close(pipes[clients * 2]); |
| 633 | |
| 634 | ++clients; |
| 635 | #endif |
| 636 | |
| 637 | #ifdef NC_ENABLED_TLS |
Jan Kundrát | 5cec3c2 | 2021-10-08 19:54:39 +0200 | [diff] [blame] | 638 | nc_assert(pipe(pipes + clients * 2) == 0); |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 639 | |
| 640 | if (!(pids[clients] = fork())) { |
| 641 | nc_client_init(); |
| 642 | |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 643 | ret = nc_client_set_schema_searchpath(TESTS_DIR "/data/modules"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 644 | nc_assert(!ret); |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 645 | |
| 646 | /* close write */ |
| 647 | close(pipes[clients * 2 + 1]); |
| 648 | tls_client_thread(&pipes[clients * 2]); |
| 649 | close(pipes[clients * 2]); |
| 650 | nc_client_destroy(); |
| 651 | exit(0); |
| 652 | } |
| 653 | /* close read */ |
| 654 | close(pipes[clients * 2]); |
| 655 | |
| 656 | ++clients; |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 657 | #endif |
| 658 | } |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 659 | |
Claus Klein | 2209191 | 2020-01-20 13:45:47 +0100 | [diff] [blame] | 660 | #endif |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 661 | |
| 662 | int |
| 663 | main(void) |
| 664 | { |
Claus Klein | 2209191 | 2020-01-20 13:45:47 +0100 | [diff] [blame] | 665 | #if _POSIX_BARRIERS >= 200112L |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 666 | int ret, i, clients = 0; |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 667 | pthread_t tids[thread_count]; |
| 668 | |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 669 | nc_verbosity(NC_VERB_VERBOSE); |
| 670 | |
| 671 | client_fork(); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 672 | |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 673 | ly_ctx_new(TESTS_DIR "/data/modules", 0, &ctx); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 674 | nc_assert(ctx); |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 675 | ly_ctx_load_module(ctx, "ietf-netconf", NULL, NULL); |
Frank Rimpler | cb9274f | 2019-03-13 16:40:34 +0000 | [diff] [blame] | 676 | |
| 677 | /* load some application models with deviations */ |
Michal Vasko | 7736745 | 2021-02-16 16:32:18 +0100 | [diff] [blame] | 678 | nc_assert(ly_ctx_load_module(ctx, "module-a", NULL, NULL)); |
| 679 | nc_assert(ly_ctx_load_module(ctx, "module-a-dv", NULL, NULL)); |
| 680 | nc_assert(ly_ctx_load_module(ctx, "module-a-dv2", NULL, NULL)); |
Frank Rimpler | cb9274f | 2019-03-13 16:40:34 +0000 | [diff] [blame] | 681 | |
Michal Vasko | 9322407 | 2021-11-09 12:14:28 +0100 | [diff] [blame] | 682 | nc_server_init(); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 683 | |
| 684 | pthread_barrier_init(&barrier, NULL, thread_count); |
| 685 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 686 | #ifdef NC_ENABLED_SSH |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 687 | /* set callback */ |
| 688 | nc_server_ssh_set_hostkey_clb(clb_hostkeys, NULL, NULL); |
| 689 | |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 690 | /* do first, so that client can connect on SSH */ |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 691 | ret = nc_server_add_endpt("main_ssh", NC_TI_LIBSSH); |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 692 | nc_assert(!ret); |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 693 | ret = nc_server_endpt_set_address("main_ssh", "0.0.0.0"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 694 | nc_assert(!ret); |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 695 | ret = nc_server_endpt_set_port("main_ssh", 6001); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 696 | nc_assert(!ret); |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 697 | ret = nc_server_ssh_add_authkey_path(TESTS_DIR "/data/key_ecdsa.pub", "test"); |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 698 | nc_assert(!ret); |
Michal Vasko | 7d25588 | 2017-02-09 13:35:08 +0100 | [diff] [blame] | 699 | ret = nc_server_ssh_endpt_add_hostkey("main_ssh", "key_rsa", -1); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 700 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 701 | |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 702 | /* client ready */ |
| 703 | ret = write(pipes[clients * 2 + 1], "ssh_ready", 9); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 704 | nc_assert(ret == 9); |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 705 | ++clients; |
| 706 | |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 707 | /* for ssh_endpt_del_authkey */ |
Michal Vasko | 7a4213f | 2022-09-08 11:02:34 +0200 | [diff] [blame] | 708 | ret = nc_server_ssh_add_authkey_path(TESTS_DIR "/data/key_ecdsa.pub", "test2"); |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 709 | nc_assert(!ret); |
| 710 | |
| 711 | ret = nc_server_add_endpt("secondary", NC_TI_LIBSSH); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 712 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 713 | #endif |
| 714 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 715 | #ifdef NC_ENABLED_TLS |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 716 | /* set callbacks */ |
| 717 | nc_server_tls_set_server_cert_clb(clb_server_cert, NULL, NULL); |
| 718 | nc_server_tls_set_trusted_cert_list_clb(clb_trusted_cert_lists, NULL, NULL); |
| 719 | |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 720 | /* do first, so that client can connect on TLS */ |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 721 | ret = nc_server_add_endpt("main_tls", NC_TI_OPENSSL); |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 722 | nc_assert(!ret); |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 723 | ret = nc_server_endpt_set_address("main_tls", "0.0.0.0"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 724 | nc_assert(!ret); |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 725 | ret = nc_server_endpt_set_port("main_tls", 6501); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 726 | nc_assert(!ret); |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 727 | ret = nc_server_tls_endpt_set_server_cert("main_tls", "main_cert"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 728 | nc_assert(!ret); |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 729 | ret = nc_server_tls_endpt_add_trusted_cert_list("main_tls", "client_cert_list"); |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 730 | nc_assert(!ret); |
Michal Vasko | 346ac56 | 2018-11-05 08:47:18 +0100 | [diff] [blame] | 731 | ret = nc_server_tls_endpt_add_ctn("main_tls", 0, "02:B3:9F:26:65:76:6B:CC:FC:86:8E:D4:1A:81:64:0F:92:EB:18:AE:FF", NC_TLS_CTN_SPECIFIED, "test"); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 732 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 733 | |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 734 | /* client ready */ |
| 735 | ret = write(pipes[clients * 2 + 1], "tls_ready", 9); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 736 | nc_assert(ret == 9); |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 737 | ++clients; |
| 738 | |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 739 | /* for tls_endpt_del_ctn */ |
Michal Vasko | 3cf4aaa | 2017-02-01 15:03:36 +0100 | [diff] [blame] | 740 | ret = nc_server_tls_endpt_add_ctn("main_tls", 1, "02:00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:A0:A1:A2:A3", NC_TLS_CTN_SAN_ANY, NULL); |
Michal Vasko | 338f847 | 2016-10-13 15:01:27 +0200 | [diff] [blame] | 741 | nc_assert(!ret); |
| 742 | |
| 743 | ret = nc_server_add_endpt("quaternary", NC_TI_OPENSSL); |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 744 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 745 | #endif |
| 746 | |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 747 | /* threads'n'stuff */ |
| 748 | ret = 0; |
| 749 | for (i = 0; i < thread_count; ++i) { |
| 750 | ret += pthread_create(&tids[i], NULL, thread_funcs[i], NULL); |
| 751 | } |
Michal Vasko | 64b31a2 | 2016-03-03 11:00:00 +0100 | [diff] [blame] | 752 | nc_assert(!ret); |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 753 | |
| 754 | /* cleanup */ |
| 755 | for (i = 0; i < thread_count; ++i) { |
| 756 | pthread_join(tids[i], NULL); |
| 757 | } |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 758 | for (i = 0; i < client_count; ++i) { |
| 759 | waitpid(pids[i], NULL, 0); |
| 760 | close(pipes[i * 2 + 1]); |
| 761 | } |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 762 | |
| 763 | pthread_barrier_destroy(&barrier); |
| 764 | |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 765 | nc_server_destroy(); |
Michal Vasko | 1dcb764 | 2021-04-14 15:28:23 +0200 | [diff] [blame] | 766 | ly_ctx_destroy(ctx); |
Claus Klein | 2209191 | 2020-01-20 13:45:47 +0100 | [diff] [blame] | 767 | #endif |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 768 | |
Michal Vasko | 734360b | 2016-02-08 15:38:25 +0100 | [diff] [blame] | 769 | return 0; |
| 770 | } |