core: Don't try to walk up pkgcache parent chains
My desktop system was aborting on upgrade with a missing metadata object, which turned out to be the fact that my previous changes to the package layering code pruned with depth=0, but the commit it was looking for had a parent commit that had been pruned. Closes: #475 Approved by: jlebon
This commit is contained in:
parent
7dd28fa964
commit
f9f326f0f9
@ -786,45 +786,26 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
find_rev_with_sepolicy (OstreeRepo *repo,
|
commit_has_matching_sepolicy (OstreeRepo *repo,
|
||||||
const char *head,
|
const char *head,
|
||||||
OstreeSePolicy *sepolicy,
|
OstreeSePolicy *sepolicy,
|
||||||
gboolean allow_noent,
|
gboolean *out_matches,
|
||||||
char **out_rev,
|
GError **error)
|
||||||
GError **error)
|
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
|
||||||
const char *sepolicy_csum_wanted = ostree_sepolicy_get_csum (sepolicy);
|
const char *sepolicy_csum_wanted = ostree_sepolicy_get_csum (sepolicy);
|
||||||
g_autofree char *commit_rev = g_strdup (head);
|
g_autoptr(GVariant) commit = NULL;
|
||||||
|
g_autofree char *sepolicy_csum = NULL;
|
||||||
|
|
||||||
/* walk up the branch until we find a matching policy */
|
if (!ostree_repo_load_commit (repo, head, &commit, NULL, error))
|
||||||
while (commit_rev != NULL)
|
return FALSE;
|
||||||
{
|
g_assert (commit);
|
||||||
g_autoptr(GVariant) commit = NULL;
|
|
||||||
g_autofree char *sepolicy_csum = NULL;
|
|
||||||
|
|
||||||
if (!ostree_repo_load_commit (repo, commit_rev, &commit, NULL, error))
|
if (!get_commit_sepolicy_csum (commit, &sepolicy_csum, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
g_assert (commit);
|
|
||||||
|
|
||||||
if (!get_commit_sepolicy_csum (commit, &sepolicy_csum, error))
|
*out_matches = strcmp (sepolicy_csum, sepolicy_csum_wanted) == 0;
|
||||||
goto out;
|
|
||||||
|
|
||||||
if (strcmp (sepolicy_csum, sepolicy_csum_wanted) == 0)
|
return TRUE;
|
||||||
break;
|
|
||||||
|
|
||||||
g_free (commit_rev);
|
|
||||||
commit_rev = ostree_commit_get_parent (commit);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (commit_rev == NULL && !allow_noent)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
*out_rev = g_steal_pointer (&commit_rev);
|
|
||||||
|
|
||||||
ret = TRUE;
|
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -869,13 +850,9 @@ find_pkg_in_ostree (OstreeRepo *repo,
|
|||||||
|
|
||||||
if (sepolicy)
|
if (sepolicy)
|
||||||
{
|
{
|
||||||
g_autofree char *cached_rev_sel = NULL;
|
if (!commit_has_matching_sepolicy (repo, cached_rev, sepolicy,
|
||||||
if (!find_rev_with_sepolicy (repo, cached_rev, sepolicy,
|
out_selinux_match, error))
|
||||||
TRUE, &cached_rev_sel, error))
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (cached_rev_sel)
|
|
||||||
*out_selinux_match = TRUE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1935,21 +1912,21 @@ rpmostree_context_assemble_commit (RpmOstreeContext *self,
|
|||||||
g_autoptr(GVariant) pkg_commit = NULL;
|
g_autoptr(GVariant) pkg_commit = NULL;
|
||||||
g_autoptr(GVariant) header_variant = NULL;
|
g_autoptr(GVariant) header_variant = NULL;
|
||||||
const char *nevra = dnf_package_get_nevra (pkg);
|
const char *nevra = dnf_package_get_nevra (pkg);
|
||||||
|
gboolean sepolicy_matches;
|
||||||
|
|
||||||
{
|
if (!ostree_repo_resolve_rev (pkgcache_repo, cachebranch, FALSE,
|
||||||
g_autofree char *branch_head_rev = NULL;
|
&cached_rev, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
if (!ostree_repo_resolve_rev (pkgcache_repo, cachebranch, FALSE,
|
if (self->sepolicy)
|
||||||
&branch_head_rev, error))
|
{
|
||||||
goto out;
|
if (!commit_has_matching_sepolicy (pkgcache_repo, cached_rev,
|
||||||
|
self->sepolicy, &sepolicy_matches,
|
||||||
if (self->sepolicy == NULL)
|
error))
|
||||||
cached_rev = g_steal_pointer (&branch_head_rev);
|
goto out;
|
||||||
else if (!find_rev_with_sepolicy (pkgcache_repo, branch_head_rev,
|
/* We already did any relabeling/reimporting above */
|
||||||
self->sepolicy, FALSE, &cached_rev,
|
g_assert (sepolicy_matches);
|
||||||
error))
|
}
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ostree_repo_load_variant (pkgcache_repo, OSTREE_OBJECT_TYPE_COMMIT, cached_rev,
|
if (!ostree_repo_load_variant (pkgcache_repo, OSTREE_OBJECT_TYPE_COMMIT, cached_rev,
|
||||||
&pkg_commit, error))
|
&pkg_commit, error))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user