Add framework for registering custom udev rules

This commit is contained in:
Adam Honse committed 2026-08-20 10:38:57 -05:00
1 parent 33854f8886
commit c5befc354b
6 files changed
+69 -1

No files matched your search

+27
View File
@@ -350,6 +350,21 @@ void DetectionManager::RegisterPreDetectionHook(PreDetectionHookFunction hook)
pre_detection_hooks.push_back(hook);
}
#ifdef __linux__
/*---------------------------------------------------------*\
| Custom Udev Rules Registration Function |
\*---------------------------------------------------------*/
void DetectionManager::RegisterCustomUdevRule(std::string name, std::string rule)
{
CustomUdevRuleBlock block;
block.name = name;
block.rule = rule;
custom_udev_rules.push_back(block);
}
#endif
/*---------------------------------------------------------*\
| Detection Callback Registration Functions |
\*---------------------------------------------------------*/
@@ -2168,6 +2183,18 @@ bool DetectionManager::GenerateUdevRules(const std::string& filepath)
fprintf(output_file, "\n");
}
/*-----------------------------------------------------*\
| Write custom udev rules |
\*-----------------------------------------------------*/
for(const CustomUdevRuleBlock& custom_rule : custom_udev_rules)
{
fprintf(output_file, "#---------------------------------------------------------------#\n");
fprintf(output_file, "# %s\n", custom_rule.name.c_str());
fprintf(output_file, "#---------------------------------------------------------------#\n");
fprintf(output_file, "%s\n", custom_rule.rule.c_str());
fprintf(output_file, "\n");
}
fclose(output_file);
LOG_INFO("[%s] Successfully generated udev rules file: %s", DETECTIONMANAGER, filepath.c_str());