Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
f44300cb
Commit
f44300cb
authored
Mar 29, 2017
by
evoskuil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: assert used for ZAP error handling aborts process.
parent
a6d03df3
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
95 additions
and
50 deletions
+95
-50
curve_server.cpp
src/curve_server.cpp
+23
-11
curve_server.hpp
src/curve_server.hpp
+1
-1
gssapi_server.cpp
src/gssapi_server.cpp
+22
-10
gssapi_server.hpp
src/gssapi_server.hpp
+1
-1
null_mechanism.cpp
src/null_mechanism.cpp
+21
-10
null_mechanism.hpp
src/null_mechanism.hpp
+1
-1
plain_server.cpp
src/plain_server.cpp
+24
-11
plain_server.hpp
src/plain_server.hpp
+1
-1
session_base.cpp
src/session_base.cpp
+1
-4
No files found.
src/curve_server.cpp
View file @
f44300cb
...
@@ -311,7 +311,7 @@ int zmq::curve_server_t::process_hello (msg_t *msg_)
...
@@ -311,7 +311,7 @@ int zmq::curve_server_t::process_hello (msg_t *msg_)
hello_nonce
,
cn_client
,
secret_key
);
hello_nonce
,
cn_client
,
secret_key
);
if
(
rc
!=
0
)
{
if
(
rc
!=
0
)
{
// Temporary support for security debugging
// Temporary support for security debugging
puts
(
"CURVE I: cannot open client HELLO -- wrong server key?"
);
puts
(
"CURVE I: cannot open client HELLO -- wrong server key?"
);
errno
=
EPROTO
;
errno
=
EPROTO
;
return
-
1
;
return
-
1
;
}
}
...
@@ -492,7 +492,9 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
...
@@ -492,7 +492,9 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
// Use ZAP protocol (RFC 27) to authenticate the user.
// Use ZAP protocol (RFC 27) to authenticate the user.
rc
=
session
->
zap_connect
();
rc
=
session
->
zap_connect
();
if
(
rc
==
0
)
{
if
(
rc
==
0
)
{
send_zap_request
(
client_key
);
rc
=
send_zap_request
(
client_key
);
if
(
rc
!=
0
)
return
-
1
;
rc
=
receive_and_process_zap_reply
();
rc
=
receive_and_process_zap_reply
();
if
(
rc
==
0
)
if
(
rc
==
0
)
state
=
status_code
==
"200"
state
=
status_code
==
"200"
...
@@ -569,7 +571,7 @@ int zmq::curve_server_t::produce_error (msg_t *msg_) const
...
@@ -569,7 +571,7 @@ int zmq::curve_server_t::produce_error (msg_t *msg_) const
return
0
;
return
0
;
}
}
void
zmq
::
curve_server_t
::
send_zap_request
(
const
uint8_t
*
key
)
int
zmq
::
curve_server_t
::
send_zap_request
(
const
uint8_t
*
key
)
{
{
int
rc
;
int
rc
;
msg_t
msg
;
msg_t
msg
;
...
@@ -579,7 +581,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
...
@@ -579,7 +581,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
errno_assert
(
rc
==
0
);
errno_assert
(
rc
==
0
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Version frame
// Version frame
rc
=
msg
.
init_size
(
3
);
rc
=
msg
.
init_size
(
3
);
...
@@ -587,7 +590,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
...
@@ -587,7 +590,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
memcpy
(
msg
.
data
(),
"1.0"
,
3
);
memcpy
(
msg
.
data
(),
"1.0"
,
3
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Request ID frame
// Request ID frame
rc
=
msg
.
init_size
(
1
);
rc
=
msg
.
init_size
(
1
);
...
@@ -595,7 +599,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
...
@@ -595,7 +599,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
memcpy
(
msg
.
data
(),
"1"
,
1
);
memcpy
(
msg
.
data
(),
"1"
,
1
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Domain frame
// Domain frame
rc
=
msg
.
init_size
(
options
.
zap_domain
.
length
());
rc
=
msg
.
init_size
(
options
.
zap_domain
.
length
());
...
@@ -603,7 +608,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
...
@@ -603,7 +608,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
memcpy
(
msg
.
data
(),
options
.
zap_domain
.
c_str
(),
options
.
zap_domain
.
length
());
memcpy
(
msg
.
data
(),
options
.
zap_domain
.
c_str
(),
options
.
zap_domain
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Address frame
// Address frame
rc
=
msg
.
init_size
(
peer_address
.
length
());
rc
=
msg
.
init_size
(
peer_address
.
length
());
...
@@ -611,7 +617,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
...
@@ -611,7 +617,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
memcpy
(
msg
.
data
(),
peer_address
.
c_str
(),
peer_address
.
length
());
memcpy
(
msg
.
data
(),
peer_address
.
c_str
(),
peer_address
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Identity frame
// Identity frame
rc
=
msg
.
init_size
(
options
.
identity_size
);
rc
=
msg
.
init_size
(
options
.
identity_size
);
...
@@ -619,7 +626,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
...
@@ -619,7 +626,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
memcpy
(
msg
.
data
(),
options
.
identity
,
options
.
identity_size
);
memcpy
(
msg
.
data
(),
options
.
identity
,
options
.
identity_size
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Mechanism frame
// Mechanism frame
rc
=
msg
.
init_size
(
5
);
rc
=
msg
.
init_size
(
5
);
...
@@ -627,14 +635,18 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
...
@@ -627,14 +635,18 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
memcpy
(
msg
.
data
(),
"CURVE"
,
5
);
memcpy
(
msg
.
data
(),
"CURVE"
,
5
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Credentials frame
// Credentials frame
rc
=
msg
.
init_size
(
crypto_box_PUBLICKEYBYTES
);
rc
=
msg
.
init_size
(
crypto_box_PUBLICKEYBYTES
);
errno_assert
(
rc
==
0
);
errno_assert
(
rc
==
0
);
memcpy
(
msg
.
data
(),
key
,
crypto_box_PUBLICKEYBYTES
);
memcpy
(
msg
.
data
(),
key
,
crypto_box_PUBLICKEYBYTES
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
return
0
;
}
}
int
zmq
::
curve_server_t
::
receive_and_process_zap_reply
()
int
zmq
::
curve_server_t
::
receive_and_process_zap_reply
()
...
...
src/curve_server.hpp
View file @
f44300cb
...
@@ -125,7 +125,7 @@ namespace zmq
...
@@ -125,7 +125,7 @@ namespace zmq
int
produce_ready
(
msg_t
*
msg_
);
int
produce_ready
(
msg_t
*
msg_
);
int
produce_error
(
msg_t
*
msg_
)
const
;
int
produce_error
(
msg_t
*
msg_
)
const
;
void
send_zap_request
(
const
uint8_t
*
key
);
int
send_zap_request
(
const
uint8_t
*
key
);
int
receive_and_process_zap_reply
();
int
receive_and_process_zap_reply
();
};
};
...
...
src/gssapi_server.cpp
View file @
f44300cb
...
@@ -123,7 +123,9 @@ int zmq::gssapi_server_t::process_handshake_command (msg_t *msg_)
...
@@ -123,7 +123,9 @@ int zmq::gssapi_server_t::process_handshake_command (msg_t *msg_)
bool
expecting_zap_reply
=
false
;
bool
expecting_zap_reply
=
false
;
int
rc
=
session
->
zap_connect
();
int
rc
=
session
->
zap_connect
();
if
(
rc
==
0
)
{
if
(
rc
==
0
)
{
send_zap_request
();
rc
=
send_zap_request
();
if
(
rc
!=
0
)
return
-
1
;
rc
=
receive_and_process_zap_reply
();
rc
=
receive_and_process_zap_reply
();
if
(
rc
!=
0
)
{
if
(
rc
!=
0
)
{
if
(
errno
!=
EAGAIN
)
if
(
errno
!=
EAGAIN
)
...
@@ -147,7 +149,7 @@ int zmq::gssapi_server_t::process_handshake_command (msg_t *msg_)
...
@@ -147,7 +149,7 @@ int zmq::gssapi_server_t::process_handshake_command (msg_t *msg_)
return
0
;
return
0
;
}
}
void
zmq
::
gssapi_server_t
::
send_zap_request
()
int
zmq
::
gssapi_server_t
::
send_zap_request
()
{
{
int
rc
;
int
rc
;
msg_t
msg
;
msg_t
msg
;
...
@@ -157,7 +159,8 @@ void zmq::gssapi_server_t::send_zap_request ()
...
@@ -157,7 +159,8 @@ void zmq::gssapi_server_t::send_zap_request ()
errno_assert
(
rc
==
0
);
errno_assert
(
rc
==
0
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Version frame
// Version frame
rc
=
msg
.
init_size
(
3
);
rc
=
msg
.
init_size
(
3
);
...
@@ -165,7 +168,8 @@ void zmq::gssapi_server_t::send_zap_request ()
...
@@ -165,7 +168,8 @@ void zmq::gssapi_server_t::send_zap_request ()
memcpy
(
msg
.
data
(),
"1.0"
,
3
);
memcpy
(
msg
.
data
(),
"1.0"
,
3
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Request ID frame
// Request ID frame
rc
=
msg
.
init_size
(
1
);
rc
=
msg
.
init_size
(
1
);
...
@@ -173,7 +177,8 @@ void zmq::gssapi_server_t::send_zap_request ()
...
@@ -173,7 +177,8 @@ void zmq::gssapi_server_t::send_zap_request ()
memcpy
(
msg
.
data
(),
"1"
,
1
);
memcpy
(
msg
.
data
(),
"1"
,
1
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Domain frame
// Domain frame
rc
=
msg
.
init_size
(
options
.
zap_domain
.
length
());
rc
=
msg
.
init_size
(
options
.
zap_domain
.
length
());
...
@@ -181,7 +186,8 @@ void zmq::gssapi_server_t::send_zap_request ()
...
@@ -181,7 +186,8 @@ void zmq::gssapi_server_t::send_zap_request ()
memcpy
(
msg
.
data
(),
options
.
zap_domain
.
c_str
(),
options
.
zap_domain
.
length
());
memcpy
(
msg
.
data
(),
options
.
zap_domain
.
c_str
(),
options
.
zap_domain
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Address frame
// Address frame
rc
=
msg
.
init_size
(
peer_address
.
length
());
rc
=
msg
.
init_size
(
peer_address
.
length
());
...
@@ -189,7 +195,8 @@ void zmq::gssapi_server_t::send_zap_request ()
...
@@ -189,7 +195,8 @@ void zmq::gssapi_server_t::send_zap_request ()
memcpy
(
msg
.
data
(),
peer_address
.
c_str
(),
peer_address
.
length
());
memcpy
(
msg
.
data
(),
peer_address
.
c_str
(),
peer_address
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Identity frame
// Identity frame
rc
=
msg
.
init_size
(
options
.
identity_size
);
rc
=
msg
.
init_size
(
options
.
identity_size
);
...
@@ -197,7 +204,8 @@ void zmq::gssapi_server_t::send_zap_request ()
...
@@ -197,7 +204,8 @@ void zmq::gssapi_server_t::send_zap_request ()
memcpy
(
msg
.
data
(),
options
.
identity
,
options
.
identity_size
);
memcpy
(
msg
.
data
(),
options
.
identity
,
options
.
identity_size
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Mechanism frame
// Mechanism frame
rc
=
msg
.
init_size
(
6
);
rc
=
msg
.
init_size
(
6
);
...
@@ -205,7 +213,8 @@ void zmq::gssapi_server_t::send_zap_request ()
...
@@ -205,7 +213,8 @@ void zmq::gssapi_server_t::send_zap_request ()
memcpy
(
msg
.
data
(),
"GSSAPI"
,
6
);
memcpy
(
msg
.
data
(),
"GSSAPI"
,
6
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Principal frame
// Principal frame
gss_buffer_desc
principal
;
gss_buffer_desc
principal
;
...
@@ -215,8 +224,11 @@ void zmq::gssapi_server_t::send_zap_request ()
...
@@ -215,8 +224,11 @@ void zmq::gssapi_server_t::send_zap_request ()
errno_assert
(
rc
==
0
);
errno_assert
(
rc
==
0
);
memcpy
(
msg
.
data
(),
principal
.
value
,
principal
.
length
);
memcpy
(
msg
.
data
(),
principal
.
value
,
principal
.
length
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
gss_release_buffer
(
&
min_stat
,
&
principal
);
gss_release_buffer
(
&
min_stat
,
&
principal
);
if
(
rc
!=
0
)
return
-
1
;
return
0
;
}
}
int
zmq
::
gssapi_server_t
::
receive_and_process_zap_reply
()
int
zmq
::
gssapi_server_t
::
receive_and_process_zap_reply
()
...
...
src/gssapi_server.hpp
View file @
f44300cb
...
@@ -85,7 +85,7 @@ namespace zmq
...
@@ -85,7 +85,7 @@ namespace zmq
void
accept_context
();
void
accept_context
();
int
produce_next_token
(
msg_t
*
msg_
);
int
produce_next_token
(
msg_t
*
msg_
);
int
process_next_token
(
msg_t
*
msg_
);
int
process_next_token
(
msg_t
*
msg_
);
void
send_zap_request
();
int
send_zap_request
();
int
receive_and_process_zap_reply
();
int
receive_and_process_zap_reply
();
};
};
...
...
src/null_mechanism.cpp
View file @
f44300cb
...
@@ -75,9 +75,11 @@ int zmq::null_mechanism_t::next_handshake_command (msg_t *msg_)
...
@@ -75,9 +75,11 @@ int zmq::null_mechanism_t::next_handshake_command (msg_t *msg_)
errno
=
EAGAIN
;
errno
=
EAGAIN
;
return
-
1
;
return
-
1
;
}
}
send_zap_request
();
int
rc
=
send_zap_request
();
if
(
rc
!=
0
)
return
-
1
;
zap_request_sent
=
true
;
zap_request_sent
=
true
;
const
int
rc
=
receive_and_process_zap_reply
();
rc
=
receive_and_process_zap_reply
();
if
(
rc
!=
0
)
if
(
rc
!=
0
)
return
-
1
;
return
-
1
;
zap_reply_received
=
true
;
zap_reply_received
=
true
;
...
@@ -212,7 +214,7 @@ zmq::mechanism_t::status_t zmq::null_mechanism_t::status () const
...
@@ -212,7 +214,7 @@ zmq::mechanism_t::status_t zmq::null_mechanism_t::status () const
return
handshaking
;
return
handshaking
;
}
}
void
zmq
::
null_mechanism_t
::
send_zap_request
()
int
zmq
::
null_mechanism_t
::
send_zap_request
()
{
{
int
rc
;
int
rc
;
msg_t
msg
;
msg_t
msg
;
...
@@ -222,7 +224,8 @@ void zmq::null_mechanism_t::send_zap_request ()
...
@@ -222,7 +224,8 @@ void zmq::null_mechanism_t::send_zap_request ()
errno_assert
(
rc
==
0
);
errno_assert
(
rc
==
0
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Version frame
// Version frame
rc
=
msg
.
init_size
(
3
);
rc
=
msg
.
init_size
(
3
);
...
@@ -230,7 +233,8 @@ void zmq::null_mechanism_t::send_zap_request ()
...
@@ -230,7 +233,8 @@ void zmq::null_mechanism_t::send_zap_request ()
memcpy
(
msg
.
data
(),
"1.0"
,
3
);
memcpy
(
msg
.
data
(),
"1.0"
,
3
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Request id frame
// Request id frame
rc
=
msg
.
init_size
(
1
);
rc
=
msg
.
init_size
(
1
);
...
@@ -238,7 +242,8 @@ void zmq::null_mechanism_t::send_zap_request ()
...
@@ -238,7 +242,8 @@ void zmq::null_mechanism_t::send_zap_request ()
memcpy
(
msg
.
data
(),
"1"
,
1
);
memcpy
(
msg
.
data
(),
"1"
,
1
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Domain frame
// Domain frame
rc
=
msg
.
init_size
(
options
.
zap_domain
.
length
());
rc
=
msg
.
init_size
(
options
.
zap_domain
.
length
());
...
@@ -246,7 +251,8 @@ void zmq::null_mechanism_t::send_zap_request ()
...
@@ -246,7 +251,8 @@ void zmq::null_mechanism_t::send_zap_request ()
memcpy
(
msg
.
data
(),
options
.
zap_domain
.
c_str
(),
options
.
zap_domain
.
length
());
memcpy
(
msg
.
data
(),
options
.
zap_domain
.
c_str
(),
options
.
zap_domain
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Address frame
// Address frame
rc
=
msg
.
init_size
(
peer_address
.
length
());
rc
=
msg
.
init_size
(
peer_address
.
length
());
...
@@ -254,7 +260,8 @@ void zmq::null_mechanism_t::send_zap_request ()
...
@@ -254,7 +260,8 @@ void zmq::null_mechanism_t::send_zap_request ()
memcpy
(
msg
.
data
(),
peer_address
.
c_str
(),
peer_address
.
length
());
memcpy
(
msg
.
data
(),
peer_address
.
c_str
(),
peer_address
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Identity frame
// Identity frame
rc
=
msg
.
init_size
(
options
.
identity_size
);
rc
=
msg
.
init_size
(
options
.
identity_size
);
...
@@ -262,14 +269,18 @@ void zmq::null_mechanism_t::send_zap_request ()
...
@@ -262,14 +269,18 @@ void zmq::null_mechanism_t::send_zap_request ()
memcpy
(
msg
.
data
(),
options
.
identity
,
options
.
identity_size
);
memcpy
(
msg
.
data
(),
options
.
identity
,
options
.
identity_size
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Mechanism frame
// Mechanism frame
rc
=
msg
.
init_size
(
4
);
rc
=
msg
.
init_size
(
4
);
errno_assert
(
rc
==
0
);
errno_assert
(
rc
==
0
);
memcpy
(
msg
.
data
(),
"NULL"
,
4
);
memcpy
(
msg
.
data
(),
"NULL"
,
4
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
return
0
;
}
}
int
zmq
::
null_mechanism_t
::
receive_and_process_zap_reply
()
int
zmq
::
null_mechanism_t
::
receive_and_process_zap_reply
()
...
...
src/null_mechanism.hpp
View file @
f44300cb
...
@@ -75,7 +75,7 @@ namespace zmq
...
@@ -75,7 +75,7 @@ namespace zmq
int
process_error_command
(
int
process_error_command
(
const
unsigned
char
*
cmd_data
,
size_t
data_size
);
const
unsigned
char
*
cmd_data
,
size_t
data_size
);
void
send_zap_request
();
int
send_zap_request
();
int
receive_and_process_zap_reply
();
int
receive_and_process_zap_reply
();
};
};
...
...
src/plain_server.cpp
View file @
f44300cb
...
@@ -191,7 +191,9 @@ int zmq::plain_server_t::process_hello (msg_t *msg_)
...
@@ -191,7 +191,9 @@ int zmq::plain_server_t::process_hello (msg_t *msg_)
// Use ZAP protocol (RFC 27) to authenticate the user.
// Use ZAP protocol (RFC 27) to authenticate the user.
int
rc
=
session
->
zap_connect
();
int
rc
=
session
->
zap_connect
();
if
(
rc
==
0
)
{
if
(
rc
==
0
)
{
send_zap_request
(
username
,
password
);
rc
=
send_zap_request
(
username
,
password
);
if
(
rc
!=
0
)
return
-
1
;
rc
=
receive_and_process_zap_reply
();
rc
=
receive_and_process_zap_reply
();
if
(
rc
==
0
)
if
(
rc
==
0
)
state
=
status_code
==
"200"
state
=
status_code
==
"200"
...
@@ -277,7 +279,7 @@ int zmq::plain_server_t::produce_error (msg_t *msg_) const
...
@@ -277,7 +279,7 @@ int zmq::plain_server_t::produce_error (msg_t *msg_) const
return
0
;
return
0
;
}
}
void
zmq
::
plain_server_t
::
send_zap_request
(
const
std
::
string
&
username
,
int
zmq
::
plain_server_t
::
send_zap_request
(
const
std
::
string
&
username
,
const
std
::
string
&
password
)
const
std
::
string
&
password
)
{
{
int
rc
;
int
rc
;
...
@@ -288,7 +290,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
...
@@ -288,7 +290,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
errno_assert
(
rc
==
0
);
errno_assert
(
rc
==
0
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Version frame
// Version frame
rc
=
msg
.
init_size
(
3
);
rc
=
msg
.
init_size
(
3
);
...
@@ -296,7 +299,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
...
@@ -296,7 +299,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
memcpy
(
msg
.
data
(),
"1.0"
,
3
);
memcpy
(
msg
.
data
(),
"1.0"
,
3
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Request id frame
// Request id frame
rc
=
msg
.
init_size
(
1
);
rc
=
msg
.
init_size
(
1
);
...
@@ -304,7 +308,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
...
@@ -304,7 +308,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
memcpy
(
msg
.
data
(),
"1"
,
1
);
memcpy
(
msg
.
data
(),
"1"
,
1
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Domain frame
// Domain frame
rc
=
msg
.
init_size
(
options
.
zap_domain
.
length
());
rc
=
msg
.
init_size
(
options
.
zap_domain
.
length
());
...
@@ -312,7 +317,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
...
@@ -312,7 +317,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
memcpy
(
msg
.
data
(),
options
.
zap_domain
.
c_str
(),
options
.
zap_domain
.
length
());
memcpy
(
msg
.
data
(),
options
.
zap_domain
.
c_str
(),
options
.
zap_domain
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Address frame
// Address frame
rc
=
msg
.
init_size
(
peer_address
.
length
());
rc
=
msg
.
init_size
(
peer_address
.
length
());
...
@@ -320,7 +326,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
...
@@ -320,7 +326,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
memcpy
(
msg
.
data
(),
peer_address
.
c_str
(),
peer_address
.
length
());
memcpy
(
msg
.
data
(),
peer_address
.
c_str
(),
peer_address
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Identity frame
// Identity frame
rc
=
msg
.
init_size
(
options
.
identity_size
);
rc
=
msg
.
init_size
(
options
.
identity_size
);
...
@@ -328,7 +335,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
...
@@ -328,7 +335,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
memcpy
(
msg
.
data
(),
options
.
identity
,
options
.
identity_size
);
memcpy
(
msg
.
data
(),
options
.
identity
,
options
.
identity_size
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Mechanism frame
// Mechanism frame
rc
=
msg
.
init_size
(
5
);
rc
=
msg
.
init_size
(
5
);
...
@@ -336,7 +344,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
...
@@ -336,7 +344,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
memcpy
(
msg
.
data
(),
"PLAIN"
,
5
);
memcpy
(
msg
.
data
(),
"PLAIN"
,
5
);
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Username frame
// Username frame
rc
=
msg
.
init_size
(
username
.
length
());
rc
=
msg
.
init_size
(
username
.
length
());
...
@@ -344,14 +353,18 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
...
@@ -344,14 +353,18 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
memcpy
(
msg
.
data
(),
username
.
c_str
(),
username
.
length
());
memcpy
(
msg
.
data
(),
username
.
c_str
(),
username
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Password frame
// Password frame
rc
=
msg
.
init_size
(
password
.
length
());
rc
=
msg
.
init_size
(
password
.
length
());
errno_assert
(
rc
==
0
);
errno_assert
(
rc
==
0
);
memcpy
(
msg
.
data
(),
password
.
c_str
(),
password
.
length
());
memcpy
(
msg
.
data
(),
password
.
c_str
(),
password
.
length
());
rc
=
session
->
write_zap_msg
(
&
msg
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
return
0
;
}
}
int
zmq
::
plain_server_t
::
receive_and_process_zap_reply
()
int
zmq
::
plain_server_t
::
receive_and_process_zap_reply
()
...
...
src/plain_server.hpp
View file @
f44300cb
...
@@ -83,7 +83,7 @@ namespace zmq
...
@@ -83,7 +83,7 @@ namespace zmq
int
process_hello
(
msg_t
*
msg_
);
int
process_hello
(
msg_t
*
msg_
);
int
process_initiate
(
msg_t
*
msg_
);
int
process_initiate
(
msg_t
*
msg_
);
void
send_zap_request
(
const
std
::
string
&
username
,
int
send_zap_request
(
const
std
::
string
&
username
,
const
std
::
string
&
password
);
const
std
::
string
&
password
);
int
receive_and_process_zap_reply
();
int
receive_and_process_zap_reply
();
};
};
...
...
src/session_base.cpp
View file @
f44300cb
...
@@ -183,14 +183,11 @@ int zmq::session_base_t::read_zap_msg (msg_t *msg_)
...
@@ -183,14 +183,11 @@ int zmq::session_base_t::read_zap_msg (msg_t *msg_)
int
zmq
::
session_base_t
::
write_zap_msg
(
msg_t
*
msg_
)
int
zmq
::
session_base_t
::
write_zap_msg
(
msg_t
*
msg_
)
{
{
if
(
zap_pipe
==
NULL
)
{
if
(
zap_pipe
==
NULL
||
!
zap_pipe
->
write
(
msg_
)
)
{
errno
=
ENOTCONN
;
errno
=
ENOTCONN
;
return
-
1
;
return
-
1
;
}
}
const
bool
ok
=
zap_pipe
->
write
(
msg_
);
zmq_assert
(
ok
);
if
((
msg_
->
flags
()
&
msg_t
::
more
)
==
0
)
if
((
msg_
->
flags
()
&
msg_t
::
more
)
==
0
)
zap_pipe
->
flush
();
zap_pipe
->
flush
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment