Merge in fixes for SASL.
[awesomized/libmemcached] / clients / memcp.cc
index 3869242b171c8cff803dda17624d4c3b0606bee2..2a73390bad50eb771c069cd45aa9864e3653b9e6 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "config.h"
 
+#include <iostream>
 #include <stdio.h>
 #include <stdlib.h>
 #include <inttypes.h>
@@ -114,8 +115,17 @@ int main(int argc, char *argv[])
   memcached_server_list_free(servers);
   memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
                          (uint64_t)opt_binary);
-  if (!initialize_sasl(memc, opt_username, opt_passwd))
+
+  if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+  {
+    memcached_free(memc);
+    std::cerr << "--username was supplied, but binary was not built with SASL support." << std::endl;
+    return EXIT_FAILURE;
+  }
+
+  if (initialize_sasl(memc, opt_username, opt_passwd) == false)
   {
+    std::cerr << "Failed to initialize SASL support." << std::endl;
     memcached_free(memc);
     return EXIT_FAILURE;
   }