New upstream version 2019.3
This commit is contained in:
commit
1b51e1d9d0
129 files changed
+3815
-1046
No files matched your search
@@ -18,8 +18,6 @@
|
||||
***/
|
||||
|
||||
/* Add new symbols here. Release commits should copy this section into -released.sym. */
|
||||
LIBOSTREE_2019.3 {
|
||||
} LIBOSTREE_2018.9;
|
||||
|
||||
/* Stub section for the stable release *after* this development one; don't
|
||||
* edit this other than to update the year. This is just a copy/paste
|
||||
|
||||
@@ -548,6 +548,28 @@ LIBOSTREE_2019.2 {
|
||||
ostree_repo_get_bootloader;
|
||||
} LIBOSTREE_2018.9;
|
||||
|
||||
LIBOSTREE_2019.3 {
|
||||
global:
|
||||
ostree_repo_write_archive_to_mtree_from_fd;
|
||||
ostree_kernel_args_free;
|
||||
ostree_kernel_args_new;
|
||||
ostree_kernel_args_cleanup;
|
||||
ostree_kernel_args_replace_take;
|
||||
ostree_kernel_args_replace;
|
||||
ostree_kernel_args_replace_argv;
|
||||
ostree_kernel_args_append;
|
||||
ostree_kernel_args_append_argv;
|
||||
ostree_kernel_args_append_argv_filtered;
|
||||
ostree_kernel_args_new_replace;
|
||||
ostree_kernel_args_delete;
|
||||
ostree_kernel_args_delete_key_entry;
|
||||
ostree_kernel_args_append_proc_cmdline;
|
||||
ostree_kernel_args_parse_append;
|
||||
ostree_kernel_args_get_last_value;
|
||||
ostree_kernel_args_from_string;
|
||||
ostree_kernel_args_to_strv;
|
||||
ostree_kernel_args_to_string;
|
||||
} LIBOSTREE_2018.9;
|
||||
|
||||
/* NOTE: Only add more content here in release commits! See the
|
||||
* comments at the top of this file.
|
||||
|
||||
@@ -51,6 +51,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeAsyncProgress, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeBootconfigParser, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeDeployment, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeGpgVerifyResult, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeKernelArgs, ostree_kernel_args_free)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeMutableTree, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRepo, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRepoFile, g_object_unref)
|
||||
|
||||
@@ -78,8 +78,8 @@ append_system_uenv (OstreeBootloaderUboot *self,
|
||||
const char *uenv_path = NULL;
|
||||
const char *ostree_arg = NULL;
|
||||
|
||||
kargs = _ostree_kernel_args_from_string (bootargs);
|
||||
ostree_arg = _ostree_kernel_args_get_last_value (kargs, "ostree");
|
||||
kargs = ostree_kernel_args_from_string (bootargs);
|
||||
ostree_arg = ostree_kernel_args_get_last_value (kargs, "ostree");
|
||||
if (!ostree_arg)
|
||||
{
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
|
||||
@@ -190,9 +190,11 @@ _ostree_repo_mode_is_bare (OstreeRepoMode mode)
|
||||
mode == OSTREE_REPO_MODE_BARE_USER_ONLY;
|
||||
}
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
GVariant *
|
||||
_ostree_detached_metadata_append_gpg_sig (GVariant *existing_metadata,
|
||||
GBytes *signature_bytes);
|
||||
#endif
|
||||
|
||||
GFile *
|
||||
_ostree_get_default_sysroot_path (void);
|
||||
|
||||
+23
-11
@@ -485,6 +485,8 @@ _ostree_raw_file_to_archive_stream (GInputStream *input,
|
||||
*
|
||||
* Convert from a "bare" file representation into an
|
||||
* OSTREE_OBJECT_TYPE_FILE stream suitable for ostree pull.
|
||||
*
|
||||
* Since: 2016.6
|
||||
*/
|
||||
gboolean
|
||||
ostree_raw_file_to_archive_z2_stream (GInputStream *input,
|
||||
@@ -581,7 +583,7 @@ ostree_raw_file_to_content_stream (GInputStream *input,
|
||||
* @input_length: Length of stream
|
||||
* @trusted: If %TRUE, assume the content has been validated
|
||||
* @out_input: (out): The raw file content stream
|
||||
* @out_file_info: (out): Normal metadata
|
||||
* @out_file_info: (out): Normal metadata
|
||||
* @out_xattrs: (out): Extended attributes
|
||||
* @cancellable: Cancellable
|
||||
* @error: Error
|
||||
@@ -680,7 +682,7 @@ ostree_content_stream_parse (gboolean compressed,
|
||||
* @path: Subpath
|
||||
* @trusted: If %TRUE, assume the content has been validated
|
||||
* @out_input: (out): The raw file content stream
|
||||
* @out_file_info: (out): Normal metadata
|
||||
* @out_file_info: (out): Normal metadata
|
||||
* @out_xattrs: (out): Extended attributes
|
||||
* @cancellable: Cancellable
|
||||
* @error: Error
|
||||
@@ -730,7 +732,7 @@ ostree_content_file_parse_at (gboolean compressed,
|
||||
* @content_path: Path to file containing content
|
||||
* @trusted: If %TRUE, assume the content has been validated
|
||||
* @out_input: (out): The raw file content stream
|
||||
* @out_file_info: (out): Normal metadata
|
||||
* @out_file_info: (out): Normal metadata
|
||||
* @out_xattrs: (out): Extended attributes
|
||||
* @cancellable: Cancellable
|
||||
* @error: Error
|
||||
@@ -1068,7 +1070,7 @@ checksum_file_async_data_free (gpointer datap)
|
||||
g_free (data->csum);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ostree_checksum_file_async:
|
||||
* @f: File path
|
||||
@@ -1098,7 +1100,7 @@ ostree_checksum_file_async (GFile *f,
|
||||
|
||||
res = g_simple_async_result_new (G_OBJECT (f), callback, user_data, ostree_checksum_file_async);
|
||||
g_simple_async_result_set_op_res_gpointer (res, data, (GDestroyNotify)checksum_file_async_data_free);
|
||||
|
||||
|
||||
g_simple_async_result_run_in_thread (res, checksum_file_async_thread, io_priority, cancellable);
|
||||
g_object_unref (res);
|
||||
}
|
||||
@@ -1323,7 +1325,7 @@ ostree_hash_object_name (gconstpointer a)
|
||||
const char *checksum;
|
||||
OstreeObjectType objtype;
|
||||
gint objtype_int;
|
||||
|
||||
|
||||
ostree_object_name_deserialize (variant, &checksum, &objtype);
|
||||
objtype_int = (gint) objtype;
|
||||
return g_str_hash (checksum) + g_int_hash (&objtype_int);
|
||||
@@ -1472,6 +1474,8 @@ ostree_checksum_to_bytes_v (const char *checksum)
|
||||
* @checksum: An ASCII checksum
|
||||
*
|
||||
* Returns: (transfer full) (array fixed-size=32): Binary version of @checksum.
|
||||
*
|
||||
* Since: 2016.8
|
||||
*/
|
||||
guchar *
|
||||
ostree_checksum_b64_to_bytes (const char *checksum)
|
||||
@@ -1571,6 +1575,8 @@ ostree_checksum_from_bytes_v (GVariant *csum_v)
|
||||
*
|
||||
* The "modified" term refers to the fact that instead of '/', the '_'
|
||||
* character is used.
|
||||
*
|
||||
* Since: 2016.8
|
||||
*/
|
||||
char *
|
||||
ostree_checksum_b64_from_bytes (const guchar *csum)
|
||||
@@ -1849,7 +1855,7 @@ _ostree_get_relative_static_delta_path (const char *from,
|
||||
g_string_append_c (ret, '/');
|
||||
g_string_append (ret, target);
|
||||
}
|
||||
|
||||
|
||||
return g_string_free (ret, FALSE);
|
||||
}
|
||||
|
||||
@@ -2174,7 +2180,7 @@ _ostree_verify_metadata_object (OstreeObjectType objtype,
|
||||
* ostree_validate_structureof_commit:
|
||||
* @commit: A commit object, %OSTREE_OBJECT_TYPE_COMMIT
|
||||
* @error: Error
|
||||
*
|
||||
*
|
||||
* Use this to validate the basic structure of @commit, independent of
|
||||
* any other objects it references.
|
||||
*
|
||||
@@ -2214,7 +2220,7 @@ ostree_validate_structureof_commit (GVariant *commit,
|
||||
* ostree_validate_structureof_dirtree:
|
||||
* @dirtree: A dirtree object, %OSTREE_OBJECT_TYPE_DIR_TREE
|
||||
* @error: Error
|
||||
*
|
||||
*
|
||||
* Use this to validate the basic structure of @dirtree, independent of
|
||||
* any other objects it references.
|
||||
*
|
||||
@@ -2326,7 +2332,7 @@ ostree_validate_structureof_file_mode (guint32 mode,
|
||||
* ostree_validate_structureof_dirmeta:
|
||||
* @dirmeta: A dirmeta object, %OSTREE_OBJECT_TYPE_DIR_META
|
||||
* @error: Error
|
||||
*
|
||||
*
|
||||
* Use this to validate the basic structure of @dirmeta.
|
||||
*
|
||||
* Returns: %TRUE if @dirmeta is structurally valid
|
||||
@@ -2340,7 +2346,7 @@ ostree_validate_structureof_dirmeta (GVariant *dirmeta,
|
||||
if (!validate_variant (dirmeta, OSTREE_DIRMETA_GVARIANT_FORMAT, error))
|
||||
return FALSE;
|
||||
|
||||
g_variant_get_child (dirmeta, 2, "u", &mode);
|
||||
g_variant_get_child (dirmeta, 2, "u", &mode);
|
||||
mode = GUINT32_FROM_BE (mode);
|
||||
|
||||
if (!S_ISDIR (mode))
|
||||
@@ -2395,6 +2401,8 @@ ostree_commit_get_timestamp (GVariant *commit_variant)
|
||||
* root "dirmeta" checksum (both in binary form, not hexadecimal).
|
||||
*
|
||||
* Returns: (nullable): A SHA-256 hex string, or %NULL if @commit_variant is not well-formed
|
||||
*
|
||||
* Since: 2018.2
|
||||
*/
|
||||
gchar *
|
||||
ostree_commit_get_content_checksum (GVariant *commit_variant)
|
||||
@@ -2454,6 +2462,7 @@ _ostree_compare_timestamps (const char *current_rev,
|
||||
}
|
||||
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
GVariant *
|
||||
_ostree_detached_metadata_append_gpg_sig (GVariant *existing_metadata,
|
||||
GBytes *signature_bytes)
|
||||
@@ -2479,6 +2488,7 @@ _ostree_detached_metadata_append_gpg_sig (GVariant *existing_metadata,
|
||||
|
||||
return g_variant_dict_end (&metadata_dict);
|
||||
}
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
/**
|
||||
* _ostree_get_default_sysroot_path:
|
||||
@@ -2513,6 +2523,8 @@ _ostree_get_default_sysroot_path (void)
|
||||
* @required_release: Release version required
|
||||
*
|
||||
* Returns: %TRUE if current libostree has at least the requested version, %FALSE otherwise
|
||||
*
|
||||
* Since: 2017.4
|
||||
*/
|
||||
gboolean
|
||||
ostree_check_version (guint required_year, guint required_release)
|
||||
|
||||
@@ -302,6 +302,11 @@ ostree_deployment_get_origin_relpath (OstreeDeployment *self)
|
||||
ostree_deployment_get_deployserial (self));
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_deployment_unlocked_state_to_string:
|
||||
*
|
||||
* Since: 2016.4
|
||||
*/
|
||||
const char *
|
||||
ostree_deployment_unlocked_state_to_string (OstreeDeploymentUnlockedState state)
|
||||
{
|
||||
@@ -317,6 +322,11 @@ ostree_deployment_unlocked_state_to_string (OstreeDeploymentUnlockedState state)
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_deployment_get_unlocked:
|
||||
*
|
||||
* Since: 2016.4
|
||||
*/
|
||||
OstreeDeploymentUnlockedState
|
||||
ostree_deployment_get_unlocked (OstreeDeployment *self)
|
||||
{
|
||||
|
||||
@@ -239,6 +239,8 @@ ostree_diff_dirs (OstreeDiffFlags flags,
|
||||
*
|
||||
* Compute the difference between directory @a and @b as 3 separate
|
||||
* sets of #OstreeDiffItem in @modified, @removed, and @added.
|
||||
*
|
||||
* Since: 2017.4
|
||||
*/
|
||||
gboolean
|
||||
ostree_diff_dirs_with_options (OstreeDiffFlags flags,
|
||||
@@ -305,7 +307,7 @@ ostree_diff_dirs_with_options (OstreeDiffFlags flags,
|
||||
{
|
||||
OstreeRepoFile *a_repof = (OstreeRepoFile*) a;
|
||||
OstreeRepoFile *b_repof = (OstreeRepoFile*) b;
|
||||
|
||||
|
||||
if (strcmp (ostree_repo_file_tree_get_contents_checksum (a_repof),
|
||||
ostree_repo_file_tree_get_contents_checksum (b_repof)) == 0)
|
||||
{
|
||||
@@ -317,7 +319,7 @@ ostree_diff_dirs_with_options (OstreeDiffFlags flags,
|
||||
g_clear_object (&child_a_info);
|
||||
g_clear_object (&child_b_info);
|
||||
|
||||
dir_enum = g_file_enumerate_children (a, OSTREE_GIO_FAST_QUERYINFO,
|
||||
dir_enum = g_file_enumerate_children (a, OSTREE_GIO_FAST_QUERYINFO,
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
cancellable, error);
|
||||
if (!dir_enum)
|
||||
@@ -368,7 +370,7 @@ ostree_diff_dirs_with_options (OstreeDiffFlags flags,
|
||||
{
|
||||
OstreeDiffItem *diff_item = diff_item_new (child_a, child_a_info,
|
||||
child_b, child_b_info, NULL, NULL);
|
||||
|
||||
|
||||
g_ptr_array_add (modified, diff_item);
|
||||
}
|
||||
else
|
||||
@@ -378,7 +380,7 @@ ostree_diff_dirs_with_options (OstreeDiffFlags flags,
|
||||
if (!diff_files (flags, child_a, child_a_info, child_b, child_b_info, &diff_item,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
|
||||
if (diff_item)
|
||||
g_ptr_array_add (modified, diff_item); /* Transfer ownership */
|
||||
|
||||
@@ -391,7 +393,7 @@ ostree_diff_dirs_with_options (OstreeDiffFlags flags,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
g_clear_object (&child_a_info);
|
||||
}
|
||||
if (temp_error != NULL)
|
||||
@@ -401,7 +403,7 @@ ostree_diff_dirs_with_options (OstreeDiffFlags flags,
|
||||
}
|
||||
|
||||
g_clear_object (&dir_enum);
|
||||
dir_enum = g_file_enumerate_children (b, OSTREE_GIO_FAST_QUERYINFO,
|
||||
dir_enum = g_file_enumerate_children (b, OSTREE_GIO_FAST_QUERYINFO,
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
cancellable, error);
|
||||
if (!dir_enum)
|
||||
|
||||
@@ -219,9 +219,9 @@ _ostree_fetcher_should_retry_request (const GError *error,
|
||||
}
|
||||
|
||||
/* Convert a HTTP status code representing an error from libsoup or libcurl to
|
||||
* a #GIOError. This will return %G_IO_ERROR_FAILED if the status code is
|
||||
* a #GIOErrorEnum. This will return %G_IO_ERROR_FAILED if the status code is
|
||||
* unknown or otherwise unhandled. */
|
||||
GIOError
|
||||
GIOErrorEnum
|
||||
_ostree_fetcher_http_status_code_to_io_error (guint status_code)
|
||||
{
|
||||
switch (status_code)
|
||||
|
||||
@@ -78,7 +78,7 @@ void _ostree_fetcher_journal_failure (const char *remote_name,
|
||||
gboolean _ostree_fetcher_should_retry_request (const GError *error,
|
||||
guint n_retries_remaining);
|
||||
|
||||
GIOError _ostree_fetcher_http_status_code_to_io_error (guint status_code);
|
||||
GIOErrorEnum _ostree_fetcher_http_status_code_to_io_error (guint status_code);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ verify_result_finalized_cb (gpointer data,
|
||||
* finalize() method, but I didn't want this keyring hack
|
||||
* bleeding into multiple classes. */
|
||||
|
||||
ot_gpgme_kill_agent (tmp_dir);
|
||||
(void) glnx_shutil_rm_rf_at (AT_FDCWD, tmp_dir, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,303 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Red Hat, Inc.
|
||||
* Copyright (C) 2019 Collabora Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0+
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "libglnx.h"
|
||||
|
||||
#include "ostree-gpg-verify-result.h"
|
||||
|
||||
/**
|
||||
* SECTION: ostree-gpg-verify-result
|
||||
* @title: GPG signature verification results
|
||||
* @short_description: Dummy functions for detached GPG signatures
|
||||
*
|
||||
* This file contain dummy functions for GPG signatures checks to
|
||||
* provide API backward compatibility.
|
||||
*/
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
#error This file should not be compiled if GPG support is enabled
|
||||
#endif
|
||||
|
||||
/**
|
||||
* OstreeGpgVerifyResult:
|
||||
*
|
||||
* Private instance structure.
|
||||
*/
|
||||
struct OstreeGpgVerifyResult {
|
||||
GObject parent;
|
||||
};
|
||||
|
||||
|
||||
typedef struct {
|
||||
GObjectClass parent_class;
|
||||
} OstreeGpgVerifyResultClass;
|
||||
|
||||
static void ostree_gpg_verify_result_initable_iface_init (GInitableIface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (OstreeGpgVerifyResult,
|
||||
ostree_gpg_verify_result,
|
||||
G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
|
||||
ostree_gpg_verify_result_initable_iface_init))
|
||||
|
||||
static void
|
||||
ostree_gpg_verify_result_class_init (OstreeGpgVerifyResultClass *class)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
ostree_gpg_verify_result_initable_iface_init (GInitableIface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
ostree_gpg_verify_result_init (OstreeGpgVerifyResult *result)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_gpg_verify_result_count_all:
|
||||
* @result: an #OstreeGpgVerifyResult
|
||||
*
|
||||
* Counts all the signatures in @result.
|
||||
*
|
||||
* Returns: signature count
|
||||
*/
|
||||
guint
|
||||
ostree_gpg_verify_result_count_all (OstreeGpgVerifyResult *result)
|
||||
{
|
||||
g_critical ("%s: GPG feature is disabled in a build time", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_gpg_verify_result_count_valid:
|
||||
* @result: an #OstreeGpgVerifyResult
|
||||
*
|
||||
* Counts only the valid signatures in @result.
|
||||
*
|
||||
* Returns: valid signature count
|
||||
*/
|
||||
guint
|
||||
ostree_gpg_verify_result_count_valid (OstreeGpgVerifyResult *result)
|
||||
{
|
||||
g_critical ("%s: GPG feature is disabled in a build time", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_gpg_verify_result_lookup:
|
||||
* @result: an #OstreeGpgVerifyResult
|
||||
* @key_id: a GPG key ID or fingerprint
|
||||
* @out_signature_index: (out): return location for the index of the signature
|
||||
* signed by @key_id, or %NULL
|
||||
*
|
||||
* Searches @result for a signature signed by @key_id. If a match is found,
|
||||
* the function returns %TRUE and sets @out_signature_index so that further
|
||||
* signature details can be obtained through ostree_gpg_verify_result_get().
|
||||
* If no match is found, the function returns %FALSE and leaves
|
||||
* @out_signature_index unchanged.
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE on failure
|
||||
**/
|
||||
gboolean
|
||||
ostree_gpg_verify_result_lookup (OstreeGpgVerifyResult *result,
|
||||
const gchar *key_id,
|
||||
guint *out_signature_index)
|
||||
{
|
||||
g_critical ("%s: GPG feature is disabled in a build time", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_gpg_verify_result_get:
|
||||
* @result: an #OstreeGpgVerifyResult
|
||||
* @signature_index: which signature to get attributes from
|
||||
* @attrs: (array length=n_attrs): Array of requested attributes
|
||||
* @n_attrs: Length of the @attrs array
|
||||
*
|
||||
* Builds a #GVariant tuple of requested attributes for the GPG signature at
|
||||
* @signature_index in @result. See the #OstreeGpgSignatureAttr description
|
||||
* for the #GVariantType of each available attribute.
|
||||
*
|
||||
* It is a programmer error to request an invalid #OstreeGpgSignatureAttr or
|
||||
* an invalid @signature_index. Use ostree_gpg_verify_result_count_all() to
|
||||
* find the number of signatures in @result.
|
||||
*
|
||||
* Returns: a new, floating, #GVariant tuple
|
||||
**/
|
||||
GVariant *
|
||||
ostree_gpg_verify_result_get (OstreeGpgVerifyResult *result,
|
||||
guint signature_index,
|
||||
OstreeGpgSignatureAttr *attrs,
|
||||
guint n_attrs)
|
||||
{
|
||||
g_critical ("%s: GPG feature is disabled in a build time", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_gpg_verify_result_get_all:
|
||||
* @result: an #OstreeGpgVerifyResult
|
||||
* @signature_index: which signature to get attributes from
|
||||
*
|
||||
* Builds a #GVariant tuple of all available attributes for the GPG signature
|
||||
* at @signature_index in @result.
|
||||
*
|
||||
* The child values in the returned #GVariant tuple are ordered to match the
|
||||
* #OstreeGpgSignatureAttr enumeration, which means the enum values can be
|
||||
* used as index values in functions like g_variant_get_child(). See the
|
||||
* #OstreeGpgSignatureAttr description for the #GVariantType of each
|
||||
* available attribute.
|
||||
*
|
||||
* <note>
|
||||
* <para>
|
||||
* The #OstreeGpgSignatureAttr enumeration may be extended in the future
|
||||
* with new attributes, which would affect the #GVariant tuple returned by
|
||||
* this function. While the position and type of current child values in
|
||||
* the #GVariant tuple will not change, to avoid backward-compatibility
|
||||
* issues <emphasis>please do not depend on the tuple's overall size or
|
||||
* type signature</emphasis>.
|
||||
* </para>
|
||||
* </note>
|
||||
*
|
||||
* It is a programmer error to request an invalid @signature_index. Use
|
||||
* ostree_gpg_verify_result_count_all() to find the number of signatures in
|
||||
* @result.
|
||||
*
|
||||
* Returns: a new, floating, #GVariant tuple
|
||||
**/
|
||||
GVariant *
|
||||
ostree_gpg_verify_result_get_all (OstreeGpgVerifyResult *result,
|
||||
guint signature_index)
|
||||
{
|
||||
g_return_val_if_fail (OSTREE_IS_GPG_VERIFY_RESULT (result), NULL);
|
||||
|
||||
g_critical ("%s: GPG feature is disabled in a build time", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_gpg_verify_result_describe:
|
||||
* @result: an #OstreeGpgVerifyResult
|
||||
* @signature_index: which signature to describe
|
||||
* @output_buffer: a #GString to hold the description
|
||||
* @line_prefix: (allow-none): optional line prefix string
|
||||
* @flags: flags to adjust the description format
|
||||
*
|
||||
* Appends a brief, human-readable description of the GPG signature at
|
||||
* @signature_index in @result to the @output_buffer. The description
|
||||
* spans multiple lines. A @line_prefix string, if given, will precede
|
||||
* each line of the description.
|
||||
*
|
||||
* The @flags argument is reserved for future variations to the description
|
||||
* format. Currently must be 0.
|
||||
*
|
||||
* It is a programmer error to request an invalid @signature_index. Use
|
||||
* ostree_gpg_verify_result_count_all() to find the number of signatures in
|
||||
* @result.
|
||||
*/
|
||||
void
|
||||
ostree_gpg_verify_result_describe (OstreeGpgVerifyResult *result,
|
||||
guint signature_index,
|
||||
GString *output_buffer,
|
||||
const gchar *line_prefix,
|
||||
OstreeGpgSignatureFormatFlags flags)
|
||||
{
|
||||
g_autoptr(GVariant) variant = NULL;
|
||||
|
||||
g_return_if_fail (OSTREE_IS_GPG_VERIFY_RESULT (result));
|
||||
|
||||
g_critical ("%s: GPG feature is disabled in a build time", __FUNCTION__);
|
||||
|
||||
variant = ostree_gpg_verify_result_get_all (result, signature_index);
|
||||
|
||||
ostree_gpg_verify_result_describe_variant (variant, output_buffer, line_prefix, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_gpg_verify_result_describe_variant:
|
||||
* @variant: a #GVariant from ostree_gpg_verify_result_get_all()
|
||||
* @output_buffer: a #GString to hold the description
|
||||
* @line_prefix: (allow-none): optional line prefix string
|
||||
* @flags: flags to adjust the description format
|
||||
*
|
||||
* Similar to ostree_gpg_verify_result_describe() but takes a #GVariant of
|
||||
* all attributes for a GPG signature instead of an #OstreeGpgVerifyResult
|
||||
* and signature index.
|
||||
*
|
||||
* The @variant <emphasis>MUST</emphasis> have been created by
|
||||
* ostree_gpg_verify_result_get_all().
|
||||
*/
|
||||
void
|
||||
ostree_gpg_verify_result_describe_variant (GVariant *variant,
|
||||
GString *output_buffer,
|
||||
const gchar *line_prefix,
|
||||
OstreeGpgSignatureFormatFlags flags)
|
||||
{
|
||||
const char *type_string;
|
||||
|
||||
g_return_if_fail (variant != NULL);
|
||||
g_return_if_fail (output_buffer != NULL);
|
||||
|
||||
/* Verify the variant's type string. This code is
|
||||
* not prepared to handle just any random GVariant. */
|
||||
type_string = g_variant_get_type_string (variant);
|
||||
g_return_if_fail (strcmp (type_string, "(bbbbbsxxsssssxx)") == 0);
|
||||
|
||||
g_string_append (output_buffer,
|
||||
"GPG feature is disabled in a build time\n");
|
||||
|
||||
g_critical ("%s: GPG feature is disabled in a build time", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_gpg_verify_result_require_valid_signature:
|
||||
* @result: (nullable): an #OstreeGpgVerifyResult
|
||||
* @error: A #GError
|
||||
*
|
||||
* Checks if the result contains at least one signature from the
|
||||
* trusted keyring. You can call this function immediately after
|
||||
* ostree_repo_verify_summary() or ostree_repo_verify_commit_ext() -
|
||||
* it will handle the %NULL @result and filled @error too.
|
||||
*
|
||||
* Returns: %TRUE if @result was not %NULL and had at least one
|
||||
* signature from trusted keyring, otherwise %FALSE
|
||||
*
|
||||
* Since: 2016.6
|
||||
*/
|
||||
gboolean
|
||||
ostree_gpg_verify_result_require_valid_signature (OstreeGpgVerifyResult *result,
|
||||
GError **error)
|
||||
{
|
||||
if (result == NULL)
|
||||
return FALSE;
|
||||
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"'%s': GPG feature is disabled in a build time",
|
||||
__FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
G_DEFINE_QUARK (OstreeGpgError, ostree_gpg_error)
|
||||
@@ -65,7 +65,9 @@ static OstreeGpgSignatureAttr all_signature_attrs[] = {
|
||||
OSTREE_GPG_SIGNATURE_ATTR_HASH_ALGO_NAME,
|
||||
OSTREE_GPG_SIGNATURE_ATTR_USER_NAME,
|
||||
OSTREE_GPG_SIGNATURE_ATTR_USER_EMAIL,
|
||||
OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT_PRIMARY
|
||||
OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT_PRIMARY,
|
||||
OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP,
|
||||
OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP_PRIMARY,
|
||||
};
|
||||
|
||||
static void ostree_gpg_verify_result_initable_iface_init (GInitableIface *iface);
|
||||
@@ -331,7 +333,9 @@ ostree_gpg_verify_result_get (OstreeGpgVerifyResult *result,
|
||||
{
|
||||
if (attrs[ii] == OSTREE_GPG_SIGNATURE_ATTR_USER_NAME ||
|
||||
attrs[ii] == OSTREE_GPG_SIGNATURE_ATTR_USER_EMAIL ||
|
||||
attrs[ii] == OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT_PRIMARY)
|
||||
attrs[ii] == OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT_PRIMARY ||
|
||||
attrs[ii] == OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP ||
|
||||
attrs[ii] == OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP_PRIMARY)
|
||||
{
|
||||
(void) gpgme_get_key (result->context, signature->fpr, &key, 0);
|
||||
break;
|
||||
@@ -345,6 +349,7 @@ ostree_gpg_verify_result_get (OstreeGpgVerifyResult *result,
|
||||
GVariant *child;
|
||||
gboolean v_boolean;
|
||||
const char *v_string = NULL;
|
||||
gint64 v_int64;
|
||||
|
||||
switch (attrs[ii])
|
||||
{
|
||||
@@ -423,6 +428,29 @@ ostree_gpg_verify_result_get (OstreeGpgVerifyResult *result,
|
||||
child = g_variant_new_string (v_string);
|
||||
break;
|
||||
|
||||
case OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP:
|
||||
v_int64 = 0;
|
||||
if (key != NULL)
|
||||
{
|
||||
gpgme_subkey_t subkey = key->subkeys;
|
||||
|
||||
while (subkey != NULL && (g_strcmp0 (subkey->fpr, signature->fpr) != 0))
|
||||
subkey = subkey->next;
|
||||
|
||||
if (subkey != NULL)
|
||||
v_int64 = subkey->expires;
|
||||
}
|
||||
child = g_variant_new_int64 (v_int64);
|
||||
break;
|
||||
|
||||
case OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP_PRIMARY:
|
||||
if (key != NULL && key->subkeys != NULL)
|
||||
v_int64 = key->subkeys->expires;
|
||||
else
|
||||
v_int64 = 0;
|
||||
child = g_variant_new_int64 (v_int64);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_critical ("Invalid signature attribute (%d)", attrs[ii]);
|
||||
g_variant_builder_clear (&builder);
|
||||
@@ -513,6 +541,49 @@ ostree_gpg_verify_result_describe (OstreeGpgVerifyResult *result,
|
||||
ostree_gpg_verify_result_describe_variant (variant, output_buffer, line_prefix, flags);
|
||||
}
|
||||
|
||||
static void
|
||||
append_expire_info (GString *output_buffer,
|
||||
const gchar *line_prefix,
|
||||
const gchar *exp_type,
|
||||
gint64 exp_timestamp,
|
||||
gboolean expired)
|
||||
{
|
||||
g_autoptr(GDateTime) date_time_utc = NULL;
|
||||
g_autoptr(GDateTime) date_time_local = NULL;
|
||||
g_autofree char *formatted_date_time = NULL;
|
||||
|
||||
if (line_prefix != NULL)
|
||||
g_string_append (output_buffer, line_prefix);
|
||||
|
||||
date_time_utc = g_date_time_new_from_unix_utc (exp_timestamp);
|
||||
if (date_time_utc == NULL)
|
||||
{
|
||||
g_string_append_printf (output_buffer,
|
||||
"%s expiry timestamp (%" G_GINT64_FORMAT ") is invalid\n",
|
||||
exp_type,
|
||||
exp_timestamp);
|
||||
return;
|
||||
}
|
||||
|
||||
date_time_local = g_date_time_to_local (date_time_utc);
|
||||
formatted_date_time = g_date_time_format (date_time_local, "%c");
|
||||
|
||||
if (expired)
|
||||
{
|
||||
g_string_append_printf (output_buffer,
|
||||
"%s expired %s\n",
|
||||
exp_type,
|
||||
formatted_date_time);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_string_append_printf (output_buffer,
|
||||
"%s expires %s\n",
|
||||
exp_type,
|
||||
formatted_date_time);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_gpg_verify_result_describe_variant:
|
||||
* @variant: a #GVariant from ostree_gpg_verify_result_get_all()
|
||||
@@ -538,6 +609,8 @@ ostree_gpg_verify_result_describe_variant (GVariant *variant,
|
||||
g_autofree char *formatted_date_time = NULL;
|
||||
gint64 timestamp;
|
||||
gint64 exp_timestamp;
|
||||
gint64 key_exp_timestamp;
|
||||
gint64 key_exp_timestamp_primary;
|
||||
const char *type_string;
|
||||
const char *fingerprint;
|
||||
const char *fingerprint_primary;
|
||||
@@ -547,6 +620,8 @@ ostree_gpg_verify_result_describe_variant (GVariant *variant,
|
||||
const char *key_id;
|
||||
gboolean valid;
|
||||
gboolean sig_expired;
|
||||
gboolean key_expired;
|
||||
gboolean key_revoked;
|
||||
gboolean key_missing;
|
||||
gsize len;
|
||||
|
||||
@@ -556,7 +631,7 @@ ostree_gpg_verify_result_describe_variant (GVariant *variant,
|
||||
/* Verify the variant's type string. This code is
|
||||
* not prepared to handle just any random GVariant. */
|
||||
type_string = g_variant_get_type_string (variant);
|
||||
g_return_if_fail (strcmp (type_string, "(bbbbbsxxsssss)") == 0);
|
||||
g_return_if_fail (strcmp (type_string, "(bbbbbsxxsssssxx)") == 0);
|
||||
|
||||
/* The default format roughly mimics the verify output generated by
|
||||
* check_sig_and_print() in gnupg/g10/mainproc.c, though obviously
|
||||
@@ -566,6 +641,10 @@ ostree_gpg_verify_result_describe_variant (GVariant *variant,
|
||||
"b", &valid);
|
||||
g_variant_get_child (variant, OSTREE_GPG_SIGNATURE_ATTR_SIG_EXPIRED,
|
||||
"b", &sig_expired);
|
||||
g_variant_get_child (variant, OSTREE_GPG_SIGNATURE_ATTR_KEY_EXPIRED,
|
||||
"b", &key_expired);
|
||||
g_variant_get_child (variant, OSTREE_GPG_SIGNATURE_ATTR_KEY_REVOKED,
|
||||
"b", &key_revoked);
|
||||
g_variant_get_child (variant, OSTREE_GPG_SIGNATURE_ATTR_KEY_MISSING,
|
||||
"b", &key_missing);
|
||||
g_variant_get_child (variant, OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT,
|
||||
@@ -582,6 +661,10 @@ ostree_gpg_verify_result_describe_variant (GVariant *variant,
|
||||
"&s", &user_name);
|
||||
g_variant_get_child (variant, OSTREE_GPG_SIGNATURE_ATTR_USER_EMAIL,
|
||||
"&s", &user_email);
|
||||
g_variant_get_child (variant, OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP,
|
||||
"x", &key_exp_timestamp);
|
||||
g_variant_get_child (variant, OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP_PRIMARY,
|
||||
"x", &key_exp_timestamp_primary);
|
||||
|
||||
len = strlen (fingerprint);
|
||||
key_id = (len > 16) ? fingerprint + len - 16 : fingerprint;
|
||||
@@ -623,6 +706,10 @@ ostree_gpg_verify_result_describe_variant (GVariant *variant,
|
||||
"Good signature from \"%s <%s>\"\n",
|
||||
user_name, user_email);
|
||||
}
|
||||
else if (key_revoked)
|
||||
{
|
||||
g_string_append (output_buffer, "Key revoked\n");
|
||||
}
|
||||
else if (sig_expired)
|
||||
{
|
||||
g_string_append_printf (output_buffer,
|
||||
@@ -652,35 +739,14 @@ ostree_gpg_verify_result_describe_variant (GVariant *variant,
|
||||
}
|
||||
|
||||
if (exp_timestamp > 0)
|
||||
{
|
||||
if (line_prefix != NULL)
|
||||
g_string_append (output_buffer, line_prefix);
|
||||
|
||||
date_time_utc = g_date_time_new_from_unix_utc (exp_timestamp);
|
||||
if (date_time_utc == NULL)
|
||||
{
|
||||
g_string_append_printf (output_buffer,
|
||||
"Signature expiry timestamp (%" G_GINT64_FORMAT ") is invalid\n",
|
||||
exp_timestamp);
|
||||
return;
|
||||
}
|
||||
|
||||
date_time_local = g_date_time_to_local (date_time_utc);
|
||||
formatted_date_time = g_date_time_format (date_time_local, "%c");
|
||||
|
||||
if (sig_expired)
|
||||
{
|
||||
g_string_append_printf (output_buffer,
|
||||
"Signature expired %s\n",
|
||||
formatted_date_time);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_string_append_printf (output_buffer,
|
||||
"Signature expires %s\n",
|
||||
formatted_date_time);
|
||||
}
|
||||
}
|
||||
append_expire_info (output_buffer, line_prefix, "Signature", exp_timestamp,
|
||||
sig_expired);
|
||||
if (key_exp_timestamp > 0)
|
||||
append_expire_info (output_buffer, line_prefix, "Key", key_exp_timestamp,
|
||||
key_expired);
|
||||
if (key_exp_timestamp_primary > 0 && (g_strcmp0 (fingerprint, fingerprint_primary) != 0))
|
||||
append_expire_info (output_buffer, line_prefix, "Primary key",
|
||||
key_exp_timestamp_primary, key_expired);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -695,6 +761,8 @@ ostree_gpg_verify_result_describe_variant (GVariant *variant,
|
||||
*
|
||||
* Returns: %TRUE if @result was not %NULL and had at least one
|
||||
* signature from trusted keyring, otherwise %FALSE
|
||||
*
|
||||
* Since: 2016.6
|
||||
*/
|
||||
gboolean
|
||||
ostree_gpg_verify_result_require_valid_signature (OstreeGpgVerifyResult *result,
|
||||
|
||||
@@ -70,6 +70,14 @@ typedef struct OstreeGpgVerifyResult OstreeGpgVerifyResult;
|
||||
* (will be the same as OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT if the
|
||||
* the signature is already from the primary key rather than a subkey,
|
||||
* and will be the empty string if the key is missing.)
|
||||
* @OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP:
|
||||
* [#G_VARIANT_TYPE_INT64] Key expiration Unix timestamp (0 if no
|
||||
* expiration or if the key is missing)
|
||||
* @OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP_PRIMARY:
|
||||
* [#G_VARIANT_TYPE_INT64] Key expiration Unix timestamp of the signing key's
|
||||
* primary key (will be the same as OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP
|
||||
* if the signing key is the primary key and 0 if no expiration or if the key
|
||||
* is missing)
|
||||
*
|
||||
* Signature attributes available from an #OstreeGpgVerifyResult.
|
||||
* The attribute's #GVariantType is shown in brackets.
|
||||
@@ -88,6 +96,8 @@ typedef enum {
|
||||
OSTREE_GPG_SIGNATURE_ATTR_USER_NAME,
|
||||
OSTREE_GPG_SIGNATURE_ATTR_USER_EMAIL,
|
||||
OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT_PRIMARY,
|
||||
OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP,
|
||||
OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP_PRIMARY,
|
||||
} OstreeGpgSignatureAttr;
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
@@ -161,6 +171,11 @@ typedef enum {
|
||||
OSTREE_GPG_ERROR_MISSING_KEY,
|
||||
} OstreeGpgError;
|
||||
|
||||
/**
|
||||
* ostree_gpg_error_quark:
|
||||
*
|
||||
* Since: 2017.10
|
||||
*/
|
||||
_OSTREE_PUBLIC
|
||||
GQuark ostree_gpg_error_quark (void);
|
||||
#define OSTREE_GPG_ERROR (ostree_gpg_error_quark ())
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "ostree-kernel-args.h"
|
||||
#include "libglnx.h"
|
||||
#include "otutil.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -60,8 +61,24 @@ _arg_has_prefix (const char *arg,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
strcmp0_equal (gconstpointer v1,
|
||||
gconstpointer v2)
|
||||
{
|
||||
return g_strcmp0 (v1, v2) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_new: (skip)
|
||||
*
|
||||
* Initializes a new OstreeKernelArgs structure and returns it
|
||||
*
|
||||
* Returns: (transfer full): A newly created #OstreeKernelArgs for kernel arguments
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
OstreeKernelArgs *
|
||||
_ostree_kernel_args_new (void)
|
||||
ostree_kernel_args_new (void)
|
||||
{
|
||||
OstreeKernelArgs *ret;
|
||||
ret = g_new0 (OstreeKernelArgs, 1);
|
||||
@@ -71,8 +88,16 @@ _ostree_kernel_args_new (void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_free:
|
||||
* @kargs: An OstreeKernelArgs that represents kernel arguments
|
||||
*
|
||||
* Frees the kargs structure
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
void
|
||||
_ostree_kernel_args_free (OstreeKernelArgs *kargs)
|
||||
ostree_kernel_args_free (OstreeKernelArgs *kargs)
|
||||
{
|
||||
if (!kargs)
|
||||
return;
|
||||
@@ -81,9 +106,238 @@ _ostree_kernel_args_free (OstreeKernelArgs *kargs)
|
||||
g_free (kargs);
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_cleanup:
|
||||
* @loc: Address of an OstreeKernelArgs pointer
|
||||
*
|
||||
* Frees the OstreeKernelArgs structure pointed by *loc
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
void
|
||||
_ostree_kernel_args_replace_take (OstreeKernelArgs *kargs,
|
||||
char *arg)
|
||||
ostree_kernel_args_cleanup (void *loc)
|
||||
{
|
||||
ostree_kernel_args_free (*((OstreeKernelArgs**)loc));
|
||||
}
|
||||
|
||||
/**
|
||||
* _ostree_kernel_arg_get_kargs_table:
|
||||
* @kargs: An OstreeKernelArgs that represents kernel arguments
|
||||
*
|
||||
* Returns: (transfer none): #GHashTable that associates with the @kargs
|
||||
*
|
||||
* Note: this function is private for now, since the data structures underneath might be changed
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
GHashTable*
|
||||
_ostree_kernel_arg_get_kargs_table (OstreeKernelArgs *kargs)
|
||||
{
|
||||
if (kargs != NULL)
|
||||
return kargs->table;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* _ostree_kernel_arg_get_key_array:
|
||||
* @kargs: An OstreeKernelArgs that represents kernel arguments
|
||||
*
|
||||
* Returns: (transfer none) (element-type utf8): #GPtrArray that associates with @kargs
|
||||
*
|
||||
* Note: this function is private for now, since the data structures underneath might be changed
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
GPtrArray*
|
||||
_ostree_kernel_arg_get_key_array (OstreeKernelArgs *kargs)
|
||||
{
|
||||
if (kargs != NULL)
|
||||
return kargs->order;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_new_replace:
|
||||
* @kargs: OstreeKernelArgs instance
|
||||
* @arg: a string argument
|
||||
* @error: error instance
|
||||
*
|
||||
* This function implements the basic logic behind key/value pair
|
||||
* replacement. Do note that the arg need to be properly formatted
|
||||
*
|
||||
* When replacing key with exact one value, the arg can be in
|
||||
* the form:
|
||||
* key, key=new_val, or key=old_val=new_val
|
||||
* The first one swaps the old_val with the key to an empty value
|
||||
* The second and third replace the old_val into the new_val
|
||||
*
|
||||
* When replacing key with multiple values, the arg can only be
|
||||
* in the form of:
|
||||
* key=old_val=new_val. Unless there is a special case where
|
||||
* there is an empty value associated with the key, then
|
||||
* key=new_val will work because old_val is empty. The empty
|
||||
* val will be swapped with the new_val in that case
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE on failure (and in some other instances such as:
|
||||
* 1. key not found in @kargs
|
||||
* 2. old value not found when @arg is in the form of key=old_val=new_val
|
||||
* 3. multiple old values found when @arg is in the form of key=old_val)
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
gboolean
|
||||
ostree_kernel_args_new_replace (OstreeKernelArgs *kargs,
|
||||
const char *arg,
|
||||
GError **error)
|
||||
{
|
||||
g_autofree char *arg_owned = g_strdup (arg);
|
||||
const char *key = arg_owned;
|
||||
const char *val = split_keyeq (arg_owned);
|
||||
|
||||
GPtrArray *values = g_hash_table_lookup (kargs->table, key);
|
||||
if (!values)
|
||||
return glnx_throw (error, "No key '%s' found", key);
|
||||
g_assert_cmpuint (values->len, >, 0);
|
||||
|
||||
/* first handle the case where the user just wants to replace an old value */
|
||||
if (val && strchr (val, '='))
|
||||
{
|
||||
g_autofree char *old_val = g_strdup (val);
|
||||
const char *new_val = split_keyeq (old_val);
|
||||
g_assert (new_val);
|
||||
|
||||
guint i = 0;
|
||||
if (!ot_ptr_array_find_with_equal_func (values, old_val, strcmp0_equal, &i))
|
||||
return glnx_throw (error, "No karg '%s=%s' found", key, old_val);
|
||||
|
||||
g_clear_pointer (&values->pdata[i], g_free);
|
||||
values->pdata[i] = g_strdup (new_val);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* can't know which val to replace without the old_val=new_val syntax */
|
||||
if (values->len > 1)
|
||||
return glnx_throw (error, "Multiple values for key '%s' found", key);
|
||||
|
||||
g_clear_pointer (&values->pdata[0], g_free);
|
||||
values->pdata[0] = g_strdup (val);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_delete_key_entry
|
||||
* @kargs: an OstreeKernelArgs instance
|
||||
* @key: the key to remove
|
||||
* @error: an GError instance
|
||||
*
|
||||
* This function removes the key entry from the hashtable
|
||||
* as well from the order pointer array inside kargs
|
||||
*
|
||||
* Note: since both table and order inside kernel args
|
||||
* are with free function, no extra free functions are
|
||||
* being called as they are done automatically by GLib
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE on failure
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
gboolean
|
||||
ostree_kernel_args_delete_key_entry (OstreeKernelArgs *kargs,
|
||||
const char *key,
|
||||
GError **error)
|
||||
{
|
||||
if (!g_hash_table_remove (kargs->table, key))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Failed to find kernel argument '%s'",
|
||||
key);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Then remove the key from order table */
|
||||
guint key_index;
|
||||
g_assert (ot_ptr_array_find_with_equal_func (kargs->order, key, g_str_equal, &key_index));
|
||||
g_assert (g_ptr_array_remove_index (kargs->order, key_index));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_delete:
|
||||
* @kargs: a OstreeKernelArgs instance
|
||||
* @arg: key or key/value pair for deletion
|
||||
* @error: an GError instance
|
||||
*
|
||||
* There are few scenarios being handled for deletion:
|
||||
*
|
||||
* 1: for input arg with a single key(i.e without = for split),
|
||||
* the key/value pair will be deleted if there is only
|
||||
* one value that is associated with the key
|
||||
*
|
||||
* 2: for input arg wth key/value pair, the specific key
|
||||
* value pair will be deleted from the pointer array
|
||||
* if those exist.
|
||||
*
|
||||
* 3: If the found key has only one value
|
||||
* associated with it, the key entry in the table will also
|
||||
* be removed, and the key will be removed from order table
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE on failure
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
gboolean
|
||||
ostree_kernel_args_delete (OstreeKernelArgs *kargs,
|
||||
const char *arg,
|
||||
GError **error)
|
||||
{
|
||||
g_autofree char *arg_owned = g_strdup (arg);
|
||||
const char *key = arg_owned;
|
||||
const char *val = split_keyeq (arg_owned);
|
||||
|
||||
GPtrArray *values = g_hash_table_lookup (kargs->table, key);
|
||||
if (!values)
|
||||
return glnx_throw (error, "No key '%s' found", key);
|
||||
g_assert_cmpuint (values->len, >, 0);
|
||||
|
||||
/* special-case: we allow deleting by key only if there's only one val */
|
||||
if (values->len == 1)
|
||||
{
|
||||
/* but if a specific val was passed, check that it's the same */
|
||||
if (val && !strcmp0_equal (val, values->pdata[0]))
|
||||
return glnx_throw (error, "No karg '%s=%s' found", key, val);
|
||||
return ostree_kernel_args_delete_key_entry (kargs, key, error);
|
||||
}
|
||||
|
||||
/* note val might be NULL here, in which case we're looking for `key`, not `key=` or
|
||||
* `key=val` */
|
||||
guint i = 0;
|
||||
if (!ot_ptr_array_find_with_equal_func (values, val, strcmp0_equal, &i))
|
||||
{
|
||||
if (!val)
|
||||
/* didn't find NULL -> only key= key=val1 key=val2 style things left, so the user
|
||||
* needs to be more specific */
|
||||
return glnx_throw (error, "Multiple values for key '%s' found", arg);
|
||||
return glnx_throw (error, "No karg '%s' found", arg);
|
||||
}
|
||||
|
||||
g_ptr_array_remove_index (values, i);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_replace_take:
|
||||
* @kargs: a OstreeKernelArgs instance
|
||||
* @arg: (transfer full): key or key/value pair for replacement
|
||||
*
|
||||
* Finds and replaces the old key if @arg is already in the hash table,
|
||||
* otherwise adds @arg as new key and split_keyeq (arg) as value.
|
||||
* Note that when replacing old key, the old values are freed.
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
void
|
||||
ostree_kernel_args_replace_take (OstreeKernelArgs *kargs,
|
||||
char *arg)
|
||||
{
|
||||
gboolean existed;
|
||||
GPtrArray *values = g_ptr_array_new_with_free_func (g_free);
|
||||
@@ -105,16 +359,38 @@ _ostree_kernel_args_replace_take (OstreeKernelArgs *kargs,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_replace:
|
||||
* @kargs: a OstreeKernelArgs instance
|
||||
* @arg: key or key/value pair for replacement
|
||||
*
|
||||
* Finds and replaces the old key if @arg is already in the hash table,
|
||||
* otherwise adds @arg as new key and split_keyeq (arg) as value.
|
||||
* Note that when replacing old key value pair, the old values are freed.
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
void
|
||||
_ostree_kernel_args_replace (OstreeKernelArgs *kargs,
|
||||
const char *arg)
|
||||
ostree_kernel_args_replace (OstreeKernelArgs *kargs,
|
||||
const char *arg)
|
||||
{
|
||||
_ostree_kernel_args_replace_take (kargs, g_strdup (arg));
|
||||
ostree_kernel_args_replace_take (kargs, g_strdup (arg));
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_append:
|
||||
* @kargs: a OstreeKernelArgs instance
|
||||
* @arg: key or key/value pair to be added
|
||||
*
|
||||
* Appends @arg which is in the form of key=value pair to the hash table kargs->table
|
||||
* (appends to the value list if key is already in the hash table)
|
||||
* and appends key to kargs->order if it is not in the hash table already.
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
void
|
||||
_ostree_kernel_args_append (OstreeKernelArgs *kargs,
|
||||
const char *arg)
|
||||
ostree_kernel_args_append (OstreeKernelArgs *kargs,
|
||||
const char *arg)
|
||||
{
|
||||
gboolean existed = TRUE;
|
||||
GPtrArray *values;
|
||||
@@ -141,23 +417,44 @@ _ostree_kernel_args_append (OstreeKernelArgs *kargs,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_replace_argv:
|
||||
* @kargs: a OstreeKernelArgs instance
|
||||
* @argv: an array of key or key/value pairs
|
||||
*
|
||||
* Finds and replaces each non-null arguments of @argv in the hash table,
|
||||
* otherwise adds individual arg as new key and split_keyeq (arg) as value.
|
||||
* Note that when replacing old key value pair, the old values are freed.
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
void
|
||||
_ostree_kernel_args_replace_argv (OstreeKernelArgs *kargs,
|
||||
char **argv)
|
||||
ostree_kernel_args_replace_argv (OstreeKernelArgs *kargs,
|
||||
char **argv)
|
||||
{
|
||||
char **strviter;
|
||||
|
||||
for (strviter = argv; strviter && *strviter; strviter++)
|
||||
{
|
||||
const char *arg = *strviter;
|
||||
_ostree_kernel_args_replace (kargs, arg);
|
||||
ostree_kernel_args_replace (kargs, arg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_append_argv_filtered:
|
||||
* @kargs: a OstreeKernelArgs instance
|
||||
* @argv: an array of key=value argument pairs
|
||||
* @prefixes: an array of prefix strings
|
||||
*
|
||||
* Appends each argument that does not have one of the @prefixes as prefix to the @kargs
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
void
|
||||
_ostree_kernel_args_append_argv_filtered (OstreeKernelArgs *kargs,
|
||||
char **argv,
|
||||
char **prefixes)
|
||||
ostree_kernel_args_append_argv_filtered (OstreeKernelArgs *kargs,
|
||||
char **argv,
|
||||
char **prefixes)
|
||||
{
|
||||
char **strviter;
|
||||
|
||||
@@ -166,21 +463,44 @@ _ostree_kernel_args_append_argv_filtered (OstreeKernelArgs *kargs,
|
||||
const char *arg = *strviter;
|
||||
|
||||
if (!_arg_has_prefix (arg, prefixes))
|
||||
_ostree_kernel_args_append (kargs, arg);
|
||||
ostree_kernel_args_append (kargs, arg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_append_argv:
|
||||
* @kargs: a OstreeKernelArgs instance
|
||||
* @argv: an array of key=value argument pairs
|
||||
*
|
||||
* Appends each value in @argv to the corresponding value array and
|
||||
* appends key to kargs->order if it is not in the hash table already.
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
void
|
||||
_ostree_kernel_args_append_argv (OstreeKernelArgs *kargs,
|
||||
char **argv)
|
||||
ostree_kernel_args_append_argv (OstreeKernelArgs *kargs,
|
||||
char **argv)
|
||||
{
|
||||
_ostree_kernel_args_append_argv_filtered (kargs, argv, NULL);
|
||||
ostree_kernel_args_append_argv_filtered (kargs, argv, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_append_proc_cmdline:
|
||||
* @kargs: a OstreeKernelArgs instance
|
||||
* @cancellable: optional GCancellable object, NULL to ignore
|
||||
* @error: an GError instance
|
||||
*
|
||||
* Appends the command line arguments in the file "/proc/cmdline"
|
||||
* that does not have "BOOT_IMAGE=" and "initrd=" as prefixes to the @kargs
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE on failure
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
gboolean
|
||||
_ostree_kernel_args_append_proc_cmdline (OstreeKernelArgs *kargs,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
ostree_kernel_args_append_proc_cmdline (OstreeKernelArgs *kargs,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GFile) proc_cmdline_path = g_file_new_for_path ("/proc/cmdline");
|
||||
g_autofree char *proc_cmdline = NULL;
|
||||
@@ -202,44 +522,76 @@ _ostree_kernel_args_append_proc_cmdline (OstreeKernelArgs *kargs,
|
||||
g_strchomp (proc_cmdline);
|
||||
|
||||
proc_cmdline_args = g_strsplit (proc_cmdline, " ", -1);
|
||||
_ostree_kernel_args_append_argv_filtered (kargs, proc_cmdline_args,
|
||||
ostree_kernel_args_append_argv_filtered (kargs, proc_cmdline_args,
|
||||
filtered_prefixes);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_parse_append:
|
||||
* @kargs: a OstreeKernelArgs instance
|
||||
* @options: a string representing command line arguments
|
||||
*
|
||||
* Parses @options by separating it by whitespaces and appends each argument to @kargs
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
void
|
||||
_ostree_kernel_args_parse_append (OstreeKernelArgs *kargs,
|
||||
const char *options)
|
||||
ostree_kernel_args_parse_append (OstreeKernelArgs *kargs,
|
||||
const char *options)
|
||||
{
|
||||
char **args = NULL;
|
||||
char **iter;
|
||||
|
||||
if (!options)
|
||||
return;
|
||||
|
||||
|
||||
args = g_strsplit (options, " ", -1);
|
||||
for (iter = args; *iter; iter++)
|
||||
{
|
||||
char *arg = *iter;
|
||||
_ostree_kernel_args_append (kargs, arg);
|
||||
ostree_kernel_args_append (kargs, arg);
|
||||
}
|
||||
g_strfreev (args);
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_from_string: (skip)
|
||||
* @options: a string representing command line arguments
|
||||
*
|
||||
* Initializes a new OstreeKernelArgs then parses and appends @options
|
||||
* to the empty OstreeKernelArgs
|
||||
*
|
||||
* Returns: (transfer full): newly allocated #OstreeKernelArgs with @options appended
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
OstreeKernelArgs *
|
||||
_ostree_kernel_args_from_string (const char *options)
|
||||
ostree_kernel_args_from_string (const char *options)
|
||||
{
|
||||
OstreeKernelArgs *ret;
|
||||
|
||||
ret = _ostree_kernel_args_new ();
|
||||
_ostree_kernel_args_parse_append (ret, options);
|
||||
ret = ostree_kernel_args_new ();
|
||||
ostree_kernel_args_parse_append (ret, options);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_to_strv:
|
||||
* @kargs: a OstreeKernelArgs instance
|
||||
*
|
||||
* Extracts all key value pairs in @kargs and appends to a temporary
|
||||
* array in forms of "key=value" or "key" if value is NULL, and returns
|
||||
* the temporary array with the GPtrArray wrapper freed
|
||||
*
|
||||
* Returns: (transfer full): an array of "key=value" pairs or "key" if value is NULL
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
char **
|
||||
_ostree_kernel_args_to_strv (OstreeKernelArgs *kargs)
|
||||
ostree_kernel_args_to_strv (OstreeKernelArgs *kargs)
|
||||
{
|
||||
GPtrArray *strv = g_ptr_array_new ();
|
||||
guint i;
|
||||
@@ -266,8 +618,25 @@ _ostree_kernel_args_to_strv (OstreeKernelArgs *kargs)
|
||||
return (char**)g_ptr_array_free (strv, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_to_string:
|
||||
* @kargs: a OstreeKernelArgs instance
|
||||
*
|
||||
* Extracts all key value pairs in @kargs and appends to a temporary
|
||||
* GString in forms of "key=value" or "key" if value is NULL separated
|
||||
* by a single whitespace, and returns the temporary string with the
|
||||
* GString wrapper freed
|
||||
*
|
||||
* Note: the application will be terminated if one of the values array
|
||||
* in @kargs is NULL
|
||||
*
|
||||
* Returns: (transfer full): a string of "key=value" pairs or "key" if value is NULL,
|
||||
* separated by single whitespaces
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
char *
|
||||
_ostree_kernel_args_to_string (OstreeKernelArgs *kargs)
|
||||
ostree_kernel_args_to_string (OstreeKernelArgs *kargs)
|
||||
{
|
||||
GString *buf = g_string_new ("");
|
||||
gboolean first = TRUE;
|
||||
@@ -302,8 +671,22 @@ _ostree_kernel_args_to_string (OstreeKernelArgs *kargs)
|
||||
return g_string_free (buf, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_kernel_args_get_last_value:
|
||||
* @kargs: a OstreeKernelArgs instance
|
||||
* @key: a key to look for in @kargs hash table
|
||||
*
|
||||
* Finds and returns the last element of value array
|
||||
* corresponding to the @key in @kargs hash table. Note that the application
|
||||
* will be terminated if the @key is found but the value array is empty
|
||||
*
|
||||
* Returns: NULL if @key is not found in the @kargs hash table,
|
||||
* otherwise returns last element of value array corresponding to @key
|
||||
*
|
||||
* Since: 2019.3
|
||||
**/
|
||||
const char *
|
||||
_ostree_kernel_args_get_last_value (OstreeKernelArgs *kargs, const char *key)
|
||||
ostree_kernel_args_get_last_value (OstreeKernelArgs *kargs, const char *key)
|
||||
{
|
||||
GPtrArray *values = g_hash_table_lookup (kargs->table, key);
|
||||
|
||||
|
||||
@@ -19,41 +19,88 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "libglnx.h"
|
||||
#include <gio/gio.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include "ostree-types.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _OstreeKernelArgs OstreeKernelArgs;
|
||||
void _ostree_kernel_args_free (OstreeKernelArgs *kargs);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(OstreeKernelArgs, _ostree_kernel_args_free);
|
||||
|
||||
OstreeKernelArgs *_ostree_kernel_args_new (void);
|
||||
void _ostree_kernel_args_replace_take (OstreeKernelArgs *kargs,
|
||||
char *key);
|
||||
void _ostree_kernel_args_replace (OstreeKernelArgs *kargs,
|
||||
const char *key);
|
||||
void _ostree_kernel_args_replace_argv (OstreeKernelArgs *kargs,
|
||||
char **argv);
|
||||
void _ostree_kernel_args_append (OstreeKernelArgs *kargs,
|
||||
const char *key);
|
||||
void _ostree_kernel_args_append_argv (OstreeKernelArgs *kargs,
|
||||
char **argv);
|
||||
void _ostree_kernel_args_append_argv_filtered (OstreeKernelArgs *kargs,
|
||||
char **argv,
|
||||
char **prefixes);
|
||||
GHashTable *_ostree_kernel_arg_get_kargs_table (OstreeKernelArgs *kargs);
|
||||
|
||||
gboolean _ostree_kernel_args_append_proc_cmdline (OstreeKernelArgs *kargs,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
GPtrArray *_ostree_kernel_arg_get_key_array (OstreeKernelArgs *kargs);
|
||||
|
||||
void _ostree_kernel_args_parse_append (OstreeKernelArgs *kargs,
|
||||
const char *options);
|
||||
_OSTREE_PUBLIC
|
||||
void ostree_kernel_args_free (OstreeKernelArgs *kargs);
|
||||
|
||||
const char *_ostree_kernel_args_get_last_value (OstreeKernelArgs *kargs, const char *key);
|
||||
_OSTREE_PUBLIC
|
||||
OstreeKernelArgs *ostree_kernel_args_new (void);
|
||||
|
||||
OstreeKernelArgs * _ostree_kernel_args_from_string (const char *options);
|
||||
_OSTREE_PUBLIC
|
||||
void ostree_kernel_args_cleanup (void *loc);
|
||||
|
||||
char ** _ostree_kernel_args_to_strv (OstreeKernelArgs *kargs);
|
||||
char * _ostree_kernel_args_to_string (OstreeKernelArgs *kargs);
|
||||
_OSTREE_PUBLIC
|
||||
void ostree_kernel_args_replace_take (OstreeKernelArgs *kargs,
|
||||
char *arg);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
void ostree_kernel_args_replace (OstreeKernelArgs *kargs,
|
||||
const char *arg);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
void ostree_kernel_args_replace_argv (OstreeKernelArgs *kargs,
|
||||
char **argv);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
void ostree_kernel_args_append (OstreeKernelArgs *kargs,
|
||||
const char *arg);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
void ostree_kernel_args_append_argv (OstreeKernelArgs *kargs,
|
||||
char **argv);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
void ostree_kernel_args_append_argv_filtered (OstreeKernelArgs *kargs,
|
||||
char **argv,
|
||||
char **prefixes);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_kernel_args_new_replace (OstreeKernelArgs *kargs,
|
||||
const char *arg,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_kernel_args_delete (OstreeKernelArgs *kargs,
|
||||
const char *arg,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_kernel_args_delete_key_entry (OstreeKernelArgs *kargs,
|
||||
const char *key,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_kernel_args_append_proc_cmdline (OstreeKernelArgs *kargs,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
void ostree_kernel_args_parse_append (OstreeKernelArgs *kargs,
|
||||
const char *options);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
const char *ostree_kernel_args_get_last_value (OstreeKernelArgs *kargs,
|
||||
const char *key);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
OstreeKernelArgs *ostree_kernel_args_from_string (const char *options);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
char **ostree_kernel_args_to_strv (OstreeKernelArgs *kargs);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
char *ostree_kernel_args_to_string (OstreeKernelArgs *kargs);
|
||||
|
||||
G_END_DECLS
|
||||
@@ -44,9 +44,9 @@ typedef struct archive OtAutoArchiveRead;
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(OtAutoArchiveRead, archive_read_free)
|
||||
|
||||
static inline OtAutoArchiveRead *
|
||||
ot_open_archive_read (const char *path, GError **error)
|
||||
ot_archive_read_new (void)
|
||||
{
|
||||
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
|
||||
OtAutoArchiveRead *a = archive_read_new ();
|
||||
|
||||
#ifdef HAVE_ARCHIVE_READ_SUPPORT_FILTER_ALL
|
||||
archive_read_support_filter_all (a);
|
||||
@@ -54,10 +54,34 @@ ot_open_archive_read (const char *path, GError **error)
|
||||
archive_read_support_compression_all (a);
|
||||
#endif
|
||||
archive_read_support_format_all (a);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
static inline OtAutoArchiveRead *
|
||||
ot_open_archive_read (const char *path, GError **error)
|
||||
{
|
||||
g_autoptr(OtAutoArchiveRead) a = ot_archive_read_new ();
|
||||
|
||||
if (archive_read_open_filename (a, path, 8192) != ARCHIVE_OK)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"%s", archive_error_string (a));
|
||||
"archive_read_open_filename: %s", archive_error_string (a));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return g_steal_pointer (&a);
|
||||
}
|
||||
|
||||
static inline OtAutoArchiveRead *
|
||||
ot_open_archive_read_fd (int fd, GError **error)
|
||||
{
|
||||
g_autoptr(OtAutoArchiveRead) a = ot_archive_read_new ();
|
||||
|
||||
if (archive_read_open_fd (a, fd, 8192) != ARCHIVE_OK)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"archive_read_open_fd: %s", archive_error_string (a));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -331,6 +331,8 @@ ostree_mutable_tree_replace_file (OstreeMutableTree *self,
|
||||
* @error: a #GError
|
||||
*
|
||||
* Remove the file or subdirectory named @name from the mutable tree @self.
|
||||
*
|
||||
* Since: 2018.9
|
||||
*/
|
||||
gboolean
|
||||
ostree_mutable_tree_remove (OstreeMutableTree *self,
|
||||
@@ -399,6 +401,14 @@ ostree_mutable_tree_ensure_dir (OstreeMutableTree *self,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_mutable_tree_lookup:
|
||||
* @self: Tree
|
||||
* @name: name
|
||||
* @out_file_checksum: (out) (transfer full): checksum
|
||||
* @out_subdir: (out) (transfer full): subdirectory
|
||||
* @error: a #GError
|
||||
*/
|
||||
gboolean
|
||||
ostree_mutable_tree_lookup (OstreeMutableTree *self,
|
||||
const char *name,
|
||||
@@ -494,6 +504,8 @@ const char empty_tree_csum[] = "6e340b9cffb37a989ca544e6bb780a2c78901d3fb3373876
|
||||
* This function enables optimisations when composing trees. The provided
|
||||
* checksums are not loaded or checked when this function is called. Instead
|
||||
* the contents will be loaded only when needed.
|
||||
*
|
||||
* Since: 2018.7
|
||||
*/
|
||||
gboolean
|
||||
ostree_mutable_tree_fill_empty_from_dirtree (OstreeMutableTree *self,
|
||||
@@ -585,7 +597,7 @@ ostree_mutable_tree_walk (OstreeMutableTree *self,
|
||||
/**
|
||||
* ostree_mutable_tree_get_subdirs:
|
||||
* @self:
|
||||
*
|
||||
*
|
||||
* Returns: (transfer none) (element-type utf8 OstreeMutableTree): All children directories
|
||||
*/
|
||||
GHashTable *
|
||||
@@ -598,7 +610,7 @@ ostree_mutable_tree_get_subdirs (OstreeMutableTree *self)
|
||||
/**
|
||||
* ostree_mutable_tree_get_files:
|
||||
* @self:
|
||||
*
|
||||
*
|
||||
* Returns: (transfer none) (element-type utf8 utf8): All children files (the value is a checksum)
|
||||
*/
|
||||
GHashTable *
|
||||
@@ -654,6 +666,8 @@ ostree_mutable_tree_new (void)
|
||||
* and checksums. The data will be loaded from the repo lazily as needed.
|
||||
*
|
||||
* Returns: (transfer full): A new tree
|
||||
*
|
||||
* Since: 2018.7
|
||||
*/
|
||||
OstreeMutableTree *
|
||||
ostree_mutable_tree_new_from_checksum (OstreeRepo *repo,
|
||||
|
||||
@@ -47,7 +47,7 @@ G_DEFINE_BOXED_TYPE (OstreeCollectionRef, ostree_collection_ref,
|
||||
* refspec; no remote name is included), which can be used for non-P2P
|
||||
* operations.
|
||||
*
|
||||
* Returns: (transfer full): a new #OstreeCollectionRef
|
||||
* Returns: (transfer full) (nullable): a new #OstreeCollectionRef
|
||||
* Since: 2018.6
|
||||
*/
|
||||
OstreeCollectionRef *
|
||||
@@ -69,7 +69,7 @@ ostree_collection_ref_new (const gchar *collection_id,
|
||||
|
||||
/**
|
||||
* ostree_collection_ref_dup:
|
||||
* @ref: an #OstreeCollectionRef
|
||||
* @ref: (not nullable): an #OstreeCollectionRef
|
||||
*
|
||||
* Create a copy of the given @ref.
|
||||
*
|
||||
@@ -104,7 +104,7 @@ ostree_collection_ref_free (OstreeCollectionRef *ref)
|
||||
|
||||
/**
|
||||
* ostree_collection_ref_hash:
|
||||
* @ref: an #OstreeCollectionRef
|
||||
* @ref: (not nullable): an #OstreeCollectionRef
|
||||
*
|
||||
* Hash the given @ref. This function is suitable for use with #GHashTable.
|
||||
* @ref must be non-%NULL.
|
||||
@@ -125,8 +125,8 @@ ostree_collection_ref_hash (gconstpointer ref)
|
||||
|
||||
/**
|
||||
* ostree_collection_ref_equal:
|
||||
* @ref1: an #OstreeCollectionRef
|
||||
* @ref2: another #OstreeCollectionRef
|
||||
* @ref1: (not nullable): an #OstreeCollectionRef
|
||||
* @ref2 : (not nullable): another #OstreeCollectionRef
|
||||
*
|
||||
* Compare @ref1 and @ref2 and return %TRUE if they have the same collection ID and
|
||||
* ref name, and %FALSE otherwise. Both @ref1 and @ref2 must be non-%NULL.
|
||||
|
||||
@@ -771,7 +771,7 @@ checkout_one_file_at (OstreeRepo *repo,
|
||||
*/
|
||||
g_mutex_lock (&repo->cache_lock);
|
||||
{
|
||||
gpointer key = GUINT_TO_POINTER ((g_ascii_xdigit_value (checksum[0]) << 4) +
|
||||
gpointer key = GUINT_TO_POINTER ((g_ascii_xdigit_value (checksum[0]) << 4) +
|
||||
g_ascii_xdigit_value (checksum[1]));
|
||||
if (repo->updated_uncompressed_dirs == NULL)
|
||||
repo->updated_uncompressed_dirs = g_hash_table_new (NULL, NULL);
|
||||
@@ -1321,6 +1321,8 @@ ostree_repo_checkout_tree_at (OstreeRepo *self,
|
||||
* Note in addition that unlike ostree_repo_checkout_tree(), the
|
||||
* default is not to use the repository-internal uncompressed objects
|
||||
* cache.
|
||||
*
|
||||
* Since: 2016.8
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_checkout_at (OstreeRepo *self,
|
||||
@@ -1391,6 +1393,8 @@ ostree_repo_checkout_at (OstreeRepo *self,
|
||||
*
|
||||
* Note that cache does *not* have its refcount incremented - the lifetime of
|
||||
* @cache must be equal to or greater than that of @opts.
|
||||
*
|
||||
* Since: 2017.13
|
||||
*/
|
||||
void
|
||||
ostree_repo_checkout_at_options_set_devino (OstreeRepoCheckoutAtOptions *opts,
|
||||
@@ -1418,7 +1422,7 @@ devino_equal (gconstpointer a,
|
||||
|
||||
/**
|
||||
* ostree_repo_devino_cache_new:
|
||||
*
|
||||
*
|
||||
* OSTree has support for pairing ostree_repo_checkout_tree_at() using
|
||||
* hardlinks in combination with a later
|
||||
* ostree_repo_write_directory_to_mtree() using a (normally modified)
|
||||
|
||||
@@ -2065,6 +2065,8 @@ ostree_repo_set_ref_immediate (OstreeRepo *self,
|
||||
* @error: GError
|
||||
*
|
||||
* Like ostree_repo_set_ref_immediate(), but creates an alias.
|
||||
*
|
||||
* Since: 2017.10
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_set_alias_ref_immediate (OstreeRepo *self,
|
||||
|
||||
@@ -292,6 +292,13 @@ ostree_repo_file_ensure_resolved (OstreeRepoFile *self,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_repo_file_get_xattrs:
|
||||
* @self: #OstreeRepoFile
|
||||
* @out_xattrs: (out) (optional): the extended attributes
|
||||
* @cancellable: Cancellable
|
||||
* @error: Error
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_file_get_xattrs (OstreeRepoFile *self,
|
||||
GVariant **out_xattrs,
|
||||
@@ -724,6 +731,13 @@ query_child_info_dir (OstreeRepo *repo,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_repo_file_tree_find_child:
|
||||
* @self: #OstreeRepoFile
|
||||
* @name: name of the child
|
||||
* @is_dir: (out caller-allocates):
|
||||
* @out_container: (out):
|
||||
*/
|
||||
int
|
||||
ostree_repo_file_tree_find_child (OstreeRepoFile *self,
|
||||
const char *name,
|
||||
@@ -769,6 +783,16 @@ ostree_repo_file_tree_find_child (OstreeRepoFile *self,
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_repo_file_tree_query_child:
|
||||
* @self: #OstreeRepoFile
|
||||
* @n:
|
||||
* @attributes:
|
||||
* @flags:
|
||||
* @out_info: (out):
|
||||
* @cancellable: Cancellable
|
||||
* @error: Error
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_file_tree_query_child (OstreeRepoFile *self,
|
||||
int n,
|
||||
|
||||
@@ -111,6 +111,8 @@ GPtrArray *ostree_repo_finder_resolve_all_finish (GAsyncResult *result,
|
||||
* which allow ostree_repo_pull_from_remotes_async() (for example) to prioritise
|
||||
* how to pull the refs.
|
||||
*
|
||||
* An #OstreeRepoFinderResult is immutable after construction.
|
||||
*
|
||||
* The @priority is used as one input of many to ordering functions like
|
||||
* ostree_repo_finder_result_compare().
|
||||
*
|
||||
|
||||
@@ -901,6 +901,37 @@ ostree_repo_import_archive_to_mtree (OstreeRepo *self,
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBARCHIVE
|
||||
static gboolean
|
||||
write_archive_to_mtree (OstreeRepo *self,
|
||||
OtAutoArchiveRead *archive,
|
||||
OstreeMutableTree *mtree,
|
||||
OstreeRepoCommitModifier *modifier,
|
||||
gboolean autocreate_parents,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
OstreeRepoImportArchiveOptions opts = { 0, };
|
||||
|
||||
opts.autocreate_parents = !!autocreate_parents;
|
||||
|
||||
if (!ostree_repo_import_archive_to_mtree (self, &opts, archive, mtree, modifier, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (archive_read_close (archive) != ARCHIVE_OK)
|
||||
{
|
||||
propagate_libarchive_error (error, archive);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
(void)archive_read_close (archive);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* ostree_repo_write_archive_to_mtree:
|
||||
* @self: An #OstreeRepo
|
||||
@@ -924,31 +955,46 @@ ostree_repo_write_archive_to_mtree (OstreeRepo *self,
|
||||
GError **error)
|
||||
{
|
||||
#ifdef HAVE_LIBARCHIVE
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
|
||||
OstreeRepoImportArchiveOptions opts = { 0, };
|
||||
|
||||
a = ot_open_archive_read (gs_file_get_path_cached (archive), error);
|
||||
if (!a)
|
||||
goto out;
|
||||
opts.autocreate_parents = !!autocreate_parents;
|
||||
|
||||
if (!ostree_repo_import_archive_to_mtree (self, &opts, a, mtree, modifier, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (archive_read_close (a) != ARCHIVE_OK)
|
||||
{
|
||||
propagate_libarchive_error (error, a);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
g_autoptr(OtAutoArchiveRead) a = ot_open_archive_read (gs_file_get_path_cached (archive), error);
|
||||
if (a)
|
||||
{
|
||||
(void)archive_read_close (a);
|
||||
}
|
||||
return ret;
|
||||
return write_archive_to_mtree (self, a, mtree, modifier, autocreate_parents, cancellable, error);
|
||||
|
||||
return FALSE;
|
||||
#else
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"This version of ostree is not compiled with libarchive support");
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_repo_write_archive_to_mtree_from_fd:
|
||||
* @self: An #OstreeRepo
|
||||
* @fd: A file descriptor to read the archive from
|
||||
* @mtree: The #OstreeMutableTree to write to
|
||||
* @modifier: (allow-none): Optional commit modifier
|
||||
* @autocreate_parents: Autocreate parent directories
|
||||
* @cancellable: Cancellable
|
||||
* @error: Error
|
||||
*
|
||||
* Read an archive from @fd and import it into the repository, writing
|
||||
* its file structure to @mtree.
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_write_archive_to_mtree_from_fd (OstreeRepo *self,
|
||||
int fd,
|
||||
OstreeMutableTree *mtree,
|
||||
OstreeRepoCommitModifier *modifier,
|
||||
gboolean autocreate_parents,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
#ifdef HAVE_LIBARCHIVE
|
||||
g_autoptr(OtAutoArchiveRead) a = ot_open_archive_read_fd (fd, error);
|
||||
if (a)
|
||||
return write_archive_to_mtree (self, a, mtree, modifier, autocreate_parents, cancellable, error);
|
||||
|
||||
return FALSE;
|
||||
#else
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"This version of ostree is not compiled with libarchive support");
|
||||
|
||||
@@ -332,6 +332,7 @@ _ostree_repo_commit_modifier_apply (OstreeRepo *self,
|
||||
gboolean
|
||||
_ostree_repo_remote_name_is_file (const char *remote_name);
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
OstreeGpgVerifyResult *
|
||||
_ostree_repo_gpg_verify_with_metadata (OstreeRepo *self,
|
||||
GBytes *signed_data,
|
||||
@@ -350,6 +351,7 @@ _ostree_repo_verify_commit_internal (OstreeRepo *self,
|
||||
GFile *extra_keyring,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
typedef enum {
|
||||
_OSTREE_REPO_IMPORT_FLAGS_NONE,
|
||||
|
||||
@@ -473,6 +473,8 @@ ostree_repo_prune (OstreeRepo *self,
|
||||
* statistics on objects that would be deleted, without actually deleting them.
|
||||
*
|
||||
* Locking: exclusive
|
||||
*
|
||||
* Since: 2017.1
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_prune_from_reachable (OstreeRepo *self,
|
||||
|
||||
@@ -104,9 +104,9 @@ typedef struct {
|
||||
gint n_scanned_metadata;
|
||||
|
||||
gboolean gpg_verify;
|
||||
gboolean gpg_verify_summary;
|
||||
gboolean require_static_deltas;
|
||||
gboolean disable_static_deltas;
|
||||
gboolean gpg_verify_summary;
|
||||
gboolean has_tombstone_commits;
|
||||
|
||||
GBytes *summary_data;
|
||||
@@ -114,7 +114,7 @@ typedef struct {
|
||||
GVariant *summary;
|
||||
GHashTable *summary_deltas_checksums;
|
||||
GHashTable *ref_original_commits; /* Maps checksum to commit, used by timestamp checks */
|
||||
GHashTable *gpg_verified_commits; /* Set<checksum> of commits that have been verified */
|
||||
GHashTable *verified_commits; /* Set<checksum> of commits that have been verified */
|
||||
GHashTable *ref_keyring_map; /* Maps OstreeCollectionRef to keyring remote name */
|
||||
GPtrArray *static_delta_superblocks;
|
||||
GHashTable *expected_commit_sizes; /* Maps commit checksum to known size */
|
||||
@@ -261,14 +261,13 @@ static gboolean scan_one_metadata_object (OtPullData *pull_data,
|
||||
GError **error);
|
||||
static void scan_object_queue_data_free (ScanObjectQueueData *scan_data);
|
||||
static gboolean
|
||||
gpg_verify_unwritten_commit (OtPullData *pull_data,
|
||||
const char *checksum,
|
||||
GVariant *commit,
|
||||
GVariant *detached_metadata,
|
||||
const OstreeCollectionRef *ref,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
ostree_verify_unwritten_commit (OtPullData *pull_data,
|
||||
const char *checksum,
|
||||
GVariant *commit,
|
||||
GVariant *detached_metadata,
|
||||
const OstreeCollectionRef *ref,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
static gboolean
|
||||
update_progress (gpointer user_data)
|
||||
@@ -1063,7 +1062,7 @@ content_fetch_on_write_complete (GObject *object,
|
||||
static void
|
||||
content_fetch_on_complete (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
gpointer user_data)
|
||||
{
|
||||
OstreeFetcher *fetcher = (OstreeFetcher *)object;
|
||||
FetchObjectData *fetch_data = user_data;
|
||||
@@ -1167,7 +1166,7 @@ on_metadata_written (GObject *object,
|
||||
g_autofree guchar *csum = NULL;
|
||||
g_autofree char *stringified_object = NULL;
|
||||
|
||||
if (!ostree_repo_write_metadata_finish ((OstreeRepo*)object, result,
|
||||
if (!ostree_repo_write_metadata_finish ((OstreeRepo*)object, result,
|
||||
&csum, error))
|
||||
goto out;
|
||||
|
||||
@@ -1294,22 +1293,22 @@ meta_fetch_on_complete (GObject *object,
|
||||
if (!_ostree_verify_metadata_object (objtype, checksum, metadata, error))
|
||||
goto out;
|
||||
|
||||
/* For commit objects, check the GPG signature before writing to the repo,
|
||||
/* For commit objects, check the signature before writing to the repo,
|
||||
* and also write the .commitpartial to say that we're still processing
|
||||
* this commit.
|
||||
*/
|
||||
if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
|
||||
{
|
||||
/* Do GPG verification. `detached_data` may be NULL if no detached
|
||||
/* Do signature verification. `detached_data` may be NULL if no detached
|
||||
* metadata was found during pull; that's handled by
|
||||
* gpg_verify_unwritten_commit(). If we ever change the pull code to
|
||||
* ostree_ostree_verify_unwritten_commit(). If we ever change the pull code to
|
||||
* not always fetch detached metadata, this bit will have to learn how
|
||||
* to look up from the disk state as well, or insert the on-disk
|
||||
* metadata into this hash.
|
||||
*/
|
||||
GVariant *detached_data = g_hash_table_lookup (pull_data->fetched_detached_metadata, checksum);
|
||||
if (!gpg_verify_unwritten_commit (pull_data, checksum, metadata, detached_data,
|
||||
fetch_data->requested_ref, pull_data->cancellable, error))
|
||||
if (!ostree_verify_unwritten_commit (pull_data, checksum, metadata, detached_data,
|
||||
fetch_data->requested_ref, pull_data->cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_repo_mark_commit_partial (pull_data->repo, checksum, TRUE, error))
|
||||
@@ -1433,6 +1432,7 @@ static_deltapart_fetch_on_complete (GObject *object,
|
||||
g_clear_pointer (&fetch_data, fetch_static_delta_data_free);
|
||||
}
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
static gboolean
|
||||
process_verify_result (OtPullData *pull_data,
|
||||
const char *checksum,
|
||||
@@ -1458,26 +1458,28 @@ process_verify_result (OtPullData *pull_data,
|
||||
* the case of "written but not verified". But we also don't want to check
|
||||
* twice, as that'd result in duplicate signals.
|
||||
*/
|
||||
g_hash_table_add (pull_data->gpg_verified_commits, g_strdup (checksum));
|
||||
g_hash_table_add (pull_data->verified_commits, g_strdup (checksum));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
static gboolean
|
||||
gpg_verify_unwritten_commit (OtPullData *pull_data,
|
||||
const char *checksum,
|
||||
GVariant *commit,
|
||||
GVariant *detached_metadata,
|
||||
const OstreeCollectionRef *ref,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
ostree_verify_unwritten_commit (OtPullData *pull_data,
|
||||
const char *checksum,
|
||||
GVariant *commit,
|
||||
GVariant *detached_metadata,
|
||||
const OstreeCollectionRef *ref,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
if (pull_data->gpg_verify)
|
||||
{
|
||||
const char *keyring_remote = NULL;
|
||||
|
||||
/* Shouldn't happen, but see comment in process_verify_result() */
|
||||
if (g_hash_table_contains (pull_data->gpg_verified_commits, checksum))
|
||||
if (g_hash_table_contains (pull_data->verified_commits, checksum))
|
||||
return TRUE;
|
||||
|
||||
if (ref != NULL)
|
||||
@@ -1494,6 +1496,7 @@ gpg_verify_unwritten_commit (OtPullData *pull_data,
|
||||
if (!process_verify_result (pull_data, checksum, result, error))
|
||||
return FALSE;
|
||||
}
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1702,6 +1705,7 @@ ostree_repo_resolve_keyring_for_collection (OstreeRepo *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
gsize i;
|
||||
g_auto(GStrv) remotes = NULL;
|
||||
g_autoptr(OstreeRemote) keyring_remote = NULL;
|
||||
@@ -1763,6 +1767,12 @@ ostree_repo_resolve_keyring_for_collection (OstreeRepo *self,
|
||||
collection_id);
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"'%s': GPG feature is disabled in a build time",
|
||||
__FUNCTION__);
|
||||
return NULL;
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBCURL_OR_LIBSOUP
|
||||
@@ -1792,11 +1802,12 @@ scan_commit_object (OtPullData *pull_data,
|
||||
GINT_TO_POINTER (depth));
|
||||
}
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
/* See comment in process_verify_result() - we now gpg check before writing,
|
||||
* but also ensure we've done it here if not already.
|
||||
*/
|
||||
if (pull_data->gpg_verify &&
|
||||
!g_hash_table_contains (pull_data->gpg_verified_commits, checksum))
|
||||
!g_hash_table_contains (pull_data->verified_commits, checksum))
|
||||
{
|
||||
g_autoptr(OstreeGpgVerifyResult) result = NULL;
|
||||
const char *keyring_remote = NULL;
|
||||
@@ -1814,6 +1825,7 @@ scan_commit_object (OtPullData *pull_data,
|
||||
if (!process_verify_result (pull_data, checksum, result, error))
|
||||
return FALSE;
|
||||
}
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
/* If we found a legacy transaction flag, assume we have to scan.
|
||||
* We always do a scan of dirtree objects; see
|
||||
@@ -2401,8 +2413,8 @@ process_one_static_delta (OtPullData *pull_data,
|
||||
g_autofree char *detached_path = _ostree_get_relative_static_delta_path (from_revision, to_revision, "commitmeta");
|
||||
g_autoptr(GVariant) detached_data = g_variant_lookup_value (metadata, detached_path, G_VARIANT_TYPE("a{sv}"));
|
||||
|
||||
if (!gpg_verify_unwritten_commit (pull_data, to_revision, to_commit, detached_data,
|
||||
ref, cancellable, error))
|
||||
if (!ostree_verify_unwritten_commit (pull_data, to_revision, to_commit, detached_data,
|
||||
ref, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (detached_data && !ostree_repo_write_commit_detached_metadata (pull_data->repo,
|
||||
@@ -2742,6 +2754,7 @@ on_superblock_fetched (GObject *src,
|
||||
ot_checksum_update_bytes (&hasher, delta_superblock_data);
|
||||
ot_checksum_get_digest (&hasher, actual_summary_digest, sizeof (actual_summary_digest));
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
/* At this point we've GPG verified the data, so in theory
|
||||
* could trust that they provided the right data, but let's
|
||||
* make this a hard error.
|
||||
@@ -2752,6 +2765,7 @@ on_superblock_fetched (GObject *src,
|
||||
"GPG verification enabled, but no summary signatures found (use gpg-verify-summary=false in remote config to disable)");
|
||||
goto out;
|
||||
}
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
if (expected_summary_digest && memcmp (expected_summary_digest, actual_summary_digest, sizeof (actual_summary_digest)))
|
||||
{
|
||||
@@ -2868,7 +2882,7 @@ _ostree_repo_load_cache_summary_if_same_sig (OstreeRepo *self,
|
||||
if (prev_fd < 0)
|
||||
return TRUE; /* Note early return */
|
||||
|
||||
g_autoptr(GBytes) old_sig_contents = glnx_fd_readall_bytes (prev_fd, cancellable, error);
|
||||
g_autoptr(GBytes) old_sig_contents = ot_fd_readall_or_mmap (prev_fd, 0, error);
|
||||
if (!old_sig_contents)
|
||||
return FALSE;
|
||||
|
||||
@@ -3618,6 +3632,17 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
pull_data->remote_name = g_strdup (pull_data->remote_refspec_name);
|
||||
}
|
||||
|
||||
#ifdef OSTREE_DISABLE_GPGME
|
||||
/* Explicitly fail here if gpg verification is requested and we have no GPG support */
|
||||
if (opt_gpg_verify_set || opt_gpg_verify_summary_set)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"'%s': GPG feature is disabled in a build time",
|
||||
__FUNCTION__);
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
||||
g_return_val_if_fail (OSTREE_IS_REPO (self), FALSE);
|
||||
g_return_val_if_fail (pull_data->maxdepth >= -1, FALSE);
|
||||
g_return_val_if_fail (!pull_data->timestamp_check || pull_data->maxdepth == 0, FALSE);
|
||||
@@ -3671,8 +3696,8 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
pull_data->ref_original_commits = g_hash_table_new_full (ostree_collection_ref_hash, ostree_collection_ref_equal,
|
||||
(GDestroyNotify)NULL,
|
||||
(GDestroyNotify)g_free);
|
||||
pull_data->gpg_verified_commits = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
(GDestroyNotify)g_free, NULL);
|
||||
pull_data->verified_commits = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
(GDestroyNotify)g_free, NULL);
|
||||
pull_data->ref_keyring_map = g_hash_table_new_full (ostree_collection_ref_hash, ostree_collection_ref_equal,
|
||||
(GDestroyNotify)ostree_collection_ref_free, (GDestroyNotify)g_free);
|
||||
pull_data->scanned_metadata = g_hash_table_new_full (ostree_hash_object_name, g_variant_equal,
|
||||
@@ -3745,6 +3770,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
g_free (pull_data->remote_name);
|
||||
pull_data->remote_name = g_strdup (remote_name_or_baseurl);
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
/* Fetch GPG verification settings from remote if it wasn't already
|
||||
* explicitly set in the options. */
|
||||
if (!opt_gpg_verify_set)
|
||||
@@ -3756,6 +3782,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
if (!ostree_repo_remote_get_gpg_verify_summary (self, pull_data->remote_name,
|
||||
&pull_data->gpg_verify_summary, error))
|
||||
goto out;
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
/* NOTE: If changing this, see the matching implementation in
|
||||
* ostree-sysroot-upgrader.c
|
||||
@@ -4060,12 +4087,14 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
goto out;
|
||||
}
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
if (!bytes_summary && pull_data->gpg_verify_summary)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
|
||||
"GPG verification enabled, but no summary found (use gpg-verify-summary=false in remote config to disable)");
|
||||
goto out;
|
||||
}
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
if (!bytes_summary && pull_data->require_static_deltas)
|
||||
{
|
||||
@@ -4074,6 +4103,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
goto out;
|
||||
}
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
if (!bytes_sig && pull_data->gpg_verify_summary)
|
||||
{
|
||||
g_set_error (error, OSTREE_GPG_ERROR, OSTREE_GPG_ERROR_NO_SIGNATURE,
|
||||
@@ -4132,6 +4162,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
if (bytes_summary)
|
||||
{
|
||||
@@ -4334,62 +4365,62 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
GLNX_HASH_TABLE_FOREACH_KV (requested_refs_to_fetch, const OstreeCollectionRef*, ref,
|
||||
const char*, override_commitid)
|
||||
{
|
||||
g_autofree char *contents = NULL;
|
||||
g_autofree char *checksum = NULL;
|
||||
g_autoptr(OstreeCollectionRef) ref_with_collection = NULL;
|
||||
|
||||
/* Support specifying "" for an override commitid */
|
||||
if (override_commitid && *override_commitid)
|
||||
{
|
||||
g_hash_table_replace (updated_requested_refs_to_fetch, ostree_collection_ref_dup (ref), g_strdup (override_commitid));
|
||||
ref_with_collection = ostree_collection_ref_dup (ref);
|
||||
checksum = g_strdup (override_commitid);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_autoptr(OstreeCollectionRef) ref_with_collection = NULL;
|
||||
|
||||
if (pull_data->summary)
|
||||
{
|
||||
gsize commit_size = 0;
|
||||
guint64 *malloced_size;
|
||||
g_autofree gchar *collection_id = NULL;
|
||||
|
||||
if (!lookup_commit_checksum_and_collection_from_summary (pull_data, ref, &contents, &commit_size, &collection_id, error))
|
||||
if (!lookup_commit_checksum_and_collection_from_summary (pull_data, ref, &checksum, &commit_size, &collection_id, error))
|
||||
goto out;
|
||||
|
||||
ref_with_collection = ostree_collection_ref_new (collection_id, ref->ref_name);
|
||||
|
||||
malloced_size = g_new0 (guint64, 1);
|
||||
*malloced_size = commit_size;
|
||||
g_hash_table_insert (pull_data->expected_commit_sizes, g_strdup (contents), malloced_size);
|
||||
g_hash_table_insert (pull_data->expected_commit_sizes, g_strdup (checksum), malloced_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!fetch_ref_contents (pull_data, main_collection_id, ref, &contents, cancellable, error))
|
||||
if (!fetch_ref_contents (pull_data, main_collection_id, ref, &checksum, cancellable, error))
|
||||
goto out;
|
||||
|
||||
ref_with_collection = ostree_collection_ref_dup (ref);
|
||||
}
|
||||
|
||||
/* If we have timestamp checking enabled, find the current value of
|
||||
* the ref, and store its timestamp in the hash map, to check later.
|
||||
*/
|
||||
if (pull_data->timestamp_check)
|
||||
{
|
||||
g_autofree char *from_rev = NULL;
|
||||
if (!ostree_repo_resolve_rev (pull_data->repo, ref_with_collection->ref_name, TRUE,
|
||||
&from_rev, error))
|
||||
goto out;
|
||||
/* Explicitly store NULL if there's no previous revision. We do
|
||||
* this so we can assert() if we somehow didn't find a ref in the
|
||||
* hash at all. Note we don't copy the collection-ref, so the
|
||||
* lifetime of this hash must be equal to `requested_refs_to_fetch`.
|
||||
*/
|
||||
g_hash_table_insert (pull_data->ref_original_commits, ref_with_collection,
|
||||
g_steal_pointer (&from_rev));
|
||||
}
|
||||
|
||||
g_hash_table_replace (updated_requested_refs_to_fetch,
|
||||
g_steal_pointer (&ref_with_collection),
|
||||
g_steal_pointer (&contents));
|
||||
}
|
||||
|
||||
/* If we have timestamp checking enabled, find the current value of
|
||||
* the ref, and store its timestamp in the hash map, to check later.
|
||||
*/
|
||||
if (pull_data->timestamp_check)
|
||||
{
|
||||
g_autofree char *from_rev = NULL;
|
||||
if (!ostree_repo_resolve_rev (pull_data->repo, ref_with_collection->ref_name, TRUE,
|
||||
&from_rev, error))
|
||||
goto out;
|
||||
/* Explicitly store NULL if there's no previous revision. We do
|
||||
* this so we can assert() if we somehow didn't find a ref in the
|
||||
* hash at all. Note we don't copy the collection-ref, so the
|
||||
* lifetime of this hash must be equal to `requested_refs_to_fetch`.
|
||||
*/
|
||||
g_hash_table_insert (pull_data->ref_original_commits, ref_with_collection,
|
||||
g_steal_pointer (&from_rev));
|
||||
}
|
||||
|
||||
g_hash_table_replace (updated_requested_refs_to_fetch,
|
||||
g_steal_pointer (&ref_with_collection),
|
||||
g_steal_pointer (&checksum));
|
||||
}
|
||||
|
||||
g_hash_table_unref (requested_refs_to_fetch);
|
||||
@@ -4613,17 +4644,23 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
g_string_append_printf (msg, "libostree pull from '%s' for %u refs complete",
|
||||
pull_data->remote_name, g_hash_table_size (requested_refs_to_fetch));
|
||||
|
||||
const char *gpg_verify_state;
|
||||
const char *verify_state;
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
if (pull_data->gpg_verify_summary)
|
||||
{
|
||||
if (pull_data->gpg_verify)
|
||||
gpg_verify_state = "summary+commit";
|
||||
verify_state = "summary+commit";
|
||||
else
|
||||
gpg_verify_state = "summary-only";
|
||||
verify_state = "summary-only";
|
||||
}
|
||||
else
|
||||
gpg_verify_state = (pull_data->gpg_verify ? "commit" : "disabled");
|
||||
g_string_append_printf (msg, "\nsecurity: GPG: %s ", gpg_verify_state);
|
||||
verify_state = (pull_data->gpg_verify ? "commit" : "disabled");
|
||||
g_string_append_printf (msg, "\nsecurity: GPG: %s ", verify_state);
|
||||
#else
|
||||
verify_state = "disabled";
|
||||
g_string_append_printf (msg, "\nsecurity: %s ", verify_state);
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
OstreeFetcherURI *first_uri = pull_data->meta_mirrorlist->pdata[0];
|
||||
g_autofree char *first_scheme = _ostree_fetcher_uri_get_scheme (first_uri);
|
||||
if (g_str_has_prefix (first_scheme, "http"))
|
||||
@@ -4658,7 +4695,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
ot_journal_send ("MESSAGE=%s", msg->str,
|
||||
"MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_MESSAGE_FETCH_COMPLETE_ID),
|
||||
"OSTREE_REMOTE=%s", pull_data->remote_name,
|
||||
"OSTREE_GPG=%s", gpg_verify_state,
|
||||
"OSTREE_GPG=%s", verify_state,
|
||||
"OSTREE_SECONDS=%u", n_seconds,
|
||||
"OSTREE_XFER_SIZE=%s", formatted_xferred,
|
||||
NULL);
|
||||
@@ -4718,7 +4755,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
g_clear_pointer (&pull_data->fetched_detached_metadata, (GDestroyNotify) g_hash_table_unref);
|
||||
g_clear_pointer (&pull_data->summary_deltas_checksums, (GDestroyNotify) g_hash_table_unref);
|
||||
g_clear_pointer (&pull_data->ref_original_commits, (GDestroyNotify) g_hash_table_unref);
|
||||
g_clear_pointer (&pull_data->gpg_verified_commits, (GDestroyNotify) g_hash_table_unref);
|
||||
g_clear_pointer (&pull_data->verified_commits, (GDestroyNotify) g_hash_table_unref);
|
||||
g_clear_pointer (&pull_data->ref_keyring_map, (GDestroyNotify) g_hash_table_unref);
|
||||
g_clear_pointer (&pull_data->requested_content, (GDestroyNotify) g_hash_table_unref);
|
||||
g_clear_pointer (&pull_data->requested_fallback_content, (GDestroyNotify) g_hash_table_unref);
|
||||
@@ -5970,7 +6007,11 @@ ostree_repo_pull_from_remotes_async (OstreeRepo *self,
|
||||
|
||||
g_variant_dict_insert (&local_options_dict, "flags", "i", OSTREE_REPO_PULL_FLAGS_UNTRUSTED | flags);
|
||||
g_variant_dict_insert_value (&local_options_dict, "collection-refs", g_variant_builder_end (&refs_to_pull_builder));
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
g_variant_dict_insert (&local_options_dict, "gpg-verify", "b", TRUE);
|
||||
#else
|
||||
g_variant_dict_insert (&local_options_dict, "gpg-verify", "b", FALSE);
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
g_variant_dict_insert (&local_options_dict, "gpg-verify-summary", "b", FALSE);
|
||||
g_variant_dict_insert (&local_options_dict, "inherit-transaction", "b", TRUE);
|
||||
if (result->remote->refspec_name != NULL)
|
||||
@@ -6103,6 +6144,8 @@ ostree_repo_pull_from_remotes_finish (OstreeRepo *self,
|
||||
* means return errors without retrying
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE on failure
|
||||
*
|
||||
* Since: 2016.6
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_remote_fetch_summary_with_options (OstreeRepo *self,
|
||||
@@ -6116,8 +6159,10 @@ ostree_repo_remote_fetch_summary_with_options (OstreeRepo *self,
|
||||
g_autofree char *metalink_url_string = NULL;
|
||||
g_autoptr(GBytes) summary = NULL;
|
||||
g_autoptr(GBytes) signatures = NULL;
|
||||
gboolean ret = FALSE;
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
gboolean gpg_verify_summary;
|
||||
#endif
|
||||
gboolean ret = FALSE;
|
||||
gboolean summary_is_from_cache;
|
||||
|
||||
g_return_val_if_fail (OSTREE_REPO (self), FALSE);
|
||||
@@ -6138,6 +6183,7 @@ ostree_repo_remote_fetch_summary_with_options (OstreeRepo *self,
|
||||
error))
|
||||
goto out;
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
if (!ostree_repo_remote_get_gpg_verify_summary (self, name, &gpg_verify_summary, error))
|
||||
goto out;
|
||||
|
||||
@@ -6191,6 +6237,10 @@ ostree_repo_remote_fetch_summary_with_options (OstreeRepo *self,
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
g_message ("%s: GPG feature is disabled in a build time", __FUNCTION__);
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
if (out_summary != NULL)
|
||||
*out_summary = g_steal_pointer (&summary);
|
||||
|
||||
|
||||
@@ -482,6 +482,8 @@ ostree_repo_resolve_rev (OstreeRepo *self,
|
||||
*
|
||||
* The flag %OSTREE_REPO_RESOLVE_REV_EXT_LOCAL_ONLY is implied so
|
||||
* using it has no effect.
|
||||
*
|
||||
* Since: 2016.7
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_resolve_rev_ext (OstreeRepo *self,
|
||||
@@ -856,6 +858,8 @@ ostree_repo_list_refs (OstreeRepo *self,
|
||||
* @out_all_refs will be returned as a mapping from refspecs (including the
|
||||
* remote name) to checksums. Differently from ostree_repo_list_refs(), the
|
||||
* @refspec_prefix will not be removed from the refspecs in the hash table.
|
||||
*
|
||||
* Since: 2016.4
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_list_refs_ext (OstreeRepo *self,
|
||||
|
||||
+140
-13
@@ -139,9 +139,11 @@ G_STATIC_ASSERT(sizeof(OstreeRepoPruneOptions) ==
|
||||
typedef struct {
|
||||
GObjectClass parent_class;
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
void (*gpg_verify_result) (OstreeRepo *self,
|
||||
const char *checksum,
|
||||
OstreeGpgVerifyResult *result);
|
||||
#endif
|
||||
} OstreeRepoClass;
|
||||
|
||||
enum {
|
||||
@@ -157,7 +159,9 @@ enum {
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
#endif
|
||||
|
||||
G_DEFINE_TYPE (OstreeRepo, ostree_repo, G_TYPE_OBJECT)
|
||||
|
||||
@@ -786,6 +790,8 @@ _ostree_repo_remote_name_is_file (const char *remote_name)
|
||||
* option name. If an error is returned, @out_value will be set to %NULL.
|
||||
*
|
||||
* Returns: %TRUE on success, otherwise %FALSE with @error set
|
||||
*
|
||||
* Since: 2016.5
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_get_remote_option (OstreeRepo *self,
|
||||
@@ -864,6 +870,8 @@ ostree_repo_get_remote_option (OstreeRepo *self,
|
||||
* to %NULL.
|
||||
*
|
||||
* Returns: %TRUE on success, otherwise %FALSE with @error set
|
||||
*
|
||||
* Since: 2016.5
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_get_remote_list_option (OstreeRepo *self,
|
||||
@@ -939,6 +947,8 @@ ostree_repo_get_remote_list_option (OstreeRepo *self,
|
||||
* error is returned, @out_value will be set to %FALSE.
|
||||
*
|
||||
* Returns: %TRUE on success, otherwise %FALSE with @error set
|
||||
*
|
||||
* Since: 2016.5
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_get_remote_boolean_option (OstreeRepo *self,
|
||||
@@ -1161,6 +1171,7 @@ ostree_repo_class_init (OstreeRepoClass *klass)
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
/**
|
||||
* OstreeRepo::gpg-verify-result:
|
||||
* @self: an #OstreeRepo
|
||||
@@ -1183,23 +1194,27 @@ ostree_repo_class_init (OstreeRepoClass *klass)
|
||||
G_TYPE_NONE, 2,
|
||||
G_TYPE_STRING,
|
||||
OSTREE_TYPE_GPG_VERIFY_RESULT);
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
}
|
||||
|
||||
static void
|
||||
ostree_repo_init (OstreeRepo *self)
|
||||
{
|
||||
static gsize gpgme_initialized;
|
||||
const GDebugKey test_error_keys[] = {
|
||||
{ "pre-commit", OSTREE_REPO_TEST_ERROR_PRE_COMMIT },
|
||||
{ "invalid-cache", OSTREE_REPO_TEST_ERROR_INVALID_CACHE },
|
||||
};
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
static gsize gpgme_initialized;
|
||||
|
||||
if (g_once_init_enter (&gpgme_initialized))
|
||||
{
|
||||
gpgme_check_version (NULL);
|
||||
gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL));
|
||||
g_once_init_leave (&gpgme_initialized, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
self->test_error_flags = g_parse_debug_string (g_getenv ("OSTREE_REPO_TEST_ERROR"),
|
||||
test_error_keys, G_N_ELEMENTS (test_error_keys));
|
||||
@@ -1255,6 +1270,8 @@ repo_open_at_take_fd (int *dfd,
|
||||
* already extant repository. If you want to create one, use ostree_repo_create_at().
|
||||
*
|
||||
* Returns: (transfer full): An accessor object for an OSTree repository located at @dfd + @path
|
||||
*
|
||||
* Since: 2017.10
|
||||
*/
|
||||
OstreeRepo*
|
||||
ostree_repo_open_at (int dfd,
|
||||
@@ -2009,8 +2026,17 @@ ostree_repo_remote_get_gpg_verify (OstreeRepo *self,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return ostree_repo_get_remote_boolean_option (self, name, "gpg-verify",
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
return ostree_repo_get_remote_boolean_option (self, name, "gpg-verify",
|
||||
TRUE, out_gpg_verify, error);
|
||||
#else
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"'%s': GPG feature is disabled in a build time",
|
||||
__FUNCTION__);
|
||||
if (out_gpg_verify != NULL)
|
||||
*out_gpg_verify = FALSE;
|
||||
return FALSE;
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2032,17 +2058,26 @@ ostree_repo_remote_get_gpg_verify_summary (OstreeRepo *self,
|
||||
gboolean *out_gpg_verify_summary,
|
||||
GError **error)
|
||||
{
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
return ostree_repo_get_remote_boolean_option (self, name, "gpg-verify-summary",
|
||||
FALSE, out_gpg_verify_summary, error);
|
||||
#else
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"'%s': GPG feature is disabled in a build time",
|
||||
__FUNCTION__);
|
||||
if (out_gpg_verify_summary != NULL)
|
||||
*out_gpg_verify_summary = FALSE;
|
||||
return FALSE;
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_repo_remote_gpg_import:
|
||||
* @self: Self
|
||||
* @name: name of a remote
|
||||
* @source_stream: (allow-none): a #GInputStream, or %NULL
|
||||
* @key_ids: (array zero-terminated=1) (element-type utf8) (allow-none): a %NULL-terminated array of GPG key IDs, or %NULL
|
||||
* @out_imported: (allow-none): return location for the number of imported
|
||||
* @source_stream: (nullable): a #GInputStream, or %NULL
|
||||
* @key_ids: (array zero-terminated=1) (element-type utf8) (nullable): a %NULL-terminated array of GPG key IDs, or %NULL
|
||||
* @out_imported: (out) (optional): return location for the number of imported
|
||||
* keys, or %NULL
|
||||
* @cancellable: a #GCancellable
|
||||
* @error: a #GError
|
||||
@@ -2066,6 +2101,7 @@ ostree_repo_remote_gpg_import (OstreeRepo *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
OstreeRemote *remote;
|
||||
g_auto(gpgme_ctx_t) source_context = NULL;
|
||||
g_auto(gpgme_ctx_t) target_context = NULL;
|
||||
@@ -2292,15 +2328,25 @@ out:
|
||||
if (remote != NULL)
|
||||
ostree_remote_unref (remote);
|
||||
|
||||
if (source_tmp_dir != NULL)
|
||||
if (source_tmp_dir != NULL) {
|
||||
ot_gpgme_kill_agent (source_tmp_dir);
|
||||
(void) glnx_shutil_rm_rf_at (AT_FDCWD, source_tmp_dir, NULL, NULL);
|
||||
}
|
||||
|
||||
if (target_tmp_dir != NULL)
|
||||
if (target_tmp_dir != NULL) {
|
||||
ot_gpgme_kill_agent (target_tmp_dir);
|
||||
(void) glnx_shutil_rm_rf_at (AT_FDCWD, target_tmp_dir, NULL, NULL);
|
||||
}
|
||||
|
||||
g_prefix_error (error, "GPG: ");
|
||||
|
||||
return ret;
|
||||
#else /* OSTREE_DISABLE_GPGME */
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"'%s': GPG feature is disabled in a build time",
|
||||
__FUNCTION__);
|
||||
return FALSE;
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2377,6 +2423,12 @@ ostree_repo_mode_to_string (OstreeRepoMode mode,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_repo_mode_from_string:
|
||||
* @mode: a repo mode as a string
|
||||
* @out_mode: (out): the corresponding #OstreeRepoMode
|
||||
* @error: a #GError if the string is not a valid mode
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_mode_from_string (const char *mode,
|
||||
OstreeRepoMode *out_mode,
|
||||
@@ -2570,6 +2622,8 @@ ostree_repo_create (OstreeRepo *self,
|
||||
* - collection-id: s: Set as collection ID in repo/config (Since 2017.9)
|
||||
*
|
||||
* Returns: (transfer full): A new OSTree repository reference
|
||||
*
|
||||
* Since: 2017.10
|
||||
*/
|
||||
OstreeRepo *
|
||||
ostree_repo_create_at (int dfd,
|
||||
@@ -3149,6 +3203,8 @@ reload_sysroot_config (OstreeRepo *self,
|
||||
*
|
||||
* By default, an #OstreeRepo will cache the remote configuration and its
|
||||
* own repo/config data. This API can be used to reload it.
|
||||
*
|
||||
* Since: 2017.2
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_reload_config (OstreeRepo *self,
|
||||
@@ -3313,6 +3369,8 @@ ostree_repo_set_disable_fsync (OstreeRepo *self,
|
||||
* per-remote summary caches. Setting this manually is useful when
|
||||
* doing operations on a system repo as a user because you don't have
|
||||
* write permissions in the repo, where the cache is normally stored.
|
||||
*
|
||||
* Since: 2016.5
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_set_cache_dir (OstreeRepo *self,
|
||||
@@ -3394,6 +3452,7 @@ ostree_repo_get_path (OstreeRepo *self)
|
||||
* repository (to see whether a ref was written).
|
||||
*
|
||||
* Returns: File descriptor for repository root - owned by @self
|
||||
* Since: 2016.4
|
||||
*/
|
||||
int
|
||||
ostree_repo_get_dfd (OstreeRepo *self)
|
||||
@@ -3466,12 +3525,15 @@ ostree_repo_get_mode (OstreeRepo *self)
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_repo_get_min_free_space:
|
||||
* ostree_repo_get_min_free_space_bytes:
|
||||
* @self: Repo
|
||||
* @out_reserved_bytes: (out): Location to store the result
|
||||
* @error: Return location for a #GError
|
||||
*
|
||||
* It can be used to query the value (in bytes) of min-free-space-* config option.
|
||||
* Determine the number of bytes of free disk space that are reserved according
|
||||
* to the repo config and return that number in @out_reserved_bytes. See the
|
||||
* documentation for the core.min-free-space-size and
|
||||
* core.min-free-space-percent repo config options.
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE otherwise.
|
||||
* Since: 2018.9
|
||||
@@ -3576,7 +3638,7 @@ list_loose_objects_at (OstreeRepo *self,
|
||||
if (objtype != OSTREE_OBJECT_TYPE_COMMIT)
|
||||
continue;
|
||||
|
||||
/* commit checksum does not match "starting with", do not add to array */
|
||||
/* commit checksum does not match "starting with", do not add to array */
|
||||
if (!g_str_has_prefix (buf, commit_starting_with))
|
||||
continue;
|
||||
}
|
||||
@@ -4334,6 +4396,8 @@ ostree_repo_import_object_from (OstreeRepo *self,
|
||||
* this will simply be a fast Unix hard link operation.
|
||||
*
|
||||
* Otherwise, a copy will be performed.
|
||||
*
|
||||
* Since: 2016.5
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_import_object_from_with_trust (OstreeRepo *self,
|
||||
@@ -4446,7 +4510,7 @@ ostree_repo_load_variant (OstreeRepo *self,
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_load_commit (OstreeRepo *self,
|
||||
const char *checksum,
|
||||
const char *checksum,
|
||||
GVariant **out_variant,
|
||||
OstreeRepoCommitState *out_state,
|
||||
GError **error)
|
||||
@@ -4874,6 +4938,7 @@ ostree_repo_append_gpg_signature (OstreeRepo *self,
|
||||
error))
|
||||
return FALSE;
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
g_autoptr(GVariant) new_metadata =
|
||||
_ostree_detached_metadata_append_gpg_sig (metadata, signature_bytes);
|
||||
|
||||
@@ -4885,8 +4950,15 @@ ostree_repo_append_gpg_signature (OstreeRepo *self,
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
#else
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"'%s': GPG feature is disabled in a build time",
|
||||
__FUNCTION__);
|
||||
return FALSE;
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
}
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
static gboolean
|
||||
sign_data (OstreeRepo *self,
|
||||
GBytes *input_data,
|
||||
@@ -4947,6 +5019,7 @@ sign_data (OstreeRepo *self,
|
||||
*out_signature = g_mapped_file_get_bytes (signature_file);
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
/**
|
||||
* ostree_repo_sign_commit:
|
||||
@@ -4967,6 +5040,7 @@ ostree_repo_sign_commit (OstreeRepo *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
g_autoptr(GBytes) commit_data = NULL;
|
||||
g_autoptr(GBytes) signature = NULL;
|
||||
|
||||
@@ -5030,6 +5104,10 @@ ostree_repo_sign_commit (OstreeRepo *self,
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
#else
|
||||
/* FIXME: Return false until refactoring */
|
||||
return FALSE;
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5076,6 +5154,7 @@ ostree_repo_add_gpg_signature_summary (OstreeRepo *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
glnx_autofd int fd = -1;
|
||||
if (!glnx_openat_rdonly (self->repo_dir_fd, "summary", TRUE, &fd, error))
|
||||
return FALSE;
|
||||
@@ -5118,8 +5197,15 @@ ostree_repo_add_gpg_signature_summary (OstreeRepo *self,
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
#else
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"'%s': GPG feature is disabled in a build time",
|
||||
__FUNCTION__);
|
||||
return FALSE;
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
}
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
/* Special remote for _ostree_repo_gpg_verify_with_metadata() */
|
||||
static const char *OSTREE_ALL_REMOTES = "__OSTREE_ALL_REMOTES__";
|
||||
|
||||
@@ -5353,6 +5439,7 @@ _ostree_repo_verify_commit_internal (OstreeRepo *self,
|
||||
keyringdir, extra_keyring,
|
||||
cancellable, error);
|
||||
}
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
/**
|
||||
* ostree_repo_verify_commit:
|
||||
@@ -5376,6 +5463,7 @@ ostree_repo_verify_commit (OstreeRepo *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
g_autoptr(OstreeGpgVerifyResult) result = NULL;
|
||||
|
||||
result = ostree_repo_verify_commit_ext (self, commit_checksum,
|
||||
@@ -5385,6 +5473,13 @@ ostree_repo_verify_commit (OstreeRepo *self,
|
||||
if (!ostree_gpg_verify_result_require_valid_signature (result, error))
|
||||
return glnx_prefix_error (error, "Commit %s", commit_checksum);
|
||||
return TRUE;
|
||||
#else
|
||||
/* FIXME: Return false until refactoring */
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"'%s': GPG feature is disabled in a build time",
|
||||
__FUNCTION__);
|
||||
return FALSE;
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5409,6 +5504,7 @@ ostree_repo_verify_commit_ext (OstreeRepo *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
return _ostree_repo_verify_commit_internal (self,
|
||||
commit_checksum,
|
||||
NULL,
|
||||
@@ -5416,6 +5512,12 @@ ostree_repo_verify_commit_ext (OstreeRepo *self,
|
||||
extra_keyring,
|
||||
cancellable,
|
||||
error);
|
||||
#else
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"'%s': GPG feature is disabled in a build time",
|
||||
__FUNCTION__);
|
||||
return NULL;
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5431,6 +5533,8 @@ ostree_repo_verify_commit_ext (OstreeRepo *self,
|
||||
* configured for @remote.
|
||||
*
|
||||
* Returns: (transfer full): an #OstreeGpgVerifyResult, or %NULL on error
|
||||
*
|
||||
* Since: 2016.14
|
||||
*/
|
||||
OstreeGpgVerifyResult *
|
||||
ostree_repo_verify_commit_for_remote (OstreeRepo *self,
|
||||
@@ -5439,6 +5543,7 @@ ostree_repo_verify_commit_for_remote (OstreeRepo *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
return _ostree_repo_verify_commit_internal (self,
|
||||
commit_checksum,
|
||||
remote_name,
|
||||
@@ -5446,6 +5551,12 @@ ostree_repo_verify_commit_for_remote (OstreeRepo *self,
|
||||
NULL,
|
||||
cancellable,
|
||||
error);
|
||||
#else
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"'%s': GPG feature is disabled in a build time",
|
||||
__FUNCTION__);
|
||||
return NULL;
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5466,6 +5577,8 @@ ostree_repo_verify_commit_for_remote (OstreeRepo *self,
|
||||
* the verifications using GPG keys in the keyrings of all remotes.
|
||||
*
|
||||
* Returns: (transfer full): an #OstreeGpgVerifyResult, or %NULL on error
|
||||
*
|
||||
* Since: 2016.6
|
||||
*/
|
||||
OstreeGpgVerifyResult *
|
||||
ostree_repo_gpg_verify_data (OstreeRepo *self,
|
||||
@@ -5481,6 +5594,7 @@ ostree_repo_gpg_verify_data (OstreeRepo *self,
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
g_return_val_if_fail (signatures != NULL, NULL);
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
return _ostree_repo_gpg_verify_data_internal (self,
|
||||
(remote_name != NULL) ? remote_name : OSTREE_ALL_REMOTES,
|
||||
data,
|
||||
@@ -5489,6 +5603,12 @@ ostree_repo_gpg_verify_data (OstreeRepo *self,
|
||||
extra_keyring,
|
||||
cancellable,
|
||||
error);
|
||||
#else
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"'%s': GPG feature is disabled in a build time",
|
||||
__FUNCTION__);
|
||||
return NULL;
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5523,6 +5643,7 @@ ostree_repo_verify_summary (OstreeRepo *self,
|
||||
signatures_variant = g_variant_new_from_bytes (OSTREE_SUMMARY_SIG_GVARIANT_FORMAT,
|
||||
signatures, FALSE);
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
return _ostree_repo_gpg_verify_with_metadata (self,
|
||||
summary,
|
||||
signatures_variant,
|
||||
@@ -5530,6 +5651,12 @@ ostree_repo_verify_summary (OstreeRepo *self,
|
||||
NULL, NULL,
|
||||
cancellable,
|
||||
error);
|
||||
#else
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"'%s': GPG feature is disabled in a build time",
|
||||
__FUNCTION__);
|
||||
return NULL;
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
}
|
||||
|
||||
/* Add an entry for a @ref ↦ @checksum mapping to an `a(s(t@ay@a{sv}))`
|
||||
@@ -6098,10 +6225,10 @@ ostree_repo_get_default_repo_finders (OstreeRepo *self)
|
||||
/**
|
||||
* ostree_repo_get_bootloader:
|
||||
* @self: an #OstreeRepo
|
||||
*
|
||||
*
|
||||
* Get the bootloader configured. See the documentation for the
|
||||
* "sysroot.bootloader" config key.
|
||||
*
|
||||
*
|
||||
* Returns: bootloader configuration for the sysroot
|
||||
* Since: 2019.2
|
||||
*/
|
||||
|
||||
+44
-34
@@ -199,18 +199,6 @@ gboolean ostree_repo_remote_get_url (OstreeRepo *self,
|
||||
char **out_url,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_repo_remote_get_gpg_verify (OstreeRepo *self,
|
||||
const char *name,
|
||||
gboolean *out_gpg_verify,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_repo_remote_get_gpg_verify_summary (OstreeRepo *self,
|
||||
const char *name,
|
||||
gboolean *out_gpg_verify_summary,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_repo_get_remote_option (OstreeRepo *self,
|
||||
const char *remote_name,
|
||||
@@ -234,14 +222,6 @@ gboolean ostree_repo_get_remote_boolean_option (OstreeRepo *self,
|
||||
gboolean *out_value,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_repo_remote_gpg_import (OstreeRepo *self,
|
||||
const char *name,
|
||||
GInputStream *source_stream,
|
||||
const char * const *key_ids,
|
||||
guint *out_imported,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_repo_remote_fetch_summary (OstreeRepo *self,
|
||||
@@ -737,6 +717,16 @@ gboolean ostree_repo_write_archive_to_mtree (OstreeRepo *
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_repo_write_archive_to_mtree_from_fd (OstreeRepo *self,
|
||||
int fd,
|
||||
OstreeMutableTree *mtree,
|
||||
OstreeRepoCommitModifier *modifier,
|
||||
gboolean autocreate_parents,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
/**
|
||||
* OstreeRepoImportArchiveTranslatePathname:
|
||||
* @repo: Repo
|
||||
@@ -1327,20 +1317,6 @@ gboolean ostree_repo_sign_delta (OstreeRepo *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean
|
||||
ostree_repo_add_gpg_signature_summary (OstreeRepo *self,
|
||||
const gchar **key_id,
|
||||
const gchar *homedir,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_repo_append_gpg_signature (OstreeRepo *self,
|
||||
const gchar *commit_checksum,
|
||||
GBytes *signature_bytes,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_repo_verify_commit (OstreeRepo *self,
|
||||
@@ -1350,6 +1326,40 @@ gboolean ostree_repo_verify_commit (OstreeRepo *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_repo_remote_get_gpg_verify (OstreeRepo *self,
|
||||
const char *name,
|
||||
gboolean *out_gpg_verify,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_repo_remote_get_gpg_verify_summary (OstreeRepo *self,
|
||||
const char *name,
|
||||
gboolean *out_gpg_verify_summary,
|
||||
GError **error);
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_repo_remote_gpg_import (OstreeRepo *self,
|
||||
const char *name,
|
||||
GInputStream *source_stream,
|
||||
const char * const *key_ids,
|
||||
guint *out_imported,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_repo_add_gpg_signature_summary (OstreeRepo *self,
|
||||
const gchar **key_id,
|
||||
const gchar *homedir,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
gboolean ostree_repo_append_gpg_signature (OstreeRepo *self,
|
||||
const gchar *commit_checksum,
|
||||
GBytes *signature_bytes,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
OstreeGpgVerifyResult * ostree_repo_verify_commit_ext (OstreeRepo *self,
|
||||
const gchar *commit_checksum,
|
||||
|
||||
@@ -351,7 +351,7 @@ initable_init (GInitable *initable,
|
||||
|
||||
if (g_str_has_prefix (line, selinuxtype_prefix))
|
||||
{
|
||||
policytype = g_strstrip (g_strdup (line + strlen (selinuxtype_prefix)));
|
||||
policytype = g_strstrip (g_strdup (line + strlen (selinuxtype_prefix)));
|
||||
policy_root = g_file_get_child (etc_selinux_dir, policytype);
|
||||
}
|
||||
else if (g_str_has_prefix (line, selinux_prefix))
|
||||
@@ -430,6 +430,8 @@ ostree_sepolicy_new (GFile *path,
|
||||
* @error: Error
|
||||
*
|
||||
* Returns: (transfer full): An accessor object for SELinux policy in root located at @rootfs_dfd
|
||||
*
|
||||
* Since: 2017.4
|
||||
*/
|
||||
OstreeSePolicy*
|
||||
ostree_sepolicy_new_at (int rootfs_dfd,
|
||||
@@ -472,6 +474,8 @@ ostree_sepolicy_get_name (OstreeSePolicy *self)
|
||||
* @self:
|
||||
*
|
||||
* Returns: (transfer none): Checksum of current policy
|
||||
*
|
||||
* Since: 2016.5
|
||||
*/
|
||||
const char *
|
||||
ostree_sepolicy_get_csum (OstreeSePolicy *self)
|
||||
|
||||
@@ -1374,7 +1374,7 @@ fsfreeze_thaw_cycle (OstreeSysroot *self,
|
||||
* the filesystem is already frozen (EBUSY).
|
||||
* OK, let's just do a syncfs.
|
||||
*/
|
||||
if (G_IN_SET (errno, EOPNOTSUPP, EPERM, EBUSY))
|
||||
if (G_IN_SET (errno, EOPNOTSUPP, ENOSYS, EPERM, EBUSY))
|
||||
{
|
||||
/* Warn if the filesystem was already frozen */
|
||||
if (errno == EBUSY)
|
||||
@@ -1759,7 +1759,7 @@ install_deployment_kernel (OstreeSysroot *sysroot,
|
||||
ostree_bootconfig_parser_set (bootconfig, "linux", boot_relpath);
|
||||
|
||||
val = ostree_bootconfig_parser_get (bootconfig, "options");
|
||||
g_autoptr(OstreeKernelArgs) kargs = _ostree_kernel_args_from_string (val);
|
||||
g_autoptr(OstreeKernelArgs) kargs = ostree_kernel_args_from_string (val);
|
||||
|
||||
if (kernel_layout->initramfs_namever)
|
||||
{
|
||||
@@ -1772,7 +1772,7 @@ install_deployment_kernel (OstreeSysroot *sysroot,
|
||||
prepare_root_arg = g_strdup_printf ("init=/ostree/boot.%d/%s/%s/%d/usr/lib/ostree/ostree-prepare-root",
|
||||
new_bootversion, osname, bootcsum,
|
||||
ostree_deployment_get_bootserial (deployment));
|
||||
_ostree_kernel_args_replace_take (kargs, g_steal_pointer (&prepare_root_arg));
|
||||
ostree_kernel_args_replace_take (kargs, g_steal_pointer (&prepare_root_arg));
|
||||
}
|
||||
|
||||
if (kernel_layout->devicetree_namever)
|
||||
@@ -1785,9 +1785,9 @@ install_deployment_kernel (OstreeSysroot *sysroot,
|
||||
g_autofree char *ostree_kernel_arg = g_strdup_printf ("ostree=/ostree/boot.%d/%s/%s/%d",
|
||||
new_bootversion, osname, bootcsum,
|
||||
ostree_deployment_get_bootserial (deployment));
|
||||
_ostree_kernel_args_replace_take (kargs, g_steal_pointer (&ostree_kernel_arg));
|
||||
ostree_kernel_args_replace_take (kargs, g_steal_pointer (&ostree_kernel_arg));
|
||||
|
||||
g_autofree char *options_key = _ostree_kernel_args_to_string (kargs);
|
||||
g_autofree char *options_key = ostree_kernel_args_to_string (kargs);
|
||||
ostree_bootconfig_parser_set (bootconfig, "options", options_key);
|
||||
|
||||
glnx_autofd int bootconf_dfd = -1;
|
||||
@@ -1895,9 +1895,9 @@ get_deployment_nonostree_kargs (OstreeDeployment *deployment)
|
||||
/* pick up kernel arguments but filter out ostree= */
|
||||
OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (deployment);
|
||||
const char *boot_options = ostree_bootconfig_parser_get (bootconfig, "options");
|
||||
g_autoptr(OstreeKernelArgs) kargs = _ostree_kernel_args_from_string (boot_options);
|
||||
_ostree_kernel_args_replace (kargs, "ostree");
|
||||
return _ostree_kernel_args_to_string (kargs);
|
||||
g_autoptr(OstreeKernelArgs) kargs = ostree_kernel_args_from_string (boot_options);
|
||||
ostree_kernel_args_replace (kargs, "ostree");
|
||||
return ostree_kernel_args_to_string (kargs);
|
||||
}
|
||||
|
||||
static char*
|
||||
@@ -2170,6 +2170,8 @@ write_deployments_finish (OstreeSysroot *self,
|
||||
* ostree_sysroot_cleanup() at some point after the transaction, or specify
|
||||
* `do_postclean` in @opts. Skipping the post-transaction cleanup is useful
|
||||
* if for example you want to control pruning of the repository.
|
||||
*
|
||||
* Since: 2017.4
|
||||
*/
|
||||
gboolean
|
||||
ostree_sysroot_write_deployments_with_options (OstreeSysroot *self,
|
||||
@@ -2461,9 +2463,9 @@ _ostree_deployment_set_bootconfig_from_kargs (OstreeDeployment *deployment,
|
||||
*/
|
||||
if (override_kernel_argv)
|
||||
{
|
||||
g_autoptr(OstreeKernelArgs) kargs = _ostree_kernel_args_new ();
|
||||
_ostree_kernel_args_append_argv (kargs, override_kernel_argv);
|
||||
g_autofree char *new_options = _ostree_kernel_args_to_string (kargs);
|
||||
g_autoptr(OstreeKernelArgs) kargs = ostree_kernel_args_new ();
|
||||
ostree_kernel_args_append_argv (kargs, override_kernel_argv);
|
||||
g_autofree char *new_options = ostree_kernel_args_to_string (kargs);
|
||||
ostree_bootconfig_parser_set (bootconfig, "options", new_options);
|
||||
}
|
||||
}
|
||||
@@ -2756,6 +2758,8 @@ _ostree_sysroot_deserialize_deployment_from_variant (GVariant *v,
|
||||
*
|
||||
* Like ostree_sysroot_deploy_tree(), but "finalization" only occurs at OS
|
||||
* shutdown time.
|
||||
*
|
||||
* Since: 2018.5
|
||||
*/
|
||||
gboolean
|
||||
ostree_sysroot_stage_tree (OstreeSysroot *self,
|
||||
@@ -3000,9 +3004,9 @@ ostree_sysroot_deployment_set_kargs (OstreeSysroot *self,
|
||||
g_autoptr(OstreeDeployment) new_deployment = ostree_deployment_clone (deployment);
|
||||
OstreeBootconfigParser *new_bootconfig = ostree_deployment_get_bootconfig (new_deployment);
|
||||
|
||||
g_autoptr(OstreeKernelArgs) kargs = _ostree_kernel_args_new ();
|
||||
_ostree_kernel_args_append_argv (kargs, new_kargs);
|
||||
g_autofree char *new_options = _ostree_kernel_args_to_string (kargs);
|
||||
g_autoptr(OstreeKernelArgs) kargs = ostree_kernel_args_new ();
|
||||
ostree_kernel_args_append_argv (kargs, new_kargs);
|
||||
g_autofree char *new_options = ostree_kernel_args_to_string (kargs);
|
||||
ostree_bootconfig_parser_set (new_bootconfig, "options", new_options);
|
||||
|
||||
g_autoptr(GPtrArray) new_deployments = g_ptr_array_new_with_free_func (g_object_unref);
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include "libglnx.h"
|
||||
#include "ostree.h"
|
||||
#include "ostree-kernel-args.h"
|
||||
#include "ostree-bootloader.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -855,6 +855,15 @@ _ostree_sysroot_reload_staged (OstreeSysroot *self,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_sysroot_load_if_changed:
|
||||
* @self: #OstreeSysroot
|
||||
* @out_changed: (out caller-allocates):
|
||||
* @cancellable: Cancellable
|
||||
* @error: Error
|
||||
*
|
||||
* Since: 2016.4
|
||||
*/
|
||||
gboolean
|
||||
ostree_sysroot_load_if_changed (OstreeSysroot *self,
|
||||
gboolean *out_changed,
|
||||
@@ -1033,6 +1042,8 @@ ostree_sysroot_get_booted_deployment (OstreeSysroot *self)
|
||||
* @self: Sysroot
|
||||
*
|
||||
* Returns: (transfer none): The currently staged deployment, or %NULL if none
|
||||
*
|
||||
* Since: 2018.5
|
||||
*/
|
||||
OstreeDeployment *
|
||||
ostree_sysroot_get_staged_deployment (OstreeSysroot *self)
|
||||
@@ -1144,6 +1155,8 @@ ostree_sysroot_get_repo (OstreeSysroot *self,
|
||||
* has been invoked successfully.
|
||||
*
|
||||
* Returns: (transfer none): The OSTree repository in sysroot @self.
|
||||
*
|
||||
* Since: 2017.7
|
||||
*/
|
||||
OstreeRepo *
|
||||
ostree_sysroot_repo (OstreeSysroot *self)
|
||||
@@ -1475,6 +1488,8 @@ ostree_sysroot_lock_finish (OstreeSysroot *self,
|
||||
* Initialize the directory structure for an "osname", which is a
|
||||
* group of operating system deployments, with a shared `/var`. One
|
||||
* is required for generating a deployment.
|
||||
*
|
||||
* Since: 2016.4
|
||||
*/
|
||||
gboolean
|
||||
ostree_sysroot_init_osname (OstreeSysroot *self,
|
||||
@@ -1673,12 +1688,12 @@ clone_deployment (OstreeSysroot *sysroot,
|
||||
/* Copy the bootloader config options */
|
||||
OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (merge_deployment);
|
||||
g_auto(GStrv) previous_args = g_strsplit (ostree_bootconfig_parser_get (bootconfig, "options"), " ", -1);
|
||||
g_autoptr(OstreeKernelArgs) kargs = _ostree_kernel_args_new ();
|
||||
_ostree_kernel_args_append_argv (kargs, previous_args);
|
||||
g_autoptr(OstreeKernelArgs) kargs = ostree_kernel_args_new ();
|
||||
ostree_kernel_args_append_argv (kargs, previous_args);
|
||||
|
||||
/* Deploy the copy */
|
||||
g_autoptr(OstreeDeployment) new_deployment = NULL;
|
||||
g_auto(GStrv) kargs_strv = _ostree_kernel_args_to_strv (kargs);
|
||||
g_auto(GStrv) kargs_strv = ostree_kernel_args_to_strv (kargs);
|
||||
if (!ostree_sysroot_deploy_tree (sysroot,
|
||||
ostree_deployment_get_osname (target_deployment),
|
||||
ostree_deployment_get_csum (target_deployment),
|
||||
@@ -1729,6 +1744,8 @@ static gboolean mkdir_unmasked (int dfd,
|
||||
*
|
||||
* The `OSTREE_DEPLOYMENT_UNLOCKED_HOTFIX` state is persistent
|
||||
* across reboots.
|
||||
*
|
||||
* Since: 2016.4
|
||||
*/
|
||||
gboolean
|
||||
ostree_sysroot_deployment_unlock (OstreeSysroot *self,
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
*
|
||||
* Since: 2017.4
|
||||
*/
|
||||
#define OSTREE_RELEASE_VERSION (2)
|
||||
#define OSTREE_RELEASE_VERSION (3)
|
||||
|
||||
/**
|
||||
* OSTREE_VERSION
|
||||
@@ -52,7 +52,7 @@
|
||||
*
|
||||
* Since: 2017.4
|
||||
*/
|
||||
#define OSTREE_VERSION (2019.2)
|
||||
#define OSTREE_VERSION (2019.3)
|
||||
|
||||
/**
|
||||
* OSTREE_VERSION_S:
|
||||
@@ -62,7 +62,7 @@
|
||||
*
|
||||
* Since: 2017.4
|
||||
*/
|
||||
#define OSTREE_VERSION_S "2019.2"
|
||||
#define OSTREE_VERSION_S "2019.3"
|
||||
|
||||
#define OSTREE_ENCODE_VERSION(year,release) \
|
||||
((year) << 16 | (release))
|
||||
@@ -91,3 +91,13 @@
|
||||
#define OSTREE_CHECK_VERSION(year,release) \
|
||||
(OSTREE_YEAR_VERSION > (year) || \
|
||||
(OSTREE_YEAR_VERSION == (year) && OSTREE_RELEASE_VERSION >= (release)))
|
||||
|
||||
/**
|
||||
* OSTREE_BUILT_FEATURES:
|
||||
*
|
||||
* Whitespace separated set of features this libostree was configured with at build time.
|
||||
* Consult the source code in configure.ac (or the CLI `ostree --version`) for examples.
|
||||
*
|
||||
* Since: 2019.3
|
||||
*/
|
||||
#define OSTREE_BUILT_FEATURES "libcurl libsoup gpgme libarchive selinux openssl libmount release p2p"
|
||||
@@ -91,3 +91,13 @@
|
||||
#define OSTREE_CHECK_VERSION(year,release) \
|
||||
(OSTREE_YEAR_VERSION > (year) || \
|
||||
(OSTREE_YEAR_VERSION == (year) && OSTREE_RELEASE_VERSION >= (release)))
|
||||
|
||||
/**
|
||||
* OSTREE_BUILT_FEATURES:
|
||||
*
|
||||
* Whitespace separated set of features this libostree was configured with at build time.
|
||||
* Consult the source code in configure.ac (or the CLI `ostree --version`) for examples.
|
||||
*
|
||||
* Since: 2019.3
|
||||
*/
|
||||
#define OSTREE_BUILT_FEATURES "@OSTREE_FEATURES@"
|
||||
@@ -39,5 +39,6 @@
|
||||
#include <ostree-repo-finder-config.h>
|
||||
#include <ostree-repo-finder-mount.h>
|
||||
#include <ostree-repo-finder-override.h>
|
||||
#include <ostree-kernel-args.h>
|
||||
#include <ostree-autocleanups.h>
|
||||
#include <ostree-version.h>
|
||||
@@ -437,3 +437,29 @@ ot_gpgme_new_ctx (const char *homedir,
|
||||
|
||||
return g_steal_pointer (&context);
|
||||
}
|
||||
|
||||
void
|
||||
ot_gpgme_kill_agent (const char *homedir)
|
||||
{
|
||||
g_return_if_fail (homedir != NULL);
|
||||
|
||||
/* Run gpg-connect-agent killagent /bye */
|
||||
g_autoptr(GError) local_error = NULL;
|
||||
g_autoptr(GSubprocess) proc = g_subprocess_new(G_SUBPROCESS_FLAGS_STDOUT_SILENCE,
|
||||
&local_error,
|
||||
"gpg-connect-agent",
|
||||
"--homedir",
|
||||
homedir,
|
||||
"killagent",
|
||||
"/bye",
|
||||
NULL);
|
||||
if (proc == NULL) {
|
||||
g_debug ("Spawning gpg-connect-agent failed: %s", local_error->message);
|
||||
return;
|
||||
}
|
||||
if (!g_subprocess_wait_check (proc, NULL, &local_error)) {
|
||||
g_debug ("Killing GPG agent with gpg-connect-agent failed: %s",
|
||||
local_error->message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -46,4 +46,6 @@ gpgme_data_t ot_gpgme_data_output (GOutputStream *output_stream);
|
||||
gpgme_ctx_t ot_gpgme_new_ctx (const char *homedir,
|
||||
GError **error);
|
||||
|
||||
void ot_gpgme_kill_agent (const char *homedir);
|
||||
|
||||
G_END_DECLS
|
||||
@@ -62,3 +62,55 @@ ot_parse_keyvalue (const char *keyvalue,
|
||||
*out_value = g_strdup (eq + 1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: temporarily copied from GLib: https://github.com/GNOME/glib/blob/a419146578a42c760cff684292465b38df855f75/glib/garray.c#L1664
|
||||
* See documentation at: https://developer.gnome.org/glib/stable/glib-Pointer-Arrays.html#g-ptr-array-find-with-equal-func
|
||||
*
|
||||
* ot_ptr_array_find_with_equal_func: (skip)
|
||||
* @haystack: pointer array to be searched
|
||||
* @needle: pointer to look for
|
||||
* @equal_func: (nullable): the function to call for each element, which should
|
||||
* return %TRUE when the desired element is found; or %NULL to use pointer
|
||||
* equality
|
||||
* @index_: (optional) (out caller-allocates): return location for the index of
|
||||
* the element, if found
|
||||
*
|
||||
* Checks whether @needle exists in @haystack, using the given @equal_func.
|
||||
* If the element is found, %TRUE is returned and the element’s index is
|
||||
* returned in @index_ (if non-%NULL). Otherwise, %FALSE is returned and @index_
|
||||
* is undefined. If @needle exists multiple times in @haystack, the index of
|
||||
* the first instance is returned.
|
||||
*
|
||||
* @equal_func is called with the element from the array as its first parameter,
|
||||
* and @needle as its second parameter. If @equal_func is %NULL, pointer
|
||||
* equality is used.
|
||||
*
|
||||
* Returns: %TRUE if @needle is one of the elements of @haystack
|
||||
* Since: 2.54
|
||||
*/
|
||||
gboolean
|
||||
ot_ptr_array_find_with_equal_func (GPtrArray *haystack,
|
||||
gconstpointer needle,
|
||||
GEqualFunc equal_func,
|
||||
guint *index_)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (haystack != NULL, FALSE);
|
||||
|
||||
if (equal_func == NULL)
|
||||
equal_func = g_direct_equal;
|
||||
|
||||
for (i = 0; i < haystack->len; i++)
|
||||
{
|
||||
if (equal_func (g_ptr_array_index (haystack, i), needle))
|
||||
{
|
||||
if (index_ != NULL)
|
||||
*index_ = i;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -34,5 +34,10 @@ ot_parse_keyvalue (const char *keyvalue,
|
||||
char **out_key,
|
||||
char **out_value,
|
||||
GError **error);
|
||||
gboolean
|
||||
ot_ptr_array_find_with_equal_func (GPtrArray *haystack,
|
||||
gconstpointer needle,
|
||||
GEqualFunc equal_func,
|
||||
guint *index_);
|
||||
|
||||
G_END_DECLS
|
||||
@@ -43,6 +43,8 @@ gboolean
|
||||
ot_util_filename_validate (const char *name,
|
||||
GError **error)
|
||||
{
|
||||
if (name == NULL)
|
||||
return glnx_throw (error, "Invalid NULL filename");
|
||||
if (strcmp (name, ".") == 0)
|
||||
return glnx_throw (error, "Invalid self-referential filename '.'");
|
||||
if (strcmp (name, "..") == 0)
|
||||
|
||||
@@ -60,5 +60,9 @@
|
||||
#include <ot-variant-utils.h>
|
||||
#include <ot-variant-builder.h>
|
||||
#include <ot-checksum-utils.h>
|
||||
#include <ot-gpg-utils.h>
|
||||
#include <ot-checksum-instream.h>
|
||||
#include <ot-tool-util.h>
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
#include <ot-gpg-utils.h>
|
||||
#endif
|
||||
@@ -72,9 +72,11 @@ static OstreeCommand commands[] = {
|
||||
{ "fsck", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_fsck,
|
||||
"Check the repository for consistency" },
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
{ "gpg-sign", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_gpg_sign,
|
||||
"Sign a commit" },
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
{ "init", OSTREE_BUILTIN_FLAG_NO_CHECK,
|
||||
ostree_builtin_init,
|
||||
"Initialize a new empty repository" },
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
#include "ostree.h"
|
||||
#include "otutil.h"
|
||||
|
||||
#include "../libostree/ostree-kernel-args.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
static gboolean opt_retain;
|
||||
@@ -133,20 +131,20 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat
|
||||
g_autoptr(OstreeKernelArgs) kargs = NULL;
|
||||
if (opt_kernel_arg_none)
|
||||
{
|
||||
kargs = _ostree_kernel_args_new ();
|
||||
kargs = ostree_kernel_args_new ();
|
||||
}
|
||||
else if (opt_kernel_proc_cmdline)
|
||||
{
|
||||
kargs = _ostree_kernel_args_new ();
|
||||
if (!_ostree_kernel_args_append_proc_cmdline (kargs, cancellable, error))
|
||||
kargs = ostree_kernel_args_new ();
|
||||
if (!ostree_kernel_args_append_proc_cmdline (kargs, cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
else if (merge_deployment && (opt_kernel_argv || opt_kernel_argv_append))
|
||||
{
|
||||
OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (merge_deployment);
|
||||
g_auto(GStrv) previous_args = g_strsplit (ostree_bootconfig_parser_get (bootconfig, "options"), " ", -1);
|
||||
kargs = _ostree_kernel_args_new ();
|
||||
_ostree_kernel_args_append_argv (kargs, previous_args);
|
||||
kargs = ostree_kernel_args_new ();
|
||||
ostree_kernel_args_append_argv (kargs, previous_args);
|
||||
}
|
||||
|
||||
/* Now replace/extend the above set. Note that if no options are specified,
|
||||
@@ -156,19 +154,19 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat
|
||||
if (opt_kernel_argv)
|
||||
{
|
||||
if (!kargs)
|
||||
kargs = _ostree_kernel_args_new ();
|
||||
_ostree_kernel_args_replace_argv (kargs, opt_kernel_argv);
|
||||
kargs = ostree_kernel_args_new ();
|
||||
ostree_kernel_args_replace_argv (kargs, opt_kernel_argv);
|
||||
}
|
||||
|
||||
if (opt_kernel_argv_append)
|
||||
{
|
||||
if (!kargs)
|
||||
kargs = _ostree_kernel_args_new ();
|
||||
_ostree_kernel_args_append_argv (kargs, opt_kernel_argv_append);
|
||||
kargs = ostree_kernel_args_new ();
|
||||
ostree_kernel_args_append_argv (kargs, opt_kernel_argv_append);
|
||||
}
|
||||
|
||||
g_autoptr(OstreeDeployment) new_deployment = NULL;
|
||||
g_auto(GStrv) kargs_strv = kargs ? _ostree_kernel_args_to_strv (kargs) : NULL;
|
||||
g_auto(GStrv) kargs_strv = kargs ? ostree_kernel_args_to_strv (kargs) : NULL;
|
||||
if (opt_stage)
|
||||
{
|
||||
if (opt_retain_pending || opt_retain_rollback)
|
||||
|
||||
@@ -30,7 +30,10 @@
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
static gboolean opt_modern;
|
||||
|
||||
static GOptionEntry options[] = {
|
||||
{ "modern", 0, 0, G_OPTION_ARG_NONE, &opt_modern, "Only create /boot and /ostree", NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@@ -58,26 +61,39 @@ ot_admin_builtin_init_fs (int argc, char **argv, OstreeCommandInvocation *invoca
|
||||
if (!glnx_opendirat (AT_FDCWD, sysroot_path, TRUE, &root_dfd, error))
|
||||
return FALSE;
|
||||
|
||||
const char *normal_toplevels[] = {"boot", "dev", "home", "proc", "run", "sys"};
|
||||
for (guint i = 0; i < G_N_ELEMENTS (normal_toplevels); i++)
|
||||
/* It's common to want to mount this outside of a deployment as well */
|
||||
if (!glnx_shutil_mkdir_p_at (root_dfd, "boot", 0755, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
/* See https://github.com/coreos/coreos-assembler/pull/688
|
||||
* For Fedora CoreOS at least, we have this now to the point where we don't
|
||||
* need this stuff in the physical sysroot. I'm not sure we ever really did,
|
||||
* but to be conservative, make it opt-in to the new model of just boot/ and ostree/.
|
||||
*/
|
||||
if (!opt_modern)
|
||||
{
|
||||
if (!glnx_shutil_mkdir_p_at (root_dfd, normal_toplevels[i], 0755,
|
||||
cancellable, error))
|
||||
const char *traditional_toplevels[] = {"boot", "dev", "home", "proc", "run", "sys"};
|
||||
for (guint i = 0; i < G_N_ELEMENTS (traditional_toplevels); i++)
|
||||
{
|
||||
if (!glnx_shutil_mkdir_p_at (root_dfd, traditional_toplevels[i], 0755,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!glnx_shutil_mkdir_p_at (root_dfd, "root", 0700,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!glnx_shutil_mkdir_p_at (root_dfd, "tmp", 01777,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
if (fchmodat (root_dfd, "tmp", 01777, 0) == -1)
|
||||
{
|
||||
glnx_set_prefix_error_from_errno (error, "chmod: %s", "tmp");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!glnx_shutil_mkdir_p_at (root_dfd, "root", 0700,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!glnx_shutil_mkdir_p_at (root_dfd, "tmp", 01777,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
if (fchmodat (root_dfd, "tmp", 01777, 0) == -1)
|
||||
{
|
||||
glnx_set_prefix_error_from_errno (error, "chmod: %s", "tmp");
|
||||
return FALSE;
|
||||
}
|
||||
g_autoptr(GFile) dir = g_file_new_for_path (sysroot_path);
|
||||
g_autoptr(OstreeSysroot) sysroot = ostree_sysroot_new (dir);
|
||||
if (!ostree_sysroot_ensure_initialized (sysroot, cancellable, error))
|
||||
|
||||
@@ -52,24 +52,39 @@ ot_admin_builtin_pin (int argc, char **argv, OstreeCommandInvocation *invocation
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
const char *deploy_index_str = argv[1];
|
||||
const int deploy_index = atoi (deploy_index_str);
|
||||
|
||||
g_autoptr(OstreeDeployment) target_deployment = ot_admin_get_indexed_deployment (sysroot, deploy_index, error);
|
||||
if (!target_deployment)
|
||||
return FALSE;
|
||||
|
||||
|
||||
gboolean current_pin = ostree_deployment_is_pinned (target_deployment);
|
||||
const gboolean desired_pin = !opt_unpin;
|
||||
if (current_pin == desired_pin)
|
||||
g_print ("Deployment is already %s\n", current_pin ? "pinned" : "unpinned");
|
||||
else
|
||||
unsigned int nsuccess = 0;
|
||||
for (unsigned int i = 1; i < argc; i++)
|
||||
{
|
||||
if (!ostree_sysroot_deployment_set_pinned (sysroot, target_deployment, desired_pin, error))
|
||||
return FALSE;
|
||||
g_print ("Deployment is now %s\n", desired_pin ? "pinned" : "unpinned");
|
||||
const char *deploy_index_str = argv[i];
|
||||
const int deploy_index = atoi (deploy_index_str);
|
||||
|
||||
g_autoptr(GError) e = NULL;
|
||||
g_autoptr(OstreeDeployment) target_deployment = ot_admin_get_indexed_deployment (sysroot, deploy_index, &e);
|
||||
if (!target_deployment)
|
||||
{
|
||||
g_print ("Invalid deployment %s: %s\n", deploy_index_str, e->message);
|
||||
continue;
|
||||
}
|
||||
|
||||
gboolean current_pin = ostree_deployment_is_pinned (target_deployment);
|
||||
const gboolean desired_pin = !opt_unpin;
|
||||
if (current_pin == desired_pin)
|
||||
{
|
||||
g_print ("Deployment %s is already %s\n", deploy_index_str, current_pin ? "pinned" : "unpinned");
|
||||
nsuccess++;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_autoptr(GError) e = NULL;
|
||||
if (ostree_sysroot_deployment_set_pinned (sysroot, target_deployment, desired_pin, &e))
|
||||
{
|
||||
g_print ("Deployment %s is now %s\n", deploy_index_str, desired_pin ? "pinned" : "unpinned");
|
||||
nsuccess++;
|
||||
}
|
||||
else
|
||||
g_print ("Failed to %s deployment %s: %s\n", desired_pin ? "pin" : "unpin", deploy_index_str, e->message);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return nsuccess > 0;
|
||||
}
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "ot-admin-builtins.h"
|
||||
#include "ot-admin-functions.h"
|
||||
#include "ostree.h"
|
||||
#include "ot-tool-util.h"
|
||||
#include "otutil.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -35,6 +35,7 @@ static GOptionEntry options[] = {
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
static gboolean
|
||||
deployment_get_gpg_verify (OstreeDeployment *deployment,
|
||||
OstreeRepo *repo)
|
||||
@@ -61,6 +62,7 @@ deployment_get_gpg_verify (OstreeDeployment *deployment,
|
||||
|
||||
return gpg_verify;
|
||||
}
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
|
||||
static gboolean
|
||||
@@ -136,6 +138,7 @@ deployment_print_status (OstreeSysroot *sysroot,
|
||||
g_print (" `- %s\n", source_title);
|
||||
}
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
if (deployment_get_gpg_verify (deployment, repo))
|
||||
{
|
||||
g_autoptr(GString) output_buffer = g_string_sized_new (256);
|
||||
@@ -168,6 +171,7 @@ deployment_print_status (OstreeSysroot *sysroot,
|
||||
|
||||
g_print ("%s", output_buffer->str);
|
||||
}
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
#include "ostree.h"
|
||||
#include "otutil.h"
|
||||
|
||||
#include "../libostree/ostree-kernel-args.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <err.h>
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@
|
||||
#include "ot-admin-instutil-builtins.h"
|
||||
|
||||
#include "otutil.h"
|
||||
|
||||
#include "../libostree/ostree-kernel-args.h"
|
||||
#include "ostree.h"
|
||||
|
||||
static gboolean opt_proc_cmdline;
|
||||
static gboolean opt_merge;
|
||||
@@ -69,14 +68,14 @@ ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeCommandInvocat
|
||||
}
|
||||
first_deployment = deployments->pdata[0];
|
||||
|
||||
kargs = _ostree_kernel_args_new ();
|
||||
kargs = ostree_kernel_args_new ();
|
||||
|
||||
/* If they want the current kernel's args, they very likely don't
|
||||
* want the ones from the merge.
|
||||
*/
|
||||
if (opt_proc_cmdline)
|
||||
{
|
||||
if (!_ostree_kernel_args_append_proc_cmdline (kargs, cancellable, error))
|
||||
if (!ostree_kernel_args_append_proc_cmdline (kargs, cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
else if (opt_merge)
|
||||
@@ -84,24 +83,24 @@ ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeCommandInvocat
|
||||
OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (first_deployment);
|
||||
g_auto(GStrv) previous_args = g_strsplit (ostree_bootconfig_parser_get (bootconfig, "options"), " ", -1);
|
||||
|
||||
_ostree_kernel_args_append_argv (kargs, previous_args);
|
||||
ostree_kernel_args_append_argv (kargs, previous_args);
|
||||
}
|
||||
|
||||
if (opt_replace)
|
||||
{
|
||||
_ostree_kernel_args_replace_argv (kargs, opt_replace);
|
||||
ostree_kernel_args_replace_argv (kargs, opt_replace);
|
||||
}
|
||||
|
||||
if (opt_append)
|
||||
{
|
||||
_ostree_kernel_args_append_argv (kargs, opt_append);
|
||||
ostree_kernel_args_append_argv (kargs, opt_append);
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
_ostree_kernel_args_append (kargs, argv[i]);
|
||||
ostree_kernel_args_append (kargs, argv[i]);
|
||||
|
||||
{
|
||||
g_auto(GStrv) kargs_strv = _ostree_kernel_args_to_strv (kargs);
|
||||
g_auto(GStrv) kargs_strv = ostree_kernel_args_to_strv (kargs);
|
||||
|
||||
if (!ostree_sysroot_deployment_set_kargs (sysroot, first_deployment,
|
||||
kargs_strv,
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "ot-builtins.h"
|
||||
#include "ostree.h"
|
||||
#include "otutil.h"
|
||||
#include "ot-tool-util.h"
|
||||
|
||||
static gboolean opt_user_mode;
|
||||
static gboolean opt_allow_noent;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "ot-editor.h"
|
||||
#include "ostree.h"
|
||||
#include "otutil.h"
|
||||
#include "ot-tool-util.h"
|
||||
#include "parse-datetime.h"
|
||||
#include "ostree-repo-private.h"
|
||||
#include "ostree-libarchive-private.h"
|
||||
@@ -61,8 +60,10 @@ static char **opt_trees;
|
||||
static gint opt_owner_uid = -1;
|
||||
static gint opt_owner_gid = -1;
|
||||
static gboolean opt_table_output;
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
static char **opt_key_ids;
|
||||
static char *opt_gpg_homedir;
|
||||
#endif
|
||||
static gboolean opt_generate_sizes;
|
||||
static gboolean opt_disable_fsync;
|
||||
static char *opt_timestamp;
|
||||
@@ -115,8 +116,10 @@ static GOptionEntry options[] = {
|
||||
{ "skip-list", 0, 0, G_OPTION_ARG_FILENAME, &opt_skiplist_file, "File containing list of files to skip", "PATH" },
|
||||
{ "consume", 0, 0, G_OPTION_ARG_NONE, &opt_consume, "Consume (delete) content after commit (for local directories)", NULL },
|
||||
{ "table-output", 0, 0, G_OPTION_ARG_NONE, &opt_table_output, "Output more information in a KEY: VALUE format", NULL },
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
{ "gpg-sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_key_ids, "GPG Key ID to sign the commit with", "KEY-ID"},
|
||||
{ "gpg-homedir", 0, 0, G_OPTION_ARG_FILENAME, &opt_gpg_homedir, "GPG Homedir to use when looking for keyrings", "HOMEDIR"},
|
||||
#endif
|
||||
{ "generate-sizes", 0, 0, G_OPTION_ARG_NONE, &opt_generate_sizes, "Generate size information along with commit metadata", NULL },
|
||||
{ "disable-fsync", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL },
|
||||
{ "fsync", 0, 0, G_OPTION_ARG_CALLBACK, parse_fsync_cb, "Specify how to invoke fsync()", "POLICY" },
|
||||
@@ -636,11 +639,22 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
|
||||
{
|
||||
if (!opt_tar_pathname_filter)
|
||||
{
|
||||
object_to_commit = g_file_new_for_path (tree);
|
||||
if (!ostree_repo_write_archive_to_mtree (repo, object_to_commit, mtree, modifier,
|
||||
opt_tar_autocreate_parents,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
if (strcmp (tree, "-") == 0)
|
||||
{
|
||||
if (!ostree_repo_write_archive_to_mtree_from_fd (repo, STDIN_FILENO, mtree, modifier,
|
||||
opt_tar_autocreate_parents,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
{
|
||||
object_to_commit = g_file_new_for_path (tree);
|
||||
|
||||
if (!ostree_repo_write_archive_to_mtree (repo, object_to_commit, mtree, modifier,
|
||||
opt_tar_autocreate_parents,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -666,7 +680,13 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
|
||||
goto out;
|
||||
}
|
||||
opts.translate_pathname_user_data = &tpdata;
|
||||
g_autoptr(OtAutoArchiveRead) archive = ot_open_archive_read (tree, error);
|
||||
|
||||
g_autoptr(OtAutoArchiveRead) archive;
|
||||
if (strcmp (tree, "-") == 0)
|
||||
archive = ot_open_archive_read_fd (STDIN_FILENO, error);
|
||||
else
|
||||
archive = ot_open_archive_read (tree, error);
|
||||
|
||||
if (!archive)
|
||||
goto out;
|
||||
if (!ostree_repo_import_archive_to_mtree (repo, &opts, archive, mtree,
|
||||
@@ -797,6 +817,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
|
||||
goto out;
|
||||
}
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
if (opt_key_ids)
|
||||
{
|
||||
char **iter;
|
||||
@@ -814,6 +835,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (opt_branch)
|
||||
ostree_repo_transaction_set_ref (repo, NULL, opt_branch, commit_checksum);
|
||||
|
||||
@@ -77,6 +77,7 @@ static GOptionEntry options[] = {
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
static void
|
||||
gpg_verify_result_cb (OstreeRepo *repo,
|
||||
const char *checksum,
|
||||
@@ -93,6 +94,7 @@ gpg_verify_result_cb (OstreeRepo *repo,
|
||||
|
||||
glnx_console_lock (console);
|
||||
}
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
static gboolean printed_console_progress;
|
||||
|
||||
@@ -360,9 +362,11 @@ ostree_builtin_pull (int argc, char **argv, OstreeCommandInvocation *invocation,
|
||||
|
||||
if (console.is_tty)
|
||||
{
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
signal_handler_id = g_signal_connect (repo, "gpg-verify-result",
|
||||
G_CALLBACK (gpg_verify_result_cb),
|
||||
&console);
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
}
|
||||
|
||||
options = g_variant_ref_sink (g_variant_builder_end (&builder));
|
||||
|
||||
@@ -32,6 +32,7 @@ static gboolean opt_list;
|
||||
static gboolean opt_alias;
|
||||
static char *opt_create;
|
||||
static gboolean opt_collections;
|
||||
static gboolean opt_force;
|
||||
|
||||
/* ATTENTION:
|
||||
* Please remember to update the bash-completion script (bash/ostree) and
|
||||
@@ -44,6 +45,7 @@ static GOptionEntry options[] = {
|
||||
{ "alias", 'A', 0, G_OPTION_ARG_NONE, &opt_alias, "If used with --create, create an alias, otherwise just list aliases", NULL },
|
||||
{ "create", 0, 0, G_OPTION_ARG_STRING, &opt_create, "Create a new ref for an existing commit", "NEWREF" },
|
||||
{ "collections", 'c', 0, G_OPTION_ARG_NONE, &opt_collections, "Enable listing collection IDs for refs", NULL },
|
||||
{ "force", 0, 0, G_OPTION_ARG_NONE, &opt_force, "Overwrite existing refs when creating", NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@@ -89,7 +91,7 @@ do_ref_with_collections (OstreeRepo *repo,
|
||||
else goto out;
|
||||
}
|
||||
|
||||
if (checksum_existing != NULL)
|
||||
if (!opt_force && checksum_existing != NULL)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"--create specified but ref %s already exists", opt_create);
|
||||
@@ -205,9 +207,11 @@ static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellab
|
||||
else goto out;
|
||||
}
|
||||
|
||||
/* We want to allow replacing an existing alias */
|
||||
/* We want to allow replacing an existing alias or a normal ref when
|
||||
* forced
|
||||
*/
|
||||
gboolean replacing_alias = opt_alias && g_hash_table_contains (ref_aliases, opt_create);
|
||||
if (!replacing_alias && checksum_existing != NULL)
|
||||
if (!replacing_alias && !opt_force && checksum_existing != NULL)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"--create specified but ref %s already exists", opt_create);
|
||||
|
||||
@@ -40,9 +40,11 @@ static OstreeCommand remote_subcommands[] = {
|
||||
{ "list", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ot_remote_builtin_list,
|
||||
"List remote repository names" },
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
{ "gpg-import", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ot_remote_builtin_gpg_import,
|
||||
"Import GPG keys" },
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
#ifdef HAVE_LIBCURL_OR_LIBSOUP
|
||||
{ "add-cookie", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ot_remote_builtin_add_cookie,
|
||||
|
||||
@@ -164,6 +164,7 @@ print_object (OstreeRepo *repo,
|
||||
flags |= OSTREE_DUMP_UNSWAPPED;
|
||||
ot_dump_object (objtype, checksum, variant, flags);
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
|
||||
{
|
||||
g_autoptr(OstreeGpgVerifyResult) result = NULL;
|
||||
@@ -207,6 +208,7 @@ print_object (OstreeRepo *repo,
|
||||
g_print ("%s", buffer->str);
|
||||
}
|
||||
}
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -193,6 +193,7 @@ ostree_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invocati
|
||||
if (!ostree_repo_regenerate_summary (repo, additional_metadata, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
if (opt_key_ids)
|
||||
{
|
||||
if (!ostree_repo_add_gpg_signature_summary (repo,
|
||||
@@ -202,6 +203,7 @@ ostree_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invocati
|
||||
error))
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (opt_view || opt_raw)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,9 @@ BUILTINPROTO(diff);
|
||||
BUILTINPROTO(export);
|
||||
BUILTINPROTO(find_remotes);
|
||||
BUILTINPROTO(create_usb);
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
BUILTINPROTO(gpg_sign);
|
||||
#endif
|
||||
BUILTINPROTO(init);
|
||||
BUILTINPROTO(log);
|
||||
BUILTINPROTO(pull);
|
||||
|
||||
+18
-5
@@ -152,11 +152,6 @@ ostree_run (int argc,
|
||||
}
|
||||
}
|
||||
|
||||
else if (g_str_equal (argv[in], "--"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
argv[out] = argv[in];
|
||||
}
|
||||
|
||||
@@ -348,6 +343,22 @@ ostree_option_context_parse (GOptionContext *context,
|
||||
if (!g_option_context_parse (context, argc, argv, error))
|
||||
return FALSE;
|
||||
|
||||
/* Filter out the first -- we see; g_option_context_parse() leaves it in */
|
||||
int in, out;
|
||||
gboolean removed_double_dashes = FALSE;
|
||||
for (in = 1, out = 1; in < *argc; in++, out++)
|
||||
{
|
||||
if (g_str_equal ((*argv)[in], "--") && !removed_double_dashes)
|
||||
{
|
||||
removed_double_dashes = TRUE;
|
||||
out--;
|
||||
continue;
|
||||
}
|
||||
|
||||
(*argv)[out] = (*argv)[in];
|
||||
}
|
||||
*argc = out;
|
||||
|
||||
if (opt_version)
|
||||
{
|
||||
/* This should now be YAML, like `docker version`, so it's both nice to read
|
||||
@@ -491,6 +502,7 @@ ostree_ensure_repo_writable (OstreeRepo *repo,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
void
|
||||
ostree_print_gpg_verify_result (OstreeGpgVerifyResult *result)
|
||||
{
|
||||
@@ -511,6 +523,7 @@ ostree_print_gpg_verify_result (OstreeGpgVerifyResult *result)
|
||||
|
||||
g_print ("%s", buffer->str);
|
||||
}
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
gboolean
|
||||
ot_enable_tombstone_commits (OstreeRepo *repo, GError **error)
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "otutil.h"
|
||||
#include "ot-tool-util.h"
|
||||
|
||||
#include "ot-main.h"
|
||||
#include "ot-remote-builtins.h"
|
||||
@@ -134,10 +133,12 @@ ot_remote_builtin_add (int argc, char **argv, OstreeCommandInvocation *invocatio
|
||||
subkey, g_variant_new_variant (g_variant_new_string (subvalue)));
|
||||
}
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
if (opt_no_gpg_verify)
|
||||
g_variant_builder_add (optbuilder, "{s@v}",
|
||||
"gpg-verify",
|
||||
g_variant_new_variant (g_variant_new_boolean (FALSE)));
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
if (opt_collection_id != NULL)
|
||||
g_variant_builder_add (optbuilder, "{s@v}", "collection-id",
|
||||
@@ -158,6 +159,7 @@ ot_remote_builtin_add (int argc, char **argv, OstreeCommandInvocation *invocatio
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
/* This is just a convenience option and is not as flexible as the full
|
||||
* "ostree remote gpg-import" command. It imports all keys from a file,
|
||||
* which is likely the most common case.
|
||||
@@ -184,6 +186,7 @@ ot_remote_builtin_add (int argc, char **argv, OstreeCommandInvocation *invocatio
|
||||
g_print ("Imported %u GPG key%s to remote \"%s\"\n",
|
||||
imported, (imported == 1) ? "" : "s", remote_name);
|
||||
}
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
|
||||
@@ -51,7 +51,9 @@ ot_remote_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invoc
|
||||
g_autoptr(GBytes) summary_bytes = NULL;
|
||||
g_autoptr(GBytes) signature_bytes = NULL;
|
||||
OstreeDumpFlags flags = OSTREE_DUMP_NONE;
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
gboolean gpg_verify_summary;
|
||||
#endif
|
||||
gboolean ret = FALSE;
|
||||
|
||||
context = g_option_context_new ("NAME");
|
||||
@@ -92,6 +94,7 @@ ot_remote_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invoc
|
||||
|
||||
ot_dump_summary_bytes (summary_bytes, flags);
|
||||
|
||||
#ifndef OSTREE_DISABLE_GPGME
|
||||
if (!ostree_repo_remote_get_gpg_verify_summary (repo, remote_name,
|
||||
&gpg_verify_summary,
|
||||
error))
|
||||
@@ -124,6 +127,7 @@ ot_remote_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invoc
|
||||
g_print ("\n");
|
||||
ostree_print_gpg_verify_result (result);
|
||||
}
|
||||
#endif /* OSTREE_DISABLE_GPGME */
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
|
||||
@@ -182,7 +182,7 @@ main(int argc, char *argv[])
|
||||
mount_var = true;
|
||||
|
||||
/* Link to the deployment's /var */
|
||||
if (mount_var && mount ("../../var", "var", NULL, MS_MGC_VAL|MS_BIND, NULL) < 0)
|
||||
if (mount_var && mount ("../../var", "var", NULL, MS_BIND, NULL) < 0)
|
||||
err (EXIT_FAILURE, "failed to bind mount ../../var to var");
|
||||
|
||||
char srcpath[PATH_MAX];
|
||||
|
||||
Reference in new issue
Block a user