21 #ifndef LIBREPORT_DUMP_DIR_H_
22 #define LIBREPORT_DUMP_DIR_H_
25 #include "libreport_types.h"
31 #include <sys/types.h>
42 int create_symlink_lockfile(
const char *filename,
const char *pid_str);
43 int create_symlink_lockfile_at(
int dir_fd,
const char *filename,
44 const char *pid_str,
bool log_all_warnings);
49 int secure_openat_read(
int dir_fd,
const char *filename);
52 DD_FAIL_QUIETLY_ENOENT = (1 << 0),
53 DD_FAIL_QUIETLY_EACCES = (1 << 1),
55 DD_OPEN_FOLLOW = (1 << 2),
56 DD_OPEN_READONLY = (1 << 3),
57 DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE = (1 << 4),
58 DD_DONT_WAIT_FOR_LOCK = (1 << 5),
60 DD_CREATE_PARENTS = (1 << 6),
80 int dd_openfd(
const char *dir);
83 struct dump_dir *dd_opendir(
const char *dir,
int flags);
97 struct dump_dir *dd_fdopendir(
int dir_fd,
const char *dir,
int flags);
99 struct dump_dir *dd_create_skeleton(
const char *dir, uid_t uid, mode_t mode,
int flags);
100 int dd_reset_ownership(
struct dump_dir *dd);
104 struct dump_dir *dd_create(
const char *dir, uid_t uid, mode_t mode);
106 void dd_create_basic_files(
struct dump_dir *dd, uid_t uid,
const char *chroot_dir);
107 int dd_exist(
const struct dump_dir *dd,
const char *path);
108 void dd_sanitize_mode_and_owner(
struct dump_dir *dd);
110 DIR *dd_init_next_file(
struct dump_dir *dd);
111 int dd_get_next_file(
struct dump_dir *dd,
char **short_name,
char **full_name);
113 char* dd_load_text_ext(
const struct dump_dir *dd,
const char *name,
unsigned flags);
114 char* dd_load_text(
const struct dump_dir *dd,
const char *name);
115 void dd_save_text(
struct dump_dir *dd,
const char *name,
const char *data);
116 void dd_save_binary(
struct dump_dir *dd,
const char *name,
const char *data,
unsigned size);
117 int dd_copy_file(
struct dump_dir *dd,
const char *name,
const char *source_path);
122 long dd_get_item_size(
struct dump_dir *dd,
const char *name);
127 int dd_delete_item(
struct dump_dir *dd,
const char *name);
140 int dd_open_item(
struct dump_dir *dd,
const char *name,
int flags);
153 FILE *dd_open_item_file(
struct dump_dir *dd,
const char *name,
int flags);
157 int dd_rename(
struct dump_dir *dd,
const char *new_path);
166 int dd_chown(
struct dump_dir *dd, uid_t new_uid);
189 #define add_reported_to_data libreport_add_reported_to_data
190 int add_reported_to_data(
char **reported_to,
const char *line);
204 #define add_reported_to_entry_data libreport_add_reported_to_entry_data
205 int add_reported_to_entry_data(
char **reported_to,
struct report_result *result);
211 #define add_reported_to libreport_add_reported_to
212 void add_reported_to(
struct dump_dir *dd,
const char *line);
218 #define add_reported_to_entry libreport_add_reported_to_entry
221 #define free_report_result libreport_free_report_result
223 #define find_in_reported_to_data libreport_find_in_reported_to_data
224 report_result_t *find_in_reported_to_data(
const char *reported_to,
const char *report_label);
225 #define find_in_reported_to libreport_find_in_reported_to
227 #define read_entire_reported_to_data libreport_read_entire_reported_to_data
228 GList *read_entire_reported_to_data(
const char* reported_to);
229 #define read_entire_reported_to libreport_read_entire_reported_to
230 GList *read_entire_reported_to(
struct dump_dir *dd);
233 void delete_dump_dir(
const char *dirname);
241 int dump_dir_accessible_by_uid(
const char *dirname, uid_t uid);
242 int fdump_dir_accessible_by_uid(
int dir_fd, uid_t uid);
245 DD_STAT_ACCESSIBLE_BY_UID = 1,
246 DD_STAT_OWNED_BY_UID = DD_STAT_ACCESSIBLE_BY_UID << 1,
256 int dump_dir_stat_for_uid(
const char *dirname, uid_t uid);
257 int fdump_dir_stat_for_uid(
int dir_fd, uid_t uid);
265 int dd_mark_as_notreportable(
struct dump_dir *dd,
const char *reason);
287 int dd_create_archive(
struct dump_dir *dd,
const char *archive_name,
288 const_string_vector_const_ptr_t exclude_elements,
int flags);