G_STATIC_ASSERT (sizeof (guint) >= sizeof (guint32));
typedef struct {
+ gboolean trusted;
OstreeRepo *repo;
guint checksum_index;
const guint8 *checksums;
_ostree_static_delta_part_execute_raw (OstreeRepo *repo,
GVariant *objects,
GVariant *part,
+ gboolean trusted,
GCancellable *cancellable,
GError **error)
{
state->repo = repo;
state->async_error = error;
+ state->trusted = trusted;
if (!_ostree_static_delta_parse_checksum_array (objects,
&checksums_data,
_ostree_static_delta_part_execute (OstreeRepo *repo,
GVariant *header,
GBytes *part_bytes,
+ gboolean trusted,
GCancellable *cancellable,
GError **error)
{
payload = g_variant_new_from_bytes (G_VARIANT_TYPE (OSTREE_STATIC_DELTA_PART_PAYLOAD_FORMAT_V0),
payload_data, FALSE);
- if (!_ostree_static_delta_part_execute_raw (repo, header, payload,
+ if (!_ostree_static_delta_part_execute_raw (repo, header, payload, trusted,
cancellable, error))
goto out;
GBytes *partdata;
GCancellable *cancellable;
GSimpleAsyncResult *result;
+ gboolean trusted;
} StaticDeltaPartExecuteAsyncData;
static void
if (!_ostree_static_delta_part_execute (data->repo,
data->header,
data->partdata,
+ data->trusted,
cancellable, &error))
g_simple_async_result_take_error (res, error);
}
_ostree_static_delta_part_execute_async (OstreeRepo *repo,
GVariant *header,
GBytes *partdata,
+ gboolean trusted,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
asyncdata->repo = g_object_ref (repo);
asyncdata->header = g_variant_ref (header);
asyncdata->partdata = g_bytes_ref (partdata);
+ asyncdata->trusted = trusted;
asyncdata->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
asyncdata->result = g_simple_async_result_new ((GObject*) repo,
metadata = g_variant_new_from_data (ostree_metadata_variant_type (state->output_objtype),
state->payload_data + offset, length, TRUE, NULL, NULL);
-
- if (!ostree_repo_write_metadata_trusted (state->repo, state->output_objtype,
- state->checksum,
- metadata,
- cancellable,
- error))
- goto out;
+
+ if (state->trusted)
+ {
+ if (!ostree_repo_write_metadata_trusted (state->repo, state->output_objtype,
+ state->checksum,
+ metadata,
+ cancellable,
+ error))
+ goto out;
+ }
+ else
+ {
+ g_autofree guchar *actual_csum = NULL;
+
+ if (!ostree_repo_write_metadata (state->repo, state->output_objtype,
+ state->checksum,
+ metadata, &actual_csum,
+ cancellable,
+ error))
+ goto out;
+ }
}
else
{
(repo->mode == OSTREE_REPO_MODE_BARE ||
repo->mode == OSTREE_REPO_MODE_BARE_USER))
{
- if (!_ostree_repo_open_trusted_content_bare (repo, state->checksum,
- state->content_size,
- &state->barecommitstate,
- &state->content_out,
- &state->have_obj,
- cancellable, error))
- goto out;
+ if (state->trusted)
+ {
+ if (!_ostree_repo_open_trusted_content_bare (repo, state->checksum,
+ state->content_size,
+ &state->barecommitstate,
+ &state->content_out,
+ &state->have_obj,
+ cancellable, error))
+ goto out;
+ }
+ else
+ {
+ if (!_ostree_repo_open_untrusted_content_bare (repo, state->checksum,
+ state->content_size,
+ &state->barecommitstate,
+ &state->content_out,
+ &state->have_obj,
+ cancellable, error))
+ goto out;
+ }
if (!state->have_obj)
{
cancellable, error))
goto out;
- if (!ostree_repo_write_content_trusted (state->repo,
- state->checksum,
- object_input,
- objlen,
- cancellable,
- error))
- goto out;
+ if (state->trusted)
+ {
+ if (!ostree_repo_write_content_trusted (state->repo,
+ state->checksum,
+ object_input,
+ objlen,
+ cancellable,
+ error))
+ goto out;
+ }
+ else
+ {
+ g_autofree guchar *actual_csum = NULL;
+ if (!ostree_repo_write_content (state->repo,
+ state->checksum,
+ object_input,
+ objlen,
+ &actual_csum,
+ cancellable,
+ error))
+ goto out;
+ }
}
}
if (!read_varuint64 (state, &state->content_size, error))
goto out;
- if (!_ostree_repo_open_trusted_content_bare (repo, state->checksum,
- state->content_size,
- &state->barecommitstate,
- &state->content_out,
- &state->have_obj,
- cancellable, error))
- goto out;
+ if (state->trusted)
+ {
+ if (!_ostree_repo_open_trusted_content_bare (repo, state->checksum,
+ state->content_size,
+ &state->barecommitstate,
+ &state->content_out,
+ &state->have_obj,
+ cancellable, error))
+ goto out;
+ }
+ else
+ {
+ if (!_ostree_repo_open_untrusted_content_bare (repo, state->checksum,
+ state->content_size,
+ &state->barecommitstate,
+ &state->content_out,
+ &state->have_obj,
+ cancellable, error))
+ goto out;
+ }
ret = TRUE;
out:
if (!g_output_stream_flush (state->content_out, cancellable, error))
goto out;
- if (!_ostree_repo_commit_trusted_content_bare (repo, state->checksum, &state->barecommitstate,
- state->uid, state->gid, state->mode,
- state->xattrs,
- cancellable, error))
- goto out;
+ if (state->trusted)
+ {
+ if (!_ostree_repo_commit_trusted_content_bare (repo, state->checksum, &state->barecommitstate,
+ state->uid, state->gid, state->mode,
+ state->xattrs,
+ cancellable, error))
+ goto out;
+ }
+ else
+ {
+ if (!_ostree_repo_commit_untrusted_content_bare (repo, state->checksum, &state->barecommitstate,
+ state->uid, state->gid, state->mode,
+ state->xattrs,
+ cancellable, error))
+ goto out;
+ }
}
if (!dispatch_unset_read_source (repo, state, cancellable, error))