* Brian Aker
* Toru Maesaka
*/
-#include <config.h>
+#include <mem_config.h>
#include <cstdio>
#include <cstring>
static char *opt_servers= NULL;
static char *stat_args= NULL;
static char *analyze_mode= NULL;
+static char *opt_username;
+static char *opt_passwd;
static struct option long_options[]=
{
{(OPTIONSTRING)"server-version", no_argument, NULL, OPT_SERVER_VERSION},
{(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS},
{(OPTIONSTRING)"analyze", optional_argument, NULL, OPT_ANALYZE},
+ {(OPTIONSTRING)"username", required_argument, NULL, OPT_USERNAME},
+ {(OPTIONSTRING)"password", required_argument, NULL, OPT_PASSWD},
{0, 0, 0, 0},
};
memcached_return_t rc= memcached_server_push(memc, servers);
memcached_server_list_free(servers);
+ 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 (opt_username)
+ {
+ memcached_return_t ret;
+ if (memcached_failed(ret= memcached_set_sasl_auth_data(memc, opt_username, opt_passwd)))
+ {
+ std::cerr << memcached_last_error_message(memc) << std::endl;
+ memcached_free(memc);
+ return EXIT_FAILURE;
+ }
+ }
+
if (rc != MEMCACHED_SUCCESS and rc != MEMCACHED_SOME_ERRORS)
{
printf("Failure to communicate with servers (%s)\n",
close_stdio();
break;
+ case OPT_USERNAME:
+ opt_username= optarg;
+ opt_binary= true;
+ break;
+
+ case OPT_PASSWD:
+ opt_passwd= optarg;
+ break;
+
case '?':
/* getopt_long already printed an error message. */
exit(1);