/*
* Copyright 2011 Avery Pennarun. All rights reserved.
- *
+ *
* (This license applies to bupsplit.c and bupsplit.h only.)
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY AVERY PENNARUN ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
{
Rollsum r;
int count;
-
+
rollsum_init(&r);
for (count = 0; count < len; count++)
{
/*
* Copyright 2011 Avery Pennarun. All rights reserved.
- *
+ *
* (This license applies to bupsplit.c and bupsplit.h only.)
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY AVERY PENNARUN ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
#ifdef __cplusplus
}
#endif
-
+
#endif /* __BUPSPLIT_H */
/**
* ostree_bootconfig_parser_clone:
* @self: Bootconfig to clone
- *
+ *
* Returns: (transfer full): Copy of @self
*/
OstreeBootconfigParser *
_ostree_bootloader_uboot_query (OstreeBootloader *bootloader,
gboolean *out_is_active,
GCancellable *cancellable,
- GError **error)
+ GError **error)
{
OstreeBootloaderUboot *self = OSTREE_BOOTLOADER_UBOOT (bootloader);
struct stat stbuf;
-/*
+/*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
GParamSpec *pspec)
{
OstreeChainInputStream *self;
-
+
self = OSTREE_CHAIN_INPUT_STREAM (object);
switch (prop_id)
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return -1;
-
+
if (self->priv->index >= self->priv->streams->len)
return 0;
-/*
+/*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
GParamSpec *pspec)
{
OstreeChecksumInputStream *self;
-
+
self = OSTREE_CHECKSUM_INPUT_STREAM (object);
switch (prop_id)
#include "otutil.h"
-static gboolean
+static gboolean
impl_ostree_generate_grub2_config (OstreeSysroot *sysroot, int bootversion, int target_fd, GCancellable *cancellable, GError **error)
{
return _ostree_bootloader_grub2_generate_config (sysroot, bootversion, target_fd, cancellable, error);
-/*
+/*
* SPDX-License-Identifier: LGPL-2.0+
*
* This library is free software; you can redistribute it and/or
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GOutputStreamClass *stream_class = G_OUTPUT_STREAM_CLASS (klass);
-
+
gobject_class->finalize = ostree_content_writer_finalize;
stream_class->write_fn = ostree_content_writer_write;
/*
* File objects are stored as a stream, with one #GVariant header,
* followed by content.
- *
+ *
* The file header is of the following form:
*
* <BE guint32 containing variant length>
* u - gid
* u - mode
* u - rdev (must be 0)
- * s - symlink target
+ * s - symlink target
* a(ayay) - xattrs
*
* Then the rest of the stream is data.
* u - gid
* u - mode
* u - rdev (must be 0)
- * s - symlink target
+ * s - symlink target
* a(ayay) - xattrs
* ---
* zlib-compressed data
#include "ostree-dummy-enumtypes.h"
-/* Exported for backwards compat - see
+/* Exported for backwards compat - see
* https://bugzilla.gnome.org/show_bug.cgi?id=764131
*/
GType
static void
on_out_splice_complete (GObject *object,
GAsyncResult *result,
- gpointer user_data)
+ gpointer user_data)
{
GTask *task = G_TASK (user_data);
OstreeFetcherPendingURI *pending;
static void
on_stream_read (GObject *object,
GAsyncResult *result,
- gpointer user_data)
+ gpointer user_data)
{
GTask *task = G_TASK (user_data);
OstreeFetcherPendingURI *pending;
static void
on_request_sent (GObject *object,
GAsyncResult *result,
- gpointer user_data)
+ gpointer user_data)
{
GTask *task = G_TASK (user_data);
/* Hold a ref to the pending across this function, since we remove
}
pending->state = OSTREE_FETCHER_STATE_DOWNLOADING;
-
+
pending->content_length = soup_request_get_content_length (pending->request);
g_input_stream_read_bytes_async (pending->request_body,
* out invalid input.
*/
gboolean
-_ostree_fetcher_uri_validate (OstreeFetcherURI *uri, GError **error)
+_ostree_fetcher_uri_validate (OstreeFetcherURI *uri, GError **error)
{
const char *scheme = g_uri_get_scheme ((GUri*)uri);
// TODO only allow file if explicitly requested by a higher level
// Don't insert a duplicate key.
if (ostree_kernel_args_contains (kargs, arg))
return;
-
+
ostree_kernel_args_append (kargs, arg);
}
char *ostree_kernel_args_to_string (OstreeKernelArgs *kargs);
_OSTREE_PUBLIC
-void ostree_kernel_args_append_if_missing (OstreeKernelArgs *kargs,
+void ostree_kernel_args_append_if_missing (OstreeKernelArgs *kargs,
const char *arg);
_OSTREE_PUBLIC
-/*
+/*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
GParamSpec *pspec)
{
OstreeLibarchiveInputStream *self;
-
+
self = OSTREE_LIBARCHIVE_INPUT_STREAM (object);
switch (prop_id)
{
OstreeLzmaCompressor *self = OSTREE_LZMA_COMPRESSOR (converter);
int res;
- lzma_action action;
+ lzma_action action;
if (inbuf_size != 0 && outbuf_size == 0)
{
guint passthrough_depth;
OstreeMetalinkState passthrough_previous;
-
+
guint found_a_file_element : 1;
guint found_our_file_element : 1;
guint verification_known : 1;
GError *temp_error = NULL;
target_uri = self->urls->pdata[self->current_url_index];
-
+
if (try_one_url (self, target_uri, &ret_data, &temp_error))
break;
else
#endif
/* Understanding ostree's fsync strategy
- *
+ *
* A long time ago, ostree used to invoke fsync() on each object,
* then move it into the objects directory. However, it turned
* out to be a *lot* faster to write the objects into a separate "staging"
* Returns: (transfer full): Checksum (as a hex string) of the committed file
* Since: 2021.2
*/
-char *
+char *
ostree_repo_write_symlink (OstreeRepo *self,
const char *expected_checksum,
guint32 uid,
* @content_len: Expected content length
* @xattrs: (allow-none): Extended attributes (GVariant type `(ayay)`)
* @error: Error
- *
+ *
* Create an `OstreeContentWriter` that allows streaming output into
* the repository.
*
* Returns: (transfer full): A new writer, or %NULL on error
* Since: 2021.2
*/
-OstreeContentWriter *
+OstreeContentWriter *
ostree_repo_write_regfile (OstreeRepo *self,
const char *expected_checksum,
guint32 uid,
*
* Since: 2020.4
*/
-gboolean
+gboolean
ostree_repo_commit_modifier_set_sepolicy_from_commit (OstreeRepoCommitModifier *modifier,
OstreeRepo *repo,
const char *rev,
g_clear_object (&self->dir);
g_free (self->attributes);
-
+
if (G_OBJECT_CLASS (ostree_repo_file_enumerator_parent_class)->dispose)
G_OBJECT_CLASS (ostree_repo_file_enumerator_parent_class)->dispose (object);
}
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GFileEnumeratorClass *enumerator_class = G_FILE_ENUMERATOR_CLASS (klass);
-
+
gobject_class->finalize = ostree_repo_file_enumerator_finalize;
gobject_class->dispose = ostree_repo_file_enumerator_dispose;
GError **error)
{
OstreeRepoFileEnumerator *self;
-
+
self = g_object_new (OSTREE_TYPE_REPO_FILE_ENUMERATOR,
"container", dir,
NULL);
self->dir = g_object_ref (dir);
self->attributes = g_strdup (attributes);
self->flags = flags;
-
+
return G_FILE_ENUMERATOR (self);
}
{
OstreeRepoFile *self;
size_t len;
-
+
self = g_object_new (OSTREE_TYPE_REPO_FILE, NULL);
self->repo = g_object_ref (parent->repo);
self->parent = g_object_ref (parent);
ostree_repo_file_hash (GFile *file)
{
OstreeRepoFile *self = OSTREE_REPO_FILE (file);
-
+
if (self->parent)
return g_file_hash (self->parent) + g_str_hash (self->name);
else
}
static const char *
-match_prefix (const char *path,
+match_prefix (const char *path,
const char *prefix)
{
int prefix_len;
prefix_len = strlen (prefix);
if (strncmp (path, prefix, prefix_len) != 0)
return NULL;
-
+
/* Handle the case where prefix is the root, so that
* the IS_DIR_SEPRARATOR check below works */
if (prefix_len > 0 &&
G_IS_DIR_SEPARATOR (prefix[prefix_len-1]))
prefix_len--;
-
+
return path + prefix_len;
}
parent_path = gs_file_get_path_cached (parent);
descendant_path = gs_file_get_path_cached (descendant);
remainder = match_prefix (descendant_path, parent_path);
-
+
if (remainder != NULL && G_IS_DIR_SEPARATOR (*remainder))
return g_strdup (remainder + 1);
return NULL;
parent = ostree_repo_file_new_child (self, filename);
g_free (filename);
-
+
if (!rest)
ret = (GFile*)parent;
else
if (!opts->disable_xattrs)
{
int i, n;
-
+
n = g_variant_n_children (xattrs);
for (i = 0; i < n; i++)
{
if (!write_header_free_entry (a, &entry, error))
goto out;
- dir_enum = g_file_enumerate_children (dir, OSTREE_GIO_FAST_QUERYINFO,
+ dir_enum = g_file_enumerate_children (dir, OSTREE_GIO_FAST_QUERYINFO,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
cancellable, error);
if (!dir_enum)
ostree_commit_metadata_for_bootable (GFile *root, GVariantDict *dict, GCancellable *cancellable, GError **error)
{
g_autoptr(GFile) modules = g_file_resolve_relative_path (root, "usr/lib/modules");
- g_autoptr(GFileEnumerator) dir_enum
+ g_autoptr(GFileEnumerator) dir_enum
= g_file_enumerate_children (modules, OSTREE_GIO_FAST_QUERYINFO,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
cancellable, error);
break;
if (g_file_info_get_file_type (child_info) != G_FILE_TYPE_DIRECTORY)
continue;
-
+
g_autoptr(GFile) kernel_path = g_file_resolve_relative_path (child_path, "vmlinuz");
if (!g_file_query_exists (kernel_path, NULL))
continue;
G_BEGIN_DECLS
-/**
+/**
* OSTREE_METADATA_KEY_BOOTABLE:
*
* GVariant type `b`: Set if this commit is intended to be bootable
* Since: 2021.1
*/
#define OSTREE_METADATA_KEY_BOOTABLE "ostree.bootable"
-/**
+/**
* OSTREE_METADATA_KEY_LINUX:
*
* GVariant type `s`: Contains the Linux kernel release (i.e. `uname -r`)
GCancellable *cancellable,
GError **error)
{
- return traverse_reachable_internal (self,
+ return traverse_reachable_internal (self,
OSTREE_REPO_COMMIT_TRAVERSE_FLAG_NONE,
depth, reachable,
cancellable, error);
if (commit_only)
{
if (!ostree_repo_list_commit_objects_starting_with (self, "", &objects, cancellable, error))
- return FALSE;
+ return FALSE;
}
- else
+ else
{
objects = ostree_repo_list_objects_set (self, OSTREE_REPO_LIST_OBJECTS_ALL | OSTREE_REPO_LIST_OBJECTS_NO_PARENTS,
cancellable, error);
g_autoptr(GHashTable) objects = NULL;
OstreeRepoPruneFlags flags = options->flags;
gboolean commit_only = (flags & OSTREE_REPO_PRUNE_FLAGS_COMMIT_ONLY) > 0;
- if (commit_only)
+ if (commit_only)
{
if (!ostree_repo_list_commit_objects_starting_with (self, "", &objects, cancellable, error))
- return FALSE;
- }
+ return FALSE;
+ }
else
{
objects =
* contain at least one valid signature. If GPG and signapi are
* both enabled, then both must find at least one valid signature.
*/
-gboolean
+gboolean
ostree_repo_signature_verify_commit_data (OstreeRepo *self,
const char *remote_name,
GBytes *commit_data,
if (custom_backend)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Cannot fetch via libostree - remote '%s' uses custom backend '%s'",
+ "Cannot fetch via libostree - remote '%s' uses custom backend '%s'",
pull_data->remote_name, custom_backend);
goto out;
}
{
OstreeRepoCommitIterResult iterres =
ostree_repo_commit_traverse_iter_next (iter, cancellable, error);
-
+
if (iterres == OSTREE_REPO_COMMIT_ITER_RESULT_ERROR)
goto out;
else if (iterres == OSTREE_REPO_COMMIT_ITER_RESULT_END)
char *name;
char *checksum;
OstreeDeltaContentSizeNames *csizenames;
-
+
ostree_repo_commit_traverse_iter_get_file (iter, &name, &checksum);
if (include_only_objects && !g_hash_table_contains (include_only_objects, checksum))
OstreeRepoCommitTraverseIter subiter = { 0, };
ostree_repo_commit_traverse_iter_get_dir (iter, &name, &content_checksum, &meta_checksum);
-
+
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_DIR_TREE,
content_checksum, &dirtree,
error))
*
* The metadata would include things like a version number, as well as
* extended verification data like a GPG signature.
- *
+ *
* The second array is an array of delta objects that should be
* fetched and applied before this one. This is a fairly generic
* recursion mechanism that would potentially allow saving significant
* Finally, we have the fallback array, which is the set of objects to
* fetch individually - the compiler determined it wasn't worth
* duplicating the space.
- */
+ */
#define OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT "(a{sv}tayay" OSTREE_COMMIT_GVARIANT_STRING "aya" OSTREE_STATIC_DELTA_META_ENTRY_FORMAT "a" OSTREE_STATIC_DELTA_FALLBACK_FORMAT ")"
/**
gboolean _ostree_static_delta_part_execute_finish (OstreeRepo *repo,
GAsyncResult *result,
- GError **error);
+ GError **error);
gboolean
_ostree_static_delta_parse_checksum_array (GVariant *array,
* data for that directory. Similarly, if
* %OSTREE_REPO_COMMIT_ITER_RESULT_FILE is returned, call
* ostree_repo_commit_traverse_iter_get_file().
- *
+ *
* If %OSTREE_REPO_COMMIT_ITER_RESULT_ERROR is returned, it is a
* program error to call any further API on @iter except for
* ostree_repo_commit_traverse_iter_clear().
if (!csum)
goto out;
ostree_checksum_inplace_from_bytes (csum, real->checksum_meta);
-
+
res = OSTREE_REPO_COMMIT_ITER_RESULT_DIR;
real->idx++;
else
res = OSTREE_REPO_COMMIT_ITER_RESULT_END;
}
-
+
real->state = res;
out:
return res;
g_hash_table_add (inout_reachable, g_variant_ref (key));
/* Save time by skipping traversal of non-commit objects */
- if (!commit_only)
+ if (!commit_only)
{
g_debug ("Traversing commit %s", commit_checksum);
ostree_cleanup_repo_commit_traverse_iter
if (!traverse_iter (repo, &iter, key, inout_reachable, inout_parents, ignore_missing_dirs, cancellable, error))
return FALSE;
- }
+ }
gboolean recurse = FALSE;
if (maxdepth == -1 || maxdepth > 0)
#include <linux/fsverity.h>
#endif
-gboolean
+gboolean
_ostree_repo_parse_fsverity_config (OstreeRepo *self, GError **error)
{
/* Currently experimental */
return glnx_throw (error, "fsverity required, but libostree compiled without support");
}
else
- {
+ {
gboolean fsverity_opportunistic = FALSE;
if (!ot_keyfile_get_boolean_with_default (self->config, fsverity_key, "opportunistic",
FALSE, &fsverity_opportunistic, error))
return glnx_throw_errno_prefix (error, "ioctl(FS_IOC_ENABLE_VERITY)");
}
}
-
+
if (supported)
*supported = TRUE;
#endif
g_mutex_unlock (&self->txn_lock);
return TRUE;
}
-
+
g_mutex_lock (&self->txn_lock);
self->fs_verity_supported = _OSTREE_FEATURE_YES;
g_mutex_unlock (&self->txn_lock);
self->remotes = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) NULL,
(GDestroyNotify) ostree_remote_unref);
- self->bls_append_values = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
+ self->bls_append_values = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
(GDestroyNotify) g_free);
g_mutex_init (&self->remotes_lock);
if (!_ostree_repo_parse_fsverity_config (self, error))
return FALSE;
-
+
{
g_clear_pointer (&self->collection_id, g_free);
if (!ot_keyfile_get_value_with_default (self->config, "core", "collection-id",
valid_bootloader = TRUE;
}
}
- if (!valid_bootloader)
+ if (!valid_bootloader)
{
return glnx_throw (error, "Invalid bootloader configuration: '%s'", bootloader);
}
/* Parse bls-append-except-default string list. */
g_auto(GStrv) read_values = NULL;
- if (!ot_keyfile_get_string_list_with_default (self->config, "sysroot", "bls-append-except-default",
+ if (!ot_keyfile_get_string_list_with_default (self->config, "sysroot", "bls-append-except-default",
';', NULL, &read_values, error))
return glnx_throw(error, "Unable to parse bls-append-except-default");
-
+
/* get all key value pairs in bls-append-except-default */
g_hash_table_remove_all (self->bls_append_values);
for (char **iter = read_values; iter && *iter; iter++)
}
char *key = g_strndup (key_value, sep - key_value);
char *value = g_strdup (sep + 1);
- g_hash_table_replace (self->bls_append_values, key, value);
+ g_hash_table_replace (self->bls_append_values, key, value);
}
return TRUE;
{
if (self->disable_xattrs)
ret_xattrs = g_variant_ref_sink (g_variant_new_array (G_VARIANT_TYPE ("(ayay)"), NULL, 0));
- else
+ else
{
ret_xattrs = ostree_fs_get_all_xattrs (fd, cancellable, error);
if (!ret_xattrs)
guint64 content_len,
GVariant *xattrs,
GError **error);
-
+
_OSTREE_PUBLIC
char * ostree_repo_write_symlink (OstreeRepo *self,
const char *expected_checksum,
_OSTREE_PUBLIC
gboolean ostree_repo_load_variant (OstreeRepo *self,
OstreeObjectType objtype,
- const char *sha256,
+ const char *sha256,
GVariant **out_variant,
GError **error);
_OSTREE_PUBLIC
gboolean ostree_repo_load_variant_if_exists (OstreeRepo *self,
OstreeObjectType objtype,
- const char *sha256,
+ const char *sha256,
GVariant **out_variant,
GError **error);
_OSTREE_PUBLIC
gboolean ostree_repo_load_commit (OstreeRepo *self,
- const char *checksum,
+ const char *checksum,
GVariant **out_commit,
OstreeRepoCommitState *out_state,
GError **error);
_OSTREE_PUBLIC
gboolean ostree_repo_query_object_storage_size (OstreeRepo *self,
OstreeObjectType objtype,
- const char *sha256,
+ const char *sha256,
guint64 *out_size,
GCancellable *cancellable,
GError **error);
GCancellable *cancellable,
GError **error);
-/**
+/**
* OstreeRepoCommitFilterResult:
* @OSTREE_REPO_COMMIT_FILTER_ALLOW: Do commit this object
* @OSTREE_REPO_COMMIT_FILTER_SKIP: Ignore this object
* @OSTREE_REPO_VERIFY_FLAGS_NONE: No flags
* @OSTREE_REPO_VERIFY_FLAGS_NO_GPG: Skip GPG verification
* @OSTREE_REPO_VERIFY_FLAGS_NO_SIGNAPI: Skip all other signature verification methods
- *
+ *
* Since: 2021.4
*/
typedef enum {
if (!rollsum_end)
{
- offset = bupsplit_find_ofs (buf + start, MIN(G_MAXINT32, remaining), &bits);
+ offset = bupsplit_find_ofs (buf + start, MIN(G_MAXINT32, remaining), &bits);
if (offset == 0)
{
rollsum_end = TRUE;
GVariant **bvpp = (GVariant**)bpp;
GVariant *b = *bvpp;
guint64 a_start, b_start;
-
+
g_variant_get_child (a, 2, "t", &a_start);
g_variant_get_child (b, 2, "t", &b_start);
/* Same crc32 but different length, skip it. */
if (to_offset != from_offset)
continue;
-
+
/* Rsync uses a cryptographic checksum, but let's be
* very conservative here and just memcmp.
*/
ret_rollsum->match_size += to_offset;
g_ptr_array_add (matches, g_variant_ref_sink (match));
break; /* Don't need any more matches */
- }
+ }
}
}
}
OstreeRepoCheckoutAtOptions coopts = {0,};
coopts.mode = OSTREE_REPO_CHECKOUT_MODE_USER;
coopts.subpath = glnx_strjoina ("/", policypath);
-
+
if (!ostree_repo_checkout_at (repo, &coopts, tmpdir.fd, policypath, commit, cancellable, error))
return glnx_prefix_error_null (error, "policy checkout");
}
if (line == NULL)
return ret;
-
+
/* Read the key itself */
/* base64 encoded key */
pk = g_variant_new_string (line);
key_stream_in = g_file_read (keyfile, NULL, error);
if (key_stream_in == NULL)
return FALSE;
-
+
key_data_in = g_data_input_stream_new (G_INPUT_STREAM(key_stream_in));
g_assert (key_data_in != NULL);
if (!_load_pk_from_stream (self, key_data_in, trusted, error))
{
if (error == NULL || *error == NULL)
- return glnx_throw (error,
+ return glnx_throw (error,
"signature: ed25519: no valid keys in file '%s'",
filename);
else
g_autofree gchar *base_dir = NULL;
g_autoptr (GDir) dir = NULL;
- base_name = g_build_filename ((gchar *)g_ptr_array_index (base_dirs, i),
+ base_name = g_build_filename ((gchar *)g_ptr_array_index (base_dirs, i),
trusted ? "trusted.ed25519" : "revoked.ed25519",
NULL);
*
* Since: 2020.2
*/
-const gchar *
+const gchar *
ostree_sign_get_name (OstreeSign *self)
{
g_assert (OSTREE_IS_SIGN (self));
{
g_clear_error (&temp_error);
goto done;
- }
+ }
else
{
g_propagate_error (error, temp_error);
name = g_file_info_get_name (file_info);
if (!parse_bootdir_name (name, NULL, NULL))
continue;
-
+
g_ptr_array_add (ret_bootdirs, g_object_ref (child));
}
-
+
done:
ret = TRUE;
ot_transfer_out_value (out_bootdirs, &ret_bootdirs);
{
g_autoptr(GError) writing_error = NULL;
g_assert_cmpint (self->boot_fd, !=, -1);
- if (!glnx_file_replace_contents_at (self->boot_fd, _OSTREE_FINALIZE_STAGED_FAILURE_PATH,
+ if (!glnx_file_replace_contents_at (self->boot_fd, _OSTREE_FINALIZE_STAGED_FAILURE_PATH,
(guint8*)finalization_error->message, -1,
0, cancellable, &writing_error))
{
g_variant_new_from_bytes ((GVariantType*)"a{sv}", contents, TRUE);
g_autoptr(GVariantDict) staged_deployment_dict =
g_variant_dict_new (staged_deployment_data);
-
+
g_autoptr(OstreeKernelArgs) kargs = ostree_kernel_args_from_string (kargs_str);
g_auto(GStrv) kargs_strv = ostree_kernel_args_to_strv (kargs);
-
+
g_variant_dict_insert (staged_deployment_dict, "kargs", "^a&s", kargs_strv);
g_autoptr(GVariant) new_staged_deployment_data = g_variant_dict_end (staged_deployment_dict);
-
+
if (!glnx_file_replace_contents_at (fd, _OSTREE_SYSROOT_RUNSTATE_STAGED,
- g_variant_get_data (new_staged_deployment_data),
+ g_variant_get_data (new_staged_deployment_data),
g_variant_get_size (new_staged_deployment_data),
GLNX_FILE_REPLACE_NODATASYNC,
cancellable, error))
// If the mount namespaces are the same, we need to unshare().
if (strcmp (mntns_pid1, mntns_self) == 0)
- {
+ {
if (unshare (CLONE_NEWNS) < 0)
return glnx_throw_errno_prefix (error, "Failed to invoke unshare(CLONE_NEWNS)");
}
* @self: Sysroot
*
* Can only be invoked after `ostree_sysroot_initialize()`.
- *
+ *
* Returns: %TRUE iff the sysroot points to a booted deployment
* Since: 2020.1
*/
guint64 result = 0;
int count = 0;
guint8 b;
-
+
/* Adapted from CodedInputStream::ReadVarint64Slow */
do
-/*
+/*
* Copyright (C) 2017 Colin Walters <walters@verbum.org>
* Copyright (C) 2022 Igalia S.L.
*
/**
* ot_gfile_replace_contents_fsync:
- *
+ *
* Like g_file_replace_contents(), except always uses fdatasync().
*/
gboolean
* zero or one of the separators and none of the others, read the
* string as a NULL-terminated array out_value. If the value string
* contains multiple of the separators, give an error.
- *
+ *
* Returns TRUE on success, FALSE on error. */
gboolean
ot_keyfile_get_string_list_with_separator_choice (GKeyFile *keyfile,
* distribute, sublicense, and/or sell copies of this software, and to permit
* persons to whom this software is furnished to do so, subject to the following
* conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of this software.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THIS SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * OUT OF OR IN CONNECTION WITH THIS SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THIS SOFTWARE.
*/
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THIS SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * OUT OF OR IN CONNECTION WITH THIS SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THIS SOFTWARE.
*/
for (i = 0; i < entries->len; i++)
{
g_string_append_printf (listing, "<a href=\"%s\">%s</a><br>\r\n",
- (char *)entries->pdata[i],
+ (char *)entries->pdata[i],
(char *)entries->pdata[i]);
g_free (g_steal_pointer (&entries->pdata[i]));
}
}
}
}
- else
+ else
{
if (!S_ISREG (stbuf.st_mode))
{
g_autofree gchar *etag = calculate_etag (mapping);
if (etag != NULL)
soup_message_headers_append (msg->response_headers, "ETag", etag);
-
+
if (msg->method == SOUP_METHOD_GET)
{
gsize buffer_length, file_size;
GSList *listeners = soup_server_get_listeners (server);
g_autoptr(GSocket) listener = NULL;
g_autoptr(GSocketAddress) addr = NULL;
-
+
g_assert (listeners);
listener = g_object_ref (listeners->data);
g_slist_free (listeners);
goto out;
g_assert (G_IS_INET_SOCKET_ADDRESS (addr));
-
+
portstr = g_strdup_printf ("%u\n", g_inet_socket_address_get_port ((GInetSocketAddress*)addr));
#else
portstr = g_strdup_printf ("%u\n", soup_server_get_port (server));
remote_options = g_variant_ref_sink (g_variant_builder_end (optbuilder));
if (!ostree_repo_remote_change (repo, NULL,
- OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS,
+ OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS,
remotename, url,
remote_options,
cancellable, error))
goto out;
}
-
+
{ GKeyFile *old_origin = ostree_deployment_get_origin (target_deployment);
g_autofree char *origin_refspec = g_key_file_get_string (old_origin, "origin", "refspec", NULL);
g_autofree char *origin_remote = NULL;
g_autofree char *origin_ref = NULL;
-
+
if (!ostree_parse_refspec (origin_refspec, &origin_remote, &origin_ref, error))
goto out;
{ g_autofree char *new_refspec = g_strconcat (remotename, ":", branch ? branch : origin_ref, NULL);
g_autoptr(GKeyFile) new_origin = NULL;
-
+
new_origin = ostree_sysroot_origin_new_from_refspec (sysroot, new_refspec);
if (!ostree_sysroot_write_origin_file (sysroot, target_deployment, new_origin,
return glnx_throw (error, "Cannot verify deployment without remote");
g_autoptr(GBytes) commit_data = g_variant_get_data_as_bytes (commit);
- g_autoptr(GBytes) commit_detached_metadata_bytes =
+ g_autoptr(GBytes) commit_detached_metadata_bytes =
commit_detached_metadata ? g_variant_get_data_as_bytes (commit_detached_metadata) : NULL;
g_autofree char *verify_text = NULL;
if (!ostree_repo_signature_verify_commit_data (repo, remote, commit_data, commit_detached_metadata_bytes, 0, &verify_text, error))
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
invocation, &sysroot, cancellable, error))
return FALSE;
-
+
if (argc > 1)
{
ot_util_usage_error (context, "This command takes no extra arguments", error);
current_deployments->len);
return NULL;
}
-
+
return g_object_ref (current_deployments->pdata[index]);
}
goto out;
}
}
- else
+ else
{
const char *bootversion_env = g_getenv ("_OSTREE_GRUB2_BOOTVERSION");
if (bootversion_env)
cancellable, error);
if (!direnum)
goto out;
-
+
while (TRUE)
{
GFileInfo *file_info;
cancellable, error);
if (!root_info)
goto out;
-
+
g_ptr_array_add (path_parts, (char*)prefix);
if (!relabel_recursively (sepolicy, dir, root_info, path_parts,
cancellable, error))
sepolicy = ostree_sepolicy_new (deployment_path, cancellable, error);
if (!sepolicy)
goto out;
-
+
policy_name = ostree_sepolicy_get_name (sepolicy);
if (policy_name)
{
ostree_kernel_args_append_if_missing (kargs, arg);
}
}
-
+
g_autofree char *new_options = ostree_kernel_args_to_string (kargs);
-
- if (!ostree_sysroot_deployment_set_kargs_in_place (sysroot, deployment, new_options,
+
+ if (!ostree_sysroot_deployment_set_kargs_in_place (sysroot, deployment, new_options,
cancellable, error))
return FALSE;
-
+
}
return TRUE;
OstreeCommandInvocation sub_invocation = { .command = subcommand };
if (!subcommand->fn (argc, argv, &sub_invocation, cancellable, error))
goto out;
-
+
ret = TRUE;
out:
return ret;
if (opt_fs_diff)
{
- OstreeDiffFlags diff_flags = OSTREE_DIFF_FLAGS_NONE;
+ OstreeDiffFlags diff_flags = OSTREE_DIFF_FLAGS_NONE;
if (opt_no_xattrs)
diff_flags |= OSTREE_DIFF_FLAGS_IGNORE_XATTRS;
-
+
if (!parse_file_or_commit (repo, src, &srcf, cancellable, error))
return FALSE;
if (!parse_file_or_commit (repo, target, &targetf, cancellable, error))
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
goto out;
-#ifdef HAVE_LIBARCHIVE
+#ifdef HAVE_LIBARCHIVE
if (argc <= 1)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"This version of ostree is not compiled with libarchive support");
goto out;
-#endif
-
+#endif
+
ret = TRUE;
out:
return ret;
if (n_fsck_partial > 0)
return glnx_throw (error, "%u partial commits from fsck-detected corruption", n_partial);
- g_print ("object fsck of %d commits completed successfully - no errors found.\n",
+ g_print ("object fsck of %d commits completed successfully - no errors found.\n",
(guint)g_hash_table_size (commits));
return TRUE;
g_file_info_get_attribute_uint32 (file_info, "unix::uid"),
g_file_info_get_attribute_uint32 (file_info, "unix::gid"),
g_file_info_get_attribute_uint64 (file_info, "standard::size"));
-
+
if (opt_checksum)
{
if (type == G_FILE_TYPE_DIRECTORY)
if (!ostree_repo_file_get_xattrs ((OstreeRepoFile*)f, &xattrs, cancellable, error))
return FALSE;
-
+
formatted = g_variant_print (xattrs, TRUE);
g_string_append (buf, "{ ");
g_string_append (buf, formatted);
if (type == G_FILE_TYPE_SYMBOLIC_LINK)
g_string_append_printf (buf, " -> %s", g_file_info_get_attribute_byte_string (file_info, "standard::symlink-target"));
-
+
g_print ("%s\n", buf->str);
return TRUE;
else
g_assert (depth == -1);
- dir_enum = g_file_enumerate_children (f, OSTREE_GIO_FAST_QUERYINFO,
+ dir_enum = g_file_enumerate_children (f, OSTREE_GIO_FAST_QUERYINFO,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- NULL,
+ NULL,
error);
if (dir_enum == NULL)
return FALSE;
-
+
while ((child_info = g_file_enumerator_next_file (dir_enum, NULL, &temp_error)) != NULL)
{
g_clear_object (&child);
cancellable, error);
if (file_info == NULL)
return FALSE;
-
+
if (!print_one_file (f, file_info, cancellable, error))
return FALSE;
-
+
if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY)
{
if (opt_recursive)
return FALSE;
}
}
-
+
return TRUE;
}
if (!print_one_argument (repo, root, "/", cancellable, error))
return FALSE;
}
-
+
return TRUE;
}
}
g_autofree char *formatted_freed_size = g_format_size_full (objsize_total, 0);
- if (opt_commit_only)
+ if (opt_commit_only)
g_print("Total (commit only) objects: %u\n", n_objects_total);
else
g_print ("Total objects: %u\n", n_objects_total);
if (src_repo_arg[0] == '/')
src_repo_uri = g_strconcat ("file://", src_repo_arg, NULL);
else
- {
+ {
g_autofree char *cwd = g_get_current_dir ();
src_repo_uri = g_strconcat ("file://", cwd, "/", src_repo_arg, NULL);
}
{ GHashTableIter hashiter;
gpointer hkey, hvalue;
-
+
g_hash_table_iter_init (&hashiter, refs_to_clone);
while (g_hash_table_iter_next (&hashiter, &hkey, &hvalue))
g_ptr_array_add (refs_to_fetch, g_strdup (hkey));
for (i = 2; i < argc; i++)
{
const char *ref = argv[i];
-
+
g_ptr_array_add (refs_to_fetch, (char*)ref);
}
g_ptr_array_add (refs_to_fetch, NULL);
progress = ostree_async_progress_new_and_connect (noninteractive_console_progress_changed, &console);
opts = g_variant_ref_sink (g_variant_builder_end (&builder));
- if (!ostree_repo_pull_with_options (repo, src_repo_uri,
+ if (!ostree_repo_pull_with_options (repo, src_repo_uri,
opts,
progress,
cancellable, error))
g_variant_new_variant (g_variant_new_strv ((const char *const*) refs_to_fetch->pdata, -1)));
g_variant_builder_add (&builder, "{s@v}", "depth",
g_variant_new_variant (g_variant_new_int32 (opt_depth)));
-
+
g_variant_builder_add (&builder, "{s@v}", "update-frequency",
g_variant_new_variant (g_variant_new_uint32 (opt_frequency)));
-
+
if (opt_network_retries >= 0)
g_variant_builder_add (&builder, "{s@v}", "n-network-retries",
g_variant_new_variant (g_variant_new_uint32 (opt_network_retries)));
return FALSE;
g_print ("%s\n", resolved_rev);
}
-
+
return TRUE;
}
args = g_strconcat (editor, " ", quoted_file, NULL);
}
- proc = g_subprocess_new (G_SUBPROCESS_FLAGS_STDIN_INHERIT, error,
+ proc = g_subprocess_new (G_SUBPROCESS_FLAGS_STDIN_INHERIT, error,
"/bin/sh", "-c", args, NULL);
if (!g_subprocess_wait_check (proc, cancellable, error))
/* Also ignore EINVAL - if the target isn't a mountpoint
* already, then assume things are OK.
*/
- if (errno != EINVAL)
+ if (errno != EINVAL)
err (EXIT_FAILURE, "failed to remount(%s) %s", writable ? "rw" : "ro", target);
else
return;
{
g_autoptr(GVariant) current_xattrs = ostree_fs_get_all_xattrs (tmpd.fd, NULL, error);
g_assert_no_error (local_error);
-
+
int r = fsetxattr (tmpd.fd, "user.ostreetesting", value, sizeof (value), 0);
if (r != 0)
g_autoptr(GVariant) new_xattrs = ostree_fs_get_all_xattrs (tmpd.fd, NULL, error);
g_assert_no_error (local_error);
-
+
compare_xattrs (current_xattrs, new_xattrs);
}
// if (r < 0)
// glnx_throw_errno_prefix (error, "lsetxattr");
// g_assert_no_error (local_error);
-
+
// g_autoptr(GVariant) new_xattrs = ostree_fs_get_all_xattrs_at (tmpd.fd, "somelink", NULL, error);
// g_assert_no_error (local_error);
-
+
// compare_xattrs (current_xattrs, new_xattrs);
}
}
g_autoptr(GBytes) commit_bytes = g_variant_get_data_as_bytes (commit);
g_autoptr(GBytes) detached_meta_bytes = g_variant_get_data_as_bytes (detached_meta);
g_autofree char *verify_report = NULL;
- if (!ostree_repo_signature_verify_commit_data (repo, "origin", commit_bytes, detached_meta_bytes, 0,
+ if (!ostree_repo_signature_verify_commit_data (repo, "origin", commit_bytes, detached_meta_bytes, 0,
&verify_report, error))
return FALSE;
- if (ostree_repo_signature_verify_commit_data (repo, "origin", commit_bytes, detached_meta_bytes,
- OSTREE_REPO_VERIFY_FLAGS_NO_GPG | OSTREE_REPO_VERIFY_FLAGS_NO_SIGNAPI,
+ if (ostree_repo_signature_verify_commit_data (repo, "origin", commit_bytes, detached_meta_bytes,
+ OSTREE_REPO_VERIFY_FLAGS_NO_GPG | OSTREE_REPO_VERIFY_FLAGS_NO_SIGNAPI,
&verify_report, error))
return glnx_throw (error, "Should not have validated");
assert_error_contains (error, "No commit verification types enabled");
// No signatures
g_autoptr(GBytes) empty = g_bytes_new_static ("", 0);
- if (ostree_repo_signature_verify_commit_data (repo, "origin", commit_bytes, empty, 0,
+ if (ostree_repo_signature_verify_commit_data (repo, "origin", commit_bytes, empty, 0,
&verify_report, error))
return glnx_throw (error, "Should not have validated");
assert_error_contains (error, "no signatures found");
// No such remote
- if (ostree_repo_signature_verify_commit_data (repo, "nosuchremote", commit_bytes, detached_meta_bytes, 0,
+ if (ostree_repo_signature_verify_commit_data (repo, "nosuchremote", commit_bytes, detached_meta_bytes, 0,
&verify_report, error))
return glnx_throw (error, "Should not have validated");
assert_error_contains (error, "Remote \"nosuchremote\" not found");
// Corrupted commit
g_autoptr(GBytes) corrupted_commit = corrupt (commit_bytes);
- if (ostree_repo_signature_verify_commit_data (repo, "origin", corrupted_commit, detached_meta_bytes, 0,
+ if (ostree_repo_signature_verify_commit_data (repo, "origin", corrupted_commit, detached_meta_bytes, 0,
&verify_report, error))
return glnx_throw (error, "Should not have validated");
assert_error_contains (error, "BAD signature");
g_assert_no_error (error);
g_assert (td->fd >= 0);
-
+
g_assert_cmpint (0, ==, archive_write_set_format_pax (a));
g_assert_cmpint (0, ==, archive_write_add_filter_gzip (a));
g_assert_cmpint (0, ==, archive_write_open_fd (a, td->fd));
goto out;
if (!ostree_repo_pull (td->repo, "origin", (char**)&refs, 0, NULL, NULL, error))
goto out;
-
+
out:
g_assert_no_error (local_error);
}
{
GError *local_error = NULL;
GError **error = &local_error;
-
+
TestData *td = (void*)data;
char *ok_refs[] = { "main", NULL };
char *bad_refs[] = { "nosuchbranch", NULL };
if (!ostree_repo_pull (td->repo, "origin", (char**)&ok_refs, 0, NULL, NULL, error))
goto out;
}
-
+
out:
g_assert_no_error (local_error);
}
g_clear_pointer (&checksum, g_free);
// Invalid checksum
- checksum = ostree_repo_write_regfile_inline (repo, "3272139f889f6a7007b3d64adc74be9e2979bf6bbe663d1512e5bd43f4de24a1",
+ checksum = ostree_repo_write_regfile_inline (repo, "3272139f889f6a7007b3d64adc74be9e2979bf6bbe663d1512e5bd43f4de24a1",
0, 0, S_IFREG | 0644, NULL, (const guint8*)contents, sizeof (contents)-1, NULL, &error);
g_assert (checksum == NULL);
g_assert (error != NULL);
g_clear_error (&error);
-
- // Now with xattrs
+
+ // Now with xattrs
g_clear_pointer (&checksum, g_free);
checksum = ostree_repo_write_regfile_inline (repo, NULL, 0, 0, S_IFREG | 0644, xattrs, (const guint8*)contents, sizeof (contents)-1, NULL, &error);
g_assert_no_error (error);
g_test_init (&argc, &argv, NULL);
- sysroot = ot_test_setup_sysroot (NULL, &error);
+ sysroot = ot_test_setup_sysroot (NULL, &error);
if (!sysroot)
goto out;
-
+
g_test_add_data_func ("/sysroot-reload", sysroot, test_sysroot_reload);
return g_test_run();