Commit 4b1c851d authored by Mike Gatny's avatar Mike Gatny Committed by Chris Busbey

Stubbed in gssapi security mechanism.

parent d1bdd45e
......@@ -296,6 +296,8 @@ ZMQ_EXPORT char *zmq_msg_gets (zmq_msg_t *msg, char *property);
#define ZMQ_IPC_FILTER_UID 59
#define ZMQ_IPC_FILTER_GID 60
#define ZMQ_CONNECT_RID 61
#define ZMQ_GSSAPI_SERVER 62
#define ZMQ_GSSAPI_CLIENT 63
/* Message options */
#define ZMQ_MORE 1
......@@ -309,6 +311,7 @@ ZMQ_EXPORT char *zmq_msg_gets (zmq_msg_t *msg, char *property);
#define ZMQ_NULL 0
#define ZMQ_PLAIN 1
#define ZMQ_CURVE 2
#define ZMQ_GSSAPI 3
/* Deprecated options and aliases */
#define ZMQ_IPV4ONLY 31
......
......@@ -25,6 +25,7 @@ libzmq_la_SOURCES = \
err.hpp \
fd.hpp \
fq.hpp \
gssapi_mechanism.hpp \
i_encoder.hpp \
i_decoder.hpp \
i_engine.hpp \
......@@ -101,6 +102,7 @@ libzmq_la_SOURCES = \
epoll.cpp \
err.cpp \
fq.cpp \
gssapi_mechanism.cpp \
io_object.cpp \
io_thread.cpp \
ip.cpp \
......
This diff is collapsed.
/*
Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __ZMQ_GSSAPI_MECHANISM_HPP_INCLUDED__
#define __ZMQ_GSSAPI_MECHANISM_HPP_INCLUDED__
#include "mechanism.hpp"
#include "options.hpp"
namespace zmq
{
class msg_t;
class session_base_t;
class gssapi_mechanism_t : public mechanism_t
{
public:
gssapi_mechanism_t (session_base_t *session_,
const std::string &peer_address,
const options_t &options_);
virtual ~gssapi_mechanism_t ();
// mechanism implementation
virtual int next_handshake_command (msg_t *msg_);
virtual int process_handshake_command (msg_t *msg_);
virtual int zap_msg_available ();
virtual bool is_handshake_complete () const;
private:
enum state_t {
sending_hello,
waiting_for_hello,
sending_welcome,
waiting_for_welcome,
sending_initiate,
waiting_for_initiate,
sending_ready,
waiting_for_ready,
waiting_for_zap_reply,
ready
};
session_base_t * const session;
const std::string peer_address;
// True iff we are awaiting reply from ZAP reply.
bool expecting_zap_reply;
state_t state;
int produce_hello (msg_t *msg_) const;
int produce_welcome (msg_t *msg_) const;
int produce_initiate (msg_t *msg_) const;
int produce_ready (msg_t *msg_) const;
int process_hello (msg_t *msg_);
int process_welcome (msg_t *msg);
int process_ready (msg_t *msg_);
int process_initiate (msg_t *msg_);
void send_zap_request (const std::string &username,
const std::string &password);
int receive_and_process_zap_reply ();
};
}
#endif
......@@ -394,13 +394,29 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
}
break;
# endif
case ZMQ_CONFLATE:
if (is_int && (value == 0 || value == 1)) {
conflate = (value != 0);
return 0;
}
break;
case ZMQ_GSSAPI_SERVER:
if (is_int && (value == 0 || value == 1)) {
as_server = value;
mechanism = ZMQ_GSSAPI;
return 0;
}
break;
case ZMQ_GSSAPI_CLIENT:
if (is_int && (value == 0 || value == 1)) {
as_server = (value == 0);
mechanism = ZMQ_GSSAPI;
return 0;
}
break;
default:
break;
......@@ -681,8 +697,23 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
return 0;
}
break;
case ZMQ_GSSAPI_SERVER:
if (is_int) {
*value = as_server && mechanism == ZMQ_GSSAPI;
return 0;
}
break;
case ZMQ_GSSAPI_CLIENT:
if (is_int) {
*value = (as_server == 0) && mechanism == ZMQ_GSSAPI;
return 0;
}
break;
}
}
errno = EINVAL;
return -1;
}
......@@ -43,6 +43,7 @@
#include "v2_decoder.hpp"
#include "null_mechanism.hpp"
#include "plain_mechanism.hpp"
#include "gssapi_mechanism.hpp"
#include "curve_client.hpp"
#include "curve_server.hpp"
#include "raw_decoder.hpp"
......@@ -477,13 +478,17 @@ bool zmq::stream_engine_t::handshake ()
zmq_assert (options.mechanism == ZMQ_NULL
|| options.mechanism == ZMQ_PLAIN
|| options.mechanism == ZMQ_CURVE);
|| options.mechanism == ZMQ_CURVE
|| options.mechanism == ZMQ_GSSAPI);
if (options.mechanism == ZMQ_NULL)
memcpy (outpos + outsize, "NULL", 4);
else
if (options.mechanism == ZMQ_PLAIN)
memcpy (outpos + outsize, "PLAIN", 5);
else
if (options.mechanism == ZMQ_GSSAPI)
memcpy (outpos + outsize, "GSSAPI", 6);
else
memcpy (outpos + outsize, "CURVE", 5);
outsize += 20;
......@@ -589,6 +594,12 @@ bool zmq::stream_engine_t::handshake ()
alloc_assert (mechanism);
}
#endif
else
if (memcmp (greeting_recv + 12, "GSSAPI\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 20) == 0) {
mechanism = new (std::nothrow)
gssapi_mechanism_t (session, peer_address, options);
alloc_assert (mechanism);
}
else {
error ();
return false;
......
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