From f790ea19b5cac55d39d72efcfafc23619faba1c2 Mon Sep 17 00:00:00 2001 From: roman Date: Fri, 3 Nov 2023 13:58:17 +0100 Subject: [PATCH] session server UPDATE remove obsolete funcions --- src/session_server.c | 27 ------------- src/session_server.h | 25 ------------ src/session_server_tls.c | 85 ---------------------------------------- 3 files changed, 137 deletions(-) diff --git a/src/session_server.c b/src/session_server.c index 6952cc48..581bb88f 100644 --- a/src/session_server.c +++ b/src/session_server.c @@ -2060,33 +2060,6 @@ nc_server_endpt_count(void) return server_opts.endpt_count; } -API int -nc_server_is_endpt(const char *name) -{ - uint16_t i; - int found = 0; - - if (!name) { - return found; - } - - /* CONFIG READ LOCK */ - pthread_rwlock_rdlock(&server_opts.config_lock); - - /* check name uniqueness */ - for (i = 0; i < server_opts.endpt_count; ++i) { - if (!strcmp(server_opts.endpts[i].name, name)) { - found = 1; - break; - } - } - - /* CONFIG UNLOCK */ - pthread_rwlock_unlock(&server_opts.config_lock); - - return found; -} - API NC_MSG_TYPE nc_accept(int timeout, const struct ly_ctx *ctx, struct nc_session **session) { diff --git a/src/session_server.h b/src/session_server.h index 65a9d8d0..b7bab618 100644 --- a/src/session_server.h +++ b/src/session_server.h @@ -378,14 +378,6 @@ void nc_ps_clear(struct nc_pollsession *ps, int all, void (*data_free)(void *)); */ int nc_server_endpt_count(void); -/** - * @brief Check if an endpoint exists. - * - * @param[in] name Endpoint name. - * @return 0 if does not exists, non-zero otherwise. - */ -int nc_server_is_endpt(const char *name); - /** @} */ /** @@ -475,23 +467,6 @@ void nc_server_ssh_set_interactive_auth_clb(int (*interactive_auth_clb)(const st * @{ */ -/** - * @brief Get a cert-to-name entry. - * - * If a parameter is NULL, it is ignored. If its dereferenced value is NULL, - * it is filled and returned. If the value is set, it is used as a filter. - * Returns first matching entry. - * - * @param[in] endpt_name Existing endpoint name. - * @param[in,out] id Priority of the entry. - * @param[in,out] fingerprint Fingerprint fo the entry. - * @param[in,out] map_type Mapping type of the entry. - * @param[in,out] name Specific username for the entry. - * @return 0 on success, -1 on not finding any match. - */ -int nc_server_tls_endpt_get_ctn(const char *endpt_name, uint32_t *id, char **fingerprint, NC_TLS_CTN_MAPTYPE *map_type, - char **name); - /** * @brief Get client certificate. * diff --git a/src/session_server_tls.c b/src/session_server_tls.c index a11c11b3..b0aa2b6b 100644 --- a/src/session_server_tls.c +++ b/src/session_server_tls.c @@ -799,91 +799,6 @@ nc_tlsclb_verify(int preverify_ok, X509_STORE_CTX *x509_ctx) return 0; } -static int -nc_server_tls_get_ctn(uint32_t *id, char **fingerprint, NC_TLS_CTN_MAPTYPE *map_type, char **name, - struct nc_server_tls_opts *opts) -{ - struct nc_ctn *ctn; - int ret = -1; - - for (ctn = opts->ctn; ctn; ctn = ctn->next) { - if (id && *id && (*id != ctn->id)) { - continue; - } - if (fingerprint && *fingerprint && (!ctn->fingerprint || strcmp(*fingerprint, ctn->fingerprint))) { - continue; - } - if (map_type && *map_type && (!ctn->map_type || (*map_type != ctn->map_type))) { - continue; - } - if (name && *name && (!ctn->name || strcmp(*name, ctn->name))) { - continue; - } - - /* first match, good enough */ - if (id && !(*id)) { - *id = ctn->id; - } - if (fingerprint && !(*fingerprint) && ctn->fingerprint) { - *fingerprint = strdup(ctn->fingerprint); - } - if (map_type && !(*map_type) && ctn->map_type) { - *map_type = ctn->map_type; - } - if (name && !(*name) && ctn->name) { - *name = strdup(ctn->name); - } - - ret = 0; - break; - } - - return ret; -} - -API int -nc_server_tls_endpt_get_ctn(const char *endpt_name, uint32_t *id, char **fingerprint, NC_TLS_CTN_MAPTYPE *map_type, - char **name) -{ - int ret; - struct nc_endpt *endpt; - - NC_CHECK_ARG_RET(NULL, endpt_name, -1); - - /* LOCK */ - endpt = nc_server_endpt_lock_get(endpt_name, NC_TI_OPENSSL, NULL); - if (!endpt) { - return -1; - } - ret = nc_server_tls_get_ctn(id, fingerprint, map_type, name, endpt->opts.tls); - /* UNLOCK */ - pthread_rwlock_unlock(&server_opts.config_lock); - - return ret; -} - -API int -nc_server_tls_ch_client_endpt_get_ctn(const char *client_name, const char *endpt_name, uint32_t *id, char **fingerprint, - NC_TLS_CTN_MAPTYPE *map_type, char **name) -{ - int ret; - struct nc_ch_client *client; - struct nc_ch_endpt *endpt; - - /* LOCK */ - endpt = nc_server_ch_client_lock(client_name, endpt_name, NC_TI_OPENSSL, &client); - if (!endpt) { - return -1; - } - - ret = nc_server_tls_get_ctn(id, fingerprint, map_type, name, endpt->opts.tls); - - /* UNLOCK */ - nc_server_ch_client_unlock(client); - - return ret; -} - API const X509 * nc_session_get_client_cert(const struct nc_session *session) {