static void write_uid_gid_map (uid_t sandbox_uid, uid_t parent_uid, uid_t sandbox_gid, uid_t parent_gid, bool deny_groups) { cleanup_free char *uid_map = NULL; cleanup_free char *gid_map = NULL; uid_map = xasprintf ("%d %d 1\n", sandbox_uid, parent_uid); if (write_file_at (proc_fd, "self/uid_map", uid_map) != 0) die_with_error ("setting up uid map"); if (deny_groups && write_file_at (proc_fd, "self/setgroups", "deny\n") != 0) die_with_error ("error writing to setgroups"); gid_map = xasprintf ("%d %d 1\n", sandbox_gid, parent_gid); if (write_file_at (proc_fd, "self/gid_map", gid_map) != 0) die_with_error ("setting up gid map"); }
static int append_to_file(char* path, void* buffer, int len) { return write_file_at(path, -1, buffer, len); }
static int update_history_values_header(int count) { g_history_values_header.items_count += count; return write_file_at(g_history_path, g_history_values_header_offset, &g_history_values_header, sizeof(history_values_header_t)); }
static int update_statistics_header() { g_statistics_header.items_count++; return write_file_at(g_statistics_path, g_statistics_header_offset, &g_statistics_header, sizeof(statistics_header_t)); }