21 #ifndef LIBREPORT_DUMP_DIR_H_ 22 #define LIBREPORT_DUMP_DIR_H_ 25 #include "libreport_types.h" 26 #include "report_result.h" 32 #include <sys/types.h> 46 int create_symlink_lockfile(
const char *filename,
const char *pid_str);
47 int create_symlink_lockfile_at(
int dir_fd,
const char *filename,
const char *pid_str);
52 int secure_openat_read(
int dir_fd,
const char *filename);
64 extern uid_t dd_g_super_user_uid;
74 extern gid_t dd_g_fs_group_gid;
81 DD_FAIL_QUIETLY_ENOENT = (1 << 0),
82 DD_FAIL_QUIETLY_EACCES = (1 << 1),
84 DD_OPEN_FOLLOW = (1 << 2),
85 DD_OPEN_READONLY = (1 << 3),
86 DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE = (1 << 4),
87 DD_DONT_WAIT_FOR_LOCK = (1 << 5),
89 DD_CREATE_PARENTS = (1 << 6),
94 DD_OPEN_FD_ONLY = (1 << 7),
124 struct dump_dir *dd_opendir(
const char *dir,
int flags);
151 struct dump_dir *dd_create_skeleton(
const char *dir, uid_t uid, mode_t mode,
int flags);
153 int dd_reset_ownership(
struct dump_dir *dd);
158 struct dump_dir *dd_create(
const char *dir, uid_t uid, mode_t mode);
181 void dd_create_basic_files(
struct dump_dir *dd, uid_t uid,
const char *chroot_dir);
182 int dd_exist(
const struct dump_dir *dd,
const char *path);
183 void dd_sanitize_mode_and_owner(
struct dump_dir *dd);
191 DIR *dd_init_next_file(
struct dump_dir *dd);
200 int dd_get_next_file(
struct dump_dir *dd,
char **short_name,
char **full_name);
207 void dd_clear_next_file(
struct dump_dir *dd);
209 char *load_text_file(
const char *path,
unsigned flags);
211 char* dd_load_text_ext(
const struct dump_dir *dd,
const char *name,
unsigned flags);
212 char* dd_load_text(
const struct dump_dir *dd,
const char *name);
213 int dd_load_int32(
const struct dump_dir *dd,
const char *name, int32_t *value);
214 int dd_load_uint32(
const struct dump_dir *dd,
const char *name, uint32_t *value);
215 int dd_load_int64(
const struct dump_dir *dd,
const char *name, int64_t *value);
216 int dd_load_uint64(
const struct dump_dir *dd,
const char *name, uint64_t *value);
226 int dd_get_env_variable(
struct dump_dir *dd,
const char *name,
char **value);
228 void dd_save_text(
struct dump_dir *dd,
const char *name,
const char *data);
229 void dd_save_binary(
struct dump_dir *dd,
const char *name,
const char *data,
unsigned size);
230 int dd_copy_file(
struct dump_dir *dd,
const char *name,
const char *source_path);
231 int dd_copy_file_unpack(
struct dump_dir *dd,
const char *name,
const char *source_path);
241 int dd_copy_file_at(
struct dump_dir *dd,
const char *name,
int src_dir_fd,
const char *src_name);
254 off_t dd_copy_fd(
struct dump_dir *dd,
const char *name,
int fd,
int copy_flags, off_t maxsize);
264 int dd_item_stat(
struct dump_dir *dd,
const char *name,
struct stat *statbuf);
270 long dd_get_item_size(
struct dump_dir *dd,
const char *name);
277 int dd_get_items_count(
struct dump_dir *dd);
283 int dd_delete_item(
struct dump_dir *dd,
const char *name);
296 int dd_open_item(
struct dump_dir *dd,
const char *name,
int flags);
309 FILE *dd_open_item_file(
struct dump_dir *dd,
const char *name,
int flags);
313 int dd_rename(
struct dump_dir *dd,
const char *new_path);
322 int dd_chown(
struct dump_dir *dd, uid_t new_uid);
329 off_t dd_compute_size(
struct dump_dir *dd,
int flags);
336 int dd_set_owner(
struct dump_dir *dd, uid_t owner);
343 int dd_set_no_owner(
struct dump_dir *dd);
350 uid_t dd_get_owner(
struct dump_dir *dd);
359 time_t dd_get_first_occurrence(
struct dump_dir *dd);
369 time_t dd_get_last_occurrence(
struct dump_dir *dd);
380 #define add_reported_to_data libreport_add_reported_to_data 381 int add_reported_to_data(
char **reported_to,
const char *line);
395 #define add_reported_to_entry_data libreport_add_reported_to_entry_data 396 int add_reported_to_entry_data(
char **reported_to,
struct report_result *result);
402 #define add_reported_to libreport_add_reported_to 403 void add_reported_to(
struct dump_dir *dd,
const char *line);
409 #define add_reported_to_entry libreport_add_reported_to_entry 410 void add_reported_to_entry(
struct dump_dir *dd,
struct report_result *result);
412 #define find_in_reported_to_data libreport_find_in_reported_to_data 413 report_result_t *find_in_reported_to_data(
const char *reported_to,
const char *report_label);
414 #define find_in_reported_to libreport_find_in_reported_to 415 report_result_t *find_in_reported_to(
struct dump_dir *dd,
const char *report_label);
416 #define read_entire_reported_to_data libreport_read_entire_reported_to_data 417 GList *read_entire_reported_to_data(
const char* reported_to);
418 #define read_entire_reported_to libreport_read_entire_reported_to 419 GList *read_entire_reported_to(
struct dump_dir *dd);
422 void delete_dump_dir(
const char *dirname);
430 int dump_dir_accessible_by_uid(
const char *dirname, uid_t uid);
435 int dd_accessible_by_uid(
struct dump_dir *dd, uid_t uid);
438 DD_STAT_ACCESSIBLE_BY_UID = 1,
439 DD_STAT_OWNED_BY_UID = DD_STAT_ACCESSIBLE_BY_UID << 1,
440 DD_STAT_NO_OWNER = DD_STAT_OWNED_BY_UID << 1,
450 int dump_dir_stat_for_uid(
const char *dirname, uid_t uid);
455 int dd_stat_for_uid(
struct dump_dir *dd, uid_t uid);
463 int dd_mark_as_notreportable(
struct dump_dir *dd,
const char *reason);
465 typedef int (*save_data_call_back)(
struct dump_dir *,
void *args);
474 struct dump_dir *create_dump_dir(
const char *base_dir_name,
const char *type,
475 uid_t uid, save_data_call_back save_data,
void *args);
477 struct dump_dir *create_dump_dir_ext(
const char *base_dir_name,
const char *type,
478 pid_t pid, uid_t uid, save_data_call_back save_data,
void *args);
500 int dd_create_archive(
struct dump_dir *dd,
const char *archive_name,
501 const_string_vector_const_ptr_t exclude_elements,
int flags);