Skip to content

Commit 1083ac1

Browse files
namsicjhpark816
authored andcommitted
CLEANUP: Wrap ascii sasl related code in #ifdef ASCII_SASL
1 parent 4c8c531 commit 1083ac1

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

memcached.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7694,6 +7694,7 @@ static void write_and_free(conn *c, char *buf, int bytes)
76947694
c->write_and_go = conn_new_cmd;
76957695
}
76967696

7697+
#ifdef ASCII_SASL
76977698
static bool authenticated_ascii(conn *c, token_t *tokens, const size_t ntokens)
76987699
{
76997700
if (c->authenticated) {
@@ -7733,6 +7734,7 @@ static bool authenticated_ascii(conn *c, token_t *tokens, const size_t ntokens)
77337734
}
77347735
return false;
77357736
}
7737+
#endif
77367738

77377739
#ifdef JHPARK_OLD_SMGET_INTERFACE
77387740
static inline int set_smget_mode_maybe(conn *c, token_t *tokens, size_t ntokens)
@@ -13171,10 +13173,12 @@ static void process_command_ascii(conn *c, char *command, int cmdlen)
1317113173

1317213174
ntokens = tokenize_command(command, cmdlen, tokens, MAX_TOKENS);
1317313175

13176+
#ifdef ASCII_SASL
1317413177
if (settings.require_sasl && !authenticated_ascii(c, tokens, ntokens)) {
1317513178
out_string(c, "CLIENT_ERROR unauthenticated");
1317613179
return;
1317713180
}
13181+
#endif
1317813182

1317913183
if ((ntokens >= 3) && (strcmp(tokens[COMMAND_TOKEN].value, "get") == 0))
1318013184
{
@@ -15145,6 +15149,10 @@ int main (int argc, char **argv)
1514515149
int cache_memory_limit = 0;
1514615150
int sticky_memory_limit = 0;
1514715151

15152+
#ifdef ASCII_SASL
15153+
#else
15154+
bool protocol_specified = false;
15155+
#endif
1514815156
bool tcp_specified = false;
1514915157
bool udp_specified = false;
1515015158

@@ -15357,6 +15365,10 @@ int main (int argc, char **argv)
1535715365
settings.backlog = atoi(optarg);
1535815366
break;
1535915367
case 'B':
15368+
#ifdef ASCII_SASL
15369+
#else
15370+
protocol_specified = true;
15371+
#endif
1536015372
if (strcmp(optarg, "auto") == 0) {
1536115373
settings.binding_protocol = negotiating_prot;
1536215374
} else if (strcmp(optarg, "binary") == 0) {
@@ -15481,6 +15493,26 @@ int main (int argc, char **argv)
1548115493
}
1548215494
}
1548315495

15496+
#ifdef ASCII_SASL
15497+
#else
15498+
if (settings.require_sasl) {
15499+
if (!protocol_specified) {
15500+
settings.binding_protocol = binary_prot;
15501+
} else {
15502+
if (settings.binding_protocol == negotiating_prot) {
15503+
mc_logger->log(EXTENSION_LOG_WARNING, NULL,
15504+
"ERROR: You cannot use auto-negotiating protocol while requiring SASL.\n");
15505+
exit(EX_USAGE);
15506+
}
15507+
if (settings.binding_protocol == ascii_prot) {
15508+
mc_logger->log(EXTENSION_LOG_WARNING, NULL,
15509+
"ERROR: You cannot use only ASCII protocol while requiring SASL.\n");
15510+
exit(EX_USAGE);
15511+
}
15512+
}
15513+
}
15514+
#endif
15515+
1548415516
if (udp_specified && settings.udpport != 0 && !tcp_specified) {
1548515517
settings.port = settings.udpport;
1548615518
}

0 commit comments

Comments
 (0)