projects
/
m6w6
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Fix exists.
[m6w6/libmemcached]
/
libmemcached
/
sasl.cc
diff --git
a/libmemcached/sasl.cc
b/libmemcached/sasl.cc
index 3aefb701f9bfd93cb0fa343f3cf7feeff5752f4c..3d93b78686b880f7cc20b4376565191f5b783eab 100644
(file)
--- a/
libmemcached/sasl.cc
+++ b/
libmemcached/sasl.cc
@@
-40,7
+40,10
@@
#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT
#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT
+#if defined(HAVE_LIBSASL) && HAVE_LIBSASL
#include <sasl/sasl.h>
#include <sasl/sasl.h>
+#endif
+
#include <pthread.h>
void memcached_set_sasl_callbacks(memcached_st *ptr,
#include <pthread.h>
void memcached_set_sasl_callbacks(memcached_st *ptr,
@@
-62,7
+65,7
@@
sasl_callback_t *memcached_get_sasl_callbacks(memcached_st *ptr)
* @param raddr remote address (out)
* @return true on success false otherwise (errno contains more info)
*/
* @param raddr remote address (out)
* @return true on success false otherwise (errno contains more info)
*/
-static memcached_return_t resolve_names(memcached_
server
_st& server, char *laddr, size_t laddr_length, char *raddr, size_t raddr_length)
+static memcached_return_t resolve_names(memcached_
instance
_st& server, char *laddr, size_t laddr_length, char *raddr, size_t raddr_length)
{
char host[NI_MAXHOST];
char port[NI_MAXSERV];
{
char host[NI_MAXHOST];
char port[NI_MAXSERV];
@@
-120,7
+123,7
@@
static void sasl_startup_function(void)
} // extern "C"
} // extern "C"
-memcached_return_t memcached_sasl_authenticate_connection(memcached_
server
_st *server)
+memcached_return_t memcached_sasl_authenticate_connection(memcached_
instance
_st *server)
{
if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
{
{
if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
{
@@
-133,9
+136,10
@@
memcached_return_t memcached_sasl_authenticate_connection(memcached_server_st *s
}
/* SANITY CHECK: SASL can only be used with the binary protocol */
}
/* SANITY CHECK: SASL can only be used with the binary protocol */
- if (
server->root->flags.binary_protocol
== false)
+ if (
memcached_is_binary(server->root)
== false)
{
{
- return MEMCACHED_PROTOCOL_ERROR;
+ return memcached_set_error(*server, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
+ memcached_literal_param("memcached_sasl_authenticate_connection() is not supported via the ASCII protocol"));
}
/* Try to get the supported mech from the server. Servers without SASL
}
/* Try to get the supported mech from the server. Servers without SASL
@@
-143,7
+147,9
@@
memcached_return_t memcached_sasl_authenticate_connection(memcached_server_st *s
* as authenticated
*/
protocol_binary_request_no_extras request= { };
* as authenticated
*/
protocol_binary_request_no_extras request= { };
- request.message.header.request.magic= PROTOCOL_BINARY_REQ;
+
+ initialize_binary_request(ptr, request.message.header);
+
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_SASL_LIST_MECHS;
if (memcached_io_write(server, request.bytes,
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_SASL_LIST_MECHS;
if (memcached_io_write(server, request.bytes,
@@
-229,14
+235,14
@@
memcached_return_t memcached_sasl_authenticate_connection(memcached_server_st *s
do {
/* send the packet */
do {
/* send the packet */
-
struct
libmemcached_io_vector_st vector[]=
+ libmemcached_io_vector_st vector[]=
{
{
- {
sizeof(request.bytes), request.bytes
},
- {
keylen, chosenmech
},
- {
len, data
}
+ {
request.bytes, sizeof(request.bytes)
},
+ {
chosenmech, keylen
},
+ {
data, len
}
};
};
- if (memcached_io_writev(server, vector, 3, true) ==
-1
)
+ if (memcached_io_writev(server, vector, 3, true) ==
false
)
{
rc= MEMCACHED_WRITE_FAILURE;
break;
{
rc= MEMCACHED_WRITE_FAILURE;
break;
@@
-321,7
+327,7
@@
memcached_return_t memcached_set_sasl_auth_data(memcached_st *ptr,
memcached_destroy_sasl_auth_data(ptr);
memcached_destroy_sasl_auth_data(ptr);
- sasl_callback_t *callbacks=
(sasl_callback_t*)libmemcached_calloc(ptr, 4, sizeof(sasl_callback_t)
);
+ sasl_callback_t *callbacks=
libmemcached_xcalloc(ptr, 4, sasl_callback_t
);
size_t password_length= strlen(password);
size_t username_length= strlen(username);
char *name= (char *)libmemcached_malloc(ptr, username_length +1);
size_t password_length= strlen(password);
size_t username_length= strlen(username);
char *name= (char *)libmemcached_malloc(ptr, username_length +1);
@@
-423,7
+429,7
@@
memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st
* into the list, but if we don't know the ID we don't know how to handle
* the context...
*/
* into the list, but if we don't know the ID we don't know how to handle
* the context...
*/
-
size
_t total= 0;
+
ptrdiff
_t total= 0;
while (source->sasl.callbacks[total].id != SASL_CB_LIST_END)
{
while (source->sasl.callbacks[total].id != SASL_CB_LIST_END)
{
@@
-441,7
+447,7
@@
memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st
++total;
}
++total;
}
- sasl_callback_t *callbacks=
(sasl_callback_t*)libmemcached_calloc(clone, total +1, sizeof(sasl_callback_t)
);
+ sasl_callback_t *callbacks=
libmemcached_xcalloc(clone, total +1, sasl_callback_t
);
if (callbacks == NULL)
{
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
if (callbacks == NULL)
{
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
@@
-449,7
+455,7
@@
memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st
memcpy(callbacks, source->sasl.callbacks, (total + 1) * sizeof(sasl_callback_t));
/* Now update the context... */
memcpy(callbacks, source->sasl.callbacks, (total + 1) * sizeof(sasl_callback_t));
/* Now update the context... */
- for (
size
_t x= 0; x < total; ++x)
+ for (
ptrdiff
_t x= 0; x < total; ++x)
{
if (callbacks[x].id == SASL_CB_USER || callbacks[x].id == SASL_CB_AUTHNAME)
{
{
if (callbacks[x].id == SASL_CB_USER || callbacks[x].id == SASL_CB_AUTHNAME)
{
@@
-458,7
+464,7
@@
memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st
if (callbacks[x].context == NULL)
{
/* Failed to allocate memory, clean up previously allocated memory */
if (callbacks[x].context == NULL)
{
/* Failed to allocate memory, clean up previously allocated memory */
- for (
size
_t y= 0; y < x; ++y)
+ for (
ptrdiff
_t y= 0; y < x; ++y)
{
libmemcached_free(clone, clone->sasl.callbacks[y].context);
}
{
libmemcached_free(clone, clone->sasl.callbacks[y].context);
}
@@
-475,7
+481,7
@@
memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st
if (n == NULL)
{
/* Failed to allocate memory, clean up previously allocated memory */
if (n == NULL)
{
/* Failed to allocate memory, clean up previously allocated memory */
- for (
size
_t y= 0; y < x; ++y)
+ for (
ptrdiff
_t y= 0; y < x; ++y)
{
libmemcached_free(clone, clone->sasl.callbacks[y].context);
}
{
libmemcached_free(clone, clone->sasl.callbacks[y].context);
}