In order to be able to mount a custom host-image as / we need to be able
to access libvirt-sandbox-init-common and all its needed dependencies.
In the container case we also need to copy libvirt-sandbox-init-lxc.
They are now copied into SANDBOXCONFIGDIR /.libs. Hard linking is not
possible since we may be working on separate partitions, and symlinks
wouldn't help to work with apparmor. Copying makes apparmor happy and
solves our problem.
---
configure.ac | 7 +
.../libvirt-sandbox-builder-container.c| 15 +-
libvirt-sandbox/libvirt-sandbox-builder.c | 159 -
libvirt-sandbox/libvirt-sandbox-builder.h | 2 +
libvirt-sandbox/libvirt-sandbox-init-lxc.c | 8 +-
libvirt-sandbox/libvirt-sandbox-init-qemu.c| 9 +-
6 files changed, 196 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index 99d22d7..608f56b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -109,6 +109,13 @@ LIBVIRT_SANDBOX_SELINUX
LIBVIRT_SANDBOX_STATIC_LIBC
+dnl search for LDD path
+AC_PATH_PROG([LDD_PATH], [ldd])
+if test -z "$LDD_PATH"; then
+AC_MSG_ERROR([Failed to find ldd.])
+fi
+AC_DEFINE_UNQUOTED([LDD_PATH], "$LDD_PATH", [path to ldd binary])
+
GOBJECT_INTROSPECTION_CHECK([$GOBJECT_INTROSPECTION_REQUIRED])
dnl Should be in m4/virt-gettext.m4 but intltoolize is too
diff --git a/libvirt-sandbox/libvirt-sandbox-builder-container.c
b/libvirt-sandbox/libvirt-sandbox-builder-container.c
index c23b82b..d226d35 100644
--- a/libvirt-sandbox/libvirt-sandbox-builder-container.c
+++ b/libvirt-sandbox/libvirt-sandbox-builder-container.c
@@ -184,7 +184,7 @@ static gboolean
gvir_sandbox_builder_container_construct_os(GVirSandboxBuilder *
gvir_config_domain_os_set_arch(os,
gvir_sandbox_config_get_arch(config));
gvir_config_domain_os_set_init(os,
- LIBEXECDIR "/libvirt-sandbox-init-lxc");
+ SANDBOXCONFIGDIR
"/.libs/libvirt-sandbox-init-lxc");
gvir_config_domain_os_set_cmdline(os, cmdline);
gvir_config_domain_set_os(domain, os);
@@ -444,6 +444,18 @@ static const gchar
*gvir_sandbox_builder_container_get_disk_prefix(GVirSandboxBu
return "sd";
}
+
+static GList
*gvir_sandbox_builder_container_get_files_to_copy(GVirSandboxBuilder *builder,
+
GVirSandboxConfig *config G_GNUC_UNUSED)
+{
+GList * tocopy =
GVIR_SANDBOX_BUILDER_CLASS(gvir_sandbox_builder_container_parent_class)->
+ get_files_to_copy(builder, config);
+gchar *file = g_strdup_printf("%s/libvirt-sandbox-init-lxc", LIBEXECDIR);
+
+return g_list_append(tocopy, file);
+}
+
+
static void
gvir_sandbox_builder_container_class_init(GVirSandboxBuilderContainerClass
*klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
@@ -458,6 +470,7 @@ static void
gvir_sandbox_builder_container_class_init(GVirSandboxBuilderContaine
builder_class->construct_features =
gvir_sandbox_builder_container_construct_features;
builder_class->construct_devices =
gvir_sandbox_builder_container_construct_devices;
builder_class->get_disk_prefix =
gvir_sandbox_builder_container_get_disk_prefix;
+builder_class->get_files_to_copy =
gvir_sandbox_builder_container_get_files_to_copy;
g_type_class_add_private(klass,
sizeof(GVirSandboxBuilderContainerPrivate));
}
diff --git a/libvirt-sandbox/libvirt-sandbox-builder.c
b/libvirt-sandbox/libvirt-sandbox-builder.c
index aa932db..2726868 100644
--- a/libvirt-sandbox/libvirt-sandbox-builder.c
+++ b/libvirt-sandbox/libvirt-sandbox-builder.c
@@ -107,6 +107,8 @@ static gboolean
gvir_sandbox_builder_clean_post_stop_default(GVirSandboxBuilder
GVirSandboxConfig
*config,
const gchar
*statedir,
GError **error);
+static GList *gvir_sandbox_builder_get_files_to_copy(GVirSandboxBuilder
*builder,
+ GVirSandboxConfig
*config);
static void gvir_sandbox_builder_get_property(GObject *object,
guint prop_id,
@@ -176,6 +178,7 @@ static void
gvir_sandbox_builder_class_init(GVirSandboxBuilderClass *klass)
klass->construct_security = gvir_sandbox_builder_construct_security;
klass->clean_post_start = gvir_sandbox_builder_clean_post_start_default;
klass->clean_post_stop = gvir_sandbox_builder_clean_post_stop_default;
+klass->get_files_to_copy = gvir_sandbox_builder_get_files_to_copy;
g_object_class_install_property(object_class,
PROP_CONNECTION,
@@ -247,6 +250,108 @@ GVirConnection
*gvir_sandbox_builder_get_connection(GVirSandboxBuilder *builder)