summaryrefslogtreecommitdiff
path: root/sasl_defs.c
diff options
context:
space:
mode:
authorDustin Sallings <dustin@spy.net>2012-01-27 23:32:20 -0800
committerDustin Sallings <dustin@spy.net>2012-01-27 23:53:33 -0800
commitb0a858ce63817f1360428674630307c4568b614c (patch)
treed232ef41eba0c96c8d35790b7cf62494e903f52c /sasl_defs.c
parent39d59a902135188359027762e804a9560222e52b (diff)
downloadmemcached-b0a858ce63817f1360428674630307c4568b614c.tar.gz
Specify hostname in sasl_server_new.
saslpasswd2 does something a little magical when initializing the structure that's different from what happens if you just pass NULL. The magic is too great for the tests as is, so this code does the same thing saslpasswd2 does to determine the fqdn.
Diffstat (limited to 'sasl_defs.c')
-rw-r--r--sasl_defs.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/sasl_defs.c b/sasl_defs.c
index 0f405d0..7922f66 100644
--- a/sasl_defs.c
+++ b/sasl_defs.c
@@ -5,6 +5,8 @@
#include <string.h>
#include <sasl/saslplug.h>
+char my_sasl_hostname[1025];
+
#ifdef HAVE_SASL_CB_GETCONF
/* The locations we may search for a SASL config file if the user didn't
* specify one in the environment variable SASL_CONF_PATH
@@ -169,6 +171,14 @@ void init_sasl(void) {
}
#endif
+ memset(my_sasl_hostname, 0, sizeof(my_sasl_hostname));
+ if (gethostname(my_sasl_hostname, sizeof(my_sasl_hostname)-1) == -1) {
+ if (settings.verbose) {
+ fprintf(stderr, "Error discovering hostname for SASL\n");
+ }
+ my_sasl_hostname[0] = '\0';
+ }
+
if (sasl_server_init(sasl_callbacks, "memcached") != SASL_OK) {
fprintf(stderr, "Error initializing sasl.\n");
exit(EXIT_FAILURE);