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

Specify what happens when neither RuleFile nor RuleFolder is set #562

Merged
merged 1 commit into from
Nov 16, 2022

Conversation

Cropi
Copy link
Member

@Cropi Cropi commented Nov 1, 2022

Precisely specify what happens when neither RuleFile nor RuleFolder is set. Whilst this is an extraordinary use case, some might be confused in case they encounter the issue.

Reproduction of the issue is straightforward: remove RuleFile and RuleFolder from the config.

Copy link
Contributor

@hartwork hartwork left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a good idea 👍

Validated based on…

if (!ns.getRulesPath().empty()) {
ruleSet.emplace_back(new FileRuleSet(interface_ptr, ns.getRulesPath()));
}
if (!ns.getRulesDirPath().empty()) {
for (auto path : getConfigsFromDir(ns.getRulesDirPath())) {
auto frs = std::make_shared<FileRuleSet>(interface_ptr, path);
auto rs = std::dynamic_pointer_cast<RuleSet>(frs);
ruleSet.push_back(rs);
}
}

…and…

/* RuleFile */
if (_config.hasSettingValue("RuleFile")) {
const std::string& rulefile_path = _config.getSettingValue("RuleFile");
if (check_permissions) {
checkFilePermissions(rulefile_path, (S_IRUSR | S_IWUSR));
}
_nss.setRulesPath(rulefile_path);
}
/* RuleDir */
if (_config.hasSettingValue("RuleFolder")) {
std::string ruledir_path = _config.getSettingValue("RuleFolder");
/* Check proper ending in path and correct it if corrupted */
if (ruledir_path.back() != '/') {
ruledir_path.append("/");
}
ruledir_path = normalizePath(ruledir_path);
if (check_permissions) {
checkFolderPermissions(ruledir_path, (S_IRUSR | S_IWUSR));
}
_nss.setRulesDirPath(ruledir_path);
}

@Cropi Cropi self-assigned this Nov 16, 2022
@Cropi Cropi merged commit 4936cb3 into USBGuard:master Nov 16, 2022
@Cropi Cropi deleted the ruleset-doc branch November 16, 2022 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants