]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
9 years agopreserve container namespace
Wolfgang Bumiller [Tue, 6 Oct 2015 08:01:02 +0000 (10:01 +0200)] 
preserve container namespace

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agostart.c:preserve_ns: added pid parameter
Wolfgang Bumiller [Tue, 6 Oct 2015 08:01:01 +0000 (10:01 +0200)] 
start.c:preserve_ns: added pid parameter

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoMake overlayfs mounts work directly
Christian Brauner [Tue, 6 Oct 2015 18:38:13 +0000 (20:38 +0200)] 
Make overlayfs mounts work directly

When users wanted to mount overlay directories with lxc.mount.entry they had to
create upperdirs and workdirs beforehand in order to mount them. To create it
for them we add the functions mount_entry_create_overlay_dirs() and
mount_entry_create_aufs_dirs() which do this for them. User can now simply
specify e.g.:

        lxc.mount.entry = /lower merged overlay lowerdir=/lower,upper=/upper,workdir=/workdir,create=dir

and /upper and /workdir will be created for them. /upper and /workdir need to
be absolute paths to directories which are created under the containerdir (e.g.
under $lxcpath/CONTAINERNAME/). Relative mountpoints, mountpoints outside the
containerdir, and mountpoints within the container's rootfs are ignored. (The
latter *might* change in the future should it be considered safe/useful.)

Specifying

        lxc.mount.entry = /lower merged overlay lowerdir=/lower:/lower2,create=dir

will lead to a read-only overlay mount in accordance with the
kernel-documentation.

Specifying

        lxc.mount.entry = /lower merged overlay lowerdir=/lower,create=dir

will fail when no upperdir and workdir options are given.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoFix the type of i in lxc_mount_auto_mounts
Stéphane Graber [Mon, 5 Oct 2015 11:12:17 +0000 (12:12 +0100)] 
Fix the type of i in lxc_mount_auto_mounts

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agolxc_mount_auto_mounts: fix weirdness
Serge Hallyn [Sat, 3 Oct 2015 21:52:16 +0000 (21:52 +0000)] 
lxc_mount_auto_mounts: fix weirdness

The default_mounts[i].destination is never NULL except in the last
'stop here' entry.  Coverity doesn't know about that and so is spewing
a warning.  In any case, let's add a more stringent check in case someone
accidentally adds a NULL there later.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agodoc: Add the note related mount in Japanese lxc.container.conf(5)
KATOH Yasufumi [Wed, 30 Sep 2015 06:19:27 +0000 (15:19 +0900)] 
doc: Add the note related mount in Japanese lxc.container.conf(5)

Update for commit 592fd47

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agolxc-test-symlink: add a test using absolute symlink
Serge Hallyn [Wed, 30 Sep 2015 18:01:01 +0000 (18:01 +0000)] 
lxc-test-symlink: add a test using absolute symlink

This would have caught the regression last night.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agoMake lxc-start-ephemeral use lxc.ephemeral
Christian Brauner [Wed, 30 Sep 2015 12:32:24 +0000 (14:32 +0200)] 
Make lxc-start-ephemeral use lxc.ephemeral

While lxc-copy is under review let users benefit (reboot survival etc.) from the
new lxc.ephemeral option already in lxc-start-ephemeral. This way we can remove
the lxc.hook.post-stop script-

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agoCleanup parts of lxc-destroy
Christian Brauner [Tue, 29 Sep 2015 17:48:23 +0000 (19:48 +0200)] 
Cleanup parts of lxc-destroy

A bit of pedantry usually doesn't hurt. The code should be easier to follow now
and avoids some repetitions.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoAdd lxc.ephemeral to lxc.container.conf manpage
Christian Brauner [Wed, 30 Sep 2015 12:56:55 +0000 (14:56 +0200)] 
Add lxc.ephemeral to lxc.container.conf manpage

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoseccomp: add aarch64 support
Bogdan Purcareata [Thu, 1 Oct 2015 08:19:37 +0000 (08:19 +0000)] 
seccomp: add aarch64 support

Enable aarch64 seccomp support for LXC containers running on ARM64
architectures. Tested with libseccomp 2.2.0 and the default seccomp
policy example files delivered with the LXC package.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoMerge pull request #666 from Ponce/slackware-template
Stéphane Graber [Wed, 30 Sep 2015 17:58:01 +0000 (13:58 -0400)] 
Merge pull request #666 from Ponce/slackware-template

Add a slackware template.

9 years agoMerge pull request #667 from cjwatson/ephemeral-parse-passwd
Stéphane Graber [Wed, 30 Sep 2015 17:56:50 +0000 (13:56 -0400)] 
Merge pull request #667 from cjwatson/ephemeral-parse-passwd

lxc-start-ephemeral: Parse passwd directly

9 years agolxc-start-ephemeral: Parse passwd directly 667/head
Colin Watson [Wed, 30 Sep 2015 12:37:10 +0000 (13:37 +0100)] 
lxc-start-ephemeral: Parse passwd directly

On Ubuntu 15.04, lxc-start-ephemeral's call to pwd.getpwnam always
fails.  While I haven't been able to prove it or track down an exact
cause, I strongly suspect that glibc does not guarantee that you can
call NSS functions after a context switch without re-execing.  (Running
"id root" in a subprocess from the same point works fine.)

It's safer to use getent to extract the relevant line from the passwd
file and parse it directly.

Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
9 years agoDefine O_PATH and O_NOFOLLOW for Android
Stéphane Graber [Tue, 29 Sep 2015 18:59:28 +0000 (14:59 -0400)] 
Define O_PATH and O_NOFOLLOW for Android

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agoAdd a slackware template. 666/head
Matteo Bernardini [Tue, 29 Sep 2015 15:35:25 +0000 (17:35 +0200)] 
Add a slackware template.

Requires pkgtools and slackpkg (from the slackware-current tree).

Signed-off-by: Matteo Bernardini <ponce@slackbuilds.org>
9 years agoCVE-2015-1335: Protect container mounts against symlinks
Serge Hallyn [Mon, 31 Aug 2015 17:57:20 +0000 (12:57 -0500)] 
CVE-2015-1335: Protect container mounts against symlinks

When a container starts up, lxc sets up the container's inital fstree
by doing a bunch of mounting, guided by the container configuration
file.  The container config is owned by the admin or user on the host,
so we do not try to guard against bad entries.  However, since the
mount target is in the container, it's possible that the container admin
could divert the mount with symbolic links.  This could bypass proper
container startup (i.e. confinement of a root-owned container by the
restrictive apparmor policy, by diverting the required write to
/proc/self/attr/current), or bypass the (path-based) apparmor policy
by diverting, say, /proc to /mnt in the container.

To prevent this,

1. do not allow mounts to paths containing symbolic links

2. do not allow bind mounts from relative paths containing symbolic
links.

Details:

Define safe_mount which ensures that the container has not inserted any
symbolic links into any mount targets for mounts to be done during
container setup.

The host's mount path may contain symbolic links.  As it is under the
control of the administrator, that's ok.  So safe_mount begins the check
for symbolic links after the rootfs->mount, by opening that directory.

It opens each directory along the path using openat() relative to the
parent directory using O_NOFOLLOW.  When the target is reached, it
mounts onto /proc/self/fd/<targetfd>.

Use safe_mount() in mount_entry(), when mounting container proc,
and when needed.  In particular, safe_mount() need not be used in
any case where:

1. the mount is done in the container's namespace
2. the mount is for the container's rootfs
3. the mount is relative to a tmpfs or proc/sysfs which we have
   just safe_mount()ed ourselves

Since we were using proc/net as a temporary placeholder for /proc/sys/net
during container startup, and proc/net is a symbolic link, use proc/tty
instead.

Update the lxc.container.conf manpage with details about the new
restrictions.

Finally, add a testcase to test some symbolic link possibilities.

Reported-by: Roman Fiedler
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agoRemove unnecessary call to free()
Christian Brauner [Mon, 28 Sep 2015 20:52:27 +0000 (22:52 +0200)] 
Remove unnecessary call to free()

Freeing memory when calloc() fails doesn't make sense

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agolxc-alpine: use getopt to parse options
Kaarle Ritvanen [Mon, 28 Sep 2015 11:51:21 +0000 (14:51 +0300)] 
lxc-alpine: use getopt to parse options

Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agolxc-alpine: avoid GNU BRE extensions for better portability
Kaarle Ritvanen [Mon, 28 Sep 2015 11:49:14 +0000 (14:49 +0300)] 
lxc-alpine: avoid GNU BRE extensions for better portability

Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agoFree allocated memory on failure (v2)
Christian Brauner [Mon, 28 Sep 2015 11:33:33 +0000 (13:33 +0200)] 
Free allocated memory on failure (v2)

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoAdd CAP_BLOCK_SUSPEND
Christian Brauner [Sun, 27 Sep 2015 10:27:07 +0000 (12:27 +0200)] 
Add CAP_BLOCK_SUSPEND

CAP_BLOCK_SUSPEND (since Linux 3.5)
    Employ features that can block system suspend (epoll(7) EPOLLWAKEUP, /proc/sys/wake_lock).

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoAdd CAP_AUDIT_READ
Christian Brauner [Sun, 27 Sep 2015 10:16:54 +0000 (12:16 +0200)] 
Add CAP_AUDIT_READ

CAP_AUDIT_READ (since Linux 3.16)
    Allow reading the audit log via a multicast netlink socket.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoCheck return value of snprintf in mount_proc_if_needed()
Christian Brauner [Sun, 27 Sep 2015 08:32:28 +0000 (10:32 +0200)] 
Check return value of snprintf in mount_proc_if_needed()

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoCheck return value of snprintf
Christian Brauner [Sun, 27 Sep 2015 08:17:34 +0000 (10:17 +0200)] 
Check return value of snprintf

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agolxc-debian: We should only check the kernel architecture.
Stéphane Graber [Mon, 28 Sep 2015 19:43:10 +0000 (15:43 -0400)] 
lxc-debian: We should only check the kernel architecture.

The dpkg architecture isn't relevant to LXC, only the kernel arch is.

Signed-off-by: Gergely Szasz <szaszg@hu.inter.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agocoverity: remove useless check
Serge Hallyn [Sat, 26 Sep 2015 21:03:53 +0000 (16:03 -0500)] 
coverity: remove useless check

handler->conf can't be null bc we checked handler->conf->epheemral
before calling lxc_destroy_container_on_signal()

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agocoverity: drop second (redundant) block
Serge Hallyn [Sat, 26 Sep 2015 19:44:40 +0000 (14:44 -0500)] 
coverity: drop second (redundant) block

Don't proceed to try the mount if we failed to create the
target if it didn't exist.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agocmds: fix abstract socket length problem
Tycho Andersen [Fri, 25 Sep 2015 22:45:59 +0000 (16:45 -0600)] 
cmds: fix abstract socket length problem

Since we want to use null-terminated abstract sockets, let's compute the length
of them correctly.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agoubuntu.common.conf: mount /dev/mqueue
Serge Hallyn [Wed, 23 Sep 2015 19:49:06 +0000 (19:49 +0000)] 
ubuntu.common.conf: mount /dev/mqueue

systemd wants it.  It doesn't seem to be a big deal, but it's
one fewer error msg.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agoFix indentation
Stéphane Graber [Mon, 21 Sep 2015 20:25:47 +0000 (16:25 -0400)] 
Fix indentation

I've noticed that a bunch of the code we've included over the past few
weeks has been using 8-spaces rather than tabs, making it all very hard
to read depending on your tabstop setting.

This commit attempts to revert all of that back to proper tabs and fix a
few more cases I've noticed here and there.

No functional changes are included in this commit.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agoovl_rsync: make sure to umount
Serge Hallyn [Mon, 21 Sep 2015 19:33:23 +0000 (19:33 +0000)] 
ovl_rsync: make sure to umount

Otherwise the kernel will umount when it gets around to it, but
that on lxc_destroy we may race with it and fail the rmdir of
the overmounted (BUSY) rootfs.

This makes lxc-test-snapshot pass for me again.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agooverlayfs_mount: create delta dir if it doesn't exist
Serge Hallyn [Mon, 21 Sep 2015 17:09:25 +0000 (17:09 +0000)] 
overlayfs_mount: create delta dir if it doesn't exist

(This *should* fix the lxc-test-snapshot testcase, but doesn't seem
to by itself.)

If it doesn't exist, we may as well start with an empty one.  This
is needed when creating an overlayfs snapshot.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agolxc_rmdir_onedev: don't fail if path doesn't exist
Serge Hallyn [Mon, 21 Sep 2015 17:01:10 +0000 (17:01 +0000)] 
lxc_rmdir_onedev: don't fail if path doesn't exist

We're asked to delete it, don't fail if it doesn't exist.

This stops lxc-destroy from failing when the container isn't fully
built.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agoMake ephemeral containers survive reboots
Christian Brauner [Mon, 21 Sep 2015 16:01:41 +0000 (18:01 +0200)] 
Make ephemeral containers survive reboots

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agoRemove ephemeral containers from lxc_snapshots
Christian Brauner [Tue, 15 Sep 2015 19:24:05 +0000 (21:24 +0200)] 
Remove ephemeral containers from lxc_snapshots

On shutdown ephemeral containers will be destroyed. We use mod_all_rdeps() from
lxccontainer.c to update the lxc_snapshots file of the original container. We
also include lxclock.h to lock the container when mod_all_rdeps() is called to
avoid races.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoMake mod_all_rdeps() public It will now also be called from start.c
Christian Brauner [Tue, 15 Sep 2015 19:24:04 +0000 (21:24 +0200)] 
Make mod_all_rdeps() public It will now also be called from start.c

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agolxc-checkconfig: add some more config options
Tycho Andersen [Fri, 11 Sep 2015 18:45:33 +0000 (12:45 -0600)] 
lxc-checkconfig: add some more config options

Here's some more config options that we do actually require to be able to
boot containers.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agogitignore: add Korean man page output
Tycho Andersen [Fri, 11 Sep 2015 18:45:34 +0000 (12:45 -0600)] 
gitignore: add Korean man page output

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agogitignore: add strange lxc@.service file
Tycho Andersen [Fri, 11 Sep 2015 18:45:35 +0000 (12:45 -0600)] 
gitignore: add strange lxc@.service file

I have no idea what this file is, but the build system seems to be
generating it, so let's ignore it.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoEnsure that mmap()ed memory is \0-terminated (v3)
Christian Brauner [Fri, 11 Sep 2015 06:07:37 +0000 (08:07 +0200)] 
Ensure that mmap()ed memory is \0-terminated (v3)

Use pwrite() to write terminating \0-byte

This allows us to use standard string handling functions and we can avoid using
the GNU-extension memmem(). This simplifies removing the container from the
lxc_snapshots file. Wrap strstr() in a while loop to remove duplicate entries.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoFixing MTU calculation in instantiate_veth()]
Stephane Nguyen [Wed, 9 Sep 2015 06:22:52 +0000 (08:22 +0200)] 
Fixing MTU calculation in instantiate_veth()]

Signed-off-by: Stephane Nguyen <stephminh@yahoo.es>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoEnable lxc_fini() to destroy container on shutdown
Christian Brauner [Tue, 8 Sep 2015 20:37:16 +0000 (22:37 +0200)] 
Enable lxc_fini() to destroy container on shutdown

When lxc.ephemeral is set to 1 in the containers config it will be destroyed on
shutdown.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoDestroy bdevs using bdev_destroy() from bdev.h
Christian Brauner [Tue, 8 Sep 2015 20:37:15 +0000 (22:37 +0200)] 
Destroy bdevs using bdev_destroy() from bdev.h

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoAdd bdev_destroy() and bdev_destroy_wrapper()
Christian Brauner [Tue, 8 Sep 2015 20:37:14 +0000 (22:37 +0200)] 
Add bdev_destroy() and bdev_destroy_wrapper()

static do_bdev_destroy() and bdev_destroy_wrapper() from lxccontainer.c become
public bdev_destroy() and bdev_destroy_wrapper() in bdev.c and bdev.h

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoAdd lxc.ephemeral lxc.ephemeral indicates whether a container will be destroyed on...
Christian Brauner [Tue, 8 Sep 2015 20:37:13 +0000 (22:37 +0200)] 
Add lxc.ephemeral lxc.ephemeral indicates whether a container will be destroyed on shutdown Can be 0 for non-ephemeral and 1 for ephemeral.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agooverlayfs_clone: rsync the mounted rootfs
Serge Hallyn [Thu, 17 Sep 2015 17:26:12 +0000 (17:26 +0000)] 
overlayfs_clone: rsync the mounted rootfs

Closes #655

We can't rsync the delta as unpriv user because we can't create
the chardevs representing a whiteout.  We can however rsync the
rootfs and have the kernel create the whiteouts for us.

do_rsync: pass --delete

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agoFix reallocation calculation
Christian Brauner [Mon, 21 Sep 2015 07:53:43 +0000 (09:53 +0200)] 
Fix reallocation calculation

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoAdd tests for snapshot clone dependencies
Serge Hallyn [Tue, 8 Sep 2015 14:55:05 +0000 (14:55 +0000)] 
Add tests for snapshot clone dependencies

Test edge cases (removing first and last entries in lxc_snapshots and the very
last snapshot) and make sure original container isn't destroyed while there are
snapshots, and is when there are none.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agoAdd a nesting.conf which can be included to support nesting containers (v2)
Serge Hallyn [Thu, 3 Sep 2015 20:24:06 +0000 (20:24 +0000)] 
Add a nesting.conf which can be included to support nesting containers (v2)

Newer kernels have added a new restriction:  if /proc or /sys on the
host has files or non-empty directories which are over-mounted, and
there is no /proc which fully visible, then it assumes there is a
"security" reason for this.  It prevents anyone in a non-initial user
namespace from creating a new proc or sysfs mount.

To work around this, this patch adds a new 'nesting.conf' which can be
lxc.include'd from a container configuration file.  It adds a
non-overmounted mount of /proc and /sys under /dev/.lxc, so that the
kernel can see that we're not trying to *hide* things like /proc/uptime.
and /sys/devices/virtual/net.  If the host adds this to the config file
for container w1, then container w1 will support unprivileged child
containers.

The nesting.conf file also sets the apparmor profile to the with-nesting
variant, since that is required anyway.  This actually means that
supporting nesting isn't really more work than it used to be, just
different.  Instead of adding

lxc.aa_profile = lxc-container-default-with-nesting

you now just need to

lxc.include = /usr/share/lxc/config/nesting.conf

(Look, fewer characters :)

Finally, in order to maintain the current apparmor protections on
proc and sys, we make /dev/.lxc/{proc,sys} non-read/writeable.
We don't need to be able to use them, we're just showing the
kernel what's what.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agodoc: Update Korean lxc-snapshot(1) for newname option
Sungbae Yoo [Tue, 1 Sep 2015 10:12:57 +0000 (19:12 +0900)] 
doc: Update Korean lxc-snapshot(1) for newname option

Update for commit dedd4f6

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agodoc: Add lxc.init_(uid|gid) in Korean lxc.container.conf(5)
Sungbae Yoo [Tue, 1 Sep 2015 08:45:38 +0000 (17:45 +0900)] 
doc: Add lxc.init_(uid|gid) in Korean lxc.container.conf(5)

update for commit dbca923

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agodoc: Update Korean lxc.cgroup.use in lxc.system.conf(5)
Sungbae Yoo [Tue, 1 Sep 2015 07:58:33 +0000 (16:58 +0900)] 
doc: Update Korean lxc.cgroup.use in lxc.system.conf(5)

Update for commit 2d8632d

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agodoc: Add the rename option to lxc-clone(1) in Korean manual
Sungbae Yoo [Tue, 1 Sep 2015 07:56:45 +0000 (16:56 +0900)] 
doc: Add the rename option to lxc-clone(1) in Korean manual

Update for commit 585f3c6

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agodoc: Add LXC-specific mount option in Korean lxc.container.conf(5)
Sungbae Yoo [Tue, 1 Sep 2015 08:02:50 +0000 (17:02 +0900)] 
doc: Add LXC-specific mount option in Korean lxc.container.conf(5)

Update for commit f5b67b3

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agodoc: Update Japanese lxc-snapshot(1) for newname option
KATOH Yasufumi [Mon, 31 Aug 2015 10:00:11 +0000 (19:00 +0900)] 
doc: Update Japanese lxc-snapshot(1) for newname option

Update for commit dedd4f6

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agodoc: Add lxc.init_(uid|gid) in Japanese lxc.container.conf(5)
KATOH Yasufumi [Mon, 31 Aug 2015 09:53:00 +0000 (18:53 +0900)] 
doc: Add lxc.init_(uid|gid) in Japanese lxc.container.conf(5)

update for commit dbca923

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agodoc: Add the common and '-s' option in lxc-destroy(1)
KATOH Yasufumi [Fri, 28 Aug 2015 07:29:03 +0000 (16:29 +0900)] 
doc: Add the common and '-s' option in lxc-destroy(1)

* Add the description of '-s' option
* Remove '-P' option, and add common options
* Improve Japanese translation

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agodoc: Add LXC-specific mount option in Japanese lxc.container.conf(5)
KATOH Yasufumi [Fri, 28 Aug 2015 06:35:50 +0000 (15:35 +0900)] 
doc: Add LXC-specific mount option in Japanese lxc.container.conf(5)

Add the description of optional, create=file/dir for lxc.mount.entry.
This is update for commit f5b67b3.

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agoDo not use strlen() on non-null terminated buffer
Christian Brauner [Mon, 7 Sep 2015 21:41:35 +0000 (23:41 +0200)] 
Do not use strlen() on non-null terminated buffer

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agocoverity: avoid use of NULL c1
Serge Hallyn [Fri, 4 Sep 2015 18:21:35 +0000 (13:21 -0500)] 
coverity: avoid use of NULL c1

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agocoverity: fix mount_entry_create_dir_file
Serge Hallyn [Fri, 4 Sep 2015 18:15:13 +0000 (13:15 -0500)] 
coverity: fix mount_entry_create_dir_file

First, fix use of uninitialized variable 'ret'.  Then, actually use
the value it returned in its caller.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoMerge pull request #649 from major/lxc-delete-network-test
Stéphane Graber [Thu, 3 Sep 2015 16:58:53 +0000 (12:58 -0400)] 
Merge pull request #649 from major/lxc-delete-network-test

Tear down network devices during container halt

9 years agoTear down network devices during container halt 649/head
Major Hayden [Wed, 2 Sep 2015 21:21:11 +0000 (16:21 -0500)] 
Tear down network devices during container halt

On very busy systems, some virtual network devices won't be destroyed after a
container halts.  This patch uses the lxc_delete_network() method to ensure
that network devices attached to the container are destroyed when the
container halts.

Without the patch, some virtual network devices are left over on the system
and must be removed with `ip link del <device>`.  This caused containers
with lxc.network.veth.pair to not be able to start.  For containers using
randomly generated virtual network device names, the old devices will hang
around on the bridge with their original MAC address.

Signed-off-by: Major Hayden <major@mhtx.net>
9 years agoMerge pull request #646 from brauner/manpages_new
Stéphane Graber [Fri, 28 Aug 2015 17:36:19 +0000 (13:36 -0400)] 
Merge pull request #646 from brauner/manpages_new

Adapt manpage for lxc-snapshot

9 years agoAdapt manpage for lxc-snapshot 646/head
Christian Brauner [Fri, 28 Aug 2015 16:55:29 +0000 (18:55 +0200)] 
Adapt manpage for lxc-snapshot

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
9 years agoMerge pull request #585 from ptoomey3/lxc-execute-as-user
Stéphane Graber [Fri, 28 Aug 2015 15:23:13 +0000 (11:23 -0400)] 
Merge pull request #585 from ptoomey3/lxc-execute-as-user

Add support for specified UID/GID for lxc-execute in a private user namespace

9 years agoMerge pull request #643 from raspberrypython/issue-616
Stéphane Graber [Fri, 28 Aug 2015 15:22:10 +0000 (11:22 -0400)] 
Merge pull request #643 from raspberrypython/issue-616

Test dpkg for multiarch support in lxc-debian template

9 years agoAlternative test for dpkg multiarch support in lxc-debian template 643/head
David Noyes [Fri, 28 Aug 2015 14:44:25 +0000 (14:44 +0000)] 
Alternative test for dpkg multiarch support in lxc-debian template

Signed-off-by: David Noyes <david.j.noyes@gmail.com>
9 years agoAdd support for get_config_item and set_config_item 585/head
Patrick Toomey [Thu, 27 Aug 2015 22:21:35 +0000 (16:21 -0600)] 
Add support for get_config_item and set_config_item

Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
9 years agoUpdate docs to reflect lxc.init_uid and lxc.init_gid options
Patrick Toomey [Wed, 19 Aug 2015 17:19:11 +0000 (11:19 -0600)] 
Update docs to reflect lxc.init_uid and lxc.init_gid options

Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
9 years agoUpdate english docs for new lxc.init_uid and lxc.init_gid options
Patrick Toomey [Wed, 19 Aug 2015 17:05:12 +0000 (11:05 -0600)] 
Update english docs for new lxc.init_uid and lxc.init_gid options

Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
9 years agoAdd support for setting lxc-execute init UID/GID via configuration file
Patrick Toomey [Wed, 19 Aug 2015 17:04:38 +0000 (11:04 -0600)] 
Add support for setting lxc-execute init UID/GID via configuration file

Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
9 years agoClarify struct field comment
Patrick Toomey [Wed, 19 Aug 2015 15:57:59 +0000 (09:57 -0600)] 
Clarify struct field comment

Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
9 years agoPass UID/GID explicitly through flags
Patrick Toomey [Tue, 18 Aug 2015 22:26:28 +0000 (16:26 -0600)] 
Pass UID/GID explicitly through flags

Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
9 years agoSet UID/GID to parent value for lxc-execute
Patrick Toomey [Mon, 20 Jul 2015 18:37:20 +0000 (12:37 -0600)] 
Set UID/GID to parent value for lxc-execute

Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
9 years agoDo not switch to root for lxc-execute
Patrick Toomey [Thu, 9 Jul 2015 22:58:17 +0000 (16:58 -0600)] 
Do not switch to root for lxc-execute

Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
9 years agoFix verification of start hook without a rootfs
David Ward [Tue, 23 Jun 2015 14:57:20 +0000 (10:57 -0400)] 
Fix verification of start hook without a rootfs

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoWhen creating container, save configuration if rootfs already exists
David Ward [Tue, 23 Jun 2015 14:57:24 +0000 (10:57 -0400)] 
When creating container, save configuration if rootfs already exists

Commit 6c6892b "fix multithreaded create()" prevented the container
configuration from being saved if the backing store does not need
to be created.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoOnly mount /proc if needed, even without a rootfs
David Ward [Tue, 23 Jun 2015 14:57:19 +0000 (10:57 -0400)] 
Only mount /proc if needed, even without a rootfs

Use the same code with and without a rootfs to check if mounting
/proc is necessary before doing so. If mounting it is unsuccessful
and there is no rootfs, continue as before.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoAllow autodev without a rootfs
David Ward [Tue, 23 Jun 2015 14:57:23 +0000 (10:57 -0400)] 
Allow autodev without a rootfs

A container without a rootfs is useful for running a collection of
processes in separate namespaces (to provide separate networking as
an example), while sharing the host filesystem (except for specific
paths that are re-mounted as needed). For multiple processes to run
automatically when such a container is started, it can be launched
using lxc-start, and a separate instance of systemd can manage just
the processes inside the container. (This assumes that the path to
the systemd unit files is re-mounted and only contains the services
that should run inside the container.) For this use case, autodev
should be permitted for a container that does not have a rootfs.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoFix /dev symlinks without a rootfs
David Ward [Tue, 23 Jun 2015 14:57:21 +0000 (10:57 -0400)] 
Fix /dev symlinks without a rootfs

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoFix container creation without a rootfs
David Ward [Tue, 23 Jun 2015 14:57:25 +0000 (10:57 -0400)] 
Fix container creation without a rootfs

It is not an error to create a container without a template or rootfs.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoFix automatic mounts without a rootfs
David Ward [Tue, 23 Jun 2015 14:57:22 +0000 (10:57 -0400)] 
Fix automatic mounts without a rootfs

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoMerge pull request #617 from alkino/master
Stéphane Graber [Thu, 27 Aug 2015 20:58:06 +0000 (16:58 -0400)] 
Merge pull request #617 from alkino/master

A little bit of refactor and doc

9 years agoMerge pull request #631 from alkino/doc
Stéphane Graber [Thu, 27 Aug 2015 20:34:00 +0000 (16:34 -0400)] 
Merge pull request #631 from alkino/doc

Add long option for -P in documentation

9 years agoMerge pull request #634 from alkino/config_mount
Stéphane Graber [Thu, 27 Aug 2015 20:33:38 +0000 (16:33 -0400)] 
Merge pull request #634 from alkino/config_mount

Split handle of lxc.mount* with 3 functions

9 years agoMerge pull request #638 from schiele/master
Stéphane Graber [Thu, 27 Aug 2015 20:22:14 +0000 (16:22 -0400)] 
Merge pull request #638 from schiele/master

check for NULL pointers before calling setenv()

9 years agoClone bridge interface MTU setting
Natanael Copa [Fri, 21 Aug 2015 09:48:10 +0000 (11:48 +0200)] 
Clone bridge interface MTU setting

Instead of require static mtu setting in config we simply clone the
existing MTU setting of the bridge interface.

This fixes issue when bridge interface has bigger MTU (like 9000 for
jumbo frame support) than the default 1500. When veth interface is
created it has by default MTU set to 1500 and when this is added to the
bridge, the kernel wee reduce the MTU for the bridge to 1500. We solve
this by cloning the MTU value from bridge interface.

This simplifies managing containers with bridge interface who supports
jumbo frames (mtu 9000) and makes it easier to move containers between
hosts with different MTU settings.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agofix open() results check to include 0
Serge Hallyn [Thu, 27 Aug 2015 20:12:26 +0000 (15:12 -0500)] 
fix open() results check to include 0

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoDestroy container with snapshots & clone-snapshots
Christian Brauner [Tue, 18 Aug 2015 11:40:11 +0000 (13:40 +0200)] 
Destroy container with snapshots & clone-snapshots

- This enables lxc-destroy to destroy a container with all its snapshots
  including clone-snapshots not located in the snaps/ folder.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agomod_rdep(): Write path and name of clone to file
Christian Brauner [Tue, 11 Aug 2015 08:33:46 +0000 (10:33 +0200)] 
mod_rdep(): Write path and name of clone to file

If we currently create clone-snapshots via lxc-clone only the plain total
number of the containers it serves as a base-container is written to the file
"lxc-snapshots". This commit modifies mod_rdep() so it will store the paths and
names to the containers that are clone-snapshots (similar to the "lxc_rdepends"
file for the clones). **Users which still have containers that have a non-empty
(with a number > 0 as an entry) "lxc-snapshots" file in the old format are not
affected by this change. It will be used until all old clones have been
deleted!** For all others, the "lxc_snapshots" file placed under the original
container now looks like this:

      /var/lib/lxc
      bb
      /var/lib/lxc
      cc
      /opt
      dd

This is an example of a container that provides the base for three
clone-snapshots bb, cc, and dd. Where bb and cc both are placed in the usual
path for privileged containers and dd is placed in a custom path.

- Add additional argument to function that takes in the clone-snapshotted
  lxc_container.
- Have mod_rdep() write the path and name of the clone-snapshotted container the
  file lxc_snapshots of the original container.
- If a clone-snapshot gets deleted the corresponding line in the file
  lxc_snapshot of the original container will be deleted and the file updated
  via mmap() + memmove() + munmap().
- Adapt has_fs_snapshots().
- **If an lxc-snapshot file in the old format is found we'll keep using it.**

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoFix grammar in some of the executables
Christian Brauner [Fri, 14 Aug 2015 18:24:05 +0000 (20:24 +0200)] 
Fix grammar in some of the executables
"NAME for name of the container" becomes "NAME of the container"

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoMake LXC_CLONE_KEEPNAME work
Christian Brauner [Fri, 14 Aug 2015 18:17:21 +0000 (20:17 +0200)] 
Make LXC_CLONE_KEEPNAME work

- Passing the LXC_CLONE_KEEPNAME flag to do_lxcapi_clone() was not respected and
  let to unexpected behaviour for e.g. lxc-clone. We wrap
  clear_unexp_config_line() and set_config_item_line() in an appropriate
  if-condition.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agolxc-destroy: Remove container with all snapshots
Christian Brauner [Fri, 14 Aug 2015 18:16:16 +0000 (20:16 +0200)] 
lxc-destroy: Remove container with all snapshots

- This enables the user to destroy a container with all its snapshots without
  having to use lxc-snapshot first to destroy all snapshots. (The enum values
  DESTROY and SNAP from the previous commit are reused here again.)
- Some unification regarding the usage of exit() and return has been done.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoRefactor lxc-snapshot
Christian Brauner [Fri, 14 Aug 2015 18:14:01 +0000 (20:14 +0200)] 
Refactor lxc-snapshot

- lxc_snapshot.c lacked necessary members in the associated lxc_arguments struct
  in arguments.h. This commit extends the lxc_arguments struct to include
  several parameters used by lxc-snapshot which allows a rewrite that is more
  consistent with the rest of the lxc-* executables.
- All tests have been moved beyond the call to lxc_log_init() to allow for the
  messages to be printed or saved.
- Some small changes to the my_args struct. (The enum task is set to SNAP (for
  snapshot) per default and variables illustrating the usage of the command line
  flags are written in all caps.)
- arguments.h has been extended to accommodate a future rewrite of lxc-clone
- Traditional behaviour of the executable has been retained in this commit.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agodoc: Update lxc.cgroup.use in lxc.system.conf(5)
KATOH Yasufumi [Wed, 19 Aug 2015 11:35:36 +0000 (20:35 +0900)] 
doc: Update lxc.cgroup.use in lxc.system.conf(5)

LXC now uses lxc.cgroup.use even when cgmanager is used.
So remove the description for the case of using cgmanager.
And add the case of not specifying it.
This commit only updates en and ja man pages.

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agolxc-debian: allow not including contrib/non-free
Antonio Terceiro [Wed, 19 Aug 2015 21:06:50 +0000 (23:06 +0200)] 
lxc-debian: allow not including contrib/non-free

Signed-off-by: Antonio Terceiro <terceiro@debian.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agolxc-debian: support stretch (Debian 9) images
Antonio Terceiro [Wed, 19 Aug 2015 20:14:13 +0000 (22:14 +0200)] 
lxc-debian: support stretch (Debian 9) images

Signed-off-by: Antonio Terceiro <terceiro@debian.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
9 years agoinit: Support older apparmor
Stéphane Graber [Thu, 27 Aug 2015 19:25:08 +0000 (15:25 -0400)] 
init: Support older apparmor

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>