abrt  2.15.0
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(struct dump_dir *dd, unsigned timeout_sec, const char *debuginfo_dirs);
48 void abrt_save_coredump(struct dump_dir *dd, unsigned timeout_sec);
49 
50 bool abrt_dir_is_in_dump_location(const char *dir_name);
51 
52 enum {
53  DD_PERM_EVENTS = 1 << 0,
54  DD_PERM_DAEMONS = 1 << 1,
55 };
56 bool abrt_dir_has_correct_permissions(const char *dir_name, int flags);
57 bool abrt_new_user_problem_entry_allowed(uid_t uid, const char *name, const char *value);
58 
59 extern unsigned int abrt_g_settings_nMaxCrashReportsSize;
60 extern char * abrt_g_settings_sWatchCrashdumpArchiveDir;
61 extern char * abrt_g_settings_dump_location;
62 extern bool abrt_g_settings_delete_uploaded;
63 extern bool abrt_g_settings_autoreporting;
64 extern char * abrt_g_settings_autoreporting_event;
65 extern bool abrt_g_settings_shortenedreporting;
66 extern bool abrt_g_settings_explorechroots;
67 extern unsigned int abrt_g_settings_debug_level;
68 
69 
70 int abrt_load_abrt_conf(void);
71 void abrt_free_abrt_conf_data(void);
72 
73 int abrt_load_abrt_conf_file(const char *file, GHashTable *settings);
74 
75 int abrt_load_abrt_plugin_conf_file(const char *file, GHashTable *settings);
76 
77 int abrt_save_abrt_conf_file(const char *file, GHashTable *settings);
78 
79 int abrt_save_abrt_plugin_conf_file(const char *file, GHashTable *settings);
80 
81 
82 void migrate_to_xdg_dirs(void);
83 
84 int check_recent_crash_file(const char *filename, const char *executable);
85 
86 /* Returns 1 if abrtd daemon is running, 0 otherwise. */
87 int abrt_daemon_is_ok(void);
88 
94 void abrt_notify_new_path(const char *path);
95 
104 int abrt_notify_new_path_with_response(const char *path, char **message);
105 
106 /* Note: should be public since unit tests need to call it */
107 char *abrt_koops_extract_version(const char *line);
108 char *abrt_kernel_tainted_short(const char *kernel_bt);
109 char *abrt_kernel_tainted_long(const char *tainted_short);
110 char *abrt_koops_hash_str_ext(const char *oops_buf, int frame_count, int duphas_flags);
111 char *abrt_koops_hash_str(const char *oops_buf);
112 
113 
114 int abrt_koops_line_skip_level(const char **c);
115 void abrt_koops_line_skip_jiffies(const char **c);
116 
117 /*
118  * extract_oops tries to find oops signatures in a log
119  */
121  char *ptr;
122  int level;
123 };
124 
125 void abrt_koops_extract_oopses_from_lines(GList **oops_list, const struct abrt_koops_line_info *lines_info, int lines_info_size);
126 void abrt_koops_extract_oopses(GList **oops_list, char *buffer, size_t buflen);
127 GList *abrt_koops_suspicious_strings_list(void);
128 GList *abrt_koops_suspicious_strings_blacklist(void);
129 void abrt_koops_print_suspicious_strings(void);
136 void abrt_koops_print_suspicious_strings_filtered(const regex_t **filterout);
137 
138 /* dbus client api */
139 
147 int chown_dir_over_dbus(const char *problem_dir_path);
148 
156 int test_exist_over_dbus(const char *problem_id, const char *element_name);
157 
165 int dbus_problem_is_complete(const char *problem_id);
166 
174 char *load_text_over_dbus(const char *problem_id, const char *element_name);
175 
184 int delete_problem_dirs_over_dbus(const GList *problem_dir_paths);
185 
191 int fill_problem_data_over_dbus(const char *problem_dir_path, const char **elements, problem_data_t *problem_data);
192 
198 problem_data_t *get_problem_data_dbus(const char *problem_dir_path);
199 
205 problem_data_t *get_full_problem_data_over_dbus(const char *problem_dir_path);
206 
214 GList *get_problems_over_dbus(bool authorize);
215 
216 #ifdef __cplusplus
217 }
218 #endif
219 
220 #endif
int delete_problem_dirs_over_dbus(const GList *problem_dir_paths)
Delets multiple problems specified by their id (as returned from problem_data_save)
int test_exist_over_dbus(const char *problem_id, const char *element_name)
Checks whether the given element name exists.
problem_data_t * get_problem_data_dbus(const char *problem_dir_path)
Fetches problem information for specified problem id.
GList * get_problems_over_dbus(bool authorize)
Fetches all problems from problem database.
void abrt_notify_new_path(const char *path)
Sends notification to abrtd that a new problem has been detected.
int chown_dir_over_dbus(const char *problem_dir_path)
Changes the access rights of the problem specified by problem id.
problem_data_t * get_full_problem_data_over_dbus(const char *problem_dir_path)
Fetches full problem data for specified problem id.
int abrt_low_free_space(unsigned setting_MaxCrashReportsSize, const char *dump_location)
Checks if there is enough free space to store the problem data.
char * load_text_over_dbus(const char *problem_id, const char *element_name)
int dbus_problem_is_complete(const char *problem_id)
Checks whether the problem corresponding to the given ID is complete.
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.
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.
void abrt_koops_print_suspicious_strings_filtered(const regex_t **filterout)