31 #include "cmdhandler.h" 35 #include "clientpipe.h" 43 static const char *module_str =
"policy_import_cmd";
45 static void database_error_help(
int sockfd) {
46 client_printf_err(sockfd,
47 "\nThe information in the database may have been changed during KASP update" 48 " and caused an update error, try rerunning policy import. If the problem persists" 49 " please check logs and database setup and after correcting the problem rerun policy import.\n" 58 " [--remove-missing-policies] aka -r\n" 66 "Import policies from kasp.xml into the enforcer database.\n" 68 "remove-missing-policies Remove any policies from database " 69 "that do not exist in the KASP file\n\n" 75 run(
int sockfd, cmdhandler_ctx_type* context,
const char *cmd)
81 int remove_missing_policies = 0, argc = 0;
82 int long_index = 0, opt = 0;
83 char buf[ODS_SE_MAXLINE];
84 char const *argv[
NARGV];
86 static struct option long_options[] = {
87 {
"remove-missing-policies", no_argument, 0,
'r'},
101 strncpy(buf, cmd,
sizeof(buf));
102 buf[
sizeof(buf)-1] =
'\0';
105 argc = ods_str_explode(buf,
NARGV, argv);
107 ods_log_error(
"[%s] too many arguments for %s command",
109 client_printf_err(sockfd,
"too many arguments\n");
114 while ((opt = getopt_long(argc, (
char*
const*)argv,
"r", long_options, &long_index)) != -1 ) {
117 remove_missing_policies = 1;
120 client_printf_err(sockfd,
"unknown arguments\n");
121 ods_log_error(
"[%s] unknown arguments for %s command",
127 switch (
policy_import(sockfd, engine, dbconn, remove_missing_policies)) {
141 database_error_help(sockfd);
152 "policy import", &usage, &help, NULL, &run
struct cmd_func_block policy_import_funcblock
const char * policy_filename
#define POLICY_IMPORT_ERR_XML
void enforce_task_flush_all(engine_type *engine, db_connection_t *dbconn)
engine_type * getglobalcontext(cmdhandler_ctx_type *context)
db_connection_t * getconnectioncontext(cmdhandler_ctx_type *context)
engineconfig_type * config
#define POLICY_IMPORT_ERR_ARGS
int policy_import(int sockfd, engine_type *engine, db_connection_t *dbconn, int do_delete)
#define POLICY_IMPORT_ERR_DATABASE
#define POLICY_IMPORT_ERR_MEMORY
int flush_resalt_task_all(engine_type *engine, db_connection_t *dbconn)