* Search for a rule that matches `match_spec' rule and * update it with a rule specified by `rule_spec'. Fail * if multiple rules match. If there are no matching * rules, append the `rule_spec' rule. * * Return the id of the updated or new rule. */
| 690 | * Return the id of the updated or new rule. |
| 691 | */ |
| 692 | uint32_t Daemon::upsertRule(const std::string& match_spec, |
| 693 | const std::string& rule_spec, |
| 694 | const bool parent_insensitive) |
| 695 | { |
| 696 | USBGUARD_LOG(Trace) << "entry:" |
| 697 | << " match_spec=" << match_spec |
| 698 | << " rule_spec=" << rule_spec |
| 699 | << " parent_insensitive=" << parent_insensitive; |
| 700 | const Rule match_rule = Rule::fromString(match_spec); |
| 701 | const Rule new_rule = Rule::fromString(rule_spec); |
| 702 | const uint32_t id = _policy.upsertRule(match_rule, new_rule, parent_insensitive); |
| 703 | |
| 704 | if (_config.hasSettingValue("RuleFile")) { |
| 705 | _policy.save(); |
| 706 | } |
| 707 | |
| 708 | USBGUARD_LOG(Trace) << "return: id=" << id; |
| 709 | return id; |
| 710 | } |
| 711 | |
| 712 | /* |
| 713 | * IPC service methods |
nothing calls this directly
no test coverage detected