Skip to content
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

Add permission control #11306

Open
wants to merge 1 commit into
base: release-7.1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 16 additions & 5 deletions fdbcli/fdbcli.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ enum {
OPT_DEBUG_TLS,
OPT_API_VERSION,
OPT_MEMORY,
OPT_ADMIN,
};

CSimpleOpt::SOption g_rgOptions[] = { { OPT_CONNFILE, "-C", SO_REQ_SEP },
Expand All @@ -125,6 +126,7 @@ CSimpleOpt::SOption g_rgOptions[] = { { OPT_CONNFILE, "-C", SO_REQ_SEP },
{ OPT_DEBUG_TLS, "--debug-tls", SO_NONE },
{ OPT_API_VERSION, "--api-version", SO_REQ_SEP },
{ OPT_MEMORY, "--memory", SO_REQ_SEP },
{ OPT_ADMIN, "--admin", SO_NONE },

#ifndef TLS_DISABLED
TLS_OPTION_FLAGS
Expand Down Expand Up @@ -991,6 +993,7 @@ struct CLIOptions {
int exit_timeout = 0;
Optional<std::string> exec;
bool initialStatusCheck = true;
bool adminControl = false;
bool cliHints = true;
bool debugTLS = false;
std::string tlsCertPath;
Expand Down Expand Up @@ -1144,6 +1147,9 @@ struct CLIOptions {
case OPT_BUILD_FLAGS:
printBuildInformation();
return FDB_EXIT_SUCCESS;
case OPT_ADMIN:
adminControl = true;
break;
}
return -1;
}
Expand Down Expand Up @@ -1850,12 +1856,17 @@ ACTOR Future<int> cli(CLIOptions opt, LineNoise* plinenoise) {
printUsage(tokens[0]);
is_error = true;
} else {
if (tokencmp(tokens[1], "on")) {
writeMode = true;
} else if (tokencmp(tokens[1], "off")) {
writeMode = false;
if (opt.adminControl){
if (tokencmp(tokens[1], "on")) {
writeMode = true;
} else if (tokencmp(tokens[1], "off")) {
writeMode = false;
} else {
printUsage(tokens[0]);
is_error = true;
}
} else {
printUsage(tokens[0]);
fprintf(stderr, "ERROR: You do not have the required permissions to access the write mode.\n");
is_error = true;
}
}
Expand Down