return AUDIT_TRAIL_ERROR_NONE;
}
+
+int audit_trail_load_ruleset(audit_trail_h handle, const char *name)
+{
+ RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(name, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
+
+ AuditTrailContext &client = GetAuditTrailContext(handle);
+ auto manager = client.createInterface<RuleManagement>();
+
+ manager.loadRuleSet(name);
+
+ return AUDIT_TRAIL_ERROR_NONE;
+}
*/
AUDIT_TRAIL_API int audit_trail_foreach_rule(audit_trail_h handle,
audit_rule_cb callback, void *user_data);
+
+/**
+ * @brief Load the specified ruleset module
+ * @details This API loads the specified ruleset module and apply the rules
+ * of the module onto this system
+ * @since_tizen 5.0
+ * @param[in] handle The audit handle
+ * @param[in] name The modules name
+ * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
+ * @retval #AUDIT_TRAIL_ERROR_NONE Successful
+ * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
+ * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre The handle must be created by audit_trail_create().
+ * @see audit_trail_create()
+ */
+AUDIT_TRAIL_API int audit_trail_load_ruleset(audit_trail_h handle,
+ const char *name);
/**
* @}
*/
return std::vector<std::vector<char>>();
}
+int RuleManagement::loadRuleSet(std::string name)
+{
+ try {
+ return context->methodCall<int>("RuleManagement::loadRuleSet", name);
+ } catch (runtime::Exception& e) {}
+ return -1;
+}
+
} // namespace AuditTrail
int removeRule(std::vector<char> data);
std::vector<std::vector<char>> getRules();
+ int loadRuleSet(std::string name);
+
private:
AuditTrailControlContext& context;
};
context.expose(this, PRIVILEGE_PLATFORM, (int)(RuleManagement::addRule)(std::vector<char>));
context.expose(this, PRIVILEGE_PLATFORM, (int)(RuleManagement::removeRule)(std::vector<char>));
context.expose(this, PRIVILEGE_PLATFORM, (std::vector<std::vector<char>>)(RuleManagement::getRules)());
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(RuleManagement::loadRuleSet)(std::string));
}
RuleManagement::~RuleManagement()
return ret;
}
+int RuleManagement::loadRuleSet(std::string name)
+{
+ context.loadRuleSet(name);
+ return 0;
+}
+
} // namespace AuditTrail
<< " -d, --add-dac-rules apply rules to catch DAC denied" << std::endl
<< " -r, --remove-rules remove all applied rules" << std::endl
<< " -l, --list-rules show the applied rules" << std::endl
+ << " -i, --load-ruleset load a ruleset module" << std::endl
<< " -h, --help show this" << std::endl
<< std::endl;
audit_rule_destroy(rule);
}
-
int removeRules()
{
audit_trail_h auditTrail = nullptr;
return 0;
}
+int loadRuleSet(std::string name)
+{
+ audit_trail_h auditTrail = nullptr;
+
+ audit_trail_create(&auditTrail);
+ if (auditTrail == nullptr) {
+ std::cerr << "Audit trail can't be usable" << std::endl;
+ return -1;
+ }
+
+ audit_trail_load_ruleset(auditTrail, name.c_str());
+ audit_trail_destroy(auditTrail);
+
+ return 0;
+}
+
int main(int argc, char* argv[])
{
int opt = 0, index, ret = 0;
{"add-dac-rules", no_argument, 0, 'd'},
{"remove-rules", no_argument, 0, 'r'},
{"list-rules", no_argument, 0, 'l'},
+ {"load-ruleset", required_argument, 0, 'l'},
{0, 0, 0, 0}
};
return EXIT_SUCCESS;
}
- while ((opt = getopt_long(argc, argv, "s:c:mdlrh", options, &index)) != -1) {
+ while ((opt = getopt_long(argc, argv, "s:c:mdlri:h", options, &index)) != -1) {
switch (opt) {
case 's':
ret = showLog(optarg);
case 'l':
ret = listAppliedRules();
break;
+ case 'i':
+ ret = loadRuleSet(optarg);
+ break;
case 'h':
default:
usage(argv[0]);