2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-03 08:05:21 +00:00

Stop including gssapi.h from dst/gssapi.h header

The only reason for including the gssapi.h from the dst/gssapi.h header
was to get the typedefs of gss_cred_id_t and gss_ctx_id_t.  Instead of
using those types directly this commit introduces dns_gss_cred_id_t and
dns_gss_ctx_id_t types that are being used in the public API and
privately retyped to their counterparts when we actually call the gss
api.

This also conceals the gssapi headers, so users of the libdns library
doesn't have to add GSSAPI_CFLAGS to the Makefile when including libdns
dst API.
This commit is contained in:
Ondřej Surý
2021-02-11 14:40:59 +01:00
committed by Mark Andrews
parent 23c3bcc711
commit a5d2ce79c8
9 changed files with 73 additions and 91 deletions

View File

@@ -9,20 +9,13 @@
* information regarding copyright ownership.
*/
#ifndef DST_GSSAPI_H
#define DST_GSSAPI_H 1
#pragma once
/*! \file dst/gssapi.h */
#include <inttypes.h>
#include <stdbool.h>
#if HAVE_GSSAPI_GSSAPI_H
#include <gssapi/gssapi.h>
#elif HAVE_GSSAPI_H
#include <gssapi.h>
#endif
#include <isc/formatcheck.h>
#include <isc/lang.h>
#include <isc/platform.h>
@@ -30,16 +23,8 @@
#include <dns/types.h>
/*
* Define dummy opaque typedefs if we are not using GSSAPI
*
* FIXME: Make the gssapi types completely opaque and include <gssapi.h> only
* internally.
*/
#if !HAVE_GSSAPI
typedef void *gss_cred_id_t;
typedef void *gss_ctx_id_t;
#endif
typedef void *dns_gss_cred_id_t;
typedef void *dns_gss_ctx_id_t;
ISC_LANG_BEGINDECLS
@@ -53,13 +38,13 @@ ISC_LANG_BEGINDECLS
isc_result_t
dst_gssapi_acquirecred(const dns_name_t *name, bool initiate,
gss_cred_id_t *cred);
dns_gss_cred_id_t *cred);
/*
* Acquires GSS credentials.
*
* Requires:
* 'name' is a valid name, preferably one known by the GSS provider
* 'initiate' indicates whether the credentials are for initiating or
* 'name' is a valid name, preferably one known by the GSS provider
* 'initiate' indicates whether the credentials are for initiating or
* accepting contexts
* 'cred' is a pointer to NULL, which will be allocated with the
* credential handle. Call dst_gssapi_releasecred to free
@@ -72,63 +57,63 @@ dst_gssapi_acquirecred(const dns_name_t *name, bool initiate,
*/
isc_result_t
dst_gssapi_releasecred(gss_cred_id_t *cred);
dst_gssapi_releasecred(dns_gss_cred_id_t *cred);
/*
* Releases GSS credentials. Calling this function does release the
* memory allocated for the credential in dst_gssapi_acquirecred()
* memory allocated for the credential in dst_gssapi_acquirecred()
*
* Requires:
* 'mctx' is a valid memory context
* 'cred' is a pointer to the credential to be released
*
* Returns:
* ISC_R_SUCCESS credential was released successfully
* ISC_R_SUCCESS credential was released successfully
* other an error occurred while releaseing
* the credential
*/
isc_result_t
dst_gssapi_initctx(const dns_name_t *name, isc_buffer_t *intoken,
isc_buffer_t *outtoken, gss_ctx_id_t *gssctx,
isc_buffer_t *outtoken, dns_gss_ctx_id_t *gssctx,
isc_mem_t *mctx, char **err_message);
/*
* Initiates a GSS context.
*
* Requires:
* 'name' is a valid name, preferably one known by the GSS
* provider
* 'intoken' is a token received from the acceptor, or NULL if
* 'name' is a valid name, preferably one known by the GSS
* provider
* 'intoken' is a token received from the acceptor, or NULL if
* there isn't one
* 'outtoken' is a buffer to receive the token generated by
* 'outtoken' is a buffer to receive the token generated by
* gss_init_sec_context() to be sent to the acceptor
* 'context' is a pointer to a valid gss_ctx_id_t
* (which may have the value GSS_C_NO_CONTEXT)
* 'context' is a pointer to a valid dns_gss_ctx_id_t
* (which may have the value DNS_GSS_C_NO_CONTEXT)
*
* Returns:
* ISC_R_SUCCESS msg was successfully updated to include the
* query to be sent
* query to be sent
* other an error occurred while building the message
* *err_message optional error message
*/
isc_result_t
dst_gssapi_acceptctx(gss_cred_id_t cred, const char *gssapi_keytab,
dst_gssapi_acceptctx(dns_gss_cred_id_t cred, const char *gssapi_keytab,
isc_region_t *intoken, isc_buffer_t **outtoken,
gss_ctx_id_t *context, dns_name_t *principal,
dns_gss_ctx_id_t *context, dns_name_t *principal,
isc_mem_t *mctx);
/*
* Accepts a GSS context.
*
* Requires:
* 'mctx' is a valid memory context
* 'mctx' is a valid memory context
* 'cred' is the acceptor's valid GSS credential handle
* 'intoken' is a token received from the initiator
* 'outtoken' is a pointer a buffer pointer used to return the token
* 'intoken' is a token received from the initiator
* 'outtoken' is a pointer a buffer pointer used to return the token
* generated by gss_accept_sec_context() to be sent to the
* initiator
* 'context' is a valid pointer to receive the generated context handle.
* On the initial call, it should be a pointer to NULL, which
* will be allocated as a gss_ctx_id_t. Subsequent calls
* will be allocated as a dns_gss_ctx_id_t. Subsequent calls
* should pass in the handle generated on the first call.
* Call dst_gssapi_releasecred to delete the context and free
* the memory.
@@ -138,16 +123,16 @@ dst_gssapi_acceptctx(gss_cred_id_t cred, const char *gssapi_keytab,
*
* Returns:
* ISC_R_SUCCESS msg was successfully updated to include the
* query to be sent
* query to be sent
* DNS_R_CONTINUE transaction still in progress
* other an error occurred while building the message
* other an error occurred while building the message
*/
isc_result_t
dst_gssapi_deletectx(isc_mem_t *mctx, gss_ctx_id_t *gssctx);
dst_gssapi_deletectx(isc_mem_t *mctx, dns_gss_ctx_id_t *gssctx);
/*
* Destroys a GSS context. This function deletes the context from the GSS
* provider and then frees the memory used by the context pointer.
* provider and then frees the memory used by the context pointer.
*
* Requires:
* 'mctx' is a valid memory context
@@ -174,11 +159,11 @@ gss_error_tostring(uint32_t major, uint32_t minor, char *buf, size_t buflen);
*
* Requires:
* 'major' is a GSS major status code
* 'minor' is a GSS minor status code
* 'minor' is a GSS minor status code
*
* Returns:
* A string containing the text representation of the error codes.
* Users should copy the string if they wish to keep it.
* Users should copy the string if they wish to keep it.
*/
bool
@@ -204,5 +189,3 @@ dst_gssapi_identitymatchesrealmms(const dns_name_t *signer,
*/
ISC_LANG_ENDDECLS
#endif /* DST_GSSAPI_H */