]> git.proxmox.com Git - mirror_lxc.git/log
mirror_lxc.git
8 years agoAdd lxc-copy to gitignore
Stéphane Graber [Fri, 11 Dec 2015 06:14:34 +0000 (01:14 -0500)]
Add lxc-copy to gitignore

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoFix seccomp profile on attach of undefined container
Stéphane Graber [Thu, 10 Dec 2015 23:58:58 +0000 (18:58 -0500)]
Fix seccomp profile on attach of undefined container

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
8 years agoMerge pull request #717 from fanyeren/patch-4
Stéphane Graber [Fri, 11 Dec 2015 06:09:22 +0000 (01:09 -0500)]
Merge pull request #717 from fanyeren/patch-4

lxc-top: limit BLKIO to 14 characters

8 years agolxc-top: limit BLKIO to 14 characters
fanyeren [Fri, 11 Dec 2015 05:56:24 +0000 (13:56 +0800)]
lxc-top: limit BLKIO to 14 characters

limit BLKIO columns to 10 characters is too small,i think 14 is a better value

Signed-off-by: feng xiahou xiahoufeng@yahoo.com
8 years agoMerge pull request #716 from fanyeren/patch-15
Stéphane Graber [Fri, 11 Dec 2015 05:32:14 +0000 (00:32 -0500)]
Merge pull request #716 from fanyeren/patch-15

lxc-top: limit CPU to 8 characters

8 years agolxc-top: limit CPU to 8 characters
fanyeren [Fri, 11 Dec 2015 05:25:52 +0000 (13:25 +0800)]
lxc-top: limit CPU to 8 characters

limit CPU columns to 8 characters is too small,i think 12 is a better value

8 years agoAdd LUA api get_ips(), get_interfaces(), rename() functions
Andrey Jr. Melnikov [Thu, 10 Dec 2015 18:08:11 +0000 (13:08 -0500)]
Add LUA api get_ips(), get_interfaces(), rename() functions

Signed-off-by: Andrey Jr. Melnikov <temnota.am@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoUpdate get_item test after the lxc.mount.entry fix
Stéphane Graber [Thu, 10 Dec 2015 04:45:26 +0000 (23:45 -0500)]
Update get_item test after the lxc.mount.entry fix

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #710 from hnakamur/improve_lxc_copy_japanese_manpage
Stéphane Graber [Thu, 10 Dec 2015 04:03:31 +0000 (23:03 -0500)]
Merge pull request #710 from hnakamur/improve_lxc_copy_japanese_manpage

Improve the lxc-copy Japanese manpage

8 years agofix 'lxc.mount.entry' key when clearing unexpanded config
Serge Hallyn [Thu, 10 Dec 2015 02:12:41 +0000 (02:12 +0000)]
fix 'lxc.mount.entry' key when clearing unexpanded config

Closes #712

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoc/r: add more logging when restore fails
Tycho Andersen [Tue, 8 Dec 2015 23:08:11 +0000 (16:08 -0700)]
c/r: add more logging when restore fails

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoc/r: escape cgroups before exec()ing criu
Tycho Andersen [Tue, 8 Dec 2015 23:08:10 +0000 (16:08 -0700)]
c/r: escape cgroups before exec()ing criu

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agocgroup: add cgroup_escape() call
Tycho Andersen [Tue, 8 Dec 2015 00:07:05 +0000 (17:07 -0700)]
cgroup: add cgroup_escape() call

We'll use this in the next patch to escape to the root cgroup before we
exec criu.

v2: s/cgm_connected/cmg_needs_disconnect/g

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoAdd LXC_TARGET env to Korean lxc.container.conf(5)
Sungbae Yoo [Fri, 4 Dec 2015 09:13:45 +0000 (09:13 +0000)]
Add LXC_TARGET env to Korean lxc.container.conf(5)

Update for commit c154af9

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoAdd support for new target plamo to configure.ac
TAMUKI Shoichi [Wed, 9 Dec 2015 03:23:12 +0000 (12:23 +0900)]
Add support for new target plamo to configure.ac

Add support for new target plamo to specify the linux distribution.
Plamo Linux uses sysvinit.

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Signed-off-by: TAMUKI Shoichi <tamuki@linet.gr.jp>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoFold dnsmasq command line in lxc-net.in
TAMUKI Shoichi [Tue, 8 Dec 2015 06:02:47 +0000 (15:02 +0900)]
Fold dnsmasq command line in lxc-net.in

Fold dnsmasq command line at about 80 chars because the line is too
long.

Signed-off-by: TAMUKI Shoichi <tamuki@linet.gr.jp>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoc/r: remove random line continuations
Tycho Andersen [Mon, 7 Dec 2015 23:51:34 +0000 (16:51 -0700)]
c/r: remove random line continuations

No idea how these got there, but let's get rid of them since they're weird.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoc/r: add a new ->migrate API call
Tycho Andersen [Mon, 30 Nov 2015 22:14:22 +0000 (15:14 -0700)]
c/r: add a new ->migrate API call

This patch adds a new ->migrate API call with three commands:

MIGRATE_DUMP: this is basically just ->checkpoint()
MIGRATE_RESTORE: this is just ->restore()
MIGRATE_PRE_DUMP: this can be used to invoke criu's pre-dump command on the
    container.

A small addition to the (pre-)dump commands is the ability to specify a
previous partial dump directory, so that one can use a pre-dump of a
container.

Finally, this new API call uses a structure to pass options so that it can
be easily extended in the future (e.g. to CRIU's --leave-frozen option in
the future, for potentially smarter failure handling on restore).

v2: remember to flip the return code for legacy ->checkpoint and ->restore
    calls

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoc/r: bump criu version requirements
Tycho Andersen [Wed, 2 Dec 2015 21:30:53 +0000 (14:30 -0700)]
c/r: bump criu version requirements

Since we're relying on 1.8 for the seccomp stuff, let's refuse to use
anything lower than that.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoapi wrapper: only reset the current config if this call set it
Tycho Andersen [Wed, 2 Dec 2015 21:30:52 +0000 (14:30 -0700)]
api wrapper: only reset the current config if this call set it

Instead of *always* resetting the current_config to null, we should only
reset it if this API call set it.

This allows nesting of API calls, e.g. c->checkpoint() can pass stuff into
criu.c, which can call c->init_pid() and not lose the ability to log stuff
afterwards.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoprune_init_cgroup: don't dereference NULL
Serge Hallyn [Sat, 5 Dec 2015 00:24:55 +0000 (18:24 -0600)]
prune_init_cgroup: don't dereference NULL

This is to avoid:

https://errors.ubuntu.com/problem/d640a68bf7343705899d7ca8c6bc070d477cd845

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoImprove the lxc-copy Japanese manpage
Hiroaki Nakamura [Fri, 4 Dec 2015 16:04:08 +0000 (01:04 +0900)]
Improve the lxc-copy Japanese manpage

Signed-off-by: Hiroaki Nakamura <hnakamur@gmail.com>
8 years agodoc: Add lxc.monitor.unshare to lxc.container.conf(5)
KATOH Yasufumi [Thu, 3 Dec 2015 11:48:18 +0000 (20:48 +0900)]
doc: Add lxc.monitor.unshare to lxc.container.conf(5)

Update for commit a8dfe4e and 6039eaa

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoAdd LXC_TARGET env to Japanese lxc.container.conf(5)
KATOH Yasufumi [Thu, 3 Dec 2015 09:55:57 +0000 (18:55 +0900)]
Add LXC_TARGET env to Japanese lxc.container.conf(5)

Update for commit c154af9

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agodoc: Add Japanese manpage for lxc-copy
KATOH Yasufumi [Thu, 3 Dec 2015 09:13:41 +0000 (18:13 +0900)]
doc: Add Japanese manpage for lxc-copy

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoConditional compilation for ARM and PPC
Christian Brauner [Thu, 3 Dec 2015 18:24:40 +0000 (19:24 +0100)]
Conditional compilation for ARM and PPC

Check if symbols SCMP_ARCH_ARM and SCMP_ARCH_PPC are defined.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoseccomp: support 32-bit arm on arm64, and 32-bit ppc on ppc64
Serge Hallyn [Wed, 2 Dec 2015 22:42:36 +0000 (22:42 +0000)]
seccomp: support 32-bit arm on arm64, and 32-bit ppc on ppc64

Generally we enforce that a [arch] seccomp section can only be used on [arch].
However, on amd64 we allow [i386] sections for i386 containers, and there we
also take [all] sections and apply them for both 32- and 64-bit.

Do that also for ppc64 and arm64.  This allows seccomp-protected armhf
containers to run on arm64.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoapparmor: support lxc.aa_profile = unchanged
Serge Hallyn [Wed, 25 Nov 2015 20:45:08 +0000 (20:45 +0000)]
apparmor: support lxc.aa_profile = unchanged

In which case lxc will not update the apparmor profile at all.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agodoc: Add Korean manpage for lxc-copy
Sungbae Yoo [Thu, 19 Nov 2015 03:10:25 +0000 (12:10 +0900)]
doc: Add Korean manpage for lxc-copy

Update for commit 2b47bac

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agolxc: let lxc-start support wlan phys
fli [Tue, 1 Dec 2015 11:17:29 +0000 (19:17 +0800)]
lxc: let lxc-start support wlan phys

The commit: e5848d395cb <netdev_move_by_index: support wlan> only
made netdev_move_by_name support wlan, instead of netdev_move_by_index.

Given netdev_move_by_name is a wrapper of netdev_move_by_index, so here
replacing all of the call to lxc_netdev_move_by_index with lxc_netdev_move_by_name
to let lxc-start support wlan phys.

Signed-off-by: fupan li <fupan.li@windriver.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agodoc: lxc.monitor.unshare requires CAP_SYS_ADMIN
Wolfgang Bumiller [Wed, 2 Dec 2015 08:03:59 +0000 (09:03 +0100)]
doc: lxc.monitor.unshare requires CAP_SYS_ADMIN

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoAdded lxc.monitor.unshare
Wolfgang Bumiller [Mon, 30 Nov 2015 07:58:53 +0000 (08:58 +0100)]
Added lxc.monitor.unshare

If manual mounting with elevated permissions is required
this can currently only be done in pre-start hooks or before
starting LXC. In both cases the mounts would appear in the
host's namespace.
With this flag the namespace is unshared before the startup
sequence, so that mounts performed in the pre-start hook
don't show up on the host.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agolog: use the right size for timestamp formatting
Tycho Andersen [Tue, 1 Dec 2015 15:59:30 +0000 (08:59 -0700)]
log: use the right size for timestamp formatting

v2: get rid of extra debug crap

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoExport LXC_TARGET env variable in stop hook
Stéphane Graber [Thu, 3 Dec 2015 05:52:58 +0000 (00:52 -0500)]
Export LXC_TARGET env variable in stop hook

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agodebian: Fix container creation on missing cache
Stéphane Graber [Fri, 20 Nov 2015 05:34:09 +0000 (00:34 -0500)]
debian: Fix container creation on missing cache

This is currently breaking our daily image builds which happen in a
perfectly clean environment without a Debian keyring and without
anything in /var/cache/lxc

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoMerge pull request #702 from hallyn/2015-11-17/comment
Stéphane Graber [Wed, 18 Nov 2015 05:18:54 +0000 (00:18 -0500)]
Merge pull request #702 from hallyn/2015-11-17/comment

lxc_container struct: add comment about moving member fns

8 years agoMerge pull request #700 from hallyn/2015-11-17/preserve_ns.2
Stéphane Graber [Wed, 18 Nov 2015 05:18:24 +0000 (00:18 -0500)]
Merge pull request #700 from hallyn/2015-11-17/preserve_ns.2

Better handle preserve_ns behavior

8 years agolxc_container struct: add comment about moving member fns
Serge Hallyn [Wed, 18 Nov 2015 05:05:37 +0000 (23:05 -0600)]
lxc_container struct: add comment about moving member fns

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoAdd getsubopt implementation for Android
Stéphane Graber [Wed, 18 Nov 2015 01:37:10 +0000 (20:37 -0500)]
Add getsubopt implementation for Android

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #701 from hallyn/fixunexp
Stéphane Graber [Tue, 17 Nov 2015 23:02:10 +0000 (18:02 -0500)]
Merge pull request #701 from hallyn/fixunexp

lxcapi_clone: restore the unexpanded config len

8 years agolxcapi_clone: restore the unexpanded config len
Serge Hallyn [Tue, 17 Nov 2015 21:05:05 +0000 (15:05 -0600)]
lxcapi_clone: restore the unexpanded config len

Otherwise it gets shortened with the temporary len but never
restored - which will only break API users which do a clone
then continue to use the original container, meaning this is
a hard one to detect.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoRevert "seccomp: handle inverted arch"
Serge Hallyn [Tue, 17 Nov 2015 20:01:04 +0000 (14:01 -0600)]
Revert "seccomp: handle inverted arch"

It breaks container starts.

This reverts commit 473ebc77d6762c2ec49fe59983dabc04f695fd01.

8 years agoBetter handle preserve_ns behavior
Serge Hallyn [Tue, 17 Nov 2015 18:59:05 +0000 (12:59 -0600)]
Better handle preserve_ns behavior

Commit b6b2b194a8 preserves the container's namespaces for
possible later use in stop hook.  But some kernels don't have
/proc/pid/ns/ns for all the namespaces we may be interested in.
So warn but continue if this is the case.

Implement stgraber's suggested semantics.

 - User requests some namespaces be preserved:
    - If /proc/self/ns is missing => fail (saying kernel misses setns)
    - If /proc/self/ns/<namespace> entry is missing => fail (saying kernel misses setns for <namespace>)
 - User doesn't request some namespaces be preserved:
    - If /proc/self/ns is missing => log an INFO message (kernel misses setns) and continue
    - If /proc/self/ns/<namespace> entry is missing => log an INFO message (kernel misses setns for <namespace>) and continue

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #692 from fwilson42/master
Stéphane Graber [Tue, 17 Nov 2015 16:43:56 +0000 (11:43 -0500)]
Merge pull request #692 from fwilson42/master

lxc-ls: use /usr/bin/env to find an appropriate python3 to run

8 years agoMerge pull request #693 from hsoft/debian-keyring
Stéphane Graber [Tue, 17 Nov 2015 16:43:19 +0000 (11:43 -0500)]
Merge pull request #693 from hsoft/debian-keyring

Fetch Debian archive GPG keyrings when they're not available

8 years agoMerge pull request #697 from hallyn/2015-11-12/seccomp
Stéphane Graber [Tue, 17 Nov 2015 16:42:14 +0000 (11:42 -0500)]
Merge pull request #697 from hallyn/2015-11-12/seccomp

seccomp: handle inverted arch

8 years agoclone: clear the rootfs out of unexpanded config
Serge Hallyn [Wed, 11 Nov 2015 17:13:25 +0000 (17:13 +0000)]
clone: clear the rootfs out of unexpanded config

Closes #694

When we start cloning container c1 to c2, we first save c1's
configuration in c2's as a starting point.  We long ago cleared
out the lxc.rootfs entry before saving it, so that if we are
killed before we update the rootfs, c2's rootfs doesn't point
to c1's.  Because then lxc-destroy -n c2 would delete c1's rootfs.

But when we introduced the unexpanded_config, we didn't update
this code to clear the rootfs out of the unexpanded_config, which
is what now actually gets saved in write_config().

Do so.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoImprove coding style and coding conventions
Christian Brauner [Tue, 10 Nov 2015 16:52:36 +0000 (17:52 +0100)]
Improve coding style and coding conventions

Local variables should not have the same name as global variables to avoid
confusion.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoFix mode when creating temporary directory
Christian Brauner [Mon, 9 Nov 2015 20:47:28 +0000 (21:47 +0100)]
Fix mode when creating temporary directory

When we create a random container directory with mkdtemp() we set the mode to
0770 otherwise do_lxcapi_clone() will complain about not being able to create
the config.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoUse correct return when clone fails
Christian Brauner [Mon, 9 Nov 2015 20:47:27 +0000 (21:47 +0100)]
Use correct return when clone fails

When the clone failed we tried to destroy the container. This will lead to a
segfault. Instead simply return -1. Also move the call to free_mnts() after the
put label to free the user specified mounts even when we just goto put.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoAdd manpage for lxc-copy
Christian Brauner [Thu, 12 Nov 2015 20:11:30 +0000 (21:11 +0100)]
Add manpage for lxc-copy

(A trivial fix for lxc-copy is included.)

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
8 years agoAdd lxc-copy executable
Christian Brauner [Fri, 6 Nov 2015 10:59:59 +0000 (11:59 +0100)]
Add lxc-copy executable

This is a complete reimplementation of lxc-clone and lxc-start-ephemeral.
lxc-copy merges the functionalities of lxc-clone + lxc-start-ephemeral.

(1) Cloning containers:

(a) as copy:

lxc-copy -n aa -N bb

(b) as snapshot:

lxc-copy -n aa -N bb -s

(2) Renaming containers:

lxc-copy -n aa -N bb -R

(3) Starting ephemeral containers:

Ephemeral containers are created and started by passing the flag -e /
--ephemeral. Whenever this flag is missing a copy of the container is created.
The flag -e / --ephemeral implies -s / --snapshot.

(a) start ephemeral container daemonized with random name:

lxc-copy -n aa -e

(b) start ephemeral container in foreground mode with random name:

lxc-copy -n aa -e -F

(c) start ephemeral container with specified name in daemonized mode:
    Analogous to lxc-start ephemeral containers start in daemonized
            mode per default:

lxc-copy -n aa -N bb -e

    One can however also explicitly pass -d / --daemon:

lxc-copy -n aa -N bb -e -d

    but both commands are equivalent.

(d) start non-ephemeral container in daemonized mode:

lxc-copy -n aa -D -e

(e) start ephemeral container in daemonized mode and keep the original
    hostname:

lxc-copy -n aa -K -e

(f) start ephemeral container in daemonized mode and keep the
    MAC-address of the original container:

lxc-copy -n aa -M -e

(g) start ephemeral container with custom mounts (additional mounts can
            be of type {bind,aufs,overlay}) in daemonized mode:

lxc-copy -n aa -e -m bind=/src:/dest:ro,aufs=/src:/dest,overlay=/src:/dest

(4) Other options:

lxc-copy --help

In order to create a random containername and random upper- and workdirs for
custom mounts we use mkdtemp() to not just create the names but also directly
create the corresponding directories. This will be safer and make the code
considerably shorter.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agodon't truncate environment sometimes in setproctitle
Tycho Andersen [Mon, 16 Nov 2015 22:12:36 +0000 (15:12 -0700)]
don't truncate environment sometimes in setproctitle

Instead, let's just allocate new space for the proctitle to live and point
the kernel at that.

v2: take out testing hunk
v3: check return from realloc

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoseccomp: handle inverted arch
Serge Hallyn [Thu, 12 Nov 2015 23:22:48 +0000 (17:22 -0600)]
seccomp: handle inverted arch

lxc uses uname to check the kernel version.  Seccomp respects userspace.  In the case
of 32-bit userspace on 64-bit kernel, this was a bad combination.

When we run into that case, make sure that the compat seccomp context is 32-bit, and
the lxc->seccomp_ctx is the 64-bit.

Closes #654

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoubuntu-cloud: Various fixes
Stéphane Graber [Thu, 12 Nov 2015 17:44:38 +0000 (12:44 -0500)]
ubuntu-cloud: Various fixes

 - Update list of supported releases
 - Make the fallback release trusty
 - Don't specify the compression algorithm (use auto-detection) so that
   people passing tarballs to the template don't see regressions.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoFetch Debian archive GPG keyrings when they're not available
Virgil Dupras [Tue, 10 Nov 2015 02:23:51 +0000 (21:23 -0500)]
Fetch Debian archive GPG keyrings when they're not available

When running the debian template on a non-debian host, it's usual not to
have debian-archive-keyring.gpg. When that happens, we skip the
signature checking of the release, which is dangerous because it's made over
HTTP.

This commit adds automatic fetching of Debian release keys.

Strongly related to #409

Signed-off-by: Virgil Dupras <hsoft@hardcoded.net>
8 years agoUse /usr/bin/env python3 instead of /usr/bin/python3 project-wide
Fox Wilson [Tue, 10 Nov 2015 20:00:25 +0000 (15:00 -0500)]
Use /usr/bin/env python3 instead of /usr/bin/python3 project-wide

This fixes invocations of certain commands when python3 is installed in
a nonstandard path (/usr/local/bin, for example).

Signed-off-by: Fox Wilson <2016fwilson@tjhsst.edu>
8 years agoutils: dialback setproctitle failure message
Tycho Andersen [Mon, 9 Nov 2015 20:33:32 +0000 (13:33 -0700)]
utils: dialback setproctitle failure message

This isn't in any way fatal, so let's only warn about it with INFO, not
ERROR.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agocoverity: avoid null pointer dereference in cgmanager
Serge Hallyn [Mon, 9 Nov 2015 20:19:12 +0000 (14:19 -0600)]
coverity: avoid null pointer dereference in cgmanager

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoc/r: use freezer to seize tasks
Tycho Andersen [Sat, 7 Nov 2015 00:26:43 +0000 (17:26 -0700)]
c/r: use freezer to seize tasks

Instead of relying on the old ptrace loop, we should instead put all the
tasks in the container into the freezer. This will stop them all at the
same time, preventing fork bombs from causing criu to infinite loop (and is
also simply a lot faster).

Note that this uses --freeze-cgroup which isn't in criu 1.7, so it should
only go into master.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agodefine PR_SET_MM_MAP & friends if necessary
Tycho Andersen [Fri, 6 Nov 2015 20:50:33 +0000 (13:50 -0700)]
define PR_SET_MM_MAP & friends if necessary

PR_SET_MM_MAP only went in to the kernel at 3.18 (or 3.19), so we need to
define these for kernels before then. If there was an error, the code
simply logs the failure and continues on.

Also, we can drop the PR_SET_MM_otherstuff contstants since those were
dropped in 93525c00c76b2804c46cf3c275d610ebe71cb4be.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoc/r: don't require a veth link to c/r
Tycho Andersen [Fri, 6 Nov 2015 19:58:02 +0000 (12:58 -0700)]
c/r: don't require a veth link to c/r

veths can be unconnected in the container's config, and we should handle
this case.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agouse PR_SET_MM_MAP instead of PR_SET_MM
Tycho Andersen [Fri, 6 Nov 2015 19:34:47 +0000 (12:34 -0700)]
use PR_SET_MM_MAP instead of PR_SET_MM

PR_SET_MM_MAP can be called as non-root, which we are in the unprivileged
(or nested) case.

Also, let's not do the strcpy() for the new cmdline until after we're sure
the prctl succeeded. This means that even if it does fail, we won't
mutilate the command line like we did before, it just won't be as pretty.

v2: remember to chop off bits of the string that are too long

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoFix calculations in clone_update_unexp_hooks()
Christian Brauner [Tue, 3 Nov 2015 18:09:56 +0000 (19:09 +0100)]
Fix calculations in clone_update_unexp_hooks()

Changes v3:
(1) Fix typo (q --> p).

(1) This commit fixes the calculations when updating paths in lxc.hooks.*
    entries. We now also update conf->unexpandend_alloced which hasn't been
done prior to this commit.

(2) Also we use the stricter check:

     if (p >= lend)
     continue;

    This should deal better with invalid config files.

(3) Insert some spaces between operators to increase readability.

(4) Use gotos to simplify function and increase readability.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoUpdate absolute paths for overlay and aufs mounts
Christian Brauner [Mon, 2 Nov 2015 22:20:36 +0000 (23:20 +0100)]
Update absolute paths for overlay and aufs mounts

When using overlay and aufs mounts with lxc.mount.entry users have to specify
absolute paths for upperdir and workdir which will then get created
automatically by mount_entry_create_overlay_dirs() and
mount_entry_create_aufs_dirs() in conf.c. When we clone a container with
overlay or aufs lxc.mount.entry entries we need to update these absolute paths.
In order to do this we add the function update_ovl_paths() in
lxccontainer.c. The function updates the mounts in two locations:

        1) lxc_conf->mount_list

and

        2) lxc_conf->unexpanded_config (by calling clone_update_unexp_ovl_dir())

If we were to only update 2) we would end up with wrong upperdir and workdir
mounts as the absolute paths would still point to the container that serves as
the base for the clone. If we were to only update 1) we would end up with wrong
upperdir and workdir lxc.mount.entry entries in the clone's config as the
absolute paths in upperdir and workdir would still point to the container that
serves as the base for the clone. Updating both will get the job done.

NOTE: This function does not sanitize paths apart from removing trailing
slashes. (So when a user specifies //home//someone/// it will be cleaned to
//home//someone. This is the minimal path cleansing which is also done by
lxc_container_new().) But the mount_entry_create_overlay_dirs() and
mount_entry_create_aufs_dirs() functions both try to be extremely strict about
when to create upperdirs and workdirs. They will only accept sanitized paths,
i.e. they require /home/someone. I think this is a (safety) virtue and we
should consider sanitizing paths in general. In short: update_ovl_paths() does
update all absolute paths to the new container but
mount_entry_create_overlay_dirs() and mount_entry_create_aufs_dirs() will still
refuse to create upperdir and workdir when the updated path is unclean. This
happens easily when e.g. a user calls lxc-clone -o OLD -n NEW -P
//home//chb///.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoAdd clone_update_unexp_ovl_paths() function
Christian Brauner [Mon, 2 Nov 2015 22:20:35 +0000 (23:20 +0100)]
Add clone_update_unexp_ovl_paths() function

This functions updates absolute paths for overlay upper- and workdirs so users
can simply clone and start new containers without worrying about absolute paths
in lxc.mount.entry overlay entries.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agohooks: put binary hooks into $libexecdir/lxc/hooks
Wolfgang Bumiller [Thu, 5 Nov 2015 14:02:11 +0000 (15:02 +0100)]
hooks: put binary hooks into $libexecdir/lxc/hooks

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agosupport arguments in lxc.init_cmd
Serge Hallyn [Thu, 5 Nov 2015 22:18:52 +0000 (22:18 +0000)]
support arguments in lxc.init_cmd

Otherwise something like
lxc.init_cmd = /sbin/init debug verbose
fails trying to execute a file called "/sbin/init debug verbose"

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoUnify the polite word style in Korean manpages
Sungbae Yoo [Mon, 2 Nov 2015 09:29:31 +0000 (18:29 +0900)]
Unify the polite word style in Korean manpages

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agodoc: Add the description of lxc.hook.stop to Korean lxc.container.conf(5)
Sungbae Yoo [Mon, 2 Nov 2015 08:32:48 +0000 (17:32 +0900)]
doc: Add the description of lxc.hook.stop to Korean lxc.container.conf(5)

Update for commit 0a2b5ab

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoonly re-open fds if stdin is a tty
Serge Hallyn [Fri, 30 Oct 2015 05:14:12 +0000 (05:14 +0000)]
only re-open fds if stdin is a tty

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoInit error_num to 1
Stéphane Graber [Thu, 5 Nov 2015 18:44:30 +0000 (13:44 -0500)]
Init error_num to 1

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agolxc-ubuntu-cloud: Never exit 0 when no container is created
Stéphane Graber [Thu, 5 Nov 2015 18:37:03 +0000 (13:37 -0500)]
lxc-ubuntu-cloud: Never exit 0 when no container is created

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #683 from Kubuxu/patch-1
Stéphane Graber [Fri, 30 Oct 2015 14:01:32 +0000 (10:01 -0400)]
Merge pull request #683 from Kubuxu/patch-1

arch template: Fix systemd-sysctl service

8 years agoarch template: Fix systemd-sysctl service
Jakub Sztandera [Fri, 30 Oct 2015 11:05:44 +0000 (12:05 +0100)]
arch template: Fix systemd-sysctl service

The systemd-sysctl service includes condition that /proc/sys/ has to be read-write.
In lxc only /proc/sys/net/ is read-write which causes the condition to fail and service not to run.
This patch changes the check to /proc/sys/net/ and makes the service apply only rules that are in net tree.

Signed-off-by: Jakub Sztandera <kubuxu@gmail.com>
8 years agodon't close std* fd if opentty fails
Serge Hallyn [Fri, 30 Oct 2015 04:51:14 +0000 (23:51 -0500)]
don't close std* fd if opentty fails

We didn't do it before, and it makes testcases fail.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoSimplify function
Christian Brauner [Sun, 25 Oct 2015 21:59:45 +0000 (22:59 +0100)]
Simplify function

Instead of duplicating the cleanup-code, once for success and once for failure,
simply keep a variable fret which is -1 in the beginning and gets set to 0 on
success or stays -1 on failure.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoParse rootfs->path
Christian Brauner [Thu, 22 Oct 2015 07:18:15 +0000 (09:18 +0200)]
Parse rootfs->path

The mount_entry_overlay_dirs() and mount_entry_aufs_dirs() functions create
workdirs and upperdirs for overlay and aufs lxc.mount.entry entries. They try
to make sure that the workdirs and upperdirs can only be created under the
containerdir (e.g. /path/to/the/container/CONTAINERNAME). In order to do this
the right hand side of

                if ((strncmp(upperdir, lxcpath, dirlen) == 0) && (strncmp(upperdir, rootfs->path, rootfslen) != 0))

was thought to check if the rootfs->path is not present in the workdir and
upperdir mount options. But the current check is bogus since it will be
trivially true whenever the container is a block-dev or overlay or aufs backed
since the rootfs->path will then have a form like e.g.

        overlayfs:/some/path:/some/other/path

This patch adds the function ovl_get_rootfs_dir() which parses rootfs->path by
searching backwards for the first occurrence of the delimiter pair ":/". We do
not simply search for ":" since it might be used in path names. If ":/" is not
found we assume the container is directory backed and simply return
strdup(rootfs->path).

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agolxc-net: switch After target to network-online.target
Serge Hallyn [Tue, 27 Oct 2015 20:05:18 +0000 (20:05 +0000)]
lxc-net: switch After target to network-online.target

Otherwise it may start too early and end up taking 10.0.3.1 even
though eth0 was eventually going to end up on 10.0.3.x.

https://bugs.launchpad.net/juju-core/+bug/1510619

Reported-by: Ryan Harper <ryan.harper@ubuntu.com>
Cc: Martin Pitt <martin.pitt@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agolxc-usernsexec: reopen fds 0,1,2 separately
Serge Hallyn [Wed, 14 Oct 2015 03:13:47 +0000 (03:13 +0000)]
lxc-usernsexec: reopen fds 0,1,2 separately

lxc-usernsexec was using fd 0 and reopening it as 0,1,2 for
the new task.  If doing "lxc-usernsexec .. < script" this
will corrupt the file 'script'.

Reported-by: Fiedler Roman <Roman.Fiedler@ait.ac.at>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoIgnore trailing /init.scope in init cgroups
Serge Hallyn [Thu, 15 Oct 2015 18:56:17 +0000 (18:56 +0000)]
Ignore trailing /init.scope in init cgroups

The lxc monitor does not store the container's cgroups, rather it
recalculates them whenever needed.

Systemd moves itself into a /init.scope cgroup for the systemd
controller.

It might be worth changing that (by storing all cgroup info in the
lxc_handler), but for now go the hacky route and chop off any
trailing /init.scope.

I definately thinkg we want to switch to storing as that will be
more bullet-proof, but for now we need a quick backportable fix
for systemd 226 guests.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoubuntu-cloud: Replace .tar.gz by .tar.xz and don't auto-generate missing tarballs
Stéphane Graber [Wed, 14 Oct 2015 02:07:04 +0000 (19:07 -0700)]
ubuntu-cloud: Replace .tar.gz by .tar.xz and don't auto-generate missing tarballs

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoMake mount_entry_create_*_dirs() more robust
Christian Brauner [Wed, 7 Oct 2015 17:34:02 +0000 (19:34 +0200)]
Make mount_entry_create_*_dirs() more robust

The mount_entry_create_*_dirs() functions currently assume that the rootfs of
the container is actually named "rootfs". This has the consequence that

del = strstr(lxcpath, "/rootfs");
if (!del) {
free(lxcpath);
lxc_free_array((void **)opts, free);
return -1;
}
*del = '\0';

will return NULL when the rootfs of a container is not actually named "rootfs".
This means the we return -1 and do not create the necessary upperdir/workdir
directories required for the overlay/aufs mount to work. Hence, let's not make
that assumption. We now pass lxc_path and lxc_name to
mount_entry_create_*_dirs() and create the path directly. To prevent failure we
also have mount_entry_create_*_dirs() check that lxc_name and lxc_path are not
empty when they are passed in.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agodoc: Add the description of lxc.hook.stop to Japanese lxc.container.conf(5)
KATOH Yasufumi [Fri, 9 Oct 2015 06:14:22 +0000 (15:14 +0900)]
doc: Add the description of lxc.hook.stop to Japanese lxc.container.conf(5)

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agodoc: Add lxc.ephemeral in Korean lxc.container.conf(5)
Sungbae Yoo [Thu, 8 Oct 2015 03:06:25 +0000 (12:06 +0900)]
doc: Add lxc.ephemeral in Korean lxc.container.conf(5)

Update for commit 4e6eb26

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agocoverity: free mounts on error path
Serge Hallyn [Sun, 18 Oct 2015 02:16:12 +0000 (21:16 -0500)]
coverity: free mounts on error path

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoTell gcc about lxcmntent for the unmount hook
Stéphane Graber [Sun, 11 Oct 2015 22:44:38 +0000 (15:44 -0700)]
Tell gcc about lxcmntent for the unmount hook

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoDon't include mntent when lxcmntent is used
Stéphane Graber [Sun, 11 Oct 2015 21:36:51 +0000 (14:36 -0700)]
Don't include mntent when lxcmntent is used

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoDon't re-include config.h in lxcmntent.h
Stéphane Graber [Sun, 11 Oct 2015 20:29:36 +0000 (13:29 -0700)]
Don't re-include config.h in lxcmntent.h

It causes trouble when importing from different paths and will always be
included ahead of time anyway.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoUpdate gitignore
Stéphane Graber [Sun, 11 Oct 2015 17:08:44 +0000 (13:08 -0400)]
Update gitignore

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoAttempt to fix bionic builds of unmount-namespace
Stéphane Graber [Sun, 11 Oct 2015 17:07:52 +0000 (13:07 -0400)]
Attempt to fix bionic builds of unmount-namespace

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agodoc: Add the note related mount in Korean lxc.container.conf(5)
Sungbae Yoo [Tue, 6 Oct 2015 09:29:01 +0000 (18:29 +0900)]
doc: Add the note related mount in Korean lxc.container.conf(5)

Update for commit 592fd47

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agodoc: Add the common and '-s' option in Korean lxc-destroy(1)
Sungbae Yoo [Tue, 6 Oct 2015 09:26:49 +0000 (18:26 +0900)]
doc: Add the common and '-s' option in Korean lxc-destroy(1)

Update for commit 3635c5e

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agodoc: Add lxc.ephemeral in Japanese lxc.container.conf(5)
KATOH Yasufumi [Tue, 6 Oct 2015 07:26:31 +0000 (16:26 +0900)]
doc: Add lxc.ephemeral in Japanese lxc.container.conf(5)

Update for commit 4e6eb26

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoadded the unmount-namespace hook
Wolfgang Bumiller [Tue, 6 Oct 2015 08:01:07 +0000 (10:01 +0200)]
added the unmount-namespace hook

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agodocument the stop hook
Wolfgang Bumiller [Tue, 6 Oct 2015 08:01:06 +0000 (10:01 +0200)]
document the stop hook

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agopass namespace handles to the stop hook
Wolfgang Bumiller [Tue, 6 Oct 2015 08:01:05 +0000 (10:01 +0200)]
pass namespace handles to the stop hook

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agorun stop hook between STOPPING and STOPPED states
Wolfgang Bumiller [Tue, 6 Oct 2015 08:01:04 +0000 (10:01 +0200)]
run stop hook between STOPPING and STOPPED states

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoadded stop-hook entries
Wolfgang Bumiller [Tue, 6 Oct 2015 08:01:03 +0000 (10:01 +0200)]
added stop-hook entries

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 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>