31#include "cmdhandler.h"
35#include "clientpipe.h"
36#include "longgetopt.h"
44static const char *module_str =
"policy_import_cmd";
46static void database_error_help(
int sockfd) {
47 client_printf_err(sockfd,
48 "\nThe information in the database may have been changed during KASP update"
49 " and caused an update error, try rerunning policy import. If the problem persists"
50 " please check logs and database setup and after correcting the problem rerun policy import.\n"
59 " [--remove-missing-policies] aka -r\n"
67 "Import policies from kasp.xml into the enforcer database.\n"
69 "remove-missing-policies Remove any policies from database "
70 "that do not exist in the KASP file\n\n"
76run(cmdhandler_ctx_type* context,
int argc,
char* argv[])
78 int sockfd = context->sockfd;
79 struct longgetopt optctx;
83 int remove_missing_policies = 0;
84 int long_index = 0, opt = 0;
86 static struct option long_options[] = {
87 {
"remove-missing-policies", no_argument, 0,
'r'},
97 for(opt = longgetopt(argc, argv,
"r", long_options, &long_index, &optctx); opt != -1;
98 opt = longgetopt(argc, argv, NULL,long_options, &long_index, &optctx)) {
101 remove_missing_policies = 1;
104 client_printf_err(sockfd,
"unknown arguments\n");
105 ods_log_error(
"[%s] unknown arguments for policy import command", module_str);
110 switch (
policy_import(sockfd, engine, dbconn, remove_missing_policies)) {
124 database_error_help(sockfd);
135 "policy import", &usage, &help, NULL, NULL, &run, NULL
void enforce_task_flush_all(engine_type *engine, db_connection_t *dbconn)
db_connection_t * getconnectioncontext(cmdhandler_ctx_type *context)
engine_type * getglobalcontext(cmdhandler_ctx_type *context)
int policy_import(int sockfd, engine_type *engine, db_connection_t *dbconn, int do_delete)
#define POLICY_IMPORT_ERR_ARGS
#define POLICY_IMPORT_ERR_DATABASE
#define POLICY_IMPORT_ERR_MEMORY
#define POLICY_IMPORT_ERR_XML
struct cmd_func_block policy_import_funcblock
int flush_resalt_task_all(engine_type *engine, db_connection_t *dbconn)
engineconfig_type * config
const char * policy_filename