Greenbone Security Assistant  7.0.0
gsad_omp.c File Reference

OMP communication module of Greenbone Security Assistant daemon. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <glib.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <fcntl.h>
#include <assert.h>
#include <time.h>
#include <microhttpd.h>
#include "gsad_base.h"
#include "gsad_omp.h"
#include "xslt_i18n.h"
#include <openvas/misc/openvas_server.h>
#include <openvas/base/openvas_file.h>
#include <openvas/base/cvss.h>
#include <openvas/omp/omp.h>
#include <openvas/omp/xml.h>
#include <libxml2/libxml/xmlmemory.h>
#include <libxml2/libxml/HTMLtree.h>
#include <libxml2/libxml/xmlIO.h>
#include <libxml2/libxml/xinclude.h>
#include <libxslt/xslt.h>
#include <libxslt/xsltInternals.h>
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
Include dependency graph for gsad_omp.c:

Go to the source code of this file.

Data Structures

struct  find_by_value_t
 Structure to search a key by value. More...
 

Macros

#define G_LOG_DOMAIN   "gsad omp"
 GLib log domain. More...
 
#define OPENVASMD_ADDRESS   "127.0.0.1"
 Manager (openvasmd) address. More...
 
#define CHECK_PARAM(name, op_name, ret_func)
 Check a param. More...
 
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
 Check a param using the direct response method. More...
 
#define PARAM_OR_SETTING(value, param, setting_id, cleanup)
 Get a value from a param or fall back to a setting. More...
 
#define CHECK(name)   CHECK_PARAM_INVALID (name, "Create Task", "new_task")
 Check a param. More...
 
#define CHECK(name)
 Check a param. More...
 
#define GET_TRASH_RESOURCE(capability, command, name)
 
#define CHECK_OMPF_RET
 
#define AUTH_CONF_SETTING(key, value)
 Generate AUTH_CONF_SETTING element for save_auth_omp. More...
 

Functions

int manager_connect (credentials_t *credentials, openvas_connection_t *connection, gchar **html, cmd_response_data_t *response_data)
 Connect to OpenVAS Manager daemon. More...
 
int token_user_remove (const char *)
 Remove a user from the session "database", releasing the user_t too. More...
 
int command_enabled (credentials_t *credentials, const gchar *name)
 Init the GSA OMP library. More...
 
void omp_init (const gchar *manager_address_unix, const gchar *manager_address_tls, int port_manager)
 Init the GSA OMP library. More...
 
void cmd_response_data_init (cmd_response_data_t *data)
 Initializes a cmd_response_data_t struct. More...
 
void cmd_response_data_reset (cmd_response_data_t *data)
 Clears a cmd_response_data_t struct. More...
 
void init_find_by_value (find_by_value_t *find, gchar *value)
 
void free_find_by_value (find_by_value_t *find)
 
int member1 (params_t *params, const char *string)
 Look for param with value 1 and name equal to given string. More...
 
void set_http_status_from_entity (entity_t entity, cmd_response_data_t *response_data)
 Set the HTTP status according to OMP response entity. More...
 
gchar * message_invalid (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *status, const char *op_name, const char *next_cmd)
 Check a param using the direct response method. More...
 
char * get_one (const char *type, credentials_t *credentials, params_t *params, const char *extra_xml, const char *extra_attribs, cmd_response_data_t *response_data)
 Get one resource, XSL transform the result. More...
 
char * edit_resource (const char *type, credentials_t *credentials, params_t *params, const char *extra_get_attribs, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit XML, XSL transform the result. More...
 
gchar * format_file_name (gchar *fname_format, credentials_t *credentials, const char *type, const char *uuid, entity_t resource_entity)
 Generates a file name for exporting. More...
 
char * export_resource (const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a resource. More...
 
char * delete_resource (const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
 Delete a resource, get all resources, XSL transform the result. More...
 
char * resource_action (credentials_t *credentials, params_t *params, const char *type, const char *action, cmd_response_data_t *response_data)
 Perform action on resource, get next page, XSL transform result. More...
 
char * new_task_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new task. More...
 
char * new_container_task_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new task. More...
 
char * upload_report_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the upload report page. More...
 
char * create_report_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a report, get all tasks, XSL transform the result. More...
 
char * import_report_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Import report, get all reports, XSL transform the result. More...
 
char * create_container_task_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a container task, serve next page. More...
 
char * create_task_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a task, get all tasks, XSL transform the result. More...
 
char * delete_task_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a task, get all tasks, XSL transform the result. More...
 
char * edit_task_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_task XML, XSL transform the result. More...
 
char * save_task_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save task, get next page, XSL transform the result. More...
 
char * save_container_task_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save container task, get next page, XSL transform the result. More...
 
char * export_task_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a task. More...
 
char * export_tasks_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of tasks. More...
 
char * stop_task_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Stop a task, get all tasks, XSL transform the result. More...
 
char * resume_task_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Resume a task, get all tasks, XSL transform the result. More...
 
char * start_task_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Start a task, get all tasks, XSL transform the result. More...
 
char * move_task_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Reassign a task to a new OMP slave. More...
 
char * get_info (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Requests SecInfo. More...
 
char * get_info_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get info, XSL transform the result. More...
 
char * get_nvts_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Requests NVT details, accepting extra commands. More...
 
char * get_tasks_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all tasks, XSL transform the result. More...
 
char * get_tasks_chart_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a tasks chart, XSL transform the result. More...
 
char * get_task_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a task, XSL transform the result. More...
 
char * create_credential_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a credential, get all credentials, XSL transform result. More...
 
char * get_credential_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one credential, XSL transform the result. More...
 
int download_credential_omp (credentials_t *credentials, params_t *params, gsize *result_len, char **html, char **login, cmd_response_data_t *response_data)
 Export a Credential in a defined format. More...
 
char * export_credential_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a Credential. More...
 
char * export_credentials_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of Credentials. More...
 
char * get_credentials_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one or all credentials, XSL transform the result. More...
 
char * delete_credential_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete credential, get all credentials, XSL transform result. More...
 
char * new_credential_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new Credential. More...
 
char * edit_credential_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_credential XML, XSL transform the result. More...
 
char * save_credential_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save credential, get next page, XSL transform the result. More...
 
char * new_agent_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new agent page. More...
 
char * create_agent_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create an agent, get all agents, XSL transform result. More...
 
char * delete_agent_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete agent, get all agents, XSL transform result. More...
 
int download_agent_omp (credentials_t *credentials, params_t *params, gsize *result_len, char **html, char **filename, cmd_response_data_t *response_data)
 Get an agent, XSL transform the result. More...
 
char * edit_agent (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_agent XML, XSL transform the result. More...
 
char * edit_agent_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_agent XML, XSL transform the result. More...
 
char * save_agent_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a agent, get all agents, XSL transform the result. More...
 
char * get_agent_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one agent, XSL transform the result. More...
 
char * get_agents_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all agents, XSL transform the result. More...
 
char * verify_agent_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Verify agent, get agents, XSL transform the result. More...
 
char * export_agent_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a agent. More...
 
char * export_agents_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of agents. More...
 
char * get_aggregate_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get an aggregate of resources. More...
 
char * new_alert_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new alert. More...
 
char * create_alert_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create an alert, get all alerts, XSL transform the result. More...
 
char * delete_alert_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete an alert, get all alerts, XSL transform the result. More...
 
char * get_alert_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one alert, XSL transform the result. More...
 
char * get_alerts_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all alerts, XSL transform the result. More...
 
char * edit_alert (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_alert XML, XSL transform the result. More...
 
char * edit_alert_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_alert XML, XSL transform the result. More...
 
char * save_alert_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify an alert, get all alerts, XSL transform the result. More...
 
char * test_alert_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Test an alert, get all alerts XSL transform the result. More...
 
char * export_alert_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export an alert. More...
 
char * export_alerts_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of alerts. More...
 
char * new_target_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new target. More...
 
char * create_target_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a target, get all targets, XSL transform the result. More...
 
char * clone_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Clone a resource, XSL transform the result. More...
 
char * delete_target_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a target, get all targets, XSL transform the result. More...
 
char * delete_trash_agent_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash agent, get all agents, XSL transform the result. More...
 
char * delete_trash_config_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash config, get all trash, XSL transform the result. More...
 
char * delete_trash_alert_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash alert, get all trash, XSL transform the result. More...
 
char * delete_trash_credential_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash credential, get all trash, XSL transform the result. More...
 
char * delete_trash_report_format_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash report format, get all trash, XSL transform the result. More...
 
char * delete_trash_schedule_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash schedule, get all trash, XSL transform the result. More...
 
char * delete_trash_target_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash target, get all trash, XSL transform the result. More...
 
char * delete_trash_task_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash task, get all trash, XSL transform the result. More...
 
char * restore_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Restore a resource, get all trash, XSL transform the result. More...
 
char * empty_trashcan_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Empty the trashcan, get all trash, XSL transform the result. More...
 
char * new_tag_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new target. More...
 
char * create_tag_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a tag, get report, XSL transform the result. More...
 
char * delete_tag_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete note, get next page, XSL transform the result. More...
 
char * delete_trash_tag_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a note, get all notes, XSL transform the result. More...
 
char * edit_tag (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_tag XML, XSL transform the result. More...
 
char * edit_tag_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_tag XML, XSL transform the result. More...
 
char * save_tag_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a tag, get all tags, XSL transform the result. More...
 
char * export_tag_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a tag. More...
 
char * export_tags_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of tags. More...
 
char * get_tag_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one tag, XSL transform the result. More...
 
char * get_tags_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all tags, XSL transform the result. More...
 
char * toggle_tag_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Set tag enabled status. More...
 
char * edit_target (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_target XML, XSL transform the result. More...
 
char * edit_target_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_target XML, XSL transform the result. More...
 
char * get_target_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one target, XSL transform the result. More...
 
char * get_targets_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all targets, XSL transform the result. More...
 
char * save_target_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a target, get all targets, XSL transform the result. More...
 
char * export_target_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a target. More...
 
char * export_targets_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of targets. More...
 
char * new_config_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new scan config page. More...
 
char * upload_config_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the upload scan config page. More...
 
char * create_config_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create config, get all configs, XSL transform the result. More...
 
char * import_config_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Import config, get all configs, XSL transform the result. More...
 
char * get_configs_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all scan configs, XSL transform the result. More...
 
char * get_config_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a config, XSL transform the result. More...
 
char * edit_config_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a config, XSL transform the result. More...
 
char * sync_config_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Sync config, get configs, XSL transform the result. More...
 
char * save_config_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save details of an NVT for a config and return the next page. More...
 
char * get_config_family_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get details of a family for a config, XSL transform the result. More...
 
char * edit_config_family_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get details of a family for editing a config, XSL transform result. More...
 
char * save_config_family_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get details of an NVT for a config, XSL transform the result. More...
 
char * get_config_nvt_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get details of an NVT for a config, XSL transform the result. More...
 
char * edit_config_nvt_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Edit details of an NVT for a config, XSL transform the result. More...
 
char * save_config_nvt_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save NVT prefs for a config, get NVT details, XSL transform result. More...
 
char * delete_config_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete config, get all configs, XSL transform the result. More...
 
char * export_config_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a config. More...
 
char * export_configs_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of scan configs. More...
 
char * export_note_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a note. More...
 
char * export_notes_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of notes. More...
 
char * export_override_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export an override. More...
 
char * export_overrides_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of overrides. More...
 
char * export_port_list_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a Port List. More...
 
char * export_port_lists_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of Port Lists. More...
 
char * export_preference_file_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a file preference. More...
 
char * export_report_format_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a report format. More...
 
char * export_report_formats_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of Report Formats. More...
 
char * delete_report_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete report, get task status, XSL transform the result. More...
 
char * get_report_omp (credentials_t *credentials, params_t *params, gsize *report_len, gchar **content_type, char **content_disposition, cmd_response_data_t *response_data)
 Get a report and XSL transform the result. More...
 
char * get_reports_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all reports, XSL transform the result. More...
 
char * get_report_section_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a report section, XSL transform the result. More...
 
char * download_ssl_cert (credentials_t *credentials, params_t *params, gsize *response_size, cmd_response_data_t *response_data)
 Get an SSL Certificate. More...
 
char * download_ca_pub (credentials_t *credentials, params_t *params, gsize *response_size, cmd_response_data_t *response_data)
 Get a Scanner's CA Certificate. More...
 
char * download_key_pub (credentials_t *credentials, params_t *params, gsize *response_size, cmd_response_data_t *response_data)
 Get a Scanner's Certificate. More...
 
char * export_result_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a result. More...
 
char * export_results_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of results. More...
 
char * get_results_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all results, XSL transform the result. More...
 
char * get_result_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one result, XSL transform the result. More...
 
char * get_notes_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all notes, XSL transform the result. More...
 
char * get_note_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a note, XSL transform the result. More...
 
char * new_note (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Return the new notes page. More...
 
char * new_note_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new notes page. More...
 
char * create_note_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a note, get report, XSL transform the result. More...
 
char * delete_note_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete note, get next page, XSL transform the result. More...
 
char * delete_trash_note_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a note, get all notes, XSL transform the result. More...
 
char * edit_note (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Edit note, get next page, XSL transform the result. More...
 
char * edit_note_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Edit note, get next page, XSL transform the result. More...
 
char * save_note_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save note, get next page, XSL transform the result. More...
 
char * get_overrides_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all overrides, XSL transform the result. More...
 
char * get_override_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get an override, XSL transform the result. More...
 
char * new_override (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Return the new overrides page. More...
 
char * new_override_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new overrides page. More...
 
char * create_override_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create an override, get report, XSL transform the result. More...
 
char * delete_override_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete override, get next page, XSL transform the result. More...
 
char * delete_trash_override_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a override, get all overrides, XSL transform the result. More...
 
char * edit_override (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Edit override, get next page, XSL transform the result. More...
 
char * edit_override_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Edit override, get next page, XSL transform the result. More...
 
char * save_override_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save override, get next page, XSL transform the result. More...
 
char * get_scanners_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all scanners, XSL transform the result. More...
 
char * get_scanner_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one scanner, XSL transform the result. More...
 
char * export_scanner_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a scanner. More...
 
char * export_scanners_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of scanners. More...
 
char * new_scanner_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new scanner page. More...
 
char * verify_scanner_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Verify scanner, get scanners, XSL transform the result. More...
 
char * create_scanner_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a scanner, get all scanners, XSL transform the result. More...
 
char * delete_scanner_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a scanner, get all scanners, XSL transform the result. More...
 
char * delete_trash_scanner_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash scanner, get all scanners, XSL transform the result. More...
 
char * edit_scanner (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_scanner XML, XSL transform the result. More...
 
char * edit_scanner_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_scanner XML, XSL transform the result. More...
 
char * save_scanner_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save scanner, get next page, XSL transform the result. More...
 
char * get_schedule_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one schedule, XSL transform the result. More...
 
char * get_schedules_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all schedules, XSL transform the result. More...
 
char * new_schedule_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new schedule page. More...
 
char * create_schedule_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a schedule, get all schedules, XSL transform the result. More...
 
char * delete_schedule_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a schedule, get all schedules, XSL transform the result. More...
 
char * get_system_reports_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all system reports, XSL transform the result. More...
 
char * get_system_report_omp (credentials_t *credentials, const char *url, params_t *params, enum content_type *content_type, gsize *content_length, cmd_response_data_t *response_data)
 Return system report image. More...
 
char * get_report_format_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one report format, XSL transform the result. More...
 
char * get_report_formats_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all Report Formats, XSL transform the result. More...
 
char * new_report_format_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new report format page. More...
 
char * delete_report_format_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete report format, get report formats, XSL transform the result. More...
 
char * edit_report_format_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_report_format XML, XSL transform the result. More...
 
char * import_report_format_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Import report format, get all report formats, XSL transform result. More...
 
char * save_report_format_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save report_format, get next page, XSL transform the result. More...
 
char * verify_report_format_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Verify report format, get report formats, XSL transform the result. More...
 
char * run_wizard_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Run a wizard and XSL transform the result. More...
 
char * get_trash_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all trash, XSL transform the result. More...
 
char * get_my_settings_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page with user's settings. More...
 
char * edit_my_settings_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page with user's settings, for editing. More...
 
char * save_my_settings_omp (credentials_t *credentials, params_t *params, const char *accept_language, char **timezone, char **password, char **severity, char **language, cmd_response_data_t *response_data)
 Returns page with user's settings, for editing. More...
 
char * get_protocol_doc_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get OMP doc. More...
 
char * export_omp_doc_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Download the OMP doc. More...
 
char * get_group_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one group, XSL transform the result. More...
 
char * get_groups_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all groups, XSL transform the result. More...
 
char * new_group_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new group. More...
 
char * delete_trash_group_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a group from trash, get all groups, XSL transform the result. More...
 
char * delete_group_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a group, get all groups, XSL transform the result. More...
 
char * create_group_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a group, get all groups, XSL transform the result. More...
 
char * edit_group (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_group XML, XSL transform the result. More...
 
char * edit_group_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_group XML, XSL transform the result. More...
 
char * export_group_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a group. More...
 
char * export_groups_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of groups. More...
 
char * save_group_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a group, return the next page. More...
 
char * get_permission_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one permission, XSL transform the result. More...
 
char * get_permissions_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all permissions, XSL transform the result. More...
 
char * delete_trash_permission_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a permission, get all permissions, XSL transform the result. More...
 
char * delete_permission_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a permission, get all permissions, XSL transform the result. More...
 
char * new_permission (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup new_permission XML, XSL transform the result. More...
 
char * new_permission_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup new_permission XML, XSL transform the result. More...
 
char * create_permission_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a permission, get all permissions, XSL transform the result. More...
 
char * new_permissions (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup new_permissions XML, XSL transform the result. More...
 
char * new_permissions_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup new_permission XML, XSL transform the result. More...
 
char * create_permissions_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create multiple permission, get next page, XSL transform the result. More...
 
char * edit_permission (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_permission XML, XSL transform the result. More...
 
char * edit_permission_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_permission XML, XSL transform the result. More...
 
char * export_permission_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a permission. More...
 
char * export_permissions_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of permissions. More...
 
char * save_permission_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a permission, get all permissions, XSL transform the result. More...
 
char * upload_port_list_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the upload port list page. More...
 
char * create_port_list_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a port list, get all port lists, XSL transform the result. More...
 
char * new_port_range_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new Port Range page. More...
 
char * create_port_range_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Add a range to a port list, XSL transform the result. More...
 
char * get_port_list_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one port_list, XSL transform the result. More...
 
char * get_port_lists_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all port_lists, XSL transform the result. More...
 
char * new_port_list_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new Port List page. More...
 
char * edit_port_list_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_port_list XML, XSL transform the result. More...
 
char * save_port_list_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a port list, get all port list, XSL transform the result. More...
 
char * delete_port_list_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a port list, get all port lists, XSL transform the result. More...
 
char * delete_trash_port_list_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash port list, get all trash, XSL transform the result. More...
 
char * delete_port_range_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a port range, get the port list, XSL transform the result. More...
 
char * import_port_list_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Import port list, get all port_lists, XSL transform the result. More...
 
char * new_role_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new role. More...
 
char * delete_trash_role_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a role from trash, get all roles, XSL transform the result. More...
 
char * delete_role_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a role, get all roles, XSL transform the result. More...
 
char * create_role_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a role, get all roles, XSL transform the result. More...
 
char * edit_role_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_role XML, XSL transform the result. More...
 
char * get_role_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one role, XSL transform the result. More...
 
char * get_roles_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all roles, XSL transform the result. More...
 
char * export_role_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a role. More...
 
char * export_roles_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of roles. More...
 
char * save_role_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a role, return the next page. More...
 
char * get_feeds_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get descriptions of the feeds connected to the manager. More...
 
char * sync_feed_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Synchronize with an NVT feed and XSL transform the result. More...
 
char * sync_scap_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Synchronize with a SCAP feed and XSL transform the result. More...
 
char * sync_cert_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Synchronize with a CERT feed and XSL transform the result. More...
 
char * get_filter_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one filter, XSL transform the result. More...
 
char * get_filters_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all filters, XSL transform the result. More...
 
char * create_filter_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a filter, get all filters, XSL transform the result. More...
 
char * delete_trash_filter_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a filter, get all filters, XSL transform the result. More...
 
char * delete_filter_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a filter, get all filters, XSL transform the result. More...
 
char * edit_filter (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_filter XML, XSL transform the result. More...
 
char * edit_filter_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_filter XML, XSL transform the result. More...
 
char * export_filter_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a filter. More...
 
char * export_filters_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of filters. More...
 
char * new_filter_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new filter. More...
 
char * save_filter_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a filter, get all filters, XSL transform the result. More...
 
char * edit_schedule (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_schedule XML, XSL transform the result. More...
 
char * edit_schedule_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_schedule XML, XSL transform the result. More...
 
char * export_schedule_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a schedule. More...
 
char * export_schedules_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of schedules. More...
 
char * save_schedule_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save schedule, get next page, XSL transform the result. More...
 
char * new_user_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new user. More...
 
char * delete_user_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a user, get all users, XSL transform the result. More...
 
char * delete_user_confirm_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Show confirmation deleting a user, XSL transform the result. More...
 
char * get_user_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one user, XSL transform the result. More...
 
char * get_users_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all users, XSL transform the result. More...
 
char * create_user_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a user, get all users, XSL transform the result. More...
 
char * edit_user (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_user XML, XSL transform the result. More...
 
char * edit_user_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_user XML, XSL transform the result. More...
 
char * auth_settings_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 
char * save_user_omp (credentials_t *credentials, params_t *params, char **password_return, char **modified_user, int *logout_user, cmd_response_data_t *response_data)
 Modify a user, get all users, XSL transform the result. More...
 
char * export_user_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a user. More...
 
char * export_users_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of users. More...
 
char * cvss_calculator (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 
char * dashboard (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Show a dashboard. More...
 
char * save_auth_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save authentication settings. More...
 
char * save_chart_preference_omp (credentials_t *credentials, params_t *params, gchar **pref_id, gchar **pref_value, cmd_response_data_t *response_data)
 Save chart preferences. More...
 
char * wizard_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns a wizard page. More...
 
char * wizard_get_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns a wizard_get page. More...
 
char * process_bulk_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Returns a process_bulk page. More...
 
char * bulk_delete_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete multiple resources, get next page, XSL transform the result. More...
 
char * new_host_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new host page. More...
 
char * create_host_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a host, serve next page. More...
 
char * get_asset_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get asset, XSL transform the result. More...
 
char * get_assets_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get assets, XSL transform the result. More...
 
char * create_asset_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create an asset, get report, XSL transform the result. More...
 
char * delete_asset_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete an asset, go to the next page. More...
 
char * export_asset_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export an asset. More...
 
char * export_assets_omp (credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of assets. More...
 
char * edit_asset (credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit XML, XSL transform the result. More...
 
char * edit_asset_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_asset XML, XSL transform the result. More...
 
char * save_asset_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify an asset, get all assets, XSL transform the result. More...
 
char * get_assets_chart_omp (credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get an assets chart, XSL transform the result. More...
 
int connect_unix (const gchar *path)
 Connect to OpenVAS Manager daemon. More...
 
int openvas_connection_open (openvas_connection_t *connection, const gchar *address, int port)
 Connect to an address. More...
 
int authenticate_omp (const gchar *username, const gchar *password, gchar **role, gchar **timezone, gchar **severity, gchar **capabilities, gchar **language, gchar **pw_warning, GTree **chart_prefs, gchar **autorefresh)
 Check authentication credentials. More...
 

Variables

int manager_use_tls = 0
 Whether to use TLS for Manager connections. More...
 
gchar * manager_address = NULL
 The address the manager is on. More...
 
int manager_port = 9390
 The port the manager is on. More...
 

Detailed Description

OMP communication module of Greenbone Security Assistant daemon.

This file implements an API for OMP. The functions call the OpenVAS Manager via OMP properly, and apply XSL-Transforms to deliver HTML results.

Definition in file gsad_omp.c.

Macro Definition Documentation

#define AUTH_CONF_SETTING (   key,
  value 
)
Value:
"<auth_conf_setting>" \
"<key>" key "</key>" \
"<value>" value "</value>" \
"</auth_conf_setting>"

Generate AUTH_CONF_SETTING element for save_auth_omp.

Definition at line 26260 of file gsad_omp.c.

Referenced by save_auth_omp().

#define CHECK (   name)    CHECK_PARAM_INVALID (name, "Create Task", "new_task")

Check a param.

Parameters
[in]nameParam name.

Definition at line 9772 of file gsad_omp.c.

Referenced by clone_omp(), create_task_omp(), and save_task_omp().

#define CHECK (   name)
Value:
if (name == NULL) \
{ \
response_data->http_status_code = MHD_HTTP_BAD_REQUEST; \
return gsad_message (credentials, \
"Internal error", __FUNCTION__, __LINE__, \
"An internal error occurred while cloning a resource. " \
"The resource was not cloned. " \
"Diagnostics: Required parameter '" G_STRINGIFY (name) \
"' was NULL.", \
"/omp?cmd=get_tasks", response_data); \
}
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440

Check a param.

Parameters
[in]nameParam name.

Definition at line 9772 of file gsad_omp.c.

#define CHECK_OMPF_RET

Definition at line 21647 of file gsad_omp.c.

Referenced by create_permissions_omp().

#define CHECK_PARAM (   name,
  op_name,
  ret_func 
)
Value:
if (name == NULL) \
{ \
gchar *msg, *ret_html; \
msg = g_strdup_printf (GSAD_MESSAGE_INVALID, \
"Given " G_STRINGIFY (name) " was invalid", \
op_name); \
ret_html = ret_func (credentials, params, msg, response_data); \
g_free (msg); \
response_data->http_status_code = MHD_HTTP_BAD_REQUEST; \
return ret_html; \
}
#define GSAD_MESSAGE_INVALID
Answer for invalid input.
Definition: gsad_base.h:44

Check a param.

Parameters
[in]nameParam name.
[in]op_nameOperation name.
[in]ret_funcFunction to return message.

Definition at line 1184 of file gsad_omp.c.

Referenced by create_permissions_omp(), sync_config_omp(), and verify_scanner_omp().

#define CHECK_PARAM_INVALID (   name,
  op_name,
  next_cmd 
)
Value:
if (name == NULL) \
{ \
return message_invalid (credentials, params, response_data, \
"Given " G_STRINGIFY (name) " was invalid", \
G_STRINGIFY (MHD_HTTP_BAD_REQUEST), \
op_name, next_cmd); \
}
gchar * message_invalid(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *status, const char *op_name, const char *next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1472

Check a param using the direct response method.

Parameters
[in]nameParam name.
[in]op_nameOperation name.
[in]next_cmdNext command.

Definition at line 1204 of file gsad_omp.c.

Referenced by auth_settings_omp(), create_agent_omp(), create_alert_omp(), create_asset_omp(), create_config_omp(), create_container_task_omp(), create_credential_omp(), create_filter_omp(), create_group_omp(), create_host_omp(), create_note_omp(), create_override_omp(), create_permission_omp(), create_port_list_omp(), create_port_range_omp(), create_report_omp(), create_role_omp(), create_scanner_omp(), create_schedule_omp(), create_tag_omp(), create_target_omp(), create_user_omp(), save_agent_omp(), save_alert_omp(), save_asset_omp(), save_auth_omp(), save_config_omp(), save_container_task_omp(), save_credential_omp(), save_filter_omp(), save_group_omp(), save_note_omp(), save_override_omp(), save_permission_omp(), save_port_list_omp(), save_report_format_omp(), save_role_omp(), save_scanner_omp(), save_schedule_omp(), save_tag_omp(), save_target_omp(), save_task_omp(), and save_user_omp().

#define G_LOG_DOMAIN   "gsad omp"

GLib log domain.

Definition at line 81 of file gsad_omp.c.

#define GET_TRASH_RESOURCE (   capability,
  command,
  name 
)

Definition at line 19184 of file gsad_omp.c.

#define OPENVASMD_ADDRESS   "127.0.0.1"

Manager (openvasmd) address.

Definition at line 86 of file gsad_omp.c.

#define PARAM_OR_SETTING (   value,
  param,
  setting_id,
  cleanup 
)
Value:
if (params_valid (params, param)) \
value = g_strdup (params_value (params, param)); \
else \
{ \
char *message; \
message = setting_get_value_error (credentials, &connection, setting_id,\
&value, response_data); \
if (message) \
{ \
cleanup; \
return message; \
} \
}
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:764

Get a value from a param or fall back to a setting.

Parameters
[out]valueVariable to assign the value to.
[in]paramThe param to try get the value from first.
[in]setting_idThe UUID of the setting to try next.
[in]cleanupCode to run on failure.

Definition at line 3418 of file gsad_omp.c.

Function Documentation

char* auth_settings_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Definition at line 25651 of file gsad_omp.c.

References CHECK_PARAM_INVALID, command_enabled(), gsad_message(), cmd_response_data_t::http_status_code, and params_value().

25653 {
25654  GString * xml;
25655  gchar * buf;
25656  const char *name;
25657 
25658  name = params_value (params, "name");
25659 
25660  CHECK_PARAM_INVALID (name, "Auth settings", "auth_settings");
25661 
25662  xml = g_string_new ("");
25663  buf = g_markup_printf_escaped ("<auth_settings name=\"%s\">", name);
25664  g_string_append (xml, buf);
25665  g_free (buf);
25666 
25667  if (command_enabled (credentials, "DESCRIBE_AUTH"))
25668  {
25669  gchar * response = NULL;
25670  entity_t entity = NULL;
25671 
25672  switch (omp (credentials, &response, &entity, response_data,
25673  "<describe_auth/>"))
25674  {
25675  case 0:
25676  case -1:
25677  break;
25678  case 1:
25679  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25680  return gsad_message (credentials,
25681  "Internal error", __FUNCTION__, __LINE__,
25682  "An internal error occurred getting the auth list. "
25683  "Diagnostics: Failure to send command to manager daemon.",
25684  "/omp?cmd=get_users", response_data);
25685  case 2:
25686  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25687  return gsad_message (credentials,
25688  "Internal error", __FUNCTION__, __LINE__,
25689  "An internal error occurred getting the auth list. "
25690  "Diagnostics: Failure to receive response from manager daemon.",
25691  "/omp?cmd=get_users", response_data);
25692  default:
25693  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25694  return gsad_message (credentials,
25695  "Internal error", __FUNCTION__, __LINE__,
25696  "An internal error occurred getting the auth list. "
25697  "Diagnostics: Internal Error.",
25698  "/omp?cmd=get_users", response_data);
25699  }
25700 
25701 
25702  g_string_append (xml, response);
25703  free_entity (entity);
25704  g_free (response);
25705  }
25706 
25707  g_string_append (xml, "</auth_settings>");
25708 
25709  return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
25710  response_data);
25711 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:304

Here is the call graph for this function:

int authenticate_omp ( const gchar *  username,
const gchar *  password,
gchar **  role,
gchar **  timezone,
gchar **  severity,
gchar **  capabilities,
gchar **  language,
gchar **  pw_warning,
GTree **  chart_prefs,
gchar **  autorefresh 
)

Check authentication credentials.

Parameters
[in]usernameUsername.
[in]passwordPassword.
[out]roleRole.
[out]timezoneTimezone.
[out]severitySeverity class.
[out]capabilitiesCapabilities of manager.
[out]languageUser Interface Language, or NULL.
[out]pw_warningPassword warning message, NULL if password is OK.
[out]chart_prefsChart preferences.
[out]autorefreshAutorefresh preference.
Returns
0 if valid, 1 failed, 2 manager down, -1 error.

Definition at line 28065 of file gsad_omp.c.

References manager_address, manager_port, and openvas_connection_open().

Referenced by exec_omp_post(), and user_find().

28069 {
28070  openvas_connection_t connection;
28071  int auth;
28072  omp_authenticate_info_opts_t auth_opts;
28073 
28074  if (openvas_connection_open (&connection,
28076  manager_port))
28077  {
28078  g_debug ("%s failed to acquire socket!\n", __FUNCTION__);
28079  return 2;
28080  }
28081 
28082 #ifdef DEBUG_AUTH
28083  /* Enable this if you need the CGI to sleep after launch. This can be useful
28084  * if you need to attach to manager process the CGI is talking to for
28085  * debugging purposes.
28086  *
28087  * It's probably easier to run gsad in the foreground under gdb and
28088  * set a break point here.
28089  */
28090  g_debug ("Sleeping!");
28091  sleep (20);
28092 #endif
28093 
28094  auth_opts = omp_authenticate_info_opts_defaults;
28095  auth_opts.username = username;
28096  auth_opts.password = password;
28097  auth_opts.role = role;
28098  auth_opts.severity = severity;
28099  auth_opts.timezone = timezone;
28100  auth_opts.pw_warning = pw_warning;
28101 
28102  auth = omp_authenticate_info_ext_c (&connection, auth_opts);
28103  if (auth == 0)
28104  {
28105  entity_t entity;
28106  const char* status;
28107  char first;
28108  gchar *response;
28109  int ret;
28110 
28111  /* Get language setting. */
28112 
28113  ret = setting_get_value (&connection,
28114  "6765549a-934e-11e3-b358-406186ea4fc5",
28115  language,
28116  NULL);
28117 
28118  switch (ret)
28119  {
28120  case 0:
28121  break;
28122  case 1:
28123  case 2:
28124  openvas_connection_close (&connection);
28125  return 2;
28126  default:
28127  openvas_connection_close (&connection);
28128  return -1;
28129  }
28130 
28131  /* Request help. */
28132 
28133  ret = openvas_connection_sendf (&connection,
28134  "<help format=\"XML\" type=\"brief\"/>");
28135  if (ret)
28136  {
28137  openvas_connection_close (&connection);
28138  return 2;
28139  }
28140 
28141  /* Read the response. */
28142 
28143  entity = NULL;
28144  if (read_entity_and_text_c (&connection, &entity, &response))
28145  {
28146  openvas_connection_close (&connection);
28147  return 2;
28148  }
28149 
28150  /* Check the response. */
28151 
28152  status = entity_attribute (entity, "status");
28153  if (status == NULL
28154  || strlen (status) == 0)
28155  {
28156  g_free (response);
28157  free_entity (entity);
28158  return -1;
28159  }
28160  first = status[0];
28161  free_entity (entity);
28162  if (first == '2')
28163  {
28164  *capabilities = response;
28165  }
28166  else
28167  {
28168  openvas_connection_close (&connection);
28169  g_free (response);
28170  return -1;
28171  }
28172 
28173  /* Get the chart preferences */
28174 
28175  ret = openvas_connection_sendf (&connection,
28176  "<get_settings"
28177  " filter='name~\"Dashboard\"'/>");
28178  if (ret)
28179  {
28180  openvas_connection_close (&connection);
28181  return 2;
28182  }
28183 
28184  /* Read the response */
28185  entity = NULL;
28186  if (read_entity_and_text_c (&connection, &entity, &response))
28187  {
28188  openvas_connection_close (&connection);
28189  return 2;
28190  }
28191 
28192  /* Check the response. */
28193  status = entity_attribute (entity, "status");
28194  if (status == NULL
28195  || strlen (status) == 0)
28196  {
28197  g_free (response);
28198  free_entity (entity);
28199  return -1;
28200  }
28201  first = status[0];
28202  if (first == '2')
28203  {
28204  entities_t entities = entity->entities;
28205  entity_t child_entity;
28206  *chart_prefs = g_tree_new_full ((GCompareDataFunc) g_strcmp0,
28207  NULL, g_free, g_free);
28208 
28209  while ((child_entity = first_entity (entities)))
28210  {
28211  if (strcmp (entity_name (child_entity), "setting") == 0)
28212  {
28213  const char *setting_id
28214  = entity_attribute (child_entity, "id");
28215  const char *setting_value
28216  = entity_text (entity_child (child_entity, "value"));
28217 
28218  if (setting_id && setting_value)
28219  g_tree_insert (*chart_prefs,
28220  g_strdup (setting_id),
28221  g_strdup (setting_value));
28222  }
28223  entities = next_entities (entities);
28224  }
28225  free_entity (entity);
28226  g_free (response);
28227  }
28228  else
28229  {
28230  free_entity (entity);
28231  g_free (response);
28232  openvas_connection_close (&connection);
28233  return -1;
28234  }
28235 
28236  /* Get autorefresh setting. */
28237 
28238  ret = setting_get_value (&connection,
28239  "578a1c14-e2dc-45ef-a591-89d31391d007",
28240  autorefresh,
28241  NULL);
28242 
28243  switch (ret)
28244  {
28245  case 0:
28246  break;
28247  case 1:
28248  case 2:
28249  openvas_connection_close (&connection);
28250  return 2;
28251  default:
28252  openvas_connection_close (&connection);
28253  return -1;
28254  }
28255 
28256  openvas_connection_close (&connection);
28257  return 0;
28258  }
28259  else
28260  {
28261  openvas_connection_close (&connection);
28262  return 1;
28263  }
28264 }
gchar * manager_address
The address the manager is on.
Definition: gsad_omp.c:96
int manager_port
The port the manager is on.
Definition: gsad_omp.c:101
int openvas_connection_open(openvas_connection_t *connection, const gchar *address, int port)
Connect to an address.
Definition: gsad_omp.c:28023

Here is the call graph for this function:

Here is the caller graph for this function:

char* bulk_delete_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete multiple resources, get next page, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 27059 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, manager_connect(), params_add(), params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), and params_values().

27061 {
27062  openvas_connection_t connection;
27063  const char *no_redirect, *type;
27064  GString *commands_xml;
27065  params_t *selected_ids;
27066  params_iterator_t iter;
27067  param_t *param;
27068  gchar *param_name;
27069  gchar *html, *response;
27070  entity_t entity;
27071  gchar *extra_attribs;
27072 
27073  no_redirect = params_value (params, "no_redirect");
27074  type = params_value (params, "resource_type");
27075  if (type == NULL)
27076  {
27077  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
27078  return gsad_message (credentials,
27079  "Internal error", __FUNCTION__, __LINE__,
27080  "An internal error occurred while deleting resources. "
27081  "The resources were not deleted. "
27082  "Diagnostics: Required parameter 'resource_type' was NULL.",
27083  "/omp?cmd=get_tasks", response_data);
27084  }
27085 
27086  /* Extra attributes */
27087  extra_attribs = NULL;
27088 
27089  /* Inheritor of user's resource */
27090  if (strcmp (type, "user") == 0)
27091  {
27092  const char* inheritor_id;
27093  inheritor_id = params_value (params, "inheritor_id");
27094  if (inheritor_id)
27095  extra_attribs = g_strdup_printf ("inheritor_id=\"%s\"", inheritor_id);
27096  }
27097 
27098  commands_xml = g_string_new ("<commands>");
27099 
27100  selected_ids = params_values (params, "bulk_selected:");
27101  if (selected_ids)
27102  {
27103  params_iterator_init (&iter, selected_ids);
27104  while (params_iterator_next (&iter, &param_name, &param))
27105  {
27106  xml_string_append (commands_xml,
27107  "<delete_%s %s_id=\"%s\" ultimate=\"0\"",
27108  type,
27109  type,
27110  param_name);
27111  if (extra_attribs)
27112  g_string_append_printf (commands_xml, " %s/>", extra_attribs);
27113  else
27114  g_string_append (commands_xml, "/>");
27115  }
27116  }
27117 
27118  g_string_append (commands_xml, "</commands>");
27119 
27120  switch (manager_connect (credentials, &connection, &html,
27121  response_data))
27122  {
27123  case 0:
27124  break;
27125  case -1:
27126  if (html)
27127  return html;
27128  /* Fall through. */
27129  default:
27130  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27131  return gsad_message (credentials,
27132  "Internal error", __FUNCTION__, __LINE__,
27133  "An internal error occurred while deleting resources. "
27134  "The resources were not deleted. "
27135  "Diagnostics: Failure to connect to manager daemon.",
27136  "/omp?cmd=get_tasks", response_data);
27137  }
27138 
27139  /* Delete the resources and get all resources. */
27140 
27141  if (openvas_connection_sendf_xml (&connection,
27142  commands_xml->str)
27143  == -1)
27144  {
27145  g_string_free (commands_xml, TRUE);
27146  openvas_connection_close (&connection);
27147  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27148  return gsad_message (credentials,
27149  "Internal error", __FUNCTION__, __LINE__,
27150  "An internal error occurred while deleting resources. "
27151  "The resources were not deleted. "
27152  "Diagnostics: Failure to send command to manager daemon.",
27153  "/omp?cmd=get_tasks", response_data);
27154  }
27155  g_string_free (commands_xml, TRUE);
27156 
27157  entity = NULL;
27158  if (read_entity_and_text_c (&connection, &entity, &response))
27159  {
27160  openvas_connection_close (&connection);
27161  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27162  return gsad_message (credentials,
27163  "Internal error", __FUNCTION__, __LINE__,
27164  "An internal error occurred while deleting resources. "
27165  "It is unclear whether the resources have been deleted or not. "
27166  "Diagnostics: Failure to read response from manager daemon.",
27167  "/omp?cmd=get_tasks", response_data);
27168  }
27169 
27170  openvas_connection_close (&connection);
27171 
27172  /* Cleanup, and return transformed XML. */
27173 
27174  if (params_given (params, "next") == 0)
27175  {
27176  gchar *next;
27177  next = g_strdup_printf ("get_%ss", type);
27178  params_add (params, "next", next);
27179  g_free (next);
27180  }
27181  html = response_from_entity (credentials, params, entity,
27182  (no_redirect && strcmp (no_redirect, "0")),
27183  NULL, NULL,
27184  NULL, NULL,
27185  "Bulk Delete", response_data);
27186  g_free (response);
27187  free_entity (entity);
27188 
27189  return html;
27190 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279
#define params_iterator_init
Definition: gsad_base.h:187
#define params_iterator_t
Definition: gsad_base.h:185
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* clone_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Clone a resource, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 9795 of file gsad_omp.c.

References CHECK, gsad_message(), cmd_response_data_t::http_status_code, manager_connect(), params_add(), params_given(), params_value(), and set_http_status_from_entity().

9797 {
9798  openvas_connection_t connection;
9799  gchar *html, *response;
9800  const char *id, *type, *alterable, *no_redirect, *next_id;
9801  gchar *next_id_name, *cap_type, *prev_action;
9802  entity_t entity;
9803 
9804  id = params_value (params, "id");
9805  type = params_value (params, "resource_type");
9806  alterable = params_value (params, "alterable");
9807  no_redirect = params_value (params, "no_redirect");
9808 
9809  CHECK (id);
9810  CHECK (type);
9811 
9812  switch (manager_connect (credentials, &connection, &html,
9813  response_data))
9814  {
9815  case 0:
9816  break;
9817  case -1:
9818  if (html)
9819  return html;
9820  /* Fall through. */
9821  default:
9822  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9823  return gsad_message (credentials,
9824  "Internal error", __FUNCTION__, __LINE__,
9825  "An internal error occurred while cloning a resource. "
9826  "The resource was not cloned. "
9827  "Diagnostics: Failure to connect to manager daemon.",
9828  "/omp?cmd=get_tasks", response_data);
9829  }
9830 
9831  /* Clone the resource. */
9832 
9833  if (alterable && strcmp (alterable, "0"))
9834  {
9835  if (openvas_connection_sendf (&connection,
9836  "<create_%s>"
9837  "<copy>%s</copy>"
9838  "<alterable>1</alterable>"
9839  "</create_%s>",
9840  type,
9841  id,
9842  type)
9843  == -1)
9844  {
9845  openvas_connection_close (&connection);
9846  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9847  return gsad_message (credentials,
9848  "Internal error", __FUNCTION__, __LINE__,
9849  "An internal error occurred while cloning a resource. "
9850  "The resource was not cloned. "
9851  "Diagnostics: Failure to send command to manager daemon.",
9852  "/omp?cmd=get_tasks", response_data);
9853  }
9854  }
9855  else if (openvas_connection_sendf (&connection,
9856  "<create_%s>"
9857  "<copy>%s</copy>"
9858  "</create_%s>",
9859  type,
9860  id,
9861  type)
9862  == -1)
9863  {
9864  openvas_connection_close (&connection);
9865  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9866  return gsad_message (credentials,
9867  "Internal error", __FUNCTION__, __LINE__,
9868  "An internal error occurred while cloning a resource. "
9869  "The resource was not cloned. "
9870  "Diagnostics: Failure to send command to manager daemon.",
9871  "/omp?cmd=get_tasks", response_data);
9872  }
9873 
9874  entity = NULL;
9875  if (read_entity_and_text_c (&connection, &entity, &response))
9876  {
9877  openvas_connection_close (&connection);
9878  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9879  return gsad_message (credentials,
9880  "Internal error", __FUNCTION__, __LINE__,
9881  "An internal error occurred while cloning a resource. "
9882  "It is unclear whether the resource has been cloned or not. "
9883  "Diagnostics: Failure to read response from manager daemon.",
9884  "/omp?cmd=get_tasks", response_data);
9885  }
9886 
9887  openvas_connection_close (&connection);
9888 
9889  /* Cleanup, and return next page. */
9890 
9891  if (omp_success (entity) == 0 || params_given (params, "next") == 0)
9892  {
9893  gchar *next;
9894  next = g_strdup_printf ("get_%ss", type);
9895  params_add (params, "next", next);
9896  g_free (next);
9897  }
9898 
9899  if (omp_success (entity))
9900  {
9901  next_id = entity_attribute (entity, "id");
9902  if (next_id == NULL)
9903  {
9904  free_entity (entity);
9905  g_free (response);
9906  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9907  return gsad_message (credentials,
9908  "Internal error", __FUNCTION__, __LINE__,
9909  "An internal error occurred while cloning a resource. "
9910  "The resource remains the same. "
9911  "Diagnostics: Error getting new resource.",
9912  "/omp?cmd=get_tasks", response_data);
9913  }
9914  next_id_name = g_strdup_printf ("%s_id", type);
9915  params_add (params, next_id_name, next_id);
9916  g_free (next_id_name);
9917  }
9918  else
9919  {
9920  set_http_status_from_entity (entity, response_data);
9921  next_id_name = NULL;
9922  next_id = NULL;
9923  }
9924 
9925  cap_type = capitalize (type);
9926  prev_action = g_strdup_printf ("Clone %s", cap_type);
9927  html = response_from_entity (credentials, params, entity,
9928  (no_redirect && strcmp (no_redirect, "0")),
9929  NULL, NULL,
9930  NULL, NULL,
9931  prev_action, response_data);
9932 
9933  free_entity (entity);
9934  g_free (cap_type);
9935  g_free (prev_action);
9936  g_free (response);
9937 
9938  return html;
9939 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:879
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK(name)
Check a param.
Definition: gsad_omp.c:9772
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

void cmd_response_data_init ( cmd_response_data_t data)

Initializes a cmd_response_data_t struct.

Parameters
[in]dataThe cmd_response_data_t struct to initialize

Definition at line 347 of file gsad_omp.c.

References cmd_response_data_t::http_status_code, and cmd_response_data_t::redirect.

Referenced by exec_omp_post(), and handle_request().

348 {
349  data->http_status_code = MHD_HTTP_OK;
350  data->redirect = NULL;
351 }
gchar * redirect
HTTP status code.
Definition: gsad_base.h:94

Here is the caller graph for this function:

void cmd_response_data_reset ( cmd_response_data_t data)

Clears a cmd_response_data_t struct.

Parameters
[in]dataStruct to reset.

Definition at line 359 of file gsad_omp.c.

Referenced by exec_omp_post(), and handle_request().

360 {
361  memset (data, 0, sizeof (cmd_response_data_t));
362 }
Response information for commands.
Definition: gsad_base.h:92

Here is the caller graph for this function:

int command_enabled ( credentials_t credentials,
const gchar *  name 
)

Init the GSA OMP library.

Parameters
[in]credentialsCredentials.
[in]nameCommand name.

Definition at line 304 of file gsad_omp.c.

References credentials_t::capabilities.

Referenced by auth_settings_omp(), edit_alert(), edit_permission(), edit_target(), edit_user(), get_info(), get_my_settings_omp(), get_one(), get_system_reports_omp(), new_permission(), and new_permissions().

305 {
306  /* TODO Hack. Fails if command named in summary of another command. */
307  return strstr (credentials->capabilities, name) ? 1 : 0;
308 }
char * capabilities
Capabilites of manager.
Definition: gsad_base.h:76

Here is the caller graph for this function:

int connect_unix ( const gchar *  path)

Connect to OpenVAS Manager daemon.

Parameters
[in]pathPath to the Manager socket.
Returns
Socket, or -1 on error.

Definition at line 27985 of file gsad_omp.c.

Referenced by openvas_connection_open().

27986 {
27987  struct sockaddr_un address;
27988  int sock;
27989 
27990  /* Make socket. */
27991 
27992  sock = socket (AF_UNIX, SOCK_STREAM, 0);
27993  if (sock == -1)
27994  {
27995  g_warning ("Failed to create server socket");
27996  return -1;
27997  }
27998 
27999  /* Connect to server. */
28000 
28001  address.sun_family = AF_UNIX;
28002  strncpy (address.sun_path, path, sizeof (address.sun_path) - 1);
28003  if (connect (sock, (struct sockaddr *) &address, sizeof (address)) == -1)
28004  {
28005  g_warning ("Failed to connect to server: %s", strerror (errno));
28006  close (sock);
28007  return -1;
28008  }
28009 
28010  return sock;
28011 }
struct sockaddr_storage address
The IP address of this program, "the GSAD".
Definition: gsad.c:255

Here is the caller graph for this function:

char* create_agent_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create an agent, get all agents, XSL transform result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 7061 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_filename(), params_value(), and params_value_size().

7063 {
7064  entity_t entity;
7065  gchar *response, *html;
7066  const char *no_redirect;
7067  const char *name, *comment, *installer, *installer_filename, *installer_sig;
7068  const char *howto_install, *howto_use;
7069  int installer_size, installer_sig_size, howto_install_size, howto_use_size;
7070  int ret;
7071  gchar *installer_64, *installer_sig_64, *howto_install_64, *howto_use_64;
7072  gchar *command;
7073 
7074  no_redirect = params_value (params, "no_redirect");
7075  name = params_value (params, "name");
7076  comment = params_value (params, "comment");
7077  installer = params_value (params, "installer");
7078  installer_filename = params_filename (params, "installer");
7079  installer_size = params_value_size (params, "installer");
7080  installer_sig = params_value (params, "installer_sig");
7081  installer_sig_size = params_value_size (params, "installer_sig");
7082  howto_install = params_value (params, "howto_install");
7083  howto_install_size = params_value_size (params, "howto_install");
7084  howto_use = params_value (params, "howto_use");
7085  howto_use_size = params_value_size (params, "howto_use");
7086 
7087  CHECK_PARAM_INVALID (name, "Create Agent", "new_agent");
7088  CHECK_PARAM_INVALID (comment, "Create Agent", "new_agent");
7089 
7090  /* Create the agent. */
7091 
7092  installer_64 = (installer_size > 0)
7093  ? g_base64_encode ((guchar *) installer,
7094  installer_size)
7095  : g_strdup ("");
7096 
7097  installer_sig_64 = (installer_sig_size > 0)
7098  ? g_base64_encode ((guchar *) installer_sig,
7099  installer_sig_size)
7100  : g_strdup ("");
7101 
7102  howto_install_64 = (howto_install_size > 0)
7103  ? g_base64_encode ((guchar *) howto_install,
7104  howto_install_size)
7105  : g_strdup ("");
7106 
7107  howto_use_64 = (howto_use_size > 0)
7108  ? g_base64_encode ((guchar *) howto_use,
7109  howto_use_size)
7110  : g_strdup ("");
7111 
7112  command = g_strdup_printf ("<create_agent>"
7113  "<name>%s</name>"
7114  "%s%s%s"
7115  "<installer>"
7116  "%s"
7117  "<signature>%s</signature>"
7118  "<filename>%s</filename>"
7119  "</installer>"
7120  "<howto_install>%s</howto_install>"
7121  "<howto_use>%s</howto_use>"
7122  "</create_agent>",
7123  name, comment ? "<comment>" : "",
7124  comment ? comment : "",
7125  comment ? "</comment>" : "",
7126  installer_64,
7127  installer_sig_64,
7128  installer_filename ? installer_filename : "",
7129  howto_install_64,
7130  howto_use_64);
7131 
7132  ret = omp (credentials,
7133  &response,
7134  &entity,
7135  response_data,
7136  command);
7137  g_free (command);
7138 
7139  g_free (installer_64);
7140  g_free (howto_install_64);
7141  g_free (howto_use_64);
7142 
7143  switch (ret)
7144  {
7145  case 0:
7146  break;
7147  case -1:
7148  /* 'omp' set response. */
7149  return response;
7150  case 1:
7151  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7152  return gsad_message (credentials,
7153  "Internal error", __FUNCTION__, __LINE__,
7154  "An internal error occurred while creating a new agent. "
7155  "No new agent was created. "
7156  "Diagnostics: Failure to send command to manager daemon.",
7157  "/omp?cmd=get_agents", response_data);
7158  case 2:
7159  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7160  return gsad_message (credentials,
7161  "Internal error", __FUNCTION__, __LINE__,
7162  "An internal error occurred while creating a new agent. "
7163  "It is unclear whether the agent has been created or not. "
7164  "Diagnostics: Failure to receive response from manager daemon.",
7165  "/omp?cmd=get_agents", response_data);
7166  default:
7167  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7168  return gsad_message (credentials,
7169  "Internal error", __FUNCTION__, __LINE__,
7170  "An internal error occurred while creating a new agent. "
7171  "It is unclear whether the agent has been created or not. "
7172  "Diagnostics: Internal Error.",
7173  "/omp?cmd=get_agents", response_data);
7174  }
7175 
7176  if (entity_attribute (entity, "id"))
7177  params_add (params, "agent_id", entity_attribute (entity, "id"));
7178  html = response_from_entity (credentials, params, entity,
7179  (no_redirect && strcmp (no_redirect, "0")),
7180  NULL, "get_agents",
7181  NULL, "new_agent",
7182  "Create Agent", response_data);
7183  free_entity (entity);
7184  g_free (response);
7185  return html;
7186 }
int params_value_size(params_t *params, const char *name)
Get the size of the value of param.
Definition: gsad_base.c:698
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_filename(params_t *params, const char *name)
Get filename of param.
Definition: gsad_base.c:732
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* create_alert_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create an alert, get all alerts, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 8347 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), and param::value.

8349 {
8350  int ret;
8351  gchar *html, *response;
8352  const char *no_redirect;
8353  const char *name, *comment, *condition, *event, *method, *filter_id;
8354  params_t *method_data, *event_data, *condition_data;
8355  entity_t entity;
8356  GString *xml;
8357 
8358  no_redirect = params_value (params, "no_redirect");
8359  name = params_value (params, "name");
8360  comment = params_value (params, "comment");
8361  condition = params_value (params, "condition");
8362  event = params_value (params, "event");
8363  method = params_value (params, "method");
8364  filter_id = params_value (params, "filter_id");
8365 
8366  CHECK_PARAM_INVALID (name, "Create Alert", "new_alert");
8367  CHECK_PARAM_INVALID (comment, "Create Alert", "new_alert");
8368  CHECK_PARAM_INVALID (condition, "Create Alert", "new_alert");
8369  CHECK_PARAM_INVALID (event, "Create Alert", "new_alert");
8370  CHECK_PARAM_INVALID (method, "Create Alert", "new_alert");
8371  CHECK_PARAM_INVALID (filter_id, "Create Alert", "new_alert");
8372 
8373  /* Create the alert. */
8374 
8375  method_data = params_values (params, "method_data:");
8376  event_data = params_values (params, "event_data:");
8377  condition_data = params_values (params, "condition_data:");
8378 
8379  xml = g_string_new ("");
8380 
8381  if ((strcmp (event, "New SecInfo arrived") == 0) && event_data)
8382  {
8383  params_iterator_t iter;
8384  char *name;
8385  param_t *param;
8386 
8387  params_iterator_init (&iter, event_data);
8388  while (params_iterator_next (&iter, &name, &param))
8389  if ((strcmp (name, "feed_event") == 0)
8390  && param->value
8391  && (strcmp (param->value, "updated") == 0))
8392  {
8393  event = "Updated SecInfo arrived";
8394  break;
8395  }
8396  }
8397 
8398  xml_string_append (xml,
8399  "<create_alert>"
8400  "<name>%s</name>"
8401  "<filter id=\"%s\"/>"
8402  "<comment>%s</comment>"
8403  "<event>%s",
8404  name,
8405  filter_id,
8406  comment ? comment : "",
8407  event);
8408 
8409  append_alert_event_data (xml, event_data, event);
8410 
8411  xml_string_append (xml,
8412  "</event>"
8413  "<method>%s",
8414  method);
8415 
8416  append_alert_method_data (xml, method_data, method);
8417 
8418  xml_string_append (xml,
8419  "</method>"
8420  "<condition>%s",
8421  condition);
8422 
8423  append_alert_condition_data (xml, condition_data, condition);
8424 
8425  xml_string_append (xml,
8426  "</condition>"
8427  "</create_alert>");
8428 
8429  ret = omp (credentials,
8430  &response,
8431  &entity,
8432  response_data,
8433  xml->str);
8434  g_string_free (xml, TRUE);
8435  switch (ret)
8436  {
8437  case 0:
8438  case -1:
8439  break;
8440  case 1:
8441  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8442  return gsad_message (credentials,
8443  "Internal error", __FUNCTION__, __LINE__,
8444  "An internal error occurred while creating a new alert. "
8445  "No new alert was created. "
8446  "Diagnostics: Failure to send command to manager daemon.",
8447  "/omp?cmd=get_alerts", response_data);
8448  case 2:
8449  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8450  return gsad_message (credentials,
8451  "Internal error", __FUNCTION__, __LINE__,
8452  "An internal error occurred while creating a new alert. "
8453  "It is unclear whether the alert has been created or not. "
8454  "Diagnostics: Failure to receive response from manager daemon.",
8455  "/omp?cmd=get_alerts", response_data);
8456  default:
8457  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8458  return gsad_message (credentials,
8459  "Internal error", __FUNCTION__, __LINE__,
8460  "An internal error occurred while creating a new alert. "
8461  "It is unclear whether the alert has been created or not. "
8462  "Diagnostics: Internal Error.",
8463  "/omp?cmd=get_alerts", response_data);
8464  }
8465 
8466  if (entity_attribute (entity, "id"))
8467  params_add (params, "alert_id", entity_attribute (entity, "id"));
8468  html = response_from_entity (credentials, params, entity,
8469  (no_redirect && strcmp (no_redirect, "0")),
8470  NULL, "get_alerts",
8471  NULL, "new_alert",
8472  "Create Alert", response_data);
8473  free_entity (entity);
8474  g_free (response);
8475  return html;
8476 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
#define params_iterator_init
Definition: gsad_base.h:187
#define params_iterator_t
Definition: gsad_base.h:185
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* create_asset_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create an asset, get report, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 27504 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, and params_value().

27506 {
27507  char *ret;
27508  gchar *response;
27509  const char *no_redirect, *report_id, *filter;
27510  entity_t entity;
27511 
27512  no_redirect = params_value (params, "no_redirect");
27513  report_id = params_value (params, "report_id");
27514  filter = params_value (params, "filter");
27515 
27516  CHECK_PARAM_INVALID (report_id, "Create Asset", "get_report_section");
27517  CHECK_PARAM_INVALID (filter, "Create Asset", "get_report_section");
27518 
27519  response = NULL;
27520  entity = NULL;
27521  switch (ompf (credentials,
27522  &response,
27523  &entity,
27524  response_data,
27525  "<create_asset>"
27526  "<report id=\"%s\">"
27527  "<filter><term>%s</term></filter>"
27528  "</report>"
27529  "</create_asset>",
27530  report_id,
27531  filter))
27532  {
27533  case 0:
27534  case -1:
27535  break;
27536  case 1:
27537  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27538  return gsad_message (credentials,
27539  "Internal error", __FUNCTION__, __LINE__,
27540  "An internal error occurred while creating an asset. "
27541  "No new asset was created. "
27542  "Diagnostics: Failure to send command to manager daemon.",
27543  "/omp?cmd=get_tasks", response_data);
27544  case 2:
27545  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27546  return gsad_message (credentials,
27547  "Internal error", __FUNCTION__, __LINE__,
27548  "An internal error occurred while creating an asset. "
27549  "It is unclear whether the asset has been created or not. "
27550  "Diagnostics: Failure to receive response from manager daemon.",
27551  "/omp?cmd=get_tasks", response_data);
27552  default:
27553  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27554  return gsad_message (credentials,
27555  "Internal error", __FUNCTION__, __LINE__,
27556  "An internal error occurred while creating an asset. "
27557  "It is unclear whether the asset has been created or not. "
27558  "Diagnostics: Internal Error.",
27559  "/omp?cmd=get_tasks", response_data);
27560  }
27561 
27562  ret = response_from_entity (credentials, params, entity,
27563  (no_redirect && strcmp (no_redirect, "0")),
27564  NULL, "get_report_section",
27565  NULL, "get_report_section",
27566  "Create Asset", response_data);
27567  free_entity (entity);
27568  g_free (response);
27569  return ret;
27570 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

char* create_config_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create config, get all configs, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 11648 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), and params_value().

11650 {
11651  gchar *html, *response;
11652  const char *no_redirect, *name, *comment, *base, *scanner = NULL;
11653  entity_t entity;
11654 
11655  no_redirect = params_value (params, "no_redirect");
11656  name = params_value (params, "name");
11657  comment = params_value (params, "comment");
11658  base = params_value (params, "base");
11659 
11660  CHECK_PARAM_INVALID (name, "New Config", "new_config");
11661  CHECK_PARAM_INVALID (comment, "New Config", "new_config");
11662  CHECK_PARAM_INVALID (base, "New Config", "new_config");
11663  if (!strcmp (base, "0"))
11664  {
11665  scanner = params_value (params, "scanner_id");
11666  CHECK_PARAM_INVALID (scanner, "New Config", "new_config");
11667  }
11668 
11669  /* Create the config. */
11670  switch (ompf (credentials,
11671  &response,
11672  &entity,
11673  response_data,
11674  "<create_config>"
11675  "<name>%s</name>"
11676  "<copy>%s</copy>"
11677  "<comment>%s</comment>"
11678  "<scanner>%s</scanner>"
11679  "</create_config>",
11680  name, base, comment,
11681  scanner ?: ""))
11682  {
11683  case 0:
11684  case -1:
11685  break;
11686  case 1:
11687  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11688  return gsad_message (credentials,
11689  "Internal error", __FUNCTION__, __LINE__,
11690  "An internal error occurred while creating a new config. "
11691  "No new config was created. "
11692  "Diagnostics: Failure to send command to manager daemon.",
11693  "/omp?cmd=get_configs", response_data);
11694  case 2:
11695  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11696  return gsad_message (credentials,
11697  "Internal error", __FUNCTION__, __LINE__,
11698  "An internal error occurred while creating a new config. "
11699  "It is unclear whether the config has been created or not. "
11700  "Diagnostics: Failure to receive response from manager daemon.",
11701  "/omp?cmd=get_configs", response_data);
11702  default:
11703  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11704  return gsad_message (credentials,
11705  "Internal error", __FUNCTION__, __LINE__,
11706  "An internal error occurred while creating a new config. "
11707  "It is unclear whether the config has been created or not. "
11708  "Diagnostics: Internal Error.",
11709  "/omp?cmd=get_configs", response_data);
11710  }
11711 
11712  if (entity_attribute (entity, "id"))
11713  params_add (params, "config_id", entity_attribute (entity, "id"));
11714  html = response_from_entity (credentials, params, entity,
11715  (no_redirect && strcmp (no_redirect, "0")),
11716  NULL, "get_configs",
11717  NULL, "new_config",
11718  "Create Config", response_data);
11719 
11720  free_entity (entity);
11721  g_free (response);
11722  return html;
11723 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* create_container_task_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a container task, serve next page.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 4134 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), and params_value().

4136 {
4137  entity_t entity;
4138  int ret;
4139  gchar *command, *html, *response;
4140  const char *no_redirect, *name, *comment;
4141 
4142  no_redirect = params_value (params, "no_redirect");
4143  name = params_value (params, "name");
4144  comment = params_value (params, "comment");
4145  CHECK_PARAM_INVALID (name, "Create Container Task", "new_container_task");
4146  CHECK_PARAM_INVALID (comment, "Create Container Task", "new_container_task");
4147 
4148  command = g_strdup_printf ("<create_task>"
4149  "<target id=\"0\"/>"
4150  "<name>%s</name>"
4151  "<comment>%s</comment>"
4152  "</create_task>",
4153  name,
4154  comment);
4155  ret = omp (credentials,
4156  &response,
4157  &entity,
4158  response_data,
4159  command);
4160  g_free (command);
4161 
4162  switch (ret)
4163  {
4164  case 0:
4165  break;
4166  case -1:
4167  /* 'omp' set response. */
4168  return response;
4169  case 1:
4170  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4171  return gsad_message (credentials,
4172  "Internal error", __FUNCTION__, __LINE__,
4173  "An internal error occurred while creating a container task. "
4174  "No task was created. "
4175  "Diagnostics: Failure to send command to manager daemon.",
4176  "/omp?cmd=get_tasks", response_data);
4177  case 2:
4178  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4179  return gsad_message (credentials,
4180  "Internal error", __FUNCTION__, __LINE__,
4181  "An internal error occurred while creating a container task. "
4182  "It is unclear whether the task has been created or not. "
4183  "Diagnostics: Failure to receive response from manager daemon.",
4184  "/omp?cmd=get_tasks", response_data);
4185  default:
4186  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4187  return gsad_message (credentials,
4188  "Internal error", __FUNCTION__, __LINE__,
4189  "An internal error occurred while creating a container task. "
4190  "It is unclear whether the task has been created or not. "
4191  "Diagnostics: Internal Error.",
4192  "/omp?cmd=get_tasks", response_data);
4193  }
4194 
4195  if (entity_attribute (entity, "id"))
4196  params_add (params, "task_id", entity_attribute (entity, "id"));
4197  html = response_from_entity (credentials, params, entity,
4198  (no_redirect && strcmp (no_redirect, "0")),
4199  NULL, "get_tasks",
4200  NULL, "new_container_task",
4201  "Create Container Task", response_data);
4202  free_entity (entity);
4203  g_free (response);
4204  return html;
4205 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* create_credential_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a credential, get all credentials, XSL transform result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 6110 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, message_invalid(), params_add(), and params_value().

6112 {
6113  int ret;
6114  gchar *html, *response;
6115  const char *no_redirect;
6116  const char *name, *comment, *login, *type, *password, *passphrase;
6117  const char *private_key, *certificate, *community, *privacy_password;
6118  const char *auth_algorithm, *privacy_algorithm, *allow_insecure;
6119  int autogenerate;
6120  entity_t entity;
6121 
6122  no_redirect = params_value (params, "no_redirect");
6123  name = params_value (params, "name");
6124  comment = params_value (params, "comment");
6125  login = params_value (params, "credential_login");
6126  type = params_value (params, "base");
6127  password = params_value (params, "lsc_password");
6128  passphrase = params_value (params, "passphrase");
6129  private_key = params_value (params, "private_key");
6130  certificate = params_value (params, "certificate");
6131  community = params_value (params, "community");
6132  privacy_password = params_value (params, "privacy_password");
6133  auth_algorithm = params_value (params, "auth_algorithm");
6134  privacy_algorithm = params_value (params, "privacy_algorithm");
6135  allow_insecure = params_value (params, "allow_insecure");
6136 
6137  if (params_value (params, "autogenerate"))
6138  autogenerate = strcmp (params_value (params, "autogenerate"), "0");
6139  else
6140  return message_invalid (credentials, params, response_data,
6141  "Given autogenerate was invalid",
6142  G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
6143  "Create Credential", "new_credential");
6144 
6145  CHECK_PARAM_INVALID (name, "Create Credential", "new_credential");
6146  CHECK_PARAM_INVALID (comment, "Create Credential", "new_credential");
6147  CHECK_PARAM_INVALID (type, "Create Credential", "new_credential");
6148  CHECK_PARAM_INVALID (allow_insecure, "Create Credential", "new_credential");
6149 
6150  if (autogenerate)
6151  {
6152  if (type && (strcmp (type, "cc") == 0))
6153  {
6154  // Auto-generate types without username
6155  ret = ompf (credentials,
6156  &response,
6157  &entity,
6158  response_data,
6159  "<create_credential>"
6160  "<name>%s</name>"
6161  "<comment>%s</comment>"
6162  "<type>%s</type>"
6163  "<allow_insecure>%s</allow_insecure>"
6164  "</create_credential>",
6165  name,
6166  comment ? comment : "",
6167  type,
6168  allow_insecure);
6169  }
6170  else
6171  {
6172  // Auto-generate types with username
6173  CHECK_PARAM_INVALID (login, "Create Credential", "new_credential");
6174 
6175  ret = ompf (credentials,
6176  &response,
6177  &entity,
6178  response_data,
6179  "<create_credential>"
6180  "<name>%s</name>"
6181  "<comment>%s</comment>"
6182  "<type>%s</type>"
6183  "<login>%s</login>"
6184  "<allow_insecure>%s</allow_insecure>"
6185  "</create_credential>",
6186  name,
6187  comment ? comment : "",
6188  type,
6189  login,
6190  allow_insecure);
6191  }
6192  }
6193  else
6194  {
6195  if (type && (strcmp (type, "up") == 0))
6196  {
6197  CHECK_PARAM_INVALID (login,
6198  "Create Credential", "new_credential");
6199  CHECK_PARAM_INVALID (password,
6200  "Create Credential", "new_credential");
6201 
6202  ret = ompf (credentials,
6203  &response,
6204  &entity,
6205  response_data,
6206  "<create_credential>"
6207  "<name>%s</name>"
6208  "<comment>%s</comment>"
6209  "<type>%s</type>"
6210  "<login>%s</login>"
6211  "<password>%s</password>"
6212  "<allow_insecure>%s</allow_insecure>"
6213  "</create_credential>",
6214  name,
6215  comment ? comment : "",
6216  type,
6217  login ? login : "",
6218  password ? password : "",
6219  allow_insecure);
6220  }
6221  else if (type && (strcmp (type, "usk") == 0))
6222  {
6223  CHECK_PARAM_INVALID (login,
6224  "Create Credential", "new_credential");
6225  CHECK_PARAM_INVALID (passphrase,
6226  "Create Credential", "new_credential");
6227  CHECK_PARAM_INVALID (private_key,
6228  "Create Credential", "new_credential");
6229 
6230  ret = ompf (credentials,
6231  &response,
6232  &entity,
6233  response_data,
6234  "<create_credential>"
6235  "<name>%s</name>"
6236  "<comment>%s</comment>"
6237  "<type>%s</type>"
6238  "<login>%s</login>"
6239  "<key>"
6240  "<private>%s</private>"
6241  "<phrase>%s</phrase>"
6242  "</key>"
6243  "<allow_insecure>%s</allow_insecure>"
6244  "</create_credential>",
6245  name,
6246  comment ? comment : "",
6247  type,
6248  login ? login : "",
6249  private_key ? private_key : "",
6250  passphrase ? passphrase : "",
6251  allow_insecure);
6252  }
6253  else if (type && (strcmp (type, "cc") == 0))
6254  {
6255  CHECK_PARAM_INVALID (certificate,
6256  "Create Credential", "new_credential");
6257  CHECK_PARAM_INVALID (private_key,
6258  "Create Credential", "new_credential");
6259 
6260  ret = ompf (credentials,
6261  &response,
6262  &entity,
6263  response_data,
6264  "<create_credential>"
6265  "<name>%s</name>"
6266  "<comment>%s</comment>"
6267  "<type>%s</type>"
6268  "<certificate>%s</certificate>"
6269  "<key>"
6270  "<private>%s</private>"
6271  "</key>"
6272  "<allow_insecure>%s</allow_insecure>"
6273  "</create_credential>",
6274  name,
6275  comment ? comment : "",
6276  type,
6277  certificate ? certificate : "",
6278  private_key ? private_key : "",
6279  allow_insecure);
6280 
6281  }
6282  else if (type && (strcmp (type, "snmp") == 0))
6283  {
6284  CHECK_PARAM_INVALID (community,
6285  "Create Credential", "new_credential");
6286  CHECK_PARAM_INVALID (login,
6287  "Create Credential", "new_credential");
6288  CHECK_PARAM_INVALID (password,
6289  "Create Credential", "new_credential");
6290  CHECK_PARAM_INVALID (privacy_password,
6291  "Create Credential", "new_credential");
6292  CHECK_PARAM_INVALID (auth_algorithm,
6293  "Create Credential", "new_credential");
6294  CHECK_PARAM_INVALID (privacy_algorithm,
6295  "Create Credential", "new_credential");
6296 
6297  if (privacy_password && strcmp (privacy_password, ""))
6298  ret = ompf (credentials,
6299  &response,
6300  &entity,
6301  response_data,
6302  "<create_credential>"
6303  "<name>%s</name>"
6304  "<comment>%s</comment>"
6305  "<type>%s</type>"
6306  "<community>%s</community>"
6307  "<login>%s</login>"
6308  "<password>%s</password>"
6309  "<privacy>"
6310  "<password>%s</password>"
6311  "<algorithm>%s</algorithm>"
6312  "</privacy>"
6313  "<auth_algorithm>%s</auth_algorithm>"
6314  "<allow_insecure>%s</allow_insecure>"
6315  "</create_credential>",
6316  name,
6317  comment ? comment : "",
6318  type,
6319  community ? community : "",
6320  login ? login : "",
6321  password ? password : "",
6322  privacy_password ? privacy_password : "",
6323  privacy_algorithm ? privacy_algorithm : "",
6324  auth_algorithm ? auth_algorithm : "",
6325  allow_insecure);
6326  else
6327  ret = ompf (credentials,
6328  &response,
6329  &entity,
6330  response_data,
6331  "<create_credential>"
6332  "<name>%s</name>"
6333  "<comment>%s</comment>"
6334  "<type>%s</type>"
6335  "<community>%s</community>"
6336  "<login>%s</login>"
6337  "<password>%s</password>"
6338  "<auth_algorithm>%s</auth_algorithm>"
6339  "<allow_insecure>%s</allow_insecure>"
6340  "</create_credential>",
6341  name,
6342  comment ? comment : "",
6343  type,
6344  community ? community : "",
6345  login ? login : "",
6346  password ? password : "",
6347  auth_algorithm ? auth_algorithm : "",
6348  allow_insecure);
6349  }
6350  else
6351  {
6352  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6353  return gsad_message (credentials,
6354  "Internal error", __FUNCTION__, __LINE__,
6355  "An internal error occurred while creating a new credential. "
6356  "The credential could not be created. "
6357  "Diagnostics: Unrecognized credential type.",
6358  "/omp?cmd=get_credentials", response_data);
6359  }
6360  }
6361 
6362  /* Create the credential. */
6363  switch (ret)
6364  {
6365  case 0:
6366  case -1:
6367  break;
6368  case 1:
6369  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6370  return gsad_message (credentials,
6371  "Internal error", __FUNCTION__, __LINE__,
6372  "An internal error occurred while creating a new credential. "
6373  "It is unclear whether the credential has been created or not. "
6374  "Diagnostics: Failure to send command to manager daemon.",
6375  "/omp?cmd=get_credentials", response_data);
6376  case 2:
6377  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6378  return gsad_message (credentials,
6379  "Internal error", __FUNCTION__, __LINE__,
6380  "An internal error occurred while creating a new credential. "
6381  "It is unclear whether the credential has been created or not. "
6382  "Diagnostics: Failure to receive response from manager daemon.",
6383  "/omp?cmd=get_credentials", response_data);
6384  default:
6385  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6386  return gsad_message (credentials,
6387  "Internal error", __FUNCTION__, __LINE__,
6388  "An internal error occurred while creating a new credential. "
6389  "It is unclear whether the credential has been created or not. "
6390  "Diagnostics: Internal Error.",
6391  "/omp?cmd=get_credentials", response_data);
6392  }
6393 
6394  if (entity_attribute (entity, "id"))
6395  params_add (params, "credential_id", entity_attribute (entity, "id"));
6396  html = response_from_entity (credentials, params, entity,
6397  (no_redirect && strcmp (no_redirect, "0")),
6398  NULL, "get_credentials",
6399  NULL, "new_credential",
6400  "Create Credential",
6401  response_data);
6402  free_entity (entity);
6403  g_free (response);
6404  return html;
6405 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gchar * message_invalid(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *status, const char *op_name, const char *next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1472
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* create_filter_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a filter, get all filters, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 24302 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_value(), param::valid, param::valid_utf8, and param::value.

24304 {
24305  gchar *html, *response;
24306  const char *no_redirect, *name, *comment, *term, *type;
24307  entity_t entity;
24308 
24309  no_redirect = params_value (params, "no_redirect");
24310  name = params_value (params, "name");
24311  comment = params_value (params, "comment");
24312  term = params_value (params, "term");
24313  type = params_value (params, "optional_resource_type");
24314 
24315  CHECK_PARAM_INVALID (name, "Create Filter", "new_filter");
24316  CHECK_PARAM_INVALID (comment, "Create Filter", "new_filter");
24317  CHECK_PARAM_INVALID (term, "Create Filter", "new_filter");
24318  CHECK_PARAM_INVALID (type, "Create Filter", "new_filter");
24319 
24320  switch (ompf (credentials,
24321  &response,
24322  &entity,
24323  response_data,
24324  "<create_filter>"
24325  "<name>%s</name>"
24326  "<comment>%s</comment>"
24327  "<term>%s</term>"
24328  "<type>%s</type>"
24329  "</create_filter>",
24330  name,
24331  comment,
24332  term,
24333  type))
24334  {
24335  case 0:
24336  case -1:
24337  break;
24338  case 1:
24339  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24340  return gsad_message (credentials,
24341  "Internal error", __FUNCTION__, __LINE__,
24342  "An internal error occurred while creating a new alert. "
24343  "No new alert was created. "
24344  "Diagnostics: Failure to send command to manager daemon.",
24345  "/omp?cmd=get_alerts", response_data);
24346  case 2:
24347  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24348  return gsad_message (credentials,
24349  "Internal error", __FUNCTION__, __LINE__,
24350  "An internal error occurred while creating a new alert. "
24351  "It is unclear whether the alert has been created or not. "
24352  "Diagnostics: Failure to receive response from manager daemon.",
24353  "/omp?cmd=get_alerts", response_data);
24354  default:
24355  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24356  return gsad_message (credentials,
24357  "Internal error", __FUNCTION__, __LINE__,
24358  "An internal error occurred while creating a new alert. "
24359  "It is unclear whether the alert has been created or not. "
24360  "Diagnostics: Internal Error.",
24361  "/omp?cmd=get_alerts", response_data);
24362  }
24363 
24364  if (omp_success (entity))
24365  {
24366  const char *filter_id;
24367 
24368  filter_id = entity_attribute (entity, "id");
24369  if (filter_id && strlen (filter_id))
24370  {
24371  param_t *param;
24372  param = params_add (params, "filt_id", filter_id);
24373  param->valid = 1;
24374  param->valid_utf8 = g_utf8_validate (param->value, -1, NULL);
24375  }
24376  }
24377 
24378  if (entity_attribute (entity, "id"))
24379  params_add (params, "filter_id", entity_attribute (entity, "id"));
24380  html = response_from_entity (credentials, params, entity,
24381  (no_redirect && strcmp (no_redirect, "0")),
24382  NULL, "get_filters",
24383  NULL, "new_filter",
24384  "Create Filter", response_data);
24385  free_entity (entity);
24386  g_free (response);
24387  return html;
24388 }
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int valid_utf8
Definition: gsad_base.h:151
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int valid
Definition: gsad_base.h:150
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* create_group_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a group, get all groups, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 20814 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_value(), and users.

20816 {
20817  gchar *html, *response, *command, *specials_element;
20818  const char *no_redirect, *name, *comment, *users, *grant_full;
20819  entity_t entity;
20820  GString *xml;
20821  int ret;
20822 
20823  no_redirect = params_value (params, "no_redirect");
20824  name = params_value (params, "name");
20825  comment = params_value (params, "comment");
20826  grant_full = params_value (params, "grant_full");
20827  users = params_value (params, "users");
20828 
20829  CHECK_PARAM_INVALID (name, "Create Group", "new_group");
20830  CHECK_PARAM_INVALID (comment, "Create Group", "new_group");
20831  CHECK_PARAM_INVALID (users, "Create Group", "new_group");
20832 
20833  /* Create the group. */
20834 
20835  xml = g_string_new ("");
20836 
20837  xml_string_append (xml,
20838  "<name>%s</name>"
20839  "<comment>%s</comment>"
20840  "<users>%s</users>",
20841  name,
20842  comment,
20843  users);
20844 
20845  if (grant_full)
20846  specials_element = g_strdup_printf ("<full/>");
20847  else
20848  specials_element = NULL;
20849 
20850  command = g_strdup_printf ("<create_group>"
20851  "%s"
20852  "<specials>"
20853  "%s"
20854  "</specials>"
20855  "</create_group>",
20856  xml->str,
20857  specials_element);
20858 
20859  g_string_free (xml, TRUE);
20860  g_free (specials_element);
20861 
20862  ret = omp (credentials, &response, &entity, response_data, command);
20863  g_free (command);
20864  switch (ret)
20865  {
20866  case 0:
20867  case -1:
20868  break;
20869  case 1:
20870  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20871  return gsad_message (credentials,
20872  "Internal error", __FUNCTION__, __LINE__,
20873  "An internal error occurred while creating a new group. "
20874  "No new group was created. "
20875  "Diagnostics: Failure to send command to manager daemon.",
20876  "/omp?cmd=get_groups", response_data);
20877  case 2:
20878  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20879  return gsad_message (credentials,
20880  "Internal error", __FUNCTION__, __LINE__,
20881  "An internal error occurred while creating a new group. "
20882  "It is unclear whether the group has been created or not. "
20883  "Diagnostics: Failure to receive response from manager daemon.",
20884  "/omp?cmd=get_groups", response_data);
20885  default:
20886  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20887  return gsad_message (credentials,
20888  "Internal error", __FUNCTION__, __LINE__,
20889  "An internal error occurred while creating a new group. "
20890  "It is unclear whether the group has been created or not. "
20891  "Diagnostics: Internal Error.",
20892  "/omp?cmd=get_groups", response_data);
20893  }
20894 
20895  if (entity_attribute (entity, "id"))
20896  params_add (params, "group_id", entity_attribute (entity, "id"));
20897  html = response_from_entity (credentials, params, entity,
20898  (no_redirect && strcmp (no_redirect, "0")),
20899  NULL, "get_groups",
20900  NULL, "new_group",
20901  "Create Group", response_data);
20902  free_entity (entity);
20903  g_free (response);
20904  return html;
20905 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
GPtrArray * users
User session data.
Definition: gsad.c:309
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* create_host_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a host, serve next page.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 27244 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), and params_value().

27246 {
27247  int ret;
27248  gchar *html, *response;
27249  const char *no_redirect, *name, *comment;
27250  entity_t entity;
27251  GString *xml;
27252 
27253  no_redirect = params_value (params, "no_redirect");
27254 
27255  name = params_value (params, "name");
27256  CHECK_PARAM_INVALID (name, "Create Host", "new_host");
27257 
27258  comment = params_value (params, "comment");
27259  CHECK_PARAM_INVALID (comment, "Create Host", "new_host");
27260 
27261  /* Create the host. */
27262 
27263  xml = g_string_new ("");
27264 
27265  xml_string_append (xml,
27266  "<create_asset>"
27267  "<asset>"
27268  "<type>host</type>"
27269  "<name>%s</name>"
27270  "<comment>%s</comment>"
27271  "</asset>"
27272  "</create_asset>",
27273  name,
27274  comment);
27275 
27276  ret = omp (credentials,
27277  &response,
27278  &entity,
27279  response_data,
27280  xml->str);
27281  g_string_free (xml, TRUE);
27282  switch (ret)
27283  {
27284  case 0:
27285  case -1:
27286  break;
27287  case 1:
27288  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27289  return gsad_message (credentials,
27290  "Internal error", __FUNCTION__, __LINE__,
27291  "An internal error occurred while creating a new host. "
27292  "No new host was created. "
27293  "Diagnostics: Failure to send command to manager daemon.",
27294  "/omp?cmd=get_assets", response_data);
27295  case 2:
27296  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27297  return gsad_message (credentials,
27298  "Internal error", __FUNCTION__, __LINE__,
27299  "An internal error occurred while creating a new host. "
27300  "It is unclear whether the host has been created or not. "
27301  "Diagnostics: Failure to receive response from manager daemon.",
27302  "/omp?cmd=get_assets", response_data);
27303  default:
27304  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27305  return gsad_message (credentials,
27306  "Internal error", __FUNCTION__, __LINE__,
27307  "An internal error occurred while creating a new host. "
27308  "It is unclear whether the host has been created or not. "
27309  "Diagnostics: Internal Error.",
27310  "/omp?cmd=get_assets", response_data);
27311  }
27312 
27313  if (entity_attribute (entity, "id"))
27314  params_add (params, "asset_id", entity_attribute (entity, "id"));
27315  html = response_from_entity (credentials, params, entity,
27316  (no_redirect && strcmp (no_redirect, "0")),
27317  NULL, "get_assets",
27318  NULL, "new_host",
27319  "Create Host", response_data);
27320  free_entity (entity);
27321  g_free (response);
27322  return html;
27323 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* create_note_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a note, get report, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 15942 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_given(), params_original_value(), params_valid(), and params_value().

15944 {
15945  char *ret;
15946  gchar *response;
15947  const char *no_redirect, *oid, *severity, *port, *hosts;
15948  const char *text, *task_id, *note_result_id;
15949  /* For get_report. */
15950  const char *active, *days;
15951  entity_t entity;
15952 
15953  no_redirect = params_value (params, "no_redirect");
15954  oid = params_value (params, "oid");
15955  CHECK_PARAM_INVALID (oid, "Create Note", "new_note");
15956 
15957  if (params_valid (params, "severity"))
15958  severity = params_value (params, "severity");
15959  else if (params_given (params, "severity")
15960  && strcmp (params_original_value (params, "severity"), ""))
15961  severity = NULL;
15962  else
15963  severity = "";
15964  CHECK_PARAM_INVALID (severity, "Create Note", "new_note");
15965 
15966  port = params_value (params, "port");
15967  if (port == NULL)
15968  port = "";
15969  if (strcmp (port, "--") == 0)
15970  {
15971  int num = -1;
15972 
15973  port = params_value (params, "port_manual");
15974  if (port)
15975  num = atoi (port);
15976  if (num < 0 || num > 65535)
15977  port = NULL;
15978  }
15979  CHECK_PARAM_INVALID (port, "Create Note", "new_note");
15980 
15981  if (params_valid (params, "hosts"))
15982  {
15983  hosts = params_value (params, "hosts");
15984  if (strcmp (hosts, "--") == 0)
15985  {
15986  if (params_valid (params, "hosts_manual"))
15987  hosts = params_value (params, "hosts_manual");
15988  else if (params_given (params, "hosts_manual")
15989  && strcmp (params_original_value (params, "hosts_manual"),
15990  ""))
15991  hosts = NULL;
15992  else
15993  hosts = "";
15994  }
15995  }
15996  else if (strcmp (params_original_value (params, "hosts"), ""))
15997  hosts = NULL;
15998  else
15999  hosts = "";
16000  CHECK_PARAM_INVALID (hosts, "Create Note", "new_note");
16001 
16002  if (params_valid (params, "note_task_id"))
16003  {
16004  task_id = params_value (params, "note_task_id");
16005  if (task_id && (strcmp (task_id, "0") == 0))
16006  task_id = params_value (params, "note_task_uuid");
16007  }
16008  else if (params_given (params, "note_task_id")
16009  && strcmp (params_original_value (params, "note_task_id"), ""))
16010  task_id = NULL;
16011  else
16012  task_id = "";
16013 
16014  active = params_value (params, "active");
16015  CHECK_PARAM_INVALID (active, "Create Note", "new_note");
16016 
16017  text = params_value (params, "text");
16018  days = params_value (params, "days");
16019 
16020  note_result_id = params_value (params, "note_result_id");
16021  if (note_result_id && (strcmp (note_result_id, "0") == 0))
16022  note_result_id = params_value (params, "note_result_uuid");
16023 
16024  response = NULL;
16025  entity = NULL;
16026  switch (ompf (credentials,
16027  &response,
16028  &entity,
16029  response_data,
16030  "<create_note>"
16031  "<active>%s</active>"
16032  "<nvt oid=\"%s\"/>"
16033  "<hosts>%s</hosts>"
16034  "<port>%s</port>"
16035  "<severity>%s</severity>"
16036  "<text>%s</text>"
16037  "<task id=\"%s\"/>"
16038  "<result id=\"%s\"/>"
16039  "</create_note>",
16040  strcmp (active, "1")
16041  ? active
16042  : (days ? days : "-1"),
16043  oid,
16044  hosts,
16045  port,
16046  severity,
16047  text ? text : "",
16048  task_id,
16049  note_result_id))
16050  {
16051  case 0:
16052  case -1:
16053  break;
16054  case 1:
16055  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16056  return gsad_message (credentials,
16057  "Internal error", __FUNCTION__, __LINE__,
16058  "An internal error occurred while creating a new note. "
16059  "No new note was created. "
16060  "Diagnostics: Failure to send command to manager daemon.",
16061  "/omp?cmd=get_notes", response_data);
16062  case 2:
16063  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16064  return gsad_message (credentials,
16065  "Internal error", __FUNCTION__, __LINE__,
16066  "An internal error occurred while creating a new note. "
16067  "It is unclear whether the note has been created or not. "
16068  "Diagnostics: Failure to receive response from manager daemon.",
16069  "/omp?cmd=get_notes", response_data);
16070  default:
16071  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16072  return gsad_message (credentials,
16073  "Internal error", __FUNCTION__, __LINE__,
16074  "An internal error occurred while creating a new note. "
16075  "It is unclear whether the note has been created or not. "
16076  "Diagnostics: Internal Error.",
16077  "/omp?cmd=get_notes", response_data);
16078  }
16079 
16080  if (entity_attribute (entity, "id"))
16081  params_add (params, "note_id", entity_attribute (entity, "id"));
16082  ret = response_from_entity (credentials, params, entity,
16083  (no_redirect && strcmp (no_redirect, "0")),
16084  NULL, "get_notes",
16085  NULL, "new_note",
16086  "Create Note", response_data);
16087  free_entity (entity);
16088  g_free (response);
16089  return ret;
16090 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
const char * params_original_value(params_t *params, const char *name)
Get original value of param, before validation.
Definition: gsad_base.c:716
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:764

Here is the call graph for this function:

char* create_override_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create an override, get report, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 16658 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_given(), params_original_value(), params_valid(), and params_value().

16660 {
16661  char *ret;
16662  gchar *response;
16663  const char *no_redirect;
16664  const char *oid, *severity, *custom_severity, *new_severity, *port, *hosts;
16665  const char *text, *task_id, *override_result_id;
16666  /* For get_report. */
16667  const char *active, *days;
16668  entity_t entity;
16669 
16670  no_redirect = params_value (params, "no_redirect");
16671  oid = params_value (params, "oid");
16672  CHECK_PARAM_INVALID (oid, "Create Override", "new_override");
16673 
16674  if (params_valid (params, "severity"))
16675  severity = params_value (params, "severity");
16676  else if (params_given (params, "severity")
16677  && strcmp (params_original_value (params, "severity"), ""))
16678  severity = NULL;
16679  else
16680  severity = "";
16681  CHECK_PARAM_INVALID (severity, "Create Override", "new_override");
16682 
16683  custom_severity = params_value (params, "custom_severity");
16684  CHECK_PARAM_INVALID (custom_severity, "Create Override", "new_override");
16685 
16686  if (custom_severity != NULL && strcmp (custom_severity, "0"))
16687  {
16688  if (params_valid (params, "new_severity"))
16689  new_severity = params_value (params, "new_severity");
16690  else if (params_original_value (params, "new_severity") == NULL
16691  || strcmp (params_original_value (params, "new_severity"), ""))
16692  new_severity = NULL;
16693  else
16694  new_severity = "";
16695  CHECK_PARAM_INVALID (new_severity, "Create Override", "new_override");
16696  }
16697  else
16698  {
16699  if (params_valid (params, "new_severity_from_list"))
16700  new_severity = params_value (params, "new_severity_from_list");
16701  else if (params_original_value (params, "new_severity_from_list") == NULL
16702  || strcmp (params_original_value (params,
16703  "new_severity_from_list"),
16704  ""))
16705  new_severity = NULL;
16706  else
16707  new_severity = "";
16708  CHECK_PARAM_INVALID (new_severity, "Create Override", "new_override");
16709  }
16710 
16711  port = params_value (params, "port");
16712  if (port == NULL)
16713  port = "";
16714  if (strcmp (port, "--") == 0)
16715  {
16716  int num = -1;
16717 
16718  port = params_value (params, "port_manual");
16719  if (port)
16720  num = atoi (port);
16721  if (num < 0 || num > 65535)
16722  port = NULL;
16723  }
16724  CHECK_PARAM_INVALID (port, "Create Override", "new_override");
16725 
16726  if (params_valid (params, "hosts"))
16727  {
16728  hosts = params_value (params, "hosts");
16729  if (strcmp (hosts, "--") == 0)
16730  {
16731  if (params_valid (params, "hosts_manual"))
16732  hosts = params_value (params, "hosts_manual");
16733  else if (params_given (params, "hosts_manual")
16734  && strcmp (params_original_value (params, "hosts_manual"),
16735  ""))
16736  hosts = NULL;
16737  else
16738  hosts = "";
16739  }
16740  }
16741  else if (strcmp (params_original_value (params, "hosts"), ""))
16742  hosts = NULL;
16743  else
16744  hosts = "";
16745  CHECK_PARAM_INVALID (hosts, "Create Override", "new_override");
16746 
16747  if (params_valid (params, "override_task_id"))
16748  {
16749  task_id = params_value (params, "override_task_id");
16750  if (task_id && (strcmp (task_id, "0") == 0))
16751  task_id = params_value (params, "override_task_uuid");
16752  }
16753  else
16754  task_id = "";
16755 
16756  active = params_value (params, "active");
16757  CHECK_PARAM_INVALID (active, "Create Override", "new_override");
16758 
16759  text = params_value (params, "text");
16760  days = params_value (params, "days");
16761 
16762  override_result_id = params_value (params, "override_result_id");
16763  if (override_result_id && (strcmp (override_result_id, "0") == 0))
16764  override_result_id = params_value (params, "override_result_uuid");
16765 
16766  response = NULL;
16767  entity = NULL;
16768  switch (ompf (credentials,
16769  &response,
16770  &entity,
16771  response_data,
16772  "<create_override>"
16773  "<active>%s</active>"
16774  "<nvt oid=\"%s\"/>"
16775  "<hosts>%s</hosts>"
16776  "<port>%s</port>"
16777  "<severity>%s</severity>"
16778  "<new_severity>%s</new_severity>"
16779  "<text>%s</text>"
16780  "<task id=\"%s\"/>"
16781  "<result id=\"%s\"/>"
16782  "</create_override>",
16783  strcmp (active, "1")
16784  ? active
16785  : (days ? days : "-1"),
16786  oid,
16787  hosts,
16788  port,
16789  severity,
16790  new_severity,
16791  text ? text : "",
16792  task_id,
16793  override_result_id))
16794  {
16795  case 0:
16796  case -1:
16797  break;
16798  case 1:
16799  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16800  return gsad_message (credentials,
16801  "Internal error", __FUNCTION__, __LINE__,
16802  "An internal error occurred while creating a new override. "
16803  "No new override was created. "
16804  "Diagnostics: Failure to send command to manager daemon.",
16805  "/omp?cmd=get_overrides", response_data);
16806  case 2:
16807  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16808  return gsad_message (credentials,
16809  "Internal error", __FUNCTION__, __LINE__,
16810  "An internal error occurred while creating a new override. "
16811  "It is unclear whether the override has been created or not. "
16812  "Diagnostics: Failure to receive response from manager daemon.",
16813  "/omp?cmd=get_overrides", response_data);
16814  default:
16815  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16816  return gsad_message (credentials,
16817  "Internal error", __FUNCTION__, __LINE__,
16818  "An internal error occurred while creating a new override. "
16819  "It is unclear whether the override has been created or not. "
16820  "Diagnostics: Internal Error.",
16821  "/omp?cmd=get_overrides", response_data);
16822  }
16823 
16824  if (entity_attribute (entity, "id"))
16825  params_add (params, "override_id", entity_attribute (entity, "id"));
16826  ret = response_from_entity (credentials, params, entity,
16827  (no_redirect && strcmp (no_redirect, "0")),
16828  NULL, "get_overrides",
16829  NULL, "new_override",
16830  "Create Override", response_data);
16831  free_entity (entity);
16832  g_free (response);
16833  return ret;
16834 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
const char * params_original_value(params_t *params, const char *name)
Get original value of param, before validation.
Definition: gsad_base.c:716
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:764

Here is the call graph for this function:

char* create_permission_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a permission, get all permissions, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 21365 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_given(), and params_value().

21367 {
21368  int ret;
21369  gchar *html, *response;
21370  const char *no_redirect, *name, *comment, *resource_id, *resource_type;
21371  const char *subject_id, *subject_type, *subject_name;
21372  entity_t entity;
21373 
21374  gchar *subject_response;
21375  entity_t get_subject_entity = NULL;
21376  entity_t subject_entity;
21377 
21378  no_redirect = params_value (params, "no_redirect");
21379  name = params_value (params, "permission");
21380  comment = params_value (params, "comment");
21381  resource_id = params_value (params, "id_or_empty");
21382  resource_type = params_value (params, "optional_resource_type");
21383  subject_type = params_value (params, "subject_type");
21384  subject_name = params_value (params, "subject_name");
21385 
21386  CHECK_PARAM_INVALID (name, "Create Permission", "new_permission");
21387  CHECK_PARAM_INVALID (comment, "Create Permission", "new_permission");
21388  if (params_given (params, "id_or_empty"))
21389  CHECK_PARAM_INVALID (resource_id, "Create Permission", "new_permission");
21390  CHECK_PARAM_INVALID (subject_type, "Create Permission", "new_permission");
21391  if (params_given (params, "optional_resource_type"))
21392  CHECK_PARAM_INVALID (resource_type, "Create Permission", "new_permission");
21393 
21394  if (params_given (params, "subject_name"))
21395  {
21396  CHECK_PARAM_INVALID (subject_name,
21397  "Create Permission", "new_permission");
21398  subject_id = NULL;
21399  ret = ompf (credentials,
21400  &subject_response,
21401  &get_subject_entity,
21402  response_data,
21403  "<get_%ss filter=\"rows=1 name=%s\">"
21404  "</get_%ss>",
21405  subject_type,
21406  subject_name,
21407  subject_type);
21408 
21409  switch (ret)
21410  {
21411  case 0:
21412  case -1:
21413  break;
21414  case 1:
21415  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21416  return gsad_message (credentials,
21417  "Internal error", __FUNCTION__, __LINE__,
21418  "An internal error occurred while getting"
21419  " the subject for a permission. "
21420  "The permission was not created. "
21421  "Diagnostics: Failure to send command"
21422  " to manager daemon.",
21423  "/omp?cmd=get_permissions", response_data);
21424  case 2:
21425  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21426  return gsad_message (credentials,
21427  "Internal error", __FUNCTION__, __LINE__,
21428  "An internal error occurred while getting"
21429  " the subject for a permission. "
21430  "The permission was not created. "
21431  "Diagnostics: Failure to receive response"
21432  " from manager daemon.",
21433  "/omp?cmd=get_permissions", response_data);
21434  default:
21435  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21436  return gsad_message (credentials,
21437  "Internal error", __FUNCTION__, __LINE__,
21438  "An internal error occurred while getting"
21439  " the subject for a permission. "
21440  "The permission was not created. "
21441  "Diagnostics: Internal Error.",
21442  "/omp?cmd=get_permissions", response_data);
21443  }
21444 
21445  subject_entity = entity_child (get_subject_entity, subject_type);
21446 
21447  if (subject_entity)
21448  subject_id = entity_attribute (subject_entity, "id");
21449 
21450  if (subject_id == NULL)
21451  {
21452  gchar *msg;
21453  msg = g_strdup_printf ("<gsad_msg status_text=\"Subject not found\""
21454  " operation=\"create_permission\">"
21455  "Could not find a %s with name '%s'."
21456  "</gsad_msg>",
21457  subject_type,
21458  subject_name ? subject_name : "");
21459  return next_page (credentials, params, msg, response_data);
21460  }
21461  }
21462  else if (strcmp (subject_type, "user") == 0)
21463  subject_id = params_value (params, "permission_user_id");
21464  else if (strcmp (subject_type, "group") == 0)
21465  subject_id = params_value (params, "permission_group_id");
21466  else if (strcmp (subject_type, "role") == 0)
21467  subject_id = params_value (params, "permission_role_id");
21468  else
21469  subject_id = NULL;
21470  CHECK_PARAM_INVALID (subject_id, "Create Permission", "new_permission");
21471 
21472  /* Create the permission(s). */
21473 
21474  if (strcmp (name, "task_proxy") == 0)
21475  {
21476  response = NULL;
21477  entity = NULL;
21478  ret = ompf (credentials,
21479  &response,
21480  &entity,
21481  response_data,
21482  "<commands>"
21483  "<create_permission>"
21484  "<name>get_tasks</name>"
21485  "<comment>%s</comment>"
21486  "<resource id=\"%s\"/>"
21487  "<subject id=\"%s\"><type>%s</type></subject>"
21488  "</create_permission>"
21489  "<create_permission>"
21490  "<name>modify_task</name>"
21491  "<comment>%s</comment>"
21492  "<resource id=\"%s\"/>"
21493  "<subject id=\"%s\"><type>%s</type></subject>"
21494  "</create_permission>"
21495  "<create_permission>"
21496  "<name>start_task</name>"
21497  "<comment>%s</comment>"
21498  "<resource id=\"%s\"/>"
21499  "<subject id=\"%s\"><type>%s</type></subject>"
21500  "</create_permission>"
21501  "<create_permission>"
21502  "<name>stop_task</name>"
21503  "<comment>%s</comment>"
21504  "<resource id=\"%s\"/>"
21505  "<subject id=\"%s\"><type>%s</type></subject>"
21506  "</create_permission>"
21507  "<create_permission>"
21508  "<name>resume_task</name>"
21509  "<comment>%s</comment>"
21510  "<resource id=\"%s\"/>"
21511  "<subject id=\"%s\"><type>%s</type></subject>"
21512  "</create_permission>"
21513  "</commands>",
21514  comment ? comment : "",
21515  resource_id ? resource_id : "",
21516  subject_id,
21517  subject_type,
21518  comment ? comment : "",
21519  resource_id ? resource_id : "",
21520  subject_id,
21521  subject_type,
21522  comment ? comment : "",
21523  resource_id ? resource_id : "",
21524  subject_id,
21525  subject_type,
21526  comment ? comment : "",
21527  resource_id ? resource_id : "",
21528  subject_id,
21529  subject_type,
21530  comment ? comment : "",
21531  resource_id ? resource_id : "",
21532  subject_id,
21533  subject_type);
21534 
21535  if (get_subject_entity)
21536  free_entity (get_subject_entity);
21537 
21538  switch (ret)
21539  {
21540  case 0:
21541  case -1:
21542  break;
21543  case 1:
21544  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21545  return gsad_message (credentials,
21546  "Internal error", __FUNCTION__, __LINE__,
21547  "An internal error occurred while creating a permission. "
21548  "The permission was not created. "
21549  "Diagnostics: Failure to send command to manager daemon.",
21550  "/omp?cmd=get_permissions", response_data);
21551  case 2:
21552  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21553  return gsad_message (credentials,
21554  "Internal error", __FUNCTION__, __LINE__,
21555  "An internal error occurred while creating a permission. "
21556  "It is unclear whether the permission has been created or not. "
21557  "Diagnostics: Failure to receive response from manager daemon.",
21558  "/omp?cmd=get_permissions", response_data);
21559  default:
21560  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21561  return gsad_message (credentials,
21562  "Internal error", __FUNCTION__, __LINE__,
21563  "An internal error occurred while creating a permission. "
21564  "It is unclear whether the permission has been created or not. "
21565  "Diagnostics: Internal Error.",
21566  "/omp?cmd=get_permissions", response_data);
21567  }
21568 
21569  if (entity_attribute (entity, "id"))
21570  params_add (params, "permission_id", entity_attribute (entity, "id"));
21571  html = response_from_entity (credentials, params, entity,
21572  (no_redirect && strcmp (no_redirect, "0")),
21573  NULL, "get_permissions",
21574  NULL, "new_permission",
21575  "Create Permission", response_data);
21576  }
21577  else
21578  {
21579  response = NULL;
21580  entity = NULL;
21581  ret = ompf (credentials,
21582  &response,
21583  &entity,
21584  response_data,
21585  "<create_permission>"
21586  "<name>%s</name>"
21587  "<comment>%s</comment>"
21588  "<resource id=\"%s\">"
21589  "<type>%s</type>"
21590  "</resource>"
21591  "<subject id=\"%s\"><type>%s</type></subject>"
21592  "</create_permission>",
21593  name,
21594  comment ? comment : "",
21595  resource_id ? resource_id : "",
21596  resource_type ? resource_type : "",
21597  subject_id,
21598  subject_type);
21599 
21600  if (get_subject_entity)
21601  free_entity (get_subject_entity);
21602 
21603  switch (ret)
21604  {
21605  case 0:
21606  case -1:
21607  break;
21608  case 1:
21609  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21610  return gsad_message (credentials,
21611  "Internal error", __FUNCTION__, __LINE__,
21612  "An internal error occurred while creating a permission. "
21613  "The permission was not created. "
21614  "Diagnostics: Failure to send command to manager daemon.",
21615  "/omp?cmd=get_permissions", response_data);
21616  case 2:
21617  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21618  return gsad_message (credentials,
21619  "Internal error", __FUNCTION__, __LINE__,
21620  "An internal error occurred while creating a permission. "
21621  "It is unclear whether the permission has been created or not. "
21622  "Diagnostics: Failure to receive response from manager daemon.",
21623  "/omp?cmd=get_permissions", response_data);
21624  default:
21625  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21626  return gsad_message (credentials,
21627  "Internal error", __FUNCTION__, __LINE__,
21628  "An internal error occurred while creating a permission. "
21629  "It is unclear whether the permission has been created or not. "
21630  "Diagnostics: Internal Error.",
21631  "/omp?cmd=get_permissions", response_data);
21632  }
21633 
21634  if (entity_attribute (entity, "id"))
21635  params_add (params, "permission_id", entity_attribute (entity, "id"));
21636  html = response_from_entity (credentials, params, entity,
21637  (no_redirect && strcmp (no_redirect, "0")),
21638  NULL, "get_permissions",
21639  NULL, "new_permission",
21640  "Create Permission", response_data);
21641  }
21642  free_entity (entity);
21643  g_free (response);
21644  return html;
21645 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* create_permissions_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create multiple permission, get next page, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 22003 of file gsad_omp.c.

References CHECK_OMPF_RET, CHECK_PARAM, gsad_message(), cmd_response_data_t::http_status_code, new_permission(), params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), cmd_response_data_t::redirect, and param::value.

22005 {
22006  int ret;
22007  gchar *html, *response, *summary_response, *next_url;
22008  int successes;
22009  const char *no_redirect, *permission, *comment, *resource_id, *resource_type;
22010  const char *subject_id, *subject_type, *subject_name;
22011  int include_related;
22012 
22013  entity_t entity;
22014 
22015  gchar *subject_response;
22016  entity_t get_subject_entity = NULL;
22017  entity_t subject_entity;
22018 
22019  no_redirect = params_value (params, "no_redirect");
22020  permission = params_value (params, "permission");
22021  comment = params_value (params, "comment");
22022  resource_id = params_value (params, "resource_id");
22023  resource_type = params_value (params, "resource_type");
22024  subject_type = params_value (params, "subject_type");
22025  subject_name = params_value (params, "subject_name");
22026 
22027  include_related = atoi (params_value (params, "include_related"));
22028  CHECK_PARAM (params_value (params, "include_related"),
22029  "Create Permission", new_permission);
22030 
22031  CHECK_PARAM (permission, "Create Permission", new_permission);
22032  CHECK_PARAM (comment, "Create Permission", new_permission);
22033  CHECK_PARAM (resource_id, "Create Permission", new_permission);
22034  CHECK_PARAM (subject_type, "Create Permission", new_permission);
22035  CHECK_PARAM (resource_type, "Create Permission", new_permission);
22036 
22037  if (params_given (params, "subject_name"))
22038  {
22039  CHECK_PARAM (subject_name, "Create Permission", new_permission);
22040  subject_id = NULL;
22041  ret = ompf (credentials,
22042  &subject_response,
22043  &get_subject_entity,
22044  response_data,
22045  "<get_%ss filter=\"rows=1 name=%s\">"
22046  "</get_%ss>",
22047  subject_type,
22048  subject_name,
22049  subject_type);
22050 
22051  switch (ret)
22052  {
22053  case 0:
22054  case -1:
22055  break;
22056  case 1:
22057  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22058  return gsad_message (credentials,
22059  "Internal error", __FUNCTION__, __LINE__,
22060  "An internal error occurred while getting"
22061  " the subject for a permission. "
22062  "The permission was not created. "
22063  "Diagnostics: Failure to send command"
22064  " to manager daemon.",
22065  "/omp?cmd=get_permissions", response_data);
22066  case 2:
22067  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22068  return gsad_message (credentials,
22069  "Internal error", __FUNCTION__, __LINE__,
22070  "An internal error occurred while getting"
22071  " the subject for a permission. "
22072  "The permission was not created. "
22073  "Diagnostics: Failure to receive response"
22074  " from manager daemon.",
22075  "/omp?cmd=get_permissions", response_data);
22076  default:
22077  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22078  return gsad_message (credentials,
22079  "Internal error", __FUNCTION__, __LINE__,
22080  "An internal error occurred while getting"
22081  " the subject for a permission. "
22082  "The permission was not created. "
22083  "Diagnostics: Internal Error.",
22084  "/omp?cmd=get_permissions", response_data);
22085  }
22086 
22087  subject_entity = entity_child (get_subject_entity, subject_type);
22088 
22089  if (subject_entity)
22090  subject_id = entity_attribute (subject_entity, "id");
22091 
22092  if (subject_id == NULL)
22093  {
22094  gchar *msg;
22095  msg = g_strdup_printf ("<gsad_msg status_text=\"Subject not found\""
22096  " operation=\"create_permission\">"
22097  "Could not find a %s with name '%s'."
22098  "</gsad_msg>",
22099  subject_type,
22100  subject_name ? subject_name : "");
22101  return next_page (credentials, params, msg, response_data);
22102  }
22103  }
22104  else if (strcmp (subject_type, "user") == 0)
22105  subject_id = params_value (params, "permission_user_id");
22106  else if (strcmp (subject_type, "group") == 0)
22107  subject_id = params_value (params, "permission_group_id");
22108  else if (strcmp (subject_type, "role") == 0)
22109  subject_id = params_value (params, "permission_role_id");
22110  else
22111  subject_id = NULL;
22112  CHECK_PARAM (subject_id, "Create Permission", new_permission);
22113 
22114  successes = 0;
22115 
22116  /* Create the permission(s). */
22117 
22118  // Main resource permissions
22119  if (include_related != 2)
22120  {
22121  if (strcmp (permission, "read") == 0
22122  || strcmp (permission, "proxy") == 0)
22123  {
22124  response = NULL;
22125  entity = NULL;
22126  ret = ompf (credentials,
22127  &response,
22128  &entity,
22129  response_data,
22130  "<create_permission>"
22131  "<name>get_%ss</name>"
22132  "<comment>%s</comment>"
22133  "<resource id=\"%s\">"
22134  "</resource>"
22135  "<subject id=\"%s\"><type>%s</type></subject>"
22136  "</create_permission>",
22137  resource_type,
22138  comment ? comment : "",
22139  resource_id,
22140  subject_id,
22141  subject_type);
22142 
22144  }
22145 
22146  if ((strcmp (permission, "proxy") == 0)
22147  && strcmp (resource_type, "result")
22148  && strcmp (resource_type, "report"))
22149  {
22150  response = NULL;
22151  entity = NULL;
22152  ret = ompf (credentials,
22153  &response,
22154  &entity,
22155  response_data,
22156  "<create_permission>"
22157  "<name>modify_%s</name>"
22158  "<comment>%s</comment>"
22159  "<resource id=\"%s\">"
22160  "</resource>"
22161  "<subject id=\"%s\"><type>%s</type></subject>"
22162  "</create_permission>",
22163  resource_type,
22164  comment ? comment : "",
22165  resource_id,
22166  subject_id,
22167  subject_type);
22168 
22170 
22171  if (strcmp (resource_type, "task") == 0)
22172  {
22173  response = NULL;
22174  entity = NULL;
22175  ret = ompf (credentials,
22176  &response,
22177  &entity,
22178  response_data,
22179  "<create_permission>"
22180  "<name>start_%s</name>"
22181  "<comment>%s</comment>"
22182  "<resource id=\"%s\">"
22183  "</resource>"
22184  "<subject id=\"%s\"><type>%s</type></subject>"
22185  "</create_permission>",
22186  resource_type,
22187  comment ? comment : "",
22188  resource_id,
22189  subject_id,
22190  subject_type);
22191 
22193 
22194  response = NULL;
22195  entity = NULL;
22196  ret = ompf (credentials,
22197  &response,
22198  &entity,
22199  response_data,
22200  "<create_permission>"
22201  "<name>stop_%s</name>"
22202  "<comment>%s</comment>"
22203  "<resource id=\"%s\">"
22204  "</resource>"
22205  "<subject id=\"%s\"><type>%s</type></subject>"
22206  "</create_permission>",
22207  resource_type,
22208  comment ? comment : "",
22209  resource_id,
22210  subject_id,
22211  subject_type);
22212 
22214 
22215  response = NULL;
22216  entity = NULL;
22217  ret = ompf (credentials,
22218  &response,
22219  &entity,
22220  response_data,
22221  "<create_permission>"
22222  "<name>resume_%s</name>"
22223  "<comment>%s</comment>"
22224  "<resource id=\"%s\">"
22225  "</resource>"
22226  "<subject id=\"%s\"><type>%s</type></subject>"
22227  "</create_permission>",
22228  resource_type,
22229  comment ? comment : "",
22230  resource_id,
22231  subject_id,
22232  subject_type);
22233 
22235  }
22236 
22237  if (strcmp (resource_type, "alert") == 0)
22238  {
22239  response = NULL;
22240  entity = NULL;
22241  ret = ompf (credentials,
22242  &response,
22243  &entity,
22244  response_data,
22245  "<create_permission>"
22246  "<name>test_%s</name>"
22247  "<comment>%s</comment>"
22248  "<resource id=\"%s\">"
22249  "</resource>"
22250  "<subject id=\"%s\"><type>%s</type></subject>"
22251  "</create_permission>",
22252  resource_type,
22253  comment ? comment : "",
22254  resource_id,
22255  subject_id,
22256  subject_type);
22257 
22259  }
22260 
22261  if (strcmp (resource_type, "agent") == 0
22262  || strcmp (resource_type, "report_format") == 0
22263  || strcmp (resource_type, "scanner") == 0)
22264  {
22265  response = NULL;
22266  entity = NULL;
22267  ret = ompf (credentials,
22268  &response,
22269  &entity,
22270  response_data,
22271  "<create_permission>"
22272  "<name>verify_%s</name>"
22273  "<comment>%s</comment>"
22274  "<resource id=\"%s\">"
22275  "</resource>"
22276  "<subject id=\"%s\"><type>%s</type></subject>"
22277  "</create_permission>",
22278  resource_type,
22279  comment ? comment : "",
22280  resource_id,
22281  subject_id,
22282  subject_type);
22283 
22285  }
22286  }
22287  }
22288 
22289  // Related permissions
22290  if (include_related)
22291  {
22292  params_t *related;
22293  related = params_values (params, "related:");
22294  if (related)
22295  {
22296  params_iterator_t iter;
22297  char *name;
22298  param_t *param;
22299 
22300  params_iterator_init (&iter, related);
22301  while (params_iterator_next (&iter, &name, &param))
22302  {
22303  char *related_id = name;
22304  char *related_type = param->value;
22305 
22306  if (strcmp (permission, "read") == 0
22307  || strcmp (permission, "proxy") == 0)
22308  {
22309  response = NULL;
22310  entity = NULL;
22311  ret = ompf (credentials,
22312  &response,
22313  &entity,
22314  response_data,
22315  "<create_permission>"
22316  "<name>get_%ss</name>"
22317  "<comment>%s</comment>"
22318  "<resource id=\"%s\">"
22319  "</resource>"
22320  "<subject id=\"%s\"><type>%s</type></subject>"
22321  "</create_permission>",
22322  related_type,
22323  comment ? comment : "",
22324  related_id,
22325  subject_id,
22326  subject_type);
22327 
22329  }
22330 
22331  if ((strcmp (permission, "proxy") == 0)
22332  && strcmp (related_type, "result")
22333  && strcmp (related_type, "report"))
22334  {
22335  response = NULL;
22336  entity = NULL;
22337  ret = ompf (credentials,
22338  &response,
22339  &entity,
22340  response_data,
22341  "<create_permission>"
22342  "<name>modify_%s</name>"
22343  "<comment>%s</comment>"
22344  "<resource id=\"%s\">"
22345  "</resource>"
22346  "<subject id=\"%s\"><type>%s</type></subject>"
22347  "</create_permission>",
22348  related_type,
22349  comment ? comment : "",
22350  related_id,
22351  subject_id,
22352  subject_type);
22353 
22355 
22356  if (strcmp (related_type, "task") == 0)
22357  {
22358  response = NULL;
22359  entity = NULL;
22360  ret = ompf (credentials,
22361  &response,
22362  &entity,
22363  response_data,
22364  "<create_permission>"
22365  "<name>start_%s</name>"
22366  "<comment>%s</comment>"
22367  "<resource id=\"%s\">"
22368  "</resource>"
22369  "<subject id=\"%s\"><type>%s</type></subject>"
22370  "</create_permission>",
22371  related_type,
22372  comment ? comment : "",
22373  related_id,
22374  subject_id,
22375  subject_type);
22376 
22378 
22379  response = NULL;
22380  entity = NULL;
22381  ret = ompf (credentials,
22382  &response,
22383  &entity,
22384  response_data,
22385  "<create_permission>"
22386  "<name>stop_%s</name>"
22387  "<comment>%s</comment>"
22388  "<resource id=\"%s\">"
22389  "</resource>"
22390  "<subject id=\"%s\"><type>%s</type></subject>"
22391  "</create_permission>",
22392  related_type,
22393  comment ? comment : "",
22394  related_id,
22395  subject_id,
22396  subject_type);
22397 
22399 
22400  response = NULL;
22401  entity = NULL;
22402  ret = ompf (credentials,
22403  &response,
22404  &entity,
22405  response_data,
22406  "<create_permission>"
22407  "<name>resume_%s</name>"
22408  "<comment>%s</comment>"
22409  "<resource id=\"%s\">"
22410  "</resource>"
22411  "<subject id=\"%s\"><type>%s</type></subject>"
22412  "</create_permission>",
22413  related_type,
22414  comment ? comment : "",
22415  related_id,
22416  subject_id,
22417  subject_type);
22418 
22420  }
22421 
22422  if (strcmp (related_type, "alert") == 0)
22423  {
22424  response = NULL;
22425  entity = NULL;
22426  ret = ompf (credentials,
22427  &response,
22428  &entity,
22429  response_data,
22430  "<create_permission>"
22431  "<name>test_%s</name>"
22432  "<comment>%s</comment>"
22433  "<resource id=\"%s\">"
22434  "</resource>"
22435  "<subject id=\"%s\"><type>%s</type></subject>"
22436  "</create_permission>",
22437  related_type,
22438  comment ? comment : "",
22439  related_id,
22440  subject_id,
22441  subject_type);
22442 
22444  }
22445 
22446  if (strcmp (related_type, "agent") == 0
22447  || strcmp (related_type, "report_format") == 0
22448  || strcmp (related_type, "scanner") == 0)
22449  {
22450  response = NULL;
22451  entity = NULL;
22452  ret = ompf (credentials,
22453  &response,
22454  &entity,
22455  response_data,
22456  "<create_permission>"
22457  "<name>verify_%s</name>"
22458  "<comment>%s</comment>"
22459  "<resource id=\"%s\">"
22460  "</resource>"
22461  "<subject id=\"%s\"><type>%s</type></subject>"
22462  "</create_permission>",
22463  related_type,
22464  comment ? comment : "",
22465  related_id,
22466  subject_id,
22467  subject_type);
22468 
22470  }
22471  }
22472  }
22473  }
22474  }
22475 
22476  if (get_subject_entity)
22477  free_entity (get_subject_entity);
22478 
22479  summary_response = g_strdup_printf("Successfully created %i permissions",
22480  successes);
22481 
22482  next_url = next_page_url (credentials, params,
22483  NULL, "new_permissions",
22484  "Create Permissions",
22485  G_STRINGIFY (MHD_HTTP_CREATED),
22486  summary_response);
22487 
22488  if (no_redirect)
22489  {
22490  html = action_result_page (credentials, response_data,
22491  "Create Permissions",
22492  G_STRINGIFY (MHD_HTTP_CREATED),
22493  summary_response,
22494  next_url);
22495  g_free (next_url);
22496  }
22497  else
22498  {
22499  html = NULL;
22500  response_data->redirect = next_url;
22501  }
22502  return html;
22503 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_OMPF_RET
Definition: gsad_omp.c:21647
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK_PARAM(name, op_name, ret_func)
Check a param.
Definition: gsad_omp.c:1184
char * new_permission(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup new_permission XML, XSL transform the result.
Definition: gsad_omp.c:21188
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
gchar * redirect
HTTP status code.
Definition: gsad_base.h:94
#define params_iterator_init
Definition: gsad_base.h:187
#define params_iterator_t
Definition: gsad_base.h:185

Here is the call graph for this function:

char* create_port_list_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a port list, get all port lists, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 22919 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), and params_value().

22921 {
22922  gchar *html, *response;
22923  const char *no_redirect, *name, *comment, *port_range, *from_file;
22924  entity_t entity;
22925 
22926  no_redirect = params_value (params, "no_redirect");
22927  name = params_value (params, "name");
22928  comment = params_value (params, "comment");
22929  port_range = params_value (params, "port_range");
22930  from_file = params_value (params, "from_file");
22931 
22932  CHECK_PARAM_INVALID (name, "Create Port List", "new_port_list");
22933  CHECK_PARAM_INVALID (comment, "Create Port List", "new_port_list");
22934  CHECK_PARAM_INVALID (port_range, "Create Port List", "new_port_list");
22935  CHECK_PARAM_INVALID (from_file, "Create Port List", "new_port_list");
22936 
22937  /* Create the port_list. */
22938 
22939  switch (ompf (credentials,
22940  &response,
22941  &entity,
22942  response_data,
22943  "<create_port_list>"
22944  "<name>%s</name>"
22945  "<port_range>%s</port_range>"
22946  "<comment>%s</comment>"
22947  "</create_port_list>",
22948  name,
22949  strcmp (from_file, "0")
22950  ? params_value (params, "file")
22951  : port_range,
22952  comment ? comment : ""))
22953  {
22954  case 0:
22955  case -1:
22956  break;
22957  case 1:
22958  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22959  return gsad_message (credentials,
22960  "Internal error", __FUNCTION__, __LINE__,
22961  "An internal error occurred while creating a new port list. "
22962  "No new port list was created. "
22963  "Diagnostics: Failure to send command to manager daemon.",
22964  "/omp?cmd=get_port_lists", response_data);
22965  case 2:
22966  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22967  return gsad_message (credentials,
22968  "Internal error", __FUNCTION__, __LINE__,
22969  "An internal error occurred while creating a new port list. "
22970  "It is unclear whether the port list has been created or not. "
22971  "Diagnostics: Failure to receive response from manager daemon.",
22972  "/omp?cmd=get_port_lists", response_data);
22973  default:
22974  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22975  return gsad_message (credentials,
22976  "Internal error", __FUNCTION__, __LINE__,
22977  "An internal error occurred while creating a new port list. "
22978  "It is unclear whether the port list has been created or not. "
22979  "Diagnostics: Internal Error.",
22980  "/omp?cmd=get_port_lists", response_data);
22981  }
22982 
22983  if (entity_attribute (entity, "id"))
22984  params_add (params, "port_list_id", entity_attribute (entity, "id"));
22985  html = response_from_entity (credentials, params, entity,
22986  (no_redirect && strcmp (no_redirect, "0")),
22987  NULL, "get_port_lists",
22988  NULL, "new_port_list",
22989  "Create Port List", response_data);
22990  free_entity (entity);
22991  g_free (response);
22992  return html;
22993 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* create_port_range_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Add a range to a port list, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 23044 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, and params_value().

23046 {
23047  int ret;
23048  gchar *html, *response;
23049  const char *no_redirect, *port_list_id, *start, *end, *type;
23050  entity_t entity;
23051 
23052  no_redirect = params_value (params, "no_redirect");
23053  port_list_id = params_value (params, "port_list_id");
23054  start = params_value (params, "port_range_start");
23055  end = params_value (params, "port_range_end");
23056  type = params_value (params, "port_type");
23057 
23058  CHECK_PARAM_INVALID (port_list_id, "Create Port Range", "edit_port_list");
23059  CHECK_PARAM_INVALID (start, "Create Port Range", "edit_port_list");
23060  CHECK_PARAM_INVALID (end, "Create Port Range", "edit_port_list");
23061  CHECK_PARAM_INVALID (type, "Create Port Range", "edit_port_list");
23062 
23063  /* Create the port range. */
23064 
23065  response = NULL;
23066  entity = NULL;
23067  ret = ompf (credentials,
23068  &response,
23069  &entity,
23070  response_data,
23071  "<create_port_range>"
23072  "<port_list id=\"%s\"/>"
23073  "<start>%s</start>"
23074  "<end>%s</end>"
23075  "<type>%s</type>"
23076  "</create_port_range>",
23077  port_list_id,
23078  start,
23079  end,
23080  type);
23081 
23082  switch (ret)
23083  {
23084  case 0:
23085  case -1:
23086  break;
23087  case 1:
23088  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23089  return gsad_message (credentials,
23090  "Internal error", __FUNCTION__, __LINE__,
23091  "An internal error occurred while creating a Port Range. "
23092  "The Port Range was not created. "
23093  "Diagnostics: Failure to send command to manager daemon.",
23094  "/omp?cmd=get_port_lists", response_data);
23095  case 2:
23096  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23097  return gsad_message (credentials,
23098  "Internal error", __FUNCTION__, __LINE__,
23099  "An internal error occurred while creating a Port Range. "
23100  "It is unclear whether the Port Range has been created or not. "
23101  "Diagnostics: Failure to receive response from manager daemon.",
23102  "/omp?cmd=get_port_lists", response_data);
23103  default:
23104  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23105  return gsad_message (credentials,
23106  "Internal error", __FUNCTION__, __LINE__,
23107  "An internal error occurred while creating a Port Range. "
23108  "It is unclear whether the Port Range has been created or not. "
23109  "Diagnostics: Internal Error.",
23110  "/omp?cmd=get_port_lists", response_data);
23111  }
23112 
23113  html = response_from_entity (credentials, params, entity,
23114  (no_redirect && strcmp (no_redirect, "0")),
23115  NULL, "edit_port_list",
23116  NULL, "edit_port_list",
23117  "Create Port Range", response_data);
23118  free_entity (entity);
23119  g_free (response);
23120  return html;
23121 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

char* create_report_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a report, get all tasks, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 3972 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, message_invalid(), params_given(), and params_value().

Referenced by import_report_omp().

3974 {
3975  entity_t entity;
3976  int ret;
3977  gchar *command, *html, *response;
3978  const char *no_redirect, *cmd, *task_id, *name, *comment, *xml_file;
3979  const char *in_assets;
3980 
3981  no_redirect = params_value (params, "no_redirect");
3982  task_id = params_value (params, "task_id");
3983  xml_file = params_value (params, "xml_file");
3984  name = params_value (params, "name");
3985  comment = params_value (params, "comment");
3986  in_assets = params_value (params, "in_assets");
3987 
3988  if (task_id == NULL)
3989  {
3990  CHECK_PARAM_INVALID (name, "Create Report", "new_container_task");
3991  CHECK_PARAM_INVALID (comment, "Create Report", "new_container_task");
3992  }
3993  CHECK_PARAM_INVALID (xml_file, "Create Report", "new_container_task");
3994 
3995  if (params_given (params, "in_assets"))
3996  CHECK_PARAM_INVALID (xml_file, "Create Report", "new_container_task");
3997 
3998  if (strlen (xml_file) == 0)
3999  {
4000  if (task_id)
4001  return message_invalid (credentials, params, response_data,
4002  "Report required",
4003  G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
4004  "Create Report", "new_container_task");
4005 
4006  /* Create only the container task. */
4007 
4008  command = g_strdup_printf ("<create_task>"
4009  "<target id=\"0\"/>"
4010  "<name>%s</name>"
4011  "<comment>%s</comment>"
4012  "</create_task>",
4013  name,
4014  comment);
4015  }
4016  else
4017  {
4018  gchar **xml_file_array, *xml_file_escaped;
4019 
4020  xml_file_array = g_strsplit (xml_file, "%", -1);
4021  if (xml_file_array != NULL && xml_file_array[0] != NULL)
4022  xml_file_escaped = g_strjoinv ("%%", xml_file_array);
4023  else
4024  xml_file_escaped = g_strdup (xml_file);
4025  g_strfreev (xml_file_array);
4026 
4027  if (task_id)
4028  command = g_strdup_printf ("<create_report>"
4029  "<in_assets>%s</in_assets>"
4030  "<task id=\"%s\"/>"
4031  "%s"
4032  "</create_report>",
4033  in_assets ? in_assets : "0",
4034  task_id ? task_id : "0",
4035  xml_file_escaped ? xml_file_escaped : "");
4036  else
4037  command = g_strdup_printf ("<create_report>"
4038  "<in_assets>%s</in_assets>"
4039  "<task>"
4040  "<name>%s</name>"
4041  "<comment>%s</comment>"
4042  "</task>"
4043  "%s"
4044  "</create_report>",
4045  in_assets ? in_assets : "",
4046  name,
4047  comment,
4048  xml_file_escaped);
4049  g_free (xml_file_escaped);
4050  }
4051 
4052  ret = omp (credentials,
4053  &response,
4054  &entity,
4055  response_data,
4056  command);
4057  g_free (command);
4058 
4059  switch (ret)
4060  {
4061  case 0:
4062  break;
4063  case -1:
4064  /* 'omp' set response. */
4065  return response;
4066  case 1:
4067  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4068  return gsad_message (credentials,
4069  "Internal error", __FUNCTION__, __LINE__,
4070  "An internal error occurred while creating a new report. "
4071  "No new report was created. "
4072  "Diagnostics: Failure to send command to manager daemon.",
4073  "/omp?cmd=get_tasks", response_data);
4074  case 2:
4075  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4076  return gsad_message (credentials,
4077  "Internal error", __FUNCTION__, __LINE__,
4078  "An internal error occurred while creating a new report. "
4079  "It is unclear whether the report has been created or not. "
4080  "Diagnostics: Failure to receive response from manager daemon.",
4081  "/omp?cmd=get_tasks", response_data);
4082  default:
4083  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4084  return gsad_message (credentials,
4085  "Internal error", __FUNCTION__, __LINE__,
4086  "An internal error occurred while creating a new report. "
4087  "It is unclear whether the report has been created or not. "
4088  "Diagnostics: Internal Error.",
4089  "/omp?cmd=get_tasks", response_data);
4090  }
4091 
4092  cmd = params_value (params, "cmd");
4093  html = response_from_entity (credentials, params, entity,
4094  (no_redirect && strcmp (no_redirect, "0")),
4095  NULL, "get_tasks",
4096  NULL,
4097  (cmd && strcmp (cmd, "import_report"))
4098  ? "new_container_task" : "upload_report",
4099  "Import Report", response_data);
4100  free_entity (entity);
4101  g_free (response);
4102  return html;
4103 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gchar * message_invalid(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *status, const char *op_name, const char *next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1472

Here is the call graph for this function:

Here is the caller graph for this function:

char* create_role_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a role, get all roles, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 23538 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_value(), and users.

23540 {
23541  char *ret;
23542  gchar *response;
23543  const char *no_redirect, *name, *comment, *users;
23544  entity_t entity;
23545 
23546  no_redirect = params_value (params, "no_redirect");
23547  name = params_value (params, "name");
23548  comment = params_value (params, "comment");
23549  users = params_value (params, "users");
23550 
23551  CHECK_PARAM_INVALID (name, "Create Role", "new_role");
23552  CHECK_PARAM_INVALID (comment, "Create Role", "new_role");
23553  CHECK_PARAM_INVALID (users, "Create Role", "new_role");
23554 
23555  response = NULL;
23556  entity = NULL;
23557  switch (ompf (credentials,
23558  &response,
23559  &entity,
23560  response_data,
23561  "<create_role>"
23562  "<name>%s</name>"
23563  "<comment>%s</comment>"
23564  "<users>%s</users>"
23565  "</create_role>",
23566  name,
23567  comment,
23568  users))
23569  {
23570  case 0:
23571  case -1:
23572  break;
23573  case 1:
23574  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23575  return gsad_message (credentials,
23576  "Internal error", __FUNCTION__, __LINE__,
23577  "An internal error occurred while creating a new role. "
23578  "No new role was created. "
23579  "Diagnostics: Failure to send command to manager daemon.",
23580  "/omp?cmd=get_targets", response_data);
23581  case 2:
23582  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23583  return gsad_message (credentials,
23584  "Internal error", __FUNCTION__, __LINE__,
23585  "An internal error occurred while creating a new role. "
23586  "It is unclear whether the role has been created or not. "
23587  "Diagnostics: Failure to receive response from manager daemon.",
23588  "/omp?cmd=get_roles", response_data);
23589  default:
23590  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23591  return gsad_message (credentials,
23592  "Internal error", __FUNCTION__, __LINE__,
23593  "An internal error occurred while creating a new role. "
23594  "It is unclear whether the role has been created or not. "
23595  "Diagnostics: Internal Error.",
23596  "/omp?cmd=get_roles", response_data);
23597  }
23598 
23599  if (entity_attribute (entity, "id"))
23600  params_add (params, "role_id", entity_attribute (entity, "id"));
23601  ret = response_from_entity (credentials, params, entity,
23602  (no_redirect && strcmp (no_redirect, "0")),
23603  NULL, "get_roles",
23604  NULL, "new_role",
23605  "Create Role", response_data);
23606  free_entity (entity);
23607  g_free (response);
23608  return ret;
23609 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
GPtrArray * users
User session data.
Definition: gsad.c:309
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* create_scanner_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a scanner, get all scanners, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 17414 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_given(), and params_value().

17416 {
17417  int ret;
17418  char *html;
17419  gchar *response = NULL;
17420  const char *no_redirect;
17421  const char *name, *comment, *host, *port, *type, *ca_pub, *credential_id;
17422  entity_t entity = NULL;
17423 
17424  no_redirect = params_value (params, "no_redirect");
17425  name = params_value (params, "name");
17426  comment = params_value (params, "comment");
17427  host = params_value (params, "scanner_host");
17428  port = params_value (params, "port");
17429  type = params_value (params, "scanner_type");
17430  ca_pub = params_value (params, "ca_pub");
17431  credential_id = params_value (params, "credential_id");
17432  CHECK_PARAM_INVALID (name, "Create Scanner", "new_scanner");
17433  CHECK_PARAM_INVALID (comment, "Create Scanner", "new_scanner");
17434  CHECK_PARAM_INVALID (host, "Create Scanner", "new_scanner");
17435  CHECK_PARAM_INVALID (port, "Create Scanner", "new_scanner");
17436  CHECK_PARAM_INVALID (type, "Create Scanner", "new_scanner");
17437  if (params_given (params, "ca_pub"))
17438  CHECK_PARAM_INVALID (ca_pub, "Create Scanner", "new_scanner");
17439  CHECK_PARAM_INVALID (credential_id, "Create Scanner", "new_scanner");
17440 
17441  if (ca_pub)
17442  ret = ompf (credentials, &response, &entity, response_data,
17443  "<create_scanner>"
17444  "<name>%s</name><comment>%s</comment>"
17445  "<host>%s</host><port>%s</port><type>%s</type>"
17446  "<ca_pub>%s</ca_pub>"
17447  "<credential id=\"%s\"/>"
17448  "</create_scanner>",
17449  name, comment, host, port, type, ca_pub, credential_id);
17450  else
17451  ret = ompf (credentials, &response, &entity, response_data,
17452  "<create_scanner>"
17453  "<name>%s</name><comment>%s</comment>"
17454  "<host>%s</host><port>%s</port><type>%s</type>"
17455  "<credential id=\"%s\"/>"
17456  "</create_scanner>",
17457  name, comment, host, port, type, credential_id);
17458  switch (ret)
17459  {
17460  case 0:
17461  case -1:
17462  break;
17463  case 1:
17464  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17465  return gsad_message
17466  (credentials, "Internal error", __FUNCTION__, __LINE__,
17467  "An internal error occurred while creating a new scanner. "
17468  "No new scanner was created. "
17469  "Diagnostics: Failure to send command to manager daemon.",
17470  "/omp?cmd=get_scanners", response_data);
17471  case 2:
17472  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17473  return gsad_message
17474  (credentials, "Internal error", __FUNCTION__, __LINE__,
17475  "An internal error occurred while creating a new scanner. "
17476  "It is unclear whether the scanner has been created or not. "
17477  "Diagnostics: Failure to receive response from manager daemon.",
17478  "/omp?cmd=get_scanners", response_data);
17479  default:
17480  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17481  return gsad_message
17482  (credentials, "Internal error", __FUNCTION__, __LINE__,
17483  "An internal error occurred while creating a new scanner. "
17484  "It is unclear whether the scanner has been created or not. "
17485  "Diagnostics: Internal Error.",
17486  "/omp?cmd=get_scanners", response_data);
17487  }
17488 
17489  if (entity_attribute (entity, "id"))
17490  params_add (params, "scanner_id", entity_attribute (entity, "id"));
17491  html = response_from_entity (credentials, params, entity,
17492  (no_redirect && strcmp (no_redirect, "0")),
17493  NULL, "get_scanners",
17494  NULL, "new_scanner",
17495  "Create Scanner", response_data);
17496  free_entity (entity);
17497  g_free (response);
17498  return html;
17499 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* create_schedule_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a schedule, get all schedules, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 17941 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), and params_value().

17943 {
17944  char *ret;
17945  gchar *response;
17946  const char *no_redirect;
17947  const char *name, *comment, *hour, *minute, *day_of_month, *month, *year;
17948  const char *period, *period_unit, *duration, *duration_unit, *timezone;
17949  entity_t entity;
17950 
17951  no_redirect = params_value (params, "no_redirect");
17952  name = params_value (params, "name");
17953  comment = params_value (params, "comment");
17954  hour = params_value (params, "hour");
17955  minute = params_value (params, "minute");
17956  day_of_month = params_value (params, "day_of_month");
17957  duration = params_value (params, "duration");
17958  duration_unit = params_value (params, "duration_unit");
17959  month = params_value (params, "month");
17960  period = params_value (params, "period");
17961  period_unit = params_value (params, "period_unit");
17962  year = params_value (params, "year");
17963  timezone = params_value (params, "timezone");
17964 
17965  CHECK_PARAM_INVALID (name, "Create Schedule", "new_schedule");
17966  CHECK_PARAM_INVALID (comment, "Create Schedule", "new_schedule");
17967  CHECK_PARAM_INVALID (hour, "Create Schedule", "new_schedule");
17968  CHECK_PARAM_INVALID (minute, "Create Schedule", "new_schedule");
17969  CHECK_PARAM_INVALID (day_of_month, "Create Schedule", "new_schedule");
17970  CHECK_PARAM_INVALID (duration, "Create Schedule", "new_schedule");
17971  CHECK_PARAM_INVALID (duration_unit, "Create Schedule", "new_schedule");
17972  CHECK_PARAM_INVALID (month, "Create Schedule", "new_schedule");
17973  CHECK_PARAM_INVALID (period, "Create Schedule", "new_schedule");
17974  CHECK_PARAM_INVALID (period_unit, "period_unit", "new_schedule");
17975  CHECK_PARAM_INVALID (year, "Create Schedule", "new_schedule");
17976  CHECK_PARAM_INVALID (timezone, "Create Schedule", "new_schedule");
17977 
17978  response = NULL;
17979  entity = NULL;
17980  switch (ompf (credentials,
17981  &response,
17982  &entity,
17983  response_data,
17984  "<create_schedule>"
17985  "<name>%s</name>"
17986  "<comment>%s</comment>"
17987  "<first_time>"
17988  "<hour>%s</hour>"
17989  "<minute>%s</minute>"
17990  "<day_of_month>%s</day_of_month>"
17991  "<month>%s</month>"
17992  "<year>%s</year>"
17993  "</first_time>"
17994  "<period>"
17995  "<unit>%s</unit>"
17996  "%s"
17997  "</period>"
17998  "<duration>"
17999  "<unit>%s</unit>"
18000  "%s"
18001  "</duration>"
18002  "<timezone>%s</timezone>"
18003  "</create_schedule>",
18004  name,
18005  comment,
18006  hour,
18007  minute,
18008  day_of_month,
18009  month,
18010  year,
18011  (strcmp (period_unit, "")
18012  ? period_unit
18013  : "second"),
18014  period,
18015  (strcmp (duration_unit, "")
18016  ? duration_unit
18017  : "second"),
18018  duration,
18019  timezone))
18020  {
18021  case 0:
18022  case -1:
18023  break;
18024  case 1:
18025  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18026  return gsad_message (credentials,
18027  "Internal error", __FUNCTION__, __LINE__,
18028  "An internal error occurred while creating a new schedule. "
18029  "No new schedule was created. "
18030  "Diagnostics: Failure to send command to manager daemon.",
18031  "/omp?cmd=get_schedules", response_data);
18032  case 2:
18033  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18034  return gsad_message (credentials,
18035  "Internal error", __FUNCTION__, __LINE__,
18036  "An internal error occurred while creating a new schedule. "
18037  "It is unclear whether the schedule has been created or not. "
18038  "Diagnostics: Failure to receive response from manager daemon.",
18039  "/omp?cmd=get_schedules", response_data);
18040  default:
18041  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18042  return gsad_message (credentials,
18043  "Internal error", __FUNCTION__, __LINE__,
18044  "An internal error occurred while creating a new schedule. "
18045  "It is unclear whether the schedule has been created or not. "
18046  "Diagnostics: Internal Error.",
18047  "/omp?cmd=get_schedules", response_data);
18048  }
18049 
18050  if (entity_attribute (entity, "id"))
18051  params_add (params, "schedule_id", entity_attribute (entity, "id"));
18052  ret = response_from_entity (credentials, params, entity,
18053  (no_redirect && strcmp (no_redirect, "0")),
18054  NULL, "get_schedules",
18055  NULL, "new_schedule",
18056  "Create Schedule", response_data);
18057  free_entity (entity);
18058  g_free (response);
18059  return ret;
18060 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* create_tag_omp (<