Remove blacklist and force module to have scope

This commit is contained in:
LoveSy 2021-01-29 15:40:40 +08:00
parent 583e24b757
commit 17291dbe51
2 changed files with 4 additions and 21 deletions

View File

@ -139,15 +139,9 @@ namespace lspd {
return true;
}
if (white_list_enable_) {
auto res = white_list_.count(package_name);
LOGD("using whitelist, %s -> %s", package_name.c_str(), BoolToString(res));
return res;
} else {
auto res = !black_list_.count(package_name);
LOGD("using blacklist, %s -> %s", package_name.c_str(), BoolToString(res));
return res;
}
auto res = white_list_.count(package_name);
LOGD("should hook %s -> %s", package_name.c_str(), BoolToString(res));
return res;
}
ConfigManager::ConfigManager(uid_t user, bool initialized) :
@ -157,19 +151,16 @@ namespace lspd {
base_config_path_(RetrieveBaseConfigPath()),
initialized_(initialized || InitConfigPath()),
installer_pkg_name_(RetrieveInstallerPkgName()),
white_list_enable_(path_exists(GetConfigPath("usewhitelist"))),
deopt_boot_image_enabled_(path_exists(GetConfigPath("deoptbootimage"))),
no_module_log_enabled_(path_exists(GetConfigPath("disable_modules_log"))),
resources_hook_enabled_(path_exists(GetConfigPath("enable_resources"))),
white_list_(GetAppList(GetConfigPath("whitelist/"))),
black_list_(GetAppList(GetConfigPath("blacklist/"))),
modules_list_(GetModuleList()),
last_write_time_(GetLastWriteTime()),
variant_(GetVariant(GetMiscPath() / "variant")) {
// use_white_list snapshot
LOGI("base config path: %s", base_config_path_.c_str());
LOGI(" using installer package name: %s", installer_pkg_name_.c_str());
LOGI(" using whitelist: %s", BoolToString(white_list_enable_));
LOGI(" deopt boot image: %s", BoolToString(deopt_boot_image_enabled_));
LOGI(" no module log: %s", BoolToString(no_module_log_enabled_));
LOGI(" resources hook: %s", BoolToString(resources_hook_enabled_));
@ -179,12 +170,6 @@ namespace lspd {
std::ostream_iterator<std::string>(join, "\n"));
return join.str();
})().c_str());
LOGI(" black list: \n %s", ([this]() {
std::ostringstream join;
std::copy(black_list_.begin(), black_list_.end(),
std::ostream_iterator<std::string>(join, "\n"));
return join.str();
})().c_str());
LOGI(" module list: \n %s", ([this]() {
std::ostringstream join;
std::vector<std::string> module_list;
@ -255,7 +240,7 @@ namespace lspd {
std::vector<std::string> ConfigManager::GetAppModuleList(const std::string &pkg_name) const {
std::vector<std::string> app_modules_list;
for (const auto&[module, scope]: modules_list_) {
if (scope.second.empty() || scope.second.count(pkg_name))
if (scope.second.count(pkg_name))
app_modules_list.push_back(scope.first);
}
return app_modules_list;

View File

@ -118,13 +118,11 @@ namespace lspd {
const std::filesystem::path base_config_path_; // /data/misc/lspd_xxxx/{user}
const bool initialized_ = false;
const std::filesystem::path installer_pkg_name_;
const bool white_list_enable_ = false;
const bool deopt_boot_image_enabled_ = false;
const bool no_module_log_enabled_ = false;
const bool resources_hook_enabled_ = false;
// snapshot at boot
const std::unordered_set<std::string> white_list_;
const std::unordered_set<std::string> black_list_;
const std::unordered_map<std::string, std::pair<std::string, std::unordered_set<std::string>>> modules_list_;