New upstream version 2019.5

This commit is contained in:
Simon McVittie committed 2019-11-02 10:23:11 +00:00
commit f2dce86edf
42 files changed
+409 -155

No files matched your search

+2
View File
@@ -18,6 +18,8 @@
***/
/* Add new symbols here. Release commits should copy this section into -released.sym. */
LIBOSTREE_2019.5 {
} LIBOSTREE_2019.4;
/* 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
+2
View File
@@ -575,6 +575,8 @@ LIBOSTREE_2019.4 {
ostree_repo_mark_commit_partial_reason;
} LIBOSTREE_2019.3;
/* No new symbols in 2019.5 */
/* NOTE: Only add more content here in release commits! See the
* comments at the top of this file.
*/
+1 -1
View File
@@ -465,7 +465,7 @@ ostree_async_progress_finish (OstreeAsyncProgress *self)
if (self->idle_source)
{
g_source_destroy (self->idle_source);
self->idle_source = NULL;
g_clear_pointer (&self->idle_source, g_source_unref);
emit_changed = TRUE;
}
}
+152
View File
@@ -0,0 +1,152 @@
/*
* Copyright (C) 2019 Colin Walters <walters@verbum.org>
*
* This program 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 licence 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 "ostree-sysroot-private.h"
#include "ostree-bootloader-zipl.h"
#include "otutil.h"
#include <string.h>
/* This is specific to zipl today, but in the future we could also
* use it for the grub2-mkconfig case.
*/
static const char zipl_requires_execute_path[] = "boot/ostree-bootloader-update.stamp";
struct _OstreeBootloaderZipl
{
GObject parent_instance;
OstreeSysroot *sysroot;
};
typedef GObjectClass OstreeBootloaderZiplClass;
static void _ostree_bootloader_zipl_bootloader_iface_init (OstreeBootloaderInterface *iface);
G_DEFINE_TYPE_WITH_CODE (OstreeBootloaderZipl, _ostree_bootloader_zipl, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (OSTREE_TYPE_BOOTLOADER, _ostree_bootloader_zipl_bootloader_iface_init));
static gboolean
_ostree_bootloader_zipl_query (OstreeBootloader *bootloader,
gboolean *out_is_active,
GCancellable *cancellable,
GError **error)
{
/* We don't auto-detect this one; should be explicitly chosen right now.
* see also https://github.com/coreos/coreos-assembler/pull/849
*/
*out_is_active = FALSE;
return TRUE;
}
static const char *
_ostree_bootloader_zipl_get_name (OstreeBootloader *bootloader)
{
return "zipl";
}
static gboolean
_ostree_bootloader_zipl_write_config (OstreeBootloader *bootloader,
int bootversion,
GPtrArray *new_deployments,
GCancellable *cancellable,
GError **error)
{
OstreeBootloaderZipl *self = OSTREE_BOOTLOADER_ZIPL (bootloader);
/* Write our stamp file */
if (!glnx_file_replace_contents_at (self->sysroot->sysroot_fd, zipl_requires_execute_path,
(guint8*)"", 0, GLNX_FILE_REPLACE_NODATASYNC,
cancellable, error))
return FALSE;
return TRUE;
}
static gboolean
_ostree_bootloader_zipl_post_bls_sync (OstreeBootloader *bootloader,
GCancellable *cancellable,
GError **error)
{
OstreeBootloaderZipl *self = OSTREE_BOOTLOADER_ZIPL (bootloader);
/* Note that unlike the grub2-mkconfig backend, we make no attempt to
* chroot().
*/
g_assert (self->sysroot->booted_deployment);
if (!glnx_fstatat_allow_noent (self->sysroot->sysroot_fd, zipl_requires_execute_path, NULL, 0, error))
return FALSE;
/* If there's no stamp file, nothing to do */
if (errno == ENOENT)
return TRUE;
const char *const zipl_argv[] = {"zipl", NULL};
int estatus;
if (!g_spawn_sync (NULL, (char**)zipl_argv, NULL, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, NULL, &estatus, error))
return FALSE;
if (!g_spawn_check_exit_status (estatus, error))
return FALSE;
if (!glnx_unlinkat (self->sysroot->sysroot_fd, zipl_requires_execute_path, 0, error))
return FALSE;
return TRUE;
}
static void
_ostree_bootloader_zipl_finalize (GObject *object)
{
OstreeBootloaderZipl *self = OSTREE_BOOTLOADER_ZIPL (object);
g_clear_object (&self->sysroot);
G_OBJECT_CLASS (_ostree_bootloader_zipl_parent_class)->finalize (object);
}
void
_ostree_bootloader_zipl_init (OstreeBootloaderZipl *self)
{
}
static void
_ostree_bootloader_zipl_bootloader_iface_init (OstreeBootloaderInterface *iface)
{
iface->query = _ostree_bootloader_zipl_query;
iface->get_name = _ostree_bootloader_zipl_get_name;
iface->write_config = _ostree_bootloader_zipl_write_config;
iface->post_bls_sync = _ostree_bootloader_zipl_post_bls_sync;
}
void
_ostree_bootloader_zipl_class_init (OstreeBootloaderZiplClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = _ostree_bootloader_zipl_finalize;
}
OstreeBootloaderZipl *
_ostree_bootloader_zipl_new (OstreeSysroot *sysroot)
{
OstreeBootloaderZipl *self = g_object_new (OSTREE_TYPE_BOOTLOADER_ZIPL, NULL);
self->sysroot = g_object_ref (sysroot);
return self;
}
+36
View File
@@ -0,0 +1,36 @@
/*
* Copyright (C) 2019 Colin Walters <walters@verbum.org>
*
* This program 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 licence 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.
*/
#pragma once
#include "ostree-bootloader.h"
G_BEGIN_DECLS
#define OSTREE_TYPE_BOOTLOADER_ZIPL (_ostree_bootloader_zipl_get_type ())
#define OSTREE_BOOTLOADER_ZIPL(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), OSTREE_TYPE_BOOTLOADER_ZIPL, OstreeBootloaderZipl))
#define OSTREE_IS_BOOTLOADER_ZIPL(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), OSTREE_TYPE_BOOTLOADER_ZIPL))
typedef struct _OstreeBootloaderZipl OstreeBootloaderZipl;
GType _ostree_bootloader_zipl_get_type (void) G_GNUC_CONST;
OstreeBootloaderZipl * _ostree_bootloader_zipl_new (OstreeSysroot *sysroot);
G_END_DECLS
+13
View File
@@ -65,6 +65,19 @@ _ostree_bootloader_write_config (OstreeBootloader *self,
cancellable, error);
}
gboolean
_ostree_bootloader_post_bls_sync (OstreeBootloader *self,
GCancellable *cancellable,
GError **error)
{
g_return_val_if_fail (OSTREE_IS_BOOTLOADER (self), FALSE);
if (OSTREE_BOOTLOADER_GET_IFACE (self)->post_bls_sync)
return OSTREE_BOOTLOADER_GET_IFACE (self)->post_bls_sync (self, cancellable, error);
return TRUE;
}
gboolean
_ostree_bootloader_is_atomic (OstreeBootloader *self)
{
+7
View File
@@ -47,6 +47,9 @@ struct _OstreeBootloaderInterface
GPtrArray *new_deployments,
GCancellable *cancellable,
GError **error);
gboolean (* post_bls_sync) (OstreeBootloader *self,
GCancellable *cancellable,
GError **error);
gboolean (* is_atomic) (OstreeBootloader *self);
};
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeBootloader, g_object_unref)
@@ -66,6 +69,10 @@ gboolean _ostree_bootloader_write_config (OstreeBootloader *self,
GCancellable *cancellable,
GError **error);
gboolean _ostree_bootloader_post_bls_sync (OstreeBootloader *self,
GCancellable *cancellable,
GError **error);
gboolean _ostree_bootloader_is_atomic (OstreeBootloader *self);
G_END_DECLS
+2
View File
@@ -717,6 +717,8 @@ checkout_one_file_at (OstreeRepo *repo,
}
current_repo = current_repo->parent_repo;
}
/* Pacify clang-analyzer which sees us testing effectively if (repo == NULL) */
g_assert (repo);
need_copy = (hardlink_res == HARDLINK_RESULT_NOT_SUPPORTED);
}
+7 -4
View File
@@ -871,7 +871,10 @@ write_content_object (OstreeRepo *self,
/* Give a null input if there's no content */
g_autoptr(GInputStream) null_input = NULL;
if (!input)
null_input = input = g_memory_input_stream_new_from_data ("", 0, NULL);
{
null_input = input = g_memory_input_stream_new_from_data ("", 0, NULL);
(void) null_input; /* quiet static analysis */
}
checksum_input = ot_checksum_instream_new_with_start (input, G_CHECKSUM_SHA256,
buf, len);
@@ -1585,7 +1588,6 @@ ostree_repo_prepare_transaction (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
g_autoptr(_OstreeRepoAutoTransaction) txn = NULL;
guint64 reserved_bytes = 0;
g_return_val_if_fail (self->in_transaction == FALSE, FALSE);
@@ -1593,7 +1595,8 @@ ostree_repo_prepare_transaction (OstreeRepo *self,
g_debug ("Preparing transaction in repository %p", self);
/* Set up to abort the transaction if we return early from this function. */
txn = self;
g_autoptr(_OstreeRepoAutoTransaction) txn = self;
(void) txn; /* Add use to silence static analysis */
memset (&self->txn.stats, 0, sizeof (OstreeRepoTransactionStats));
@@ -1649,7 +1652,7 @@ ostree_repo_prepare_transaction (OstreeRepo *self,
return FALSE;
/* Success: do not abort the transaction when returning. */
txn = NULL;
txn = NULL; (void) txn;
if (out_transaction_resume)
*out_transaction_resume = ret_transaction_resume;
+6 -5
View File
@@ -2181,7 +2181,6 @@ static void
start_fetch (OtPullData *pull_data,
FetchObjectData *fetch)
{
gboolean is_meta;
g_autofree char *obj_subpath = NULL;
guint64 *expected_max_size_p;
guint64 expected_max_size;
@@ -2190,13 +2189,12 @@ start_fetch (OtPullData *pull_data,
GPtrArray *mirrorlist = NULL;
ostree_object_name_deserialize (fetch->object, &expected_checksum, &objtype);
is_meta = OSTREE_OBJECT_TYPE_IS_META (objtype);
g_debug ("starting fetch of %s.%s%s", expected_checksum,
ostree_object_type_to_string (objtype),
fetch->is_detached_meta ? " (detached)" : "");
is_meta = OSTREE_OBJECT_TYPE_IS_META (objtype);
gboolean is_meta = OSTREE_OBJECT_TYPE_IS_META (objtype);
if (is_meta)
pull_data->n_outstanding_metadata_fetches++;
else
@@ -3575,7 +3573,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
g_autofree char **refs_to_fetch = NULL;
g_autoptr(GVariantIter) collection_refs_iter = NULL;
g_autofree char **override_commit_ids = NULL;
GSource *update_timeout = NULL;
g_autoptr(GSource) update_timeout = NULL;
gboolean opt_gpg_verify_set = FALSE;
gboolean opt_gpg_verify_summary_set = FALSE;
gboolean opt_collection_refs_set = FALSE;
@@ -3677,6 +3675,10 @@ ostree_repo_pull_with_options (OstreeRepo *self,
pull_data->async_error = &pull_data->cached_async_error;
else
pull_data->async_error = NULL;
/* Note we're using the thread default (or global) context here, so it may outlive the
* OtPullData object if there's another ref on it. Thus, always detach/destroy sources
* local to the `ostree_repo_pull*` operation rather than trying to transfer ownership. */
pull_data->main_context = g_main_context_ref_thread_default ();
pull_data->flags = flags;
@@ -4516,7 +4518,6 @@ ostree_repo_pull_with_options (OstreeRepo *self,
g_source_set_priority (update_timeout, G_PRIORITY_HIGH);
g_source_set_callback (update_timeout, update_progress, pull_data, NULL);
g_source_attach (update_timeout, pull_data->main_context);
g_source_unref (update_timeout);
}
/* Now await work completion */
+6 -4
View File
@@ -1548,8 +1548,8 @@ keyfile_set_from_vardict (GKeyFile *keyfile,
g_key_file_set_string_list (keyfile, section, key, strv_child, len);
}
else
g_critical ("Unhandled type '%s' in " G_GNUC_FUNCTION,
(char*)g_variant_get_type (child));
g_critical ("Unhandled type '%s' in %s",
(char*)g_variant_get_type (child), G_STRFUNC);
}
}
@@ -3184,8 +3184,10 @@ reload_sysroot_config (OstreeRepo *self,
* binary "x" in /usr/lib/ostree/bootloaders/x). See:
* https://github.com/ostreedev/ostree/issues/1719
* https://github.com/ostreedev/ostree/issues/1801
* Also, dedup these strings with the bootloader implementations
*/
if (!(g_str_equal (bootloader, "auto") || g_str_equal (bootloader, "none")))
if (!(g_str_equal (bootloader, "auto") || g_str_equal (bootloader, "none")
|| g_str_equal (bootloader, "zipl")))
return glnx_throw (error, "Invalid bootloader configuration: '%s'", bootloader);
g_free (self->bootloader);
@@ -4197,7 +4199,7 @@ ostree_repo_has_object (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
gboolean ret_have_object;
gboolean ret_have_object = FALSE;
if (!_ostree_repo_has_loose_object (self, checksum, objtype, &ret_have_object,
cancellable, error))
+1
View File
@@ -313,6 +313,7 @@ cleanup_old_deployments (OstreeSysroot *self,
if (!list_all_deployment_directories (self, &all_deployment_dirs,
cancellable, error))
return FALSE;
g_assert (all_deployment_dirs); /* Pacify static analysis */
for (guint i = 0; i < all_deployment_dirs->len; i++)
{
OstreeDeployment *deployment = all_deployment_dirs->pdata[i];
+51 -5
View File
@@ -43,6 +43,7 @@
#include "ostree.h"
#include "ostree-sysroot-private.h"
#include "ostree-sepolicy-private.h"
#include "ostree-bootloader-zipl.h"
#include "ostree-deployment-private.h"
#include "ostree-core-private.h"
#include "ostree-linuxfsutil.h"
@@ -753,15 +754,14 @@ prepare_deployment_etc (OstreeSysroot *sysroot,
return FALSE;
gboolean usretc_exists = (errno == 0);
if (etc_exists && usretc_exists)
return glnx_throw (error, "Tree contains both /etc and /usr/etc");
else if (etc_exists)
if (etc_exists)
{
if (usretc_exists)
return glnx_throw (error, "Tree contains both /etc and /usr/etc");
/* Compatibility hack */
if (!glnx_renameat (deployment_dfd, "etc", deployment_dfd, "usr/etc", error))
return FALSE;
usretc_exists = TRUE;
etc_exists = FALSE;
}
if (usretc_exists)
@@ -878,6 +878,8 @@ typedef struct {
int boot_dfd;
char *kernel_srcpath;
char *kernel_namever;
char *kernel_hmac_srcpath;
char *kernel_hmac_namever;
char *initramfs_srcpath;
char *initramfs_namever;
char *devicetree_srcpath;
@@ -890,6 +892,8 @@ _ostree_kernel_layout_free (OstreeKernelLayout *layout)
glnx_close_fd (&layout->boot_dfd);
g_free (layout->kernel_srcpath);
g_free (layout->kernel_namever);
g_free (layout->kernel_hmac_srcpath);
g_free (layout->kernel_hmac_namever);
g_free (layout->initramfs_srcpath);
g_free (layout->initramfs_namever);
g_free (layout->devicetree_srcpath);
@@ -1032,6 +1036,16 @@ get_kernel_from_tree_usrlib_modules (int deployment_dfd,
g_clear_object (&in);
glnx_close_fd (&fd);
/* And finally, look for any HMAC file. This is needed for FIPS mode on some distros. */
if (!glnx_fstatat_allow_noent (ret_layout->boot_dfd, ".vmlinuz.hmac", NULL, 0, error))
return FALSE;
if (errno == 0)
{
ret_layout->kernel_hmac_srcpath = g_strdup (".vmlinuz.hmac");
/* Name it as dracut expects it: https://github.com/dracutdevs/dracut/blob/225e4b94cbdb702cf512490dcd2ad9ca5f5b22c1/modules.d/01fips/fips.sh#L129 */
ret_layout->kernel_hmac_namever = g_strdup_printf (".%s.hmac", ret_layout->kernel_namever);
}
char hexdigest[OSTREE_SHA256_STRING_LEN+1];
ot_checksum_get_hexdigest (&checksum, hexdigest, sizeof (hexdigest));
ret_layout->bootcsum = g_strdup (hexdigest);
@@ -1686,6 +1700,20 @@ install_deployment_kernel (OstreeSysroot *sysroot,
}
}
if (kernel_layout->kernel_hmac_srcpath)
{
if (!glnx_fstatat_allow_noent (bootcsum_dfd, kernel_layout->kernel_hmac_namever, &stbuf, 0, error))
return FALSE;
if (errno == ENOENT)
{
if (!install_into_boot (sepolicy, kernel_layout->boot_dfd, kernel_layout->kernel_hmac_srcpath,
bootcsum_dfd, kernel_layout->kernel_hmac_namever,
sysroot->debug_flags,
cancellable, error))
return FALSE;
}
}
g_autofree char *contents = NULL;
if (!glnx_fstatat_allow_noent (deployment_dfd, "usr/lib/os-release", &stbuf, 0, error))
return FALSE;
@@ -1830,6 +1858,7 @@ prepare_new_bootloader_link (OstreeSysroot *sysroot,
/* Update the /boot/loader symlink to point to /boot/loader.$new_bootversion */
static gboolean
swap_bootloader (OstreeSysroot *sysroot,
OstreeBootloader *bootloader,
int current_bootversion,
int new_bootversion,
GCancellable *cancellable,
@@ -1863,6 +1892,15 @@ swap_bootloader (OstreeSysroot *sysroot,
if (fsync (boot_dfd) != 0)
return glnx_throw_errno_prefix (error, "fsync(boot)");
/* TODO: In the future also execute this automatically via a systemd unit
* if we detect it's necessary.
**/
if (bootloader)
{
if (!_ostree_bootloader_post_bls_sync (bootloader, cancellable, error))
return FALSE;
}
return TRUE;
}
@@ -2129,7 +2167,7 @@ write_deployments_bootswap (OstreeSysroot *self,
if (!full_system_sync (self, out_syncstats, cancellable, error))
return FALSE;
if (!swap_bootloader (self, self->bootversion, new_bootversion,
if (!swap_bootloader (self, bootloader, self->bootversion, new_bootversion,
cancellable, error))
return FALSE;
@@ -2356,6 +2394,14 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self,
{
/* No bootloader specified; do not query bootloaders to run. */
}
else if (g_str_equal (bootloader_config, "zipl"))
{
/* Because we do not mark zipl as active by default, lets creating one here,
* which is basically the same what _ostree_sysroot_query_bootloader() does
* for other bootloaders if being activated.
* */
bootloader = (OstreeBootloader*) _ostree_bootloader_zipl_new (self);
}
bootloader_is_atomic = bootloader != NULL && _ostree_bootloader_is_atomic (bootloader);
+2 -4
View File
@@ -945,6 +945,7 @@ ostree_sysroot_load_if_changed (OstreeSysroot *self,
g_autoptr(GPtrArray) deployments = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
g_assert (boot_loader_configs); /* Pacify static analysis */
for (guint i = 0; i < boot_loader_configs->len; i++)
{
OstreeBootconfigParser *config = boot_loader_configs->pdata[i];
@@ -1671,10 +1672,7 @@ ostree_sysroot_simple_write_deployment (OstreeSysroot *sysroot,
/* add it last if no crossover defined (or it's the first deployment in the sysroot) */
if (!added_new)
{
g_ptr_array_add (new_deployments, g_object_ref (new_deployment));
added_new = TRUE;
}
g_ptr_array_add (new_deployments, g_object_ref (new_deployment));
OstreeSysrootWriteDeploymentsOpts write_opts = { .do_postclean = postclean };
if (!ostree_sysroot_write_deployments_with_options (sysroot, new_deployments, &write_opts,
+3 -3
View File
@@ -43,7 +43,7 @@
*
* Since: 2017.4
*/
#define OSTREE_RELEASE_VERSION (4)
#define OSTREE_RELEASE_VERSION (5)
/**
* OSTREE_VERSION
@@ -52,7 +52,7 @@
*
* Since: 2017.4
*/
#define OSTREE_VERSION (2019.4)
#define OSTREE_VERSION (2019.5)
/**
* OSTREE_VERSION_S:
@@ -62,7 +62,7 @@
*
* Since: 2017.4
*/
#define OSTREE_VERSION_S "2019.4"
#define OSTREE_VERSION_S "2019.5"
#define OSTREE_ENCODE_VERSION(year,release) \
((year) << 16 | (release))