-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
INTERNAL: Make the -S option available with ascii protocol #819
Merged
+46
โ35
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7693,6 +7693,46 @@ static void write_and_free(conn *c, char *buf, int bytes) | |
c->write_and_go = conn_new_cmd; | ||
} | ||
|
||
static bool authenticated_ascii(conn *c, token_t *tokens, const size_t ntokens) | ||
{ | ||
if (c->authenticated) { | ||
return true; | ||
} | ||
|
||
if ((ntokens >= 5) && | ||
(strcmp(tokens[COMMAND_TOKEN].value, "bop") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "lop") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "mop") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "sop") == 0)) { | ||
return (strncmp(tokens[KEY_TOKEN+1].value, "arcus:", 6) == 0); | ||
} | ||
if ((ntokens >= 3) && | ||
(strcmp(tokens[COMMAND_TOKEN].value, "get") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "set") == 0)) { | ||
return (strncmp(tokens[KEY_TOKEN].value, "arcus:", 6) == 0); | ||
} | ||
if ((ntokens >= 2) && | ||
(strcmp(tokens[COMMAND_TOKEN].value, "dump") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "cmdlog") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "config") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "flush_all") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "flush_prefix") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "getattr") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "help") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "lqdetect") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "quit") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "ready") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "scan") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "setattr") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "shutdown") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "stats") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "version") == 0 || | ||
strcmp(tokens[COMMAND_TOKEN].value, "zkensmeble") == 0)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์๋ ํํ๋ก ๋ณ๊ฒฝํ์์ฃ . ์๋ ์ฝ๋๊ฐ ์ง๊ด์ ์ผ๋ก ์ฝ๊ธฐ๊ฐ ์ฝ์ต๋๋ค. static bool authenticated_ascii(conn *c, token_t *tokens, const size_t ntokens)
{
if (c->authenticated) {
return true;
}
if ((ntokens >= 2) &&
(strcmp(tokens[COMMAND_TOKEN].value, "dump") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "cmdlog") == 0 ||
. . .
strcmp(tokens[COMMAND_TOKEN].value, "version") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "zkensemble") == 0)) {
return true;
}
if ((ntokens >= 3) &&
(strcmp(tokens[COMMAND_TOKEN].value, "set") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "get") == 0)) {
return (strncmp(tokens[KEY_TOKEN].value, "arcus:", 6) == 0);
}
if ((ntokens >= 5) &&
(strcmp(tokens[COMMAND_TOKEN].value, "lop") == 0 ||
...
strcmp(tokens[COMMAND_TOKEN].value, "bop") == 0)) {
return (strncmp(tokens[COMMAND_TOKEN+2].value, "arcus:", 6) == 0);
}
return false;
}
|
||
|
||
#ifdef JHPARK_OLD_SMGET_INTERFACE | ||
static inline int set_smget_mode_maybe(conn *c, token_t *tokens, size_t ntokens) | ||
{ | ||
|
@@ -13092,6 +13132,11 @@ static void process_command_ascii(conn *c, char *command, int cmdlen) | |
|
||
ntokens = tokenize_command(command, cmdlen, tokens, MAX_TOKENS); | ||
|
||
if (settings.require_sasl && !authenticated_ascii(c, tokens, ntokens)) { | ||
out_string(c, "CLIENT_ERROR unauthenticated"); | ||
return; | ||
} | ||
|
||
if ((ntokens >= 3) && (strcmp(tokens[COMMAND_TOKEN].value, "get") == 0)) | ||
{ | ||
process_get_command(c, tokens, ntokens, false); | ||
|
@@ -15061,7 +15106,6 @@ int main (int argc, char **argv) | |
int cache_memory_limit = 0; | ||
int sticky_memory_limit = 0; | ||
|
||
bool protocol_specified = false; | ||
bool tcp_specified = false; | ||
bool udp_specified = false; | ||
|
||
|
@@ -15274,7 +15318,6 @@ int main (int argc, char **argv) | |
settings.backlog = atoi(optarg); | ||
break; | ||
case 'B': | ||
protocol_specified = true; | ||
if (strcmp(optarg, "auto") == 0) { | ||
settings.binding_protocol = negotiating_prot; | ||
} else if (strcmp(optarg, "binary") == 0) { | ||
|
@@ -15399,23 +15442,6 @@ int main (int argc, char **argv) | |
} | ||
} | ||
|
||
if (settings.require_sasl) { | ||
if (!protocol_specified) { | ||
settings.binding_protocol = binary_prot; | ||
} else { | ||
if (settings.binding_protocol == negotiating_prot) { | ||
mc_logger->log(EXTENSION_LOG_WARNING, NULL, | ||
"ERROR: You cannot use auto-negotiating protocol while requiring SASL.\n"); | ||
exit(EX_USAGE); | ||
} | ||
if (settings.binding_protocol == ascii_prot) { | ||
mc_logger->log(EXTENSION_LOG_WARNING, NULL, | ||
"ERROR: You cannot use only ASCII protocol while requiring SASL.\n"); | ||
exit(EX_USAGE); | ||
} | ||
} | ||
} | ||
|
||
if (udp_specified && settings.udpport != 0 && !tcp_specified) { | ||
settings.port = settings.udpport; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ if (supports_sasl()) { | |
plan skip_all => "The binary 'saslpasswd' is missing from your system"; | ||
} | ||
else { | ||
plan tests => 33; | ||
plan tests => 30; | ||
} | ||
} else { | ||
plan tests => 1; | ||
|
@@ -42,21 +42,6 @@ if (supports_sasl()) { | |
exit 0; | ||
} | ||
|
||
eval { | ||
my $server = get_memcached($engine, "-S -B auto"); | ||
}; | ||
ok($@, "SASL shouldn't be used with protocol auto negotiate"); | ||
|
||
eval { | ||
my $server = get_memcached($engine, "-S -B ascii"); | ||
}; | ||
ok($@, "SASL isn't implemented in the ascii protocol"); | ||
|
||
eval { | ||
my $server = get_memcached($engine, "-S -B binary -B ascii"); | ||
}; | ||
ok($@, "SASL isn't implemented in the ascii protocol"); | ||
|
||
# Based almost 100% off testClient.py which is: | ||
# Copyright (c) 2007 Dustin Sallings <[email protected]> | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@namsic
์๋์ ๊ฐ์ด ์กฐ๊ธ์ด๋ผ๋ ์ต์ ํํ๋ ๋ฐฉ์์ ๊ฒํ ํด ์ฃผ์ธ์.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฒซ ๊ธ์ ํ์ธํ์ฌ switchํ ๋ค ๋ฌธ์์ด ๋น๊ตํ๋ ๊ตฌํ๋ ๊ฒํ ํ ๋งํ ๊ฒ ๊ฐ์ต๋๋ค.
https://github.com/naver/arcus-c-client/blob/09c014d1fd0a97f3ab19ea46422251a4db3dbf25/libmemcached/response.cc#L281
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@namsic
c client ๋ฐฉ์์ผ๋ก ๊ตฌํํฉ์๋ค.