33 #include "clientpipe.h" 41 static const char *module_str =
"policy_import_cmd";
43 static void database_error_help(
int sockfd) {
44 client_printf_err(sockfd,
45 "\nThe information in the database may have been changed during KASP update" 46 " and caused an update error, try rerunning policy import. If the problem persists" 47 " please check logs and database setup and after correcting the problem rerun policy import.\n" 56 " [--remove-missing-policies] aka -r\n" 64 "Import policies from kasp.xml into the enforcer database.\n" 66 "remove-missing-policies Remove any policies from database " 67 "that do not exist in the KASP file\n\n" 73 handles(
const char *cmd, ssize_t n)
79 run(
int sockfd,
engine_type* engine,
const char *cmd, ssize_t n,
84 int remove_missing_policies, argc;
85 char buf[ODS_SE_MAXLINE];
86 char const *argv[
NARGV];
98 strncpy(buf, cmd,
sizeof(buf));
99 buf[
sizeof(buf)-1] =
'\0';
101 argc = ods_str_explode(buf,
NARGV, argv);
105 client_printf(sockfd,
"too many arguments\n");
108 remove_missing_policies = (ods_find_arg(&argc, argv,
"remove-missing-policies",
"r") >= 0);
112 client_printf(sockfd,
"unknown arguments\n");
116 switch (
policy_import(sockfd, engine, dbconn, remove_missing_policies)) {
129 database_error_help(sockfd);
void ods_log_debug(const char *format,...)
const char * policy_filename
#define POLICY_IMPORT_ERR_XML
int(* run)(int sockfd, struct engine_struct *engine, const char *cmd, ssize_t n, db_connection_t *dbconn)
struct cmd_func_block * policy_import_funcblock(void)
void(* usage)(int sockfd)
engineconfig_type * config
#define POLICY_IMPORT_ERR_ARGS
int flush_resalt_task(engine_type *engine)
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(* handles)(const char *cmd, ssize_t n)
void ods_log_warning(const char *format,...)
int flush_enforce_task(engine_type *engine, bool enforce_all)