mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-29 20:59:47 +01:00
gssapi: add NAMETYPE socket options
Problem: principals are looked up unconditionally with the GSS_C_NT_HOSTBASED_SERVICE name type. Solution: Add two new socket options to set the name type for ZMQ_GSSAPI_PRINCIPAL and ZMQ_GSSAPI_SERVICE_PRINCIPAL: ZMQ_GSSAPI_PRINCIPAL_NAMETYPE ZMQ_GSSAPI_SERVICE_PRINCIPAL_NAMETYPE They take an integer argument which must be one of ZMQ_GSSAPI_NT_HOSTBASED (0) - default ZMQ_GSSAPI_NT_USER_NAME (1) ZMQ_GSSAPI_NT_KRB5_PRINCIPAL (2) These correspond to GSSAPI name types of: GSS_C_NT_HOSTBASED_SERVICE GSS_C_NT_USER_NAME GSS_KRB5_NT_PRINCIPAL_NAME Fixes #2542
This commit is contained in:
@@ -321,18 +321,36 @@ int zmq::gssapi_mechanism_base_t::process_ready (msg_t *msg_)
|
||||
return parse_metadata (ptr, bytes_left);
|
||||
}
|
||||
|
||||
int zmq::gssapi_mechanism_base_t::acquire_credentials (char * service_name_, gss_cred_id_t * cred_)
|
||||
const gss_OID zmq::gssapi_mechanism_base_t::convert_nametype (int zmq_nametype)
|
||||
{
|
||||
switch (zmq_nametype) {
|
||||
case ZMQ_GSSAPI_NT_HOSTBASED:
|
||||
return GSS_C_NT_HOSTBASED_SERVICE;
|
||||
case ZMQ_GSSAPI_NT_USER_NAME:
|
||||
return GSS_C_NT_USER_NAME;
|
||||
case ZMQ_GSSAPI_NT_KRB5_PRINCIPAL:
|
||||
#ifdef GSS_KRB5_NT_PRINCIPAL_NAME
|
||||
return (gss_OID)GSS_KRB5_NT_PRINCIPAL_NAME;
|
||||
#else
|
||||
return GSS_C_NT_USER_NAME;
|
||||
#endif
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int zmq::gssapi_mechanism_base_t::acquire_credentials (char * service_name_, gss_cred_id_t * cred_, int zmq_name_type_)
|
||||
{
|
||||
OM_uint32 maj_stat;
|
||||
OM_uint32 min_stat;
|
||||
gss_name_t server_name;
|
||||
gss_OID name_type = convert_nametype (zmq_name_type_);
|
||||
|
||||
gss_buffer_desc name_buf;
|
||||
name_buf.value = service_name_;
|
||||
name_buf.length = strlen ((char *) name_buf.value) + 1;
|
||||
|
||||
maj_stat = gss_import_name (&min_stat, &name_buf,
|
||||
GSS_C_NT_HOSTBASED_SERVICE, &server_name);
|
||||
name_type, &server_name);
|
||||
|
||||
if (maj_stat != GSS_S_COMPLETE)
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user