]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
attach: handle apparmor transitions in !NEWNS cases
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Wed, 6 Mar 2013 19:41:04 +0000 (13:41 -0600)
committerStéphane Graber <stgraber@ubuntu.com>
Wed, 6 Mar 2013 23:47:36 +0000 (18:47 -0500)
If we're not attaching to the mount ns , then don't enter the
container's apparmor policy.  Since we're running binaries from the host
and not the container, that actually seems the sane thing to do (besides
also the lazier thing).

If we dont' do this patch, then we will need to move the apparmor attach
past the procfs remount, will need to also mount securityfs if available,
and for the !remount_proc_sys case we'll want to mount those just long
enough to do the apparmor transition.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/lxc_attach.c

index 1622cb12f73fc67b275e05800709e6141c70c812..6f60ecb0a2d12a6d2d83b8211b0ac5a9da869fe0 100644 (file)
@@ -376,9 +376,11 @@ int main(int argc, char *argv[])
                lxc_sync_fini_parent(handler);
                close(cgroup_ipc_sockets[1]);
 
-               if (attach_apparmor(init_ctx->aa_profile) < 0) {
-                       ERROR("failed switching apparmor profiles");
-                       return -1;
+               if ((namespace_flags & CLONE_NEWNS)) {
+                       if (attach_apparmor(init_ctx->aa_profile) < 0) {
+                               ERROR("failed switching apparmor profiles");
+                               return -1;
+                       }
                }
 
                /* A description of the purpose of this functionality is