fix: fix su's lexer
This commit is contained in:
@ -115,8 +115,10 @@ std::vector<std::string> BookStoreEngineClass::ExecuteSu(
|
|||||||
std::string user_id, password;
|
std::string user_id, password;
|
||||||
if (!CommandSuLexer(cmd, user_id, password))
|
if (!CommandSuLexer(cmd, user_id, password))
|
||||||
return std::vector<std::string>({"Invalid"});
|
return std::vector<std::string>({"Invalid"});
|
||||||
|
// debugPrint("su", user_id, " ", password);
|
||||||
if (login_stack.size() > 0 &&
|
if (login_stack.size() > 0 &&
|
||||||
user_data_base.GetPrevilege(login_stack.top().first) == 7) {
|
user_data_base.GetPrevilege(login_stack.top().first) == 7) {
|
||||||
|
// debugPrint("has root previlege");
|
||||||
if (user_data_base.GetPrevilege(user_id) == -1)
|
if (user_data_base.GetPrevilege(user_id) == -1)
|
||||||
return std::vector<std::string>({"Invalid"});
|
return std::vector<std::string>({"Invalid"});
|
||||||
login_stack.push(std::make_pair(user_id, ""));
|
login_stack.push(std::make_pair(user_id, ""));
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
bool CommandSuLexer(const std::string &command, std::string &user_id,
|
bool CommandSuLexer(const std::string &command, std::string &user_id,
|
||||||
std::string &password) {
|
std::string &password) {
|
||||||
static std::basic_regex main_pattern(
|
static std::basic_regex main_pattern(
|
||||||
R"(^ *su +(?:[0-9a-zA-Z_]{1,30}) +(?:[0-9a-zA-Z_]{1,30})? *$)",
|
R"(^ *su +(?:[0-9a-zA-Z_]{1,30})(?: +[0-9a-zA-Z_]{1,30})? *$)",
|
||||||
std::regex_constants::optimize);
|
std::regex_constants::optimize);
|
||||||
if (std::regex_match(command, main_pattern)) {
|
if (std::regex_match(command, main_pattern)) {
|
||||||
std::stringstream ss(command);
|
std::stringstream ss(command);
|
||||||
|
Reference in New Issue
Block a user