mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-21 02:50:37 +03:00
sepolicy: Fix regressions from introduction of sepolicy_new_at()
Being bitten by lack of PR testing here. There are two bugs: - First and foremost, I forgot that GObject will call the property setters with the defaults. This meant we were getting both path="/var/tmp/blah" and fd=-1, and we were accepting -1 as a fd, which then got converted into AT_FDCWD which was wrong. - Since these properties are construct only and mutually exclusive, don't try to handle one resetting the other. Assert that exactly one of them is set. Closes: #769 Approved by: jlebon
This commit is contained in:
parent
305db981d4
commit
8d4dec1b53
@ -112,15 +112,18 @@ ostree_sepolicy_set_property(GObject *object,
|
||||
{
|
||||
/* Canonicalize */
|
||||
self->path = g_file_new_for_path (gs_file_get_path_cached (path));
|
||||
g_assert_cmpint (self->rootfs_dfd, ==, -1);
|
||||
}
|
||||
self->rootfs_dfd = -1;
|
||||
}
|
||||
break;
|
||||
case PROP_ROOTFS_DFD:
|
||||
{
|
||||
self->rootfs_dfd = g_value_get_int (value);
|
||||
g_clear_object (&self->path);
|
||||
self->path = ot_fdrel_to_gfile (self->rootfs_dfd, ".");
|
||||
int fd = g_value_get_int (value);
|
||||
if (fd != -1)
|
||||
{
|
||||
g_assert (self->path == NULL);
|
||||
self->rootfs_dfd = fd;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -282,6 +285,7 @@ initable_init (GInitable *initable,
|
||||
#ifdef HAVE_SELINUX
|
||||
gboolean ret = FALSE;
|
||||
OstreeSePolicy *self = OSTREE_SEPOLICY (initable);
|
||||
g_autoptr(GFile) path = NULL;
|
||||
g_autoptr(GFile) etc_selinux_dir = NULL;
|
||||
g_autoptr(GFile) policy_config_path = NULL;
|
||||
g_autoptr(GFile) policy_root = NULL;
|
||||
@ -293,19 +297,27 @@ initable_init (GInitable *initable,
|
||||
const char *selinuxtype_prefix = "SELINUXTYPE=";
|
||||
|
||||
/* TODO - use this below */
|
||||
if (self->rootfs_dfd == -1)
|
||||
if (self->rootfs_dfd != -1)
|
||||
path = ot_fdrel_to_gfile (self->rootfs_dfd, ".");
|
||||
else if (self->path)
|
||||
{
|
||||
path = g_object_ref (self->path);
|
||||
#if 0
|
||||
/* TODO - use this below */
|
||||
if (!glnx_opendirat (AT_FDCWD, gs_file_get_path_cached (self->path), TRUE,
|
||||
&self->rootfs_dfd_owned, error))
|
||||
goto out;
|
||||
self->rootfs_dfd = self->rootfs_dfd_owned;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
|
||||
etc_selinux_dir = g_file_resolve_relative_path (self->path, "etc/selinux");
|
||||
etc_selinux_dir = g_file_resolve_relative_path (path, "etc/selinux");
|
||||
if (!g_file_query_exists (etc_selinux_dir, NULL))
|
||||
{
|
||||
g_object_unref (etc_selinux_dir);
|
||||
etc_selinux_dir = g_file_resolve_relative_path (self->path, "usr/etc/selinux");
|
||||
etc_selinux_dir = g_file_resolve_relative_path (path, "usr/etc/selinux");
|
||||
}
|
||||
policy_config_path = g_file_get_child (etc_selinux_dir, "config");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user