Author: kroosec Date: 2016-09-16 16:48:22 +0200 (Fri, 16 Sep 2016) New Revision: 26235
Modified: trunk/openvas-libraries/ChangeLog trunk/openvas-libraries/misc/network.c trunk/openvas-libraries/misc/network.h Log: * misc/network.c (ovas_scanner_context_s): Remove unused struct. (ovas_scanner_context_new, ovas_scanner_context_free) (ovas_scanner_context_attach): Remove unused functions. * misc/network.h: Remove unused declarations. Modified: trunk/openvas-libraries/ChangeLog =================================================================== --- trunk/openvas-libraries/ChangeLog 2016-09-16 14:48:12 UTC (rev 26234) +++ trunk/openvas-libraries/ChangeLog 2016-09-16 14:48:22 UTC (rev 26235) @@ -1,3 +1,11 @@ +2016-09-16 Hani Benhabiles <hani.benhabi...@greenbone.net> + + * misc/network.c (ovas_scanner_context_s): Remove unused struct. + (ovas_scanner_context_new, ovas_scanner_context_free) + (ovas_scanner_context_attach): Remove unused functions. + + * misc/network.h: Remove unused declarations. + 2016-09-13 Hani Benhabiles <hani.benhabi...@greenbone.net> * base/openvas_networking.c (port_range_ranges): Check if parameter is Modified: trunk/openvas-libraries/misc/network.c =================================================================== --- trunk/openvas-libraries/misc/network.c 2016-09-16 14:48:12 UTC (rev 26234) +++ trunk/openvas-libraries/misc/network.c 2016-09-16 14:48:22 UTC (rev 26235) @@ -1127,194 +1127,7 @@ /*NOTREACHED*/ } -/* - * Scanner socket functions - */ - -struct ovas_scanner_context_s -{ - /** Transport encapsulation to use */ - openvas_encaps_t encaps; - - /** GnuTLS credentials */ - gnutls_certificate_credentials_t tls_cred; - - /** GnuTLS priority string */ - char *priority; - - gnutls_session_t tls_session; -}; - - -/** - * @brief Creates a new ovas_scanner_context_t. - * - * If any of the SSL encapsulations are used, the parameters certfile, keyfile, - * and cafile should be the filenames of the scanner certificate and - * corresponding key and the CA certificate. The optional passwd parameter is - * used as the password to decrypt the keyfile if it is encrypted. - */ -ovas_scanner_context_t -ovas_scanner_context_new (openvas_encaps_t encaps, const char *certfile, - const char *keyfile, const char *passwd, - const char *cafile, const char *priority, - const char *dhparams) -{ - ovas_scanner_context_t ctx = NULL; - - ctx = g_malloc0 (sizeof (*ctx)); - ctx->encaps = encaps; - ctx->priority = g_strdup (priority); - - if (ctx->encaps != OPENVAS_ENCAPS_IP) - { - int ret = gnutls_certificate_allocate_credentials (&(ctx->tls_cred)); - if (ret < 0) - { - tlserror ("gnutls_certificate_allocate_credentials", ret); - ctx->tls_cred = NULL; - goto fail; - } - - if (certfile && keyfile) - { - if (load_cert_and_key (ctx->tls_cred, certfile, keyfile, passwd) < 0) - goto fail; - } - - if (cafile != NULL) - { - ret = - gnutls_certificate_set_x509_trust_file (ctx->tls_cred, cafile, - GNUTLS_X509_FMT_PEM); - if (ret < 0) - { - tlserror ("gnutls_certificate_set_x509_trust_file", ret); - goto fail; - } - } - if (dhparams && set_gnutls_dhparams (ctx->tls_cred, dhparams)) - log_legacy_write ("Couldn't set DH parameters from %s\n", dhparams); - } - - return ctx; - - -fail: - ovas_scanner_context_free (ctx); - return NULL; -} - - -/** - * @brief Frees the ovas_scanner_context_t instance ctx. - * - * If ctx is NULL, nothing is done. - * - * @param ctx ovas_scanner_context_t to free. - */ -void -ovas_scanner_context_free (ovas_scanner_context_t ctx) -{ - if (ctx == NULL) - return; - - if (ctx->tls_cred != NULL) - gnutls_certificate_free_credentials (ctx->tls_cred); - - g_free (ctx->priority); - g_free (ctx); -} - -/** - * @brief Sets up SSL/TLS on the socket soc and returns a openvas file - * @brief descriptor. - * - * The parameters for the SSL/TLS layer are taken from ctx. - * Afterwards, the credentials of ctx are also referenced by the SSL/TLS - * objects associated with the openvas file descriptor. This means that - * the context ctx must not be freed until the openvas file descriptor is - * closed. - * - * @return The openvas file descriptor on success and -1 on failure. - */ int -ovas_scanner_context_attach (ovas_scanner_context_t ctx, int soc) -{ - int fd; - openvas_connection *fp = NULL; - int ret; - - fd = openvas_register_connection (soc, NULL, NULL, ctx->encaps); - if (fd < 0) - return -1; - - fp = OVAS_CONNECTION_FROM_FD (fd); - - if (fp->transport != OPENVAS_ENCAPS_IP) - { - ret = gnutls_init (&(fp->tls_session), GNUTLS_SERVER); - if (ret < 0) - { - tlserror ("gnutls_init", ret); - goto fail; - } - ctx->tls_session = fp->tls_session; - - ret = set_gnutls_protocol (fp->tls_session, fp->transport, ctx->priority); - if (ret < 0) - goto fail; - - if (ctx->tls_cred) - { - /* *fp contains a field for the gnutls credentials. We do not - * set it here because ctx->tls_cred is owned by ctx and - * copying it to fp->tls_cred would lead to it being freed - * when the connection is closed. */ - ret = - gnutls_credentials_set (fp->tls_session, GNUTLS_CRD_CERTIFICATE, - ctx->tls_cred); - if (ret < 0) - { - tlserror ("gnutls_credentials_set", ret); - return -1; - } - } - - - /* request client certificate if any. */ - gnutls_certificate_server_set_request (fp->tls_session, - GNUTLS_CERT_REQUIRE); - - gnutls_transport_set_ptr (fp->tls_session, - (gnutls_transport_ptr_t) - GSIZE_TO_POINTER (fp->fd)); - retry: - ret = gnutls_handshake (fp->tls_session); - if (ret < 0) - { - if (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED) - goto retry; -#ifdef DEBUG_SSL - tlserror ("gnutls_handshake", ret); -#endif - goto fail; - } - - if (openvas_server_verify (fp->tls_session)) - { - goto fail; - } - } - - return fd; - -fail: - release_connection_fd (fd, 0); - return -1; -} - -int stream_set_timeout (int fd, int timeout) { int old; Modified: trunk/openvas-libraries/misc/network.h =================================================================== --- trunk/openvas-libraries/misc/network.h 2016-09-16 14:48:12 UTC (rev 26234) +++ trunk/openvas-libraries/misc/network.h 2016-09-16 14:48:22 UTC (rev 26235) @@ -104,17 +104,6 @@ int stream_get_buffer_sz (int); int stream_get_err (int); -struct ovas_scanner_context_s; -typedef struct ovas_scanner_context_s *ovas_scanner_context_t; - -ovas_scanner_context_t -ovas_scanner_context_new (openvas_encaps_t, const char *, const char *, - const char *, const char *, const char *, - const char *); - -void ovas_scanner_context_free (ovas_scanner_context_t); -int ovas_scanner_context_attach (ovas_scanner_context_t ctx, int soc); - int openvas_register_connection (int s, void *ssl, gnutls_certificate_credentials_t certcred, openvas_encaps_t encaps); _______________________________________________ Openvas-commits mailing list Openvas-commits@wald.intevation.org https://lists.wald.intevation.org/cgi-bin/mailman/listinfo/openvas-commits