Commit 87834dd6 authored by Chris Busbey's avatar Chris Busbey Committed by Chris Busbey

fixed up comments from pr

parent 5441db3d
......@@ -39,9 +39,22 @@ zmq::gssapi_client_t::gssapi_client_t (const options_t &options_) :
security_context_established (false)
{
const std::string::size_type service_size = options_.gss_service_principle.size();
service_name = new char[service_size+1];
service_name = static_cast <char *>(malloc(service_size+1));
assert(service_name);
memcpy(service_name, options_.gss_service_principle.c_str(), service_size+1 );
maj_stat = GSS_S_COMPLETE;
if(!options_.gss_principle.empty())
{
const std::string::size_type principle_size = options_.gss_principle.size();
principle_name = static_cast <char *>(malloc(principle_size+1));
assert(principle_name);
memcpy(principle_name, options_.gss_principle.c_str(), principle_size+1 );
if (acquire_credentials (principle_name, &cred) != 0)
maj_stat = GSS_S_FAILURE;
}
mechs.elements = NULL;
mechs.count = 0;
}
......
......@@ -38,7 +38,7 @@ zmq::gssapi_mechanism_base_t::gssapi_mechanism_base_t (const options_t & options
/// FIXME remove? in_buf (),
target_name (GSS_C_NO_NAME),
principle_name (NULL),
maj_stat (GSS_S_CONTINUE_NEEDED),
maj_stat (GSS_S_COMPLETE),
min_stat (0),
init_sec_min_stat (0),
ret_flags (0),
......@@ -46,15 +46,6 @@ zmq::gssapi_mechanism_base_t::gssapi_mechanism_base_t (const options_t & options
cred (GSS_C_NO_CREDENTIAL),
context (GSS_C_NO_CONTEXT)
{
if(!options_.gss_principle.empty())
{
const std::string::size_type principle_size = options_.gss_principle.size();
principle_name = new char[principle_size+1];
memcpy(principle_name, options_.gss_principle.c_str(), principle_size+1 );
if (acquire_credentials (principle_name, &cred) != 0)
maj_stat = GSS_S_FAILURE;
}
}
zmq::gssapi_mechanism_base_t::~gssapi_mechanism_base_t ()
......
......@@ -17,6 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "platform.hpp"
#ifdef ZMQ_HAVE_WINDOWS
#include "windows.hpp"
......@@ -42,12 +43,26 @@ zmq::gssapi_server_t::gssapi_server_t (session_base_t *session_,
state (recv_next_token),
security_context_established (false)
{
maj_stat = GSS_S_CONTINUE_NEEDED;
if(!options_.gss_principle.empty())
{
const std::string::size_type principle_size = options_.gss_principle.size();
principle_name = static_cast <char *>(malloc(principle_size+1));
assert(principle_name);
memcpy(principle_name, options_.gss_principle.c_str(), principle_size+1 );
if (acquire_credentials (principle_name, &cred) != 0)
maj_stat = GSS_S_FAILURE;
}
}
zmq::gssapi_server_t::~gssapi_server_t ()
{
if(cred)
gss_release_cred(&min_stat, &cred);
if(target_name)
gss_release_name(&min_stat, &target_name);
}
int zmq::gssapi_server_t::next_handshake_command (msg_t *msg_)
......@@ -72,7 +87,6 @@ int zmq::gssapi_server_t::next_handshake_command (msg_t *msg_)
return -1;
if (maj_stat == GSS_S_COMPLETE) {
gss_release_name(&min_stat, &target_name);
security_context_established = true;
}
......
......@@ -422,7 +422,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
if (optvallen_ > 0 && optvallen_ < 256 && optval_ != NULL) {
gss_service_principle.assign ((const char *) optval_, optvallen_);
mechanism = ZMQ_GSSAPI;
as_server = 1;
as_server = 0;
return 0;
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment