21 #ifndef LIBREPORT_DUMP_DIR_H_ 22 #define LIBREPORT_DUMP_DIR_H_ 25 #include "libreport_types.h" 31 #include <sys/types.h> 45 int create_symlink_lockfile(
const char *filename,
const char *pid_str);
46 int create_symlink_lockfile_at(
int dir_fd,
const char *filename,
const char *pid_str);
51 int secure_openat_read(
int dir_fd,
const char *filename);
63 extern uid_t dd_g_super_user_uid;
73 extern gid_t dd_g_fs_group_gid;
80 DD_FAIL_QUIETLY_ENOENT = (1 << 0),
81 DD_FAIL_QUIETLY_EACCES = (1 << 1),
83 DD_OPEN_FOLLOW = (1 << 2),
84 DD_OPEN_READONLY = (1 << 3),
85 DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE = (1 << 4),
86 DD_DONT_WAIT_FOR_LOCK = (1 << 5),
88 DD_CREATE_PARENTS = (1 << 6),
93 DD_OPEN_FD_ONLY = (1 << 7),
123 struct dump_dir *dd_opendir(
const char *dir,
int flags);
150 struct dump_dir *dd_create_skeleton(
const char *dir, uid_t uid, mode_t mode,
int flags);
152 int dd_reset_ownership(
struct dump_dir *dd);
157 struct dump_dir *dd_create(
const char *dir, uid_t uid, mode_t mode);
180 void dd_create_basic_files(
struct dump_dir *dd, uid_t uid,
const char *chroot_dir);
181 int dd_exist(
const struct dump_dir *dd,
const char *path);
182 void dd_sanitize_mode_and_owner(
struct dump_dir *dd);
190 DIR *dd_init_next_file(
struct dump_dir *dd);
199 int dd_get_next_file(
struct dump_dir *dd,
char **short_name,
char **full_name);
206 void dd_clear_next_file(
struct dump_dir *dd);
208 char *load_text_file(
const char *path,
unsigned flags);
210 char* dd_load_text_ext(
const struct dump_dir *dd,
const char *name,
unsigned flags);
211 char* dd_load_text(
const struct dump_dir *dd,
const char *name);
212 int dd_load_int32(
const struct dump_dir *dd,
const char *name, int32_t *value);
213 int dd_load_uint32(
const struct dump_dir *dd,
const char *name, uint32_t *value);
214 int dd_load_int64(
const struct dump_dir *dd,
const char *name, int64_t *value);
215 int dd_load_uint64(
const struct dump_dir *dd,
const char *name, uint64_t *value);
225 int dd_get_env_variable(
struct dump_dir *dd,
const char *name,
char **value);
227 void dd_save_text(
struct dump_dir *dd,
const char *name,
const char *data);
228 void dd_save_binary(
struct dump_dir *dd,
const char *name,
const char *data,
unsigned size);
229 int dd_copy_file(
struct dump_dir *dd,
const char *name,
const char *source_path);
230 int dd_copy_file_unpack(
struct dump_dir *dd,
const char *name,
const char *source_path);
240 int dd_copy_file_at(
struct dump_dir *dd,
const char *name,
int src_dir_fd,
const char *src_name);
253 off_t dd_copy_fd(
struct dump_dir *dd,
const char *name,
int fd,
int copy_flags, off_t maxsize);
263 int dd_item_stat(
struct dump_dir *dd,
const char *name,
struct stat *statbuf);
269 long dd_get_item_size(
struct dump_dir *dd,
const char *name);
276 int dd_get_items_count(
struct dump_dir *dd);
282 int dd_delete_item(
struct dump_dir *dd,
const char *name);
295 int dd_open_item(
struct dump_dir *dd,
const char *name,
int flags);
308 FILE *dd_open_item_file(
struct dump_dir *dd,
const char *name,
int flags);
312 int dd_rename(
struct dump_dir *dd,
const char *new_path);
321 int dd_chown(
struct dump_dir *dd, uid_t new_uid);
328 off_t dd_compute_size(
struct dump_dir *dd,
int flags);
335 int dd_set_owner(
struct dump_dir *dd, uid_t owner);
342 int dd_set_no_owner(
struct dump_dir *dd);
349 uid_t dd_get_owner(
struct dump_dir *dd);
358 time_t dd_get_first_occurrence(
struct dump_dir *dd);
368 time_t dd_get_last_occurrence(
struct dump_dir *dd);
390 #define add_reported_to_data libreport_add_reported_to_data 391 int add_reported_to_data(
char **reported_to,
const char *line);
405 #define add_reported_to_entry_data libreport_add_reported_to_entry_data 406 int add_reported_to_entry_data(
char **reported_to,
struct report_result *result);
412 #define add_reported_to libreport_add_reported_to 413 void add_reported_to(
struct dump_dir *dd,
const char *line);
419 #define add_reported_to_entry libreport_add_reported_to_entry 422 #define free_report_result libreport_free_report_result 424 #define find_in_reported_to_data libreport_find_in_reported_to_data 425 report_result_t *find_in_reported_to_data(
const char *reported_to,
const char *report_label);
426 #define find_in_reported_to libreport_find_in_reported_to 428 #define read_entire_reported_to_data libreport_read_entire_reported_to_data 429 GList *read_entire_reported_to_data(
const char* reported_to);
430 #define read_entire_reported_to libreport_read_entire_reported_to 431 GList *read_entire_reported_to(
struct dump_dir *dd);
434 void delete_dump_dir(
const char *dirname);
442 int dump_dir_accessible_by_uid(
const char *dirname, uid_t uid);
447 int dd_accessible_by_uid(
struct dump_dir *dd, uid_t uid);
450 DD_STAT_ACCESSIBLE_BY_UID = 1,
451 DD_STAT_OWNED_BY_UID = DD_STAT_ACCESSIBLE_BY_UID << 1,
452 DD_STAT_NO_OWNER = DD_STAT_OWNED_BY_UID << 1,
462 int dump_dir_stat_for_uid(
const char *dirname, uid_t uid);
467 int dd_stat_for_uid(
struct dump_dir *dd, uid_t uid);
475 int dd_mark_as_notreportable(
struct dump_dir *dd,
const char *reason);
477 typedef int (*save_data_call_back)(
struct dump_dir *,
void *args);
486 struct dump_dir *create_dump_dir(
const char *base_dir_name,
const char *type,
487 uid_t uid, save_data_call_back save_data,
void *args);
489 struct dump_dir *create_dump_dir_ext(
const char *base_dir_name,
const char *type,
490 pid_t pid, uid_t uid, save_data_call_back save_data,
void *args);
512 int dd_create_archive(
struct dump_dir *dd,
const char *archive_name,
513 const_string_vector_const_ptr_t exclude_elements,
int flags);