Blame src/include/libabrt.h

Packit Service 8a8a03
/*
Packit Service 8a8a03
 * Utility routines.
Packit Service 8a8a03
 *
Packit Service 8a8a03
 * Licensed under GPLv2, see file COPYING in this tarball for details.
Packit Service 8a8a03
 */
Packit Service 8a8a03
Packit Service 8a8a03
/** @file libabrt.h */
Packit Service 8a8a03
Packit Service 8a8a03
#ifndef LIBABRT_H_
Packit Service 8a8a03
#define LIBABRT_H_
Packit Service 8a8a03
Packit Service 8a8a03
#include <regex.h>
Packit Service 8a8a03
Packit Service 8a8a03
#include <gio/gio.h> /* dbus */
Packit Service 8a8a03
#include "abrt-dbus.h"
Packit Service 8a8a03
/* libreport's internal functions we use: */
Packit Service 8a8a03
#include <libreport/internal_libreport.h>
Packit Service 8a8a03
#include "hooklib.h"
Packit Service 8a8a03
Packit Service 8a8a03
#undef ARRAY_SIZE
Packit Service 8a8a03
#define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
Packit Service 8a8a03
Packit Service 8a8a03
#ifdef __cplusplus
Packit Service 8a8a03
extern "C" {
Packit Service 8a8a03
#endif
Packit Service 8a8a03
Packit Service 8a8a03
/* Some libc's forget to declare these, do it ourself */
Packit Service 8a8a03
extern char **environ;
Packit Service 8a8a03
#if defined(__GLIBC__) && __GLIBC__ < 2
Packit Service 8a8a03
int vdprintf(int d, const char *format, va_list ap);
Packit Service 8a8a03
#endif
Packit Service 8a8a03
Packit Service 8a8a03
Packit Service 8a8a03
#define low_free_space abrt_low_free_space
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @brief Checks if there is enough free space to store the problem data
Packit Service 8a8a03
Packit Service 8a8a03
  @param setting_MaxCrashReportsSize Maximum data size
Packit Service 8a8a03
  @param dump_location Location to check for the available space
Packit Service 8a8a03
*/
Packit Service 8a8a03
int low_free_space(unsigned setting_MaxCrashReportsSize, const char *dump_location);
Packit Service 8a8a03
Packit Service 8a8a03
#define trim_problem_dirs abrt_trim_problem_dirs
Packit Service 8a8a03
void trim_problem_dirs(const char *dirname, double cap_size, const char *exclude_path);
Packit Service 8a8a03
#define ensure_writable_dir_id abrt_ensure_writable_dir_uid_git
Packit Service 8a8a03
void ensure_writable_dir_uid_gid(const char *dir, mode_t mode, uid_t uid, gid_t gid);
Packit Service 8a8a03
#define ensure_writable_dir abrt_ensure_writable_dir
Packit Service 8a8a03
void ensure_writable_dir(const char *dir, mode_t mode, const char *user);
Packit Service 8a8a03
#define ensure_writable_dir_group abrt_ensure_writable_dir_group
Packit Service 8a8a03
void ensure_writable_dir_group(const char *dir, mode_t mode, const char *user, const char *group);
Packit Service 8a8a03
#define run_unstrip_n abrt_run_unstrip_n
Packit Service 8a8a03
char *run_unstrip_n(const char *dump_dir_name, unsigned timeout_sec);
Packit Service 8a8a03
#define get_backtrace abrt_get_backtrace
Packit Service 8a8a03
char *get_backtrace(const char *dump_dir_name, unsigned timeout_sec, const char *debuginfo_dirs);
Packit Service 8a8a03
Packit Service 8a8a03
#define dir_is_in_dump_location abrt_dir_is_in_dump_location
Packit Service 8a8a03
bool dir_is_in_dump_location(const char *dir_name);
Packit Service 8a8a03
Packit Service 8a8a03
enum {
Packit Service 8a8a03
    DD_PERM_EVENTS  = 1 << 0,
Packit Service 8a8a03
    DD_PERM_DAEMONS = 1 << 1,
Packit Service 8a8a03
};
Packit Service 8a8a03
#define dir_has_correct_permissions abrt_dir_has_correct_permissions
Packit Service 8a8a03
bool dir_has_correct_permissions(const char *dir_name, int flags);
Packit Service 8a8a03
#define allowed_new_user_problem_entry abrt_allowed_new_user_problem_entry
Packit Service 8a8a03
bool allowed_new_user_problem_entry(uid_t uid, const char *name, const char *value);
Packit Service 8a8a03
Packit Service 8a8a03
#define g_settings_nMaxCrashReportsSize abrt_g_settings_nMaxCrashReportsSize
Packit Service 8a8a03
extern unsigned int  g_settings_nMaxCrashReportsSize;
Packit Service 8a8a03
#define g_settings_sWatchCrashdumpArchiveDir abrt_g_settings_sWatchCrashdumpArchiveDir
Packit Service 8a8a03
extern char *        g_settings_sWatchCrashdumpArchiveDir;
Packit Service 8a8a03
#define g_settings_dump_location abrt_g_settings_dump_location
Packit Service 8a8a03
extern char *        g_settings_dump_location;
Packit Service 8a8a03
#define g_settings_delete_uploaded abrt_g_settings_delete_uploaded
Packit Service 8a8a03
extern bool          g_settings_delete_uploaded;
Packit Service 8a8a03
#define g_settings_autoreporting abrt_g_settings_autoreporting
Packit Service 8a8a03
extern bool          g_settings_autoreporting;
Packit Service 8a8a03
#define g_settings_autoreporting_event abrt_g_settings_autoreporting_event
Packit Service 8a8a03
extern char *        g_settings_autoreporting_event;
Packit Service 8a8a03
#define g_settings_shortenedreporting abrt_g_settings_shortenedreporting
Packit Service 8a8a03
extern bool          g_settings_shortenedreporting;
Packit Service 8a8a03
#define g_settings_explorechroots abrt_g_settings_explorechroots
Packit Service 8a8a03
extern bool          g_settings_explorechroots;
Packit Service 8a8a03
#define g_settings_debug_level abrt_g_settings_debug_level
Packit Service 8a8a03
extern unsigned int  g_settings_debug_level;
Packit Service 8a8a03
Packit Service 8a8a03
Packit Service 8a8a03
#define load_abrt_conf abrt_load_abrt_conf
Packit Service 8a8a03
int load_abrt_conf(void);
Packit Service 8a8a03
#define free_abrt_conf_data abrt_free_abrt_conf_data
Packit Service 8a8a03
void free_abrt_conf_data(void);
Packit Service 8a8a03
Packit Service 8a8a03
#define load_abrt_conf_file abrt_load_abrt_conf_file
Packit Service 8a8a03
int load_abrt_conf_file(const char *file, map_string_t *settings);
Packit Service 8a8a03
Packit Service 8a8a03
#define load_abrt_plugin_conf_file abrt_load_abrt_plugin_conf_file
Packit Service 8a8a03
int load_abrt_plugin_conf_file(const char *file, map_string_t *settings);
Packit Service 8a8a03
Packit Service 8a8a03
#define save_abrt_conf_file abrt_save_abrt_conf_file
Packit Service 8a8a03
int save_abrt_conf_file(const char *file, map_string_t *settings);
Packit Service 8a8a03
Packit Service 8a8a03
#define save_abrt_plugin_conf_file abrt_save_abrt_plugin_conf_file
Packit Service 8a8a03
int save_abrt_plugin_conf_file(const char *file, map_string_t *settings);
Packit Service 8a8a03
Packit Service 8a8a03
Packit Service 8a8a03
void migrate_to_xdg_dirs(void);
Packit Service 8a8a03
Packit Service 8a8a03
int check_recent_crash_file(const char *filename, const char *executable);
Packit Service 8a8a03
Packit Service 8a8a03
/* Returns 1 if abrtd daemon is running, 0 otherwise. */
Packit Service 8a8a03
#define daemon_is_ok abrt_daemon_is_ok
Packit Service 8a8a03
int daemon_is_ok(void);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
@brief Sends notification to abrtd that a new problem has been detected
Packit Service 8a8a03
Packit Service 8a8a03
@param[in] path Path to the problem directory containing the problem data
Packit Service 8a8a03
*/
Packit Service 8a8a03
#define notify_new_path abrt_notify_new_path
Packit Service 8a8a03
void notify_new_path(const char *path);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
@brief Sends notification to abrtd that a new problem has been detected and
Packit Service 8a8a03
wait for the reply
Packit Service 8a8a03
Packit Service 8a8a03
@param path Path to the problem directory containing the problem data
Packit Service 8a8a03
@param message The abrtd reply
Packit Service 8a8a03
@return -errno on error otherwise return value of abrtd
Packit Service 8a8a03
*/
Packit Service 8a8a03
#define notify_new_path_with_response abrt_notify_new_path_with_response
Packit Service 8a8a03
int notify_new_path_with_response(const char *path, char **message);
Packit Service 8a8a03
Packit Service 8a8a03
/* Note: should be public since unit tests need to call it */
Packit Service 8a8a03
#define koops_extract_version abrt_koops_extract_version
Packit Service 8a8a03
char *koops_extract_version(const char *line);
Packit Service 8a8a03
#define kernel_tainted_short abrt_kernel_tainted_short
Packit Service 8a8a03
char *kernel_tainted_short(const char *kernel_bt);
Packit Service 8a8a03
#define kernel_tainted_long abrt_kernel_tainted_long
Packit Service 8a8a03
char *kernel_tainted_long(const char *tainted_short);
Packit Service 8a8a03
#define koops_hash_str_ext abrt_koops_hash_str_ext
Packit Service 8a8a03
int koops_hash_str_ext(char hash_str[SHA1_RESULT_LEN*2 + 1], const char *oops_buf, int frame_count, int duphas_flags);
Packit Service 8a8a03
#define koops_hash_str abrt_koops_hash_str
Packit Service 8a8a03
int koops_hash_str(char hash_str[SHA1_RESULT_LEN*2 + 1], const char *oops_buf);
Packit Service 8a8a03
Packit Service 8a8a03
Packit Service 8a8a03
#define koops_line_skip_level abrt_koops_line_skip_level
Packit Service 8a8a03
int koops_line_skip_level(const char **c);
Packit Service 8a8a03
#define koops_line_skip_jiffies abrt_koops_line_skip_jiffies
Packit Service 8a8a03
void koops_line_skip_jiffies(const char **c);
Packit Service 8a8a03
Packit Service 8a8a03
/*
Packit Service 8a8a03
 * extract_oops tries to find oops signatures in a log
Packit Service 8a8a03
 */
Packit Service 8a8a03
struct abrt_koops_line_info {
Packit Service 8a8a03
    char *ptr;
Packit Service 8a8a03
    int level;
Packit Service 8a8a03
};
Packit Service 8a8a03
Packit Service 8a8a03
#define koops_extract_oopses_from_lines abrt_koops_extract_oopses_from_lines
Packit Service 8a8a03
void koops_extract_oopses_from_lines(GList **oops_list, const struct abrt_koops_line_info *lines_info, int lines_info_size);
Packit Service 8a8a03
#define koops_extract_oopses abrt_koops_extract_oopses
Packit Service 8a8a03
void koops_extract_oopses(GList **oops_list, char *buffer, size_t buflen);
Packit Service 8a8a03
#define koops_suspicious_strings_list abrt_koops_suspicious_strings_list
Packit Service 8a8a03
GList *koops_suspicious_strings_list(void);
Packit Service 8a8a03
#define koops_suspicious_strings_blacklist abrt_koops_suspicious_strings_blacklist
Packit Service 8a8a03
GList *koops_suspicious_strings_blacklist(void);
Packit Service 8a8a03
#define koops_print_suspicious_strings abrt_koops_print_suspicious_strings
Packit Service 8a8a03
void koops_print_suspicious_strings(void);
Packit Service 8a8a03
/**
Packit Service 8a8a03
 * Prints all suspicious strings that do not match any of the regular
Packit Service 8a8a03
 * expression in NULL terminated list.
Packit Service 8a8a03
 *
Packit Service 8a8a03
 * The regular expression should be compiled with REG_NOSUB flag.
Packit Service 8a8a03
 */
Packit Service 8a8a03
#define koops_print_suspicious_strings_filtered abrt_koops_print_suspicious_strings_filtered
Packit Service 8a8a03
void koops_print_suspicious_strings_filtered(const regex_t **filterout);
Packit Service 8a8a03
Packit Service 8a8a03
/* dbus client api */
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @brief Changes the access rights of the problem specified by problem id
Packit Service 8a8a03
Packit Service 8a8a03
  Requires authorization
Packit Service 8a8a03
Packit Service 8a8a03
  @return 0 if successful; non-zero on failure
Packit Service 8a8a03
*/
Packit Service 8a8a03
int chown_dir_over_dbus(const char *problem_dir_path);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @brief Checks whether the given element name exists
Packit Service 8a8a03
Packit Service 8a8a03
  Might require authorization
Packit Service 8a8a03
Packit Service 8a8a03
  @return Positive number if such an element exist, 0 if doesn't and negative number if an error occurs.
Packit Service 8a8a03
 */
Packit Service 8a8a03
int test_exist_over_dbus(const char *problem_id, const char *element_name);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @brief Checks whether the problem corresponding to the given ID is complete
Packit Service 8a8a03
Packit Service 8a8a03
  Might require authorization
Packit Service 8a8a03
Packit Service 8a8a03
  @return Positive number if the problem is complete, 0 if doesn't and negative number if an error occurs.
Packit Service 8a8a03
 */
Packit Service 8a8a03
int dbus_problem_is_complete(const char *problem_id);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @ Returns value of the given element name
Packit Service 8a8a03
Packit Service 8a8a03
  Might require authorization
Packit Service 8a8a03
Packit Service 8a8a03
  @return malloced string or NULL if no such an element exists; ERR_PTR in case of any error.
Packit Service 8a8a03
 */
Packit Service 8a8a03
char *load_text_over_dbus(const char *problem_id, const char *element_name);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
 @brief Delets multiple problems specified by their id (as returned from problem_data_save)
Packit Service 8a8a03
Packit Service 8a8a03
 @param problem_dir_paths List of problem ids
Packit Service 8a8a03
Packit Service 8a8a03
 @return 0 if operation was successful, non-zero on failure
Packit Service 8a8a03
*/
Packit Service 8a8a03
Packit Service 8a8a03
int delete_problem_dirs_over_dbus(const GList *problem_dir_paths);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @brief Fetches given problem elements for specified problem id
Packit Service 8a8a03
Packit Service 8a8a03
  @return returns non-zero value on failures and prints error message
Packit Service 8a8a03
*/
Packit Service 8a8a03
int fill_problem_data_over_dbus(const char *problem_dir_path, const char **elements, problem_data_t *problem_data);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @brief Fetches problem information for specified problem id
Packit Service 8a8a03
Packit Service 8a8a03
  @return a valid pointer to problem_data_t or ERR_PTR on failure
Packit Service 8a8a03
*/
Packit Service 8a8a03
problem_data_t *get_problem_data_dbus(const char *problem_dir_path);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @brief Fetches full problem data for specified problem id
Packit Service 8a8a03
Packit Service 8a8a03
  @return a valid pointer to problem_data_t or ERR_PTR on failure
Packit Service 8a8a03
*/
Packit Service 8a8a03
problem_data_t *get_full_problem_data_over_dbus(const char *problem_dir_path);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @brief Fetches all problems from problem database
Packit Service 8a8a03
Packit Service 8a8a03
  @param authorize If set to true will try to fetch even problems owned by other users (will require root authorization over policy kit)
Packit Service 8a8a03
Packit Service 8a8a03
  @return List of problem ids or ERR_PTR on failure (NULL is an empty list)
Packit Service 8a8a03
*/
Packit Service 8a8a03
GList *get_problems_over_dbus(bool authorize);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @struct ignored_problems
Packit Service 8a8a03
  @brief An opaque structure holding a list of ignored problems
Packit Service 8a8a03
*/
Packit Service 8a8a03
typedef struct ignored_problems ignored_problems_t;
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @brief Initializes a new instance of ignored problems
Packit Service 8a8a03
Packit Service 8a8a03
  @param file_path A malloced string holding a path to a file containing the list of ignored problems. Function takes ownership of the malloced memory, which will be freed in ignored_problems_free()
Packit Service 8a8a03
  @see ignored_problems_free()
Packit Service 8a8a03
  @return Fully initialized instance of ignored problems struct which must be destroyed by ignored_problems_free()
Packit Service 8a8a03
*/
Packit Service 8a8a03
ignored_problems_t *ignored_problems_new(char *file_path);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @brief Destroys an instance of ignored problems
Packit Service 8a8a03
Packit Service 8a8a03
  This function never fails. Supports the common behaviour where it accepts
Packit Service 8a8a03
  NULL pointers.
Packit Service 8a8a03
Packit Service 8a8a03
  @param set A destroyed instance
Packit Service 8a8a03
*/
Packit Service 8a8a03
void ignored_problems_free(ignored_problems_t *set);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @brief Adds a problem to the ignored problems
Packit Service 8a8a03
Packit Service 8a8a03
  This function never fails. All errors will be logged.
Packit Service 8a8a03
Packit Service 8a8a03
  @param set An instance of ignored problems to which the problem will be added
Packit Service 8a8a03
  @param problem_id An identifier of a problem which will be added to an ignored set
Packit Service 8a8a03
*/
Packit Service 8a8a03
void ignored_problems_add(ignored_problems_t *set, const char *problem_id);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @brief Removes a problem from the ignored problems
Packit Service 8a8a03
Packit Service 8a8a03
  This function never fails. All errors will be logged.
Packit Service 8a8a03
Packit Service 8a8a03
  @param set An instance of ignored problems from which the problem will be deleted
Packit Service 8a8a03
  @param problem_id An identifier of a problem which will be removed from an ignored problems struct
Packit Service 8a8a03
*/
Packit Service 8a8a03
void ignored_problems_remove(ignored_problems_t *set, const char *problem_id);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @brief Checks if a problem is in the ignored problems
Packit Service 8a8a03
Packit Service 8a8a03
  This function never fails. All errors will be logged. If any error occurs,
Packit Service 8a8a03
  the function returns 0 value.
Packit Service 8a8a03
Packit Service 8a8a03
  @param set An instance of ignored problems in which the problem will be searched
Packit Service 8a8a03
  @param problem_id An identifier of a problem
Packit Service 8a8a03
  @return Non 0 value if the problem is ignored; otherwise returns 0 value.
Packit Service 8a8a03
*/
Packit Service 8a8a03
bool ignored_problems_contains(ignored_problems_t *set, const char *problem_id);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @brief Adds a problem defined by its data to the ignored problems
Packit Service 8a8a03
Packit Service 8a8a03
  This function never fails. All errors will be logged.
Packit Service 8a8a03
Packit Service 8a8a03
  @param set An instance of ignored problems to which the problem will be added
Packit Service 8a8a03
  @param pd A data of a problem which will be added to an ignored set
Packit Service 8a8a03
*/
Packit Service 8a8a03
void ignored_problems_add_problem_data(ignored_problems_t *set, problem_data_t *pd);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @brief Removes a problem defined by its data from the ignored problems
Packit Service 8a8a03
Packit Service 8a8a03
  This function never fails. All errors will be logged.
Packit Service 8a8a03
Packit Service 8a8a03
  @param set An instance of ignored problems from which the problem will be deleted
Packit Service 8a8a03
  @param pd A data of a problem which will be removed from an ignored problems struct
Packit Service 8a8a03
*/
Packit Service 8a8a03
void ignored_problems_remove_problem_data(ignored_problems_t *set, problem_data_t *pd);
Packit Service 8a8a03
Packit Service 8a8a03
/**
Packit Service 8a8a03
  @brief Checks if a problem defined its data is in the ignored problems
Packit Service 8a8a03
Packit Service 8a8a03
  This function never fails. All errors will be logged. If any error occurs,
Packit Service 8a8a03
  the function returns 0 value.
Packit Service 8a8a03
Packit Service 8a8a03
  @param set An instance of ignored problems in which the problem will be searched
Packit Service 8a8a03
  @param pd A data of a problem
Packit Service 8a8a03
  @return Non 0 value if the problem is ignored; otherwise returns 0 value.
Packit Service 8a8a03
*/
Packit Service 8a8a03
bool ignored_problems_contains_problem_data(ignored_problems_t *set, problem_data_t *pd);
Packit Service 8a8a03
Packit Service 8a8a03
#ifdef __cplusplus
Packit Service 8a8a03
}
Packit Service 8a8a03
#endif
Packit Service 8a8a03
Packit Service 8a8a03
#endif