abrt  2.14.5
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 
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, GHashTable *settings);
73 
74 int abrt_load_abrt_plugin_conf_file(const char *file, GHashTable *settings);
75 
76 int abrt_save_abrt_conf_file(const char *file, GHashTable *settings);
77 
78 int abrt_save_abrt_plugin_conf_file(const char *file, GHashTable *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 
215 #ifdef __cplusplus
216 }
217 #endif
218 
219 #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)