abrt  2.14.2
A tool to inform users about various problems on the running system
libabrt.h
Go to the documentation of this file.
1 /*
2  * Utility routines.
3  *
4  * Licensed under GPLv2, see file COPYING in this tarball for details.
5  */
6 
9 #ifndef LIBABRT_H_
10 #define LIBABRT_H_
11 
12 #include <regex.h>
13 
14 #include <gio/gio.h> /* dbus */
15 #include "abrt-dbus.h"
16 /* libreport's internal functions we use: */
17 #include <libreport/internal_libreport.h>
18 #include "hooklib.h"
19 
20 #undef ARRAY_SIZE
21 #define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Some libc's forget to declare these, do it ourself */
28 extern char **environ;
29 #if defined(__GLIBC__) && __GLIBC__ < 2
30 int vdprintf(int d, const char *format, va_list ap);
31 #endif
32 
33 
40 int abrt_low_free_space(unsigned setting_MaxCrashReportsSize, const char *dump_location);
41 
42 void abrt_trim_problem_dirs(const char *dirname, double cap_size, const char *exclude_path);
43 void abrt_ensure_writable_dir_uid_gid(const char *dir, mode_t mode, uid_t uid, gid_t gid);
44 void abrt_ensure_writable_dir(const char *dir, mode_t mode, const char *user);
45 void abrt_ensure_writable_dir_group(const char *dir, mode_t mode, const char *user, const char *group);
46 char *abrt_run_unstrip_n(const char *dump_dir_name, unsigned timeout_sec);
47 char *abrt_get_backtrace(const char *dump_dir_name, unsigned timeout_sec, const char *debuginfo_dirs);
48 
49 bool abrt_dir_is_in_dump_location(const char *dir_name);
50 
51 enum {
52  DD_PERM_EVENTS = 1 << 0,
53  DD_PERM_DAEMONS = 1 << 1,
54 };
55 bool abrt_dir_has_correct_permissions(const char *dir_name, int flags);
56 bool abrt_new_user_problem_entry_allowed(uid_t uid, const char *name, const char *value);
57 
58 extern unsigned int abrt_g_settings_nMaxCrashReportsSize;
59 extern char * abrt_g_settings_sWatchCrashdumpArchiveDir;
60 extern char * abrt_g_settings_dump_location;
61 extern bool abrt_g_settings_delete_uploaded;
62 extern bool abrt_g_settings_autoreporting;
63 extern char * abrt_g_settings_autoreporting_event;
64 extern bool abrt_g_settings_shortenedreporting;
65 extern bool abrt_g_settings_explorechroots;
66 extern unsigned int abrt_g_settings_debug_level;
67 
68 
69 int abrt_load_abrt_conf(void);
70 void abrt_free_abrt_conf_data(void);
71 
72 int abrt_load_abrt_conf_file(const char *file, map_string_t *settings);
73 
74 int abrt_load_abrt_plugin_conf_file(const char *file, map_string_t *settings);
75 
76 int abrt_save_abrt_conf_file(const char *file, map_string_t *settings);
77 
78 int abrt_save_abrt_plugin_conf_file(const char *file, map_string_t *settings);
79 
80 
81 void migrate_to_xdg_dirs(void);
82 
83 int check_recent_crash_file(const char *filename, const char *executable);
84 
85 /* Returns 1 if abrtd daemon is running, 0 otherwise. */
86 int abrt_daemon_is_ok(void);
87 
93 void abrt_notify_new_path(const char *path);
94 
103 int abrt_notify_new_path_with_response(const char *path, char **message);
104 
105 /* Note: should be public since unit tests need to call it */
106 char *abrt_koops_extract_version(const char *line);
107 char *abrt_kernel_tainted_short(const char *kernel_bt);
108 char *abrt_kernel_tainted_long(const char *tainted_short);
109 char *abrt_koops_hash_str_ext(const char *oops_buf, int frame_count, int duphas_flags);
110 char *abrt_koops_hash_str(const char *oops_buf);
111 
112 
113 int abrt_koops_line_skip_level(const char **c);
114 void abrt_koops_line_skip_jiffies(const char **c);
115 
116 /*
117  * extract_oops tries to find oops signatures in a log
118  */
120  char *ptr;
121  int level;
122 };
123 
124 void abrt_koops_extract_oopses_from_lines(GList **oops_list, const struct abrt_koops_line_info *lines_info, int lines_info_size);
125 void abrt_koops_extract_oopses(GList **oops_list, char *buffer, size_t buflen);
126 GList *abrt_koops_suspicious_strings_list(void);
127 GList *abrt_koops_suspicious_strings_blacklist(void);
128 void abrt_koops_print_suspicious_strings(void);
135 void abrt_koops_print_suspicious_strings_filtered(const regex_t **filterout);
136 
137 /* dbus client api */
138 
146 int chown_dir_over_dbus(const char *problem_dir_path);
147 
155 int test_exist_over_dbus(const char *problem_id, const char *element_name);
156 
164 int dbus_problem_is_complete(const char *problem_id);
165 
173 char *load_text_over_dbus(const char *problem_id, const char *element_name);
174 
183 int delete_problem_dirs_over_dbus(const GList *problem_dir_paths);
184 
190 int fill_problem_data_over_dbus(const char *problem_dir_path, const char **elements, problem_data_t *problem_data);
191 
197 problem_data_t *get_problem_data_dbus(const char *problem_dir_path);
198 
204 problem_data_t *get_full_problem_data_over_dbus(const char *problem_dir_path);
205 
213 GList *get_problems_over_dbus(bool authorize);
214 
219 typedef struct ignored_problems ignored_problems_t;
220 
228 ignored_problems_t *ignored_problems_new(char *file_path);
229 
239 
248 void ignored_problems_add(ignored_problems_t *set, const char *problem_id);
249 
258 void ignored_problems_remove(ignored_problems_t *set, const char *problem_id);
259 
270 bool ignored_problems_contains(ignored_problems_t *set, const char *problem_id);
271 
280 void ignored_problems_add_problem_data(ignored_problems_t *set, problem_data_t *pd);
281 
290 void ignored_problems_remove_problem_data(ignored_problems_t *set, problem_data_t *pd);
291 
302 bool ignored_problems_contains_problem_data(ignored_problems_t *set, problem_data_t *pd);
303 
304 #ifdef __cplusplus
305 }
306 #endif
307 
308 #endif
chown_dir_over_dbus
int chown_dir_over_dbus(const char *problem_dir_path)
Changes the access rights of the problem specified by problem id.
ignored_problems_add
void ignored_problems_add(ignored_problems_t *set, const char *problem_id)
Adds a problem to the ignored problems.
abrt_notify_new_path
void abrt_notify_new_path(const char *path)
Sends notification to abrtd that a new problem has been detected.
get_problems_over_dbus
GList * get_problems_over_dbus(bool authorize)
Fetches all problems from problem database.
ignored_problems_add_problem_data
void ignored_problems_add_problem_data(ignored_problems_t *set, problem_data_t *pd)
Adds a problem defined by its data to the ignored problems.
test_exist_over_dbus
int test_exist_over_dbus(const char *problem_id, const char *element_name)
Checks whether the given element name exists.
ignored_problems_new
ignored_problems_t * ignored_problems_new(char *file_path)
Initializes a new instance of ignored problems.
ignored_problems_remove
void ignored_problems_remove(ignored_problems_t *set, const char *problem_id)
Removes a problem from the ignored problems.
abrt_koops_print_suspicious_strings_filtered
void abrt_koops_print_suspicious_strings_filtered(const regex_t **filterout)
ignored_problems_contains
bool ignored_problems_contains(ignored_problems_t *set, const char *problem_id)
Checks if a problem is in the ignored problems.
ignored_problems
An opaque structure holding a list of ignored problems.
abrt_low_free_space
int abrt_low_free_space(unsigned setting_MaxCrashReportsSize, const char *dump_location)
Checks if there is enough free space to store the problem data.
ignored_problems_contains_problem_data
bool ignored_problems_contains_problem_data(ignored_problems_t *set, problem_data_t *pd)
Checks if a problem defined its data is in the ignored problems.
hooklib.h
fill_problem_data_over_dbus
int fill_problem_data_over_dbus(const char *problem_dir_path, const char **elements, problem_data_t *problem_data)
Fetches given problem elements for specified problem id.
load_text_over_dbus
char * load_text_over_dbus(const char *problem_id, const char *element_name)
get_full_problem_data_over_dbus
problem_data_t * get_full_problem_data_over_dbus(const char *problem_dir_path)
Fetches full problem data for specified problem id.
ignored_problems_remove_problem_data
void ignored_problems_remove_problem_data(ignored_problems_t *set, problem_data_t *pd)
Removes a problem defined by its data from the ignored problems.
dbus_problem_is_complete
int dbus_problem_is_complete(const char *problem_id)
Checks whether the problem corresponding to the given ID is complete.
ignored_problems_free
void ignored_problems_free(ignored_problems_t *set)
Destroys an instance of ignored problems.
get_problem_data_dbus
problem_data_t * get_problem_data_dbus(const char *problem_dir_path)
Fetches problem information for specified problem id.
delete_problem_dirs_over_dbus
int delete_problem_dirs_over_dbus(const GList *problem_dir_paths)
Delets multiple problems specified by their id (as returned from problem_data_save)
abrt_koops_line_info
Definition: libabrt.h:119
abrt_notify_new_path_with_response
int abrt_notify_new_path_with_response(const char *path, char **message)
Sends notification to abrtd that a new problem has been detected and wait for the reply.