]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
8 years agolxc_setup_tios(): Ignore SIGTTOU and SIGTTIN signals 1386/head
Thomas Jarosch [Thu, 2 Feb 2017 11:48:35 +0000 (12:48 +0100)] 
lxc_setup_tios(): Ignore SIGTTOU and SIGTTIN signals

Prevent an endless loop while executing lxc-attach in the background:

The kernel might fire SIGTTOU while an ioctl() in tcsetattr()
is executed. When the ioctl() is resumed and retries,
the signal handler interrupts it again.

We can't configure the TTY to stop sending
the signals in the first place since that
is a modification/write to the TTY already.

Still we clear the TOSTOP flag to prevent further signals.

Command to reproduce the hang:
----------------------------
cat > lxc_hang.sh << EOF
/usr/bin/timeout 5s /usr/bin/lxc-attach -n SOMECONTAINER -- /bin/true
EOF
sh lxc_hang.sh    # hangs
----------------------------

Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
8 years agoCVE-2016-10124: make lxc-attach use a pty
Christian Brauner [Mon, 16 Jan 2017 14:10:45 +0000 (15:10 +0100)] 
CVE-2016-10124: make lxc-attach use a pty

Previous versions of lxc-attach simply attached to the specified namespaces of
a container and ran a shell or the specified command without first allocating a
pseudo terminal. This made them vulnerable to input faking via a TIOCSTI ioctl
call after switching between userspace execution contexts with different
privilege levels. Newer versions of lxc-attach will try to allocate a pseudo
terminal master/slave pair on the host and attach any standard file descriptors
which refer to a terminal to the slave side of the pseudo terminal before
executing a shell or command. Note, that if none of the standard file
descriptors refer to a  terminal lxc-attach will not try to allocate a pseudo
terminal. Instead it will simply attach to the containers namespaces and run a
shell or the specified command.

(This is a backport of a series of patches fixing CVE-2016-10124.)

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoCVE-2016-10124: backport new console backend
Christian Brauner [Mon, 16 Jan 2017 14:03:59 +0000 (15:03 +0100)] 
CVE-2016-10124: backport new console backend

- Make escape sequence to exit tty optional since we want to reuse
  lxc_console_cb_tty_stdin() in lxc_attach.c.
- Export the following functions since they can be reused in other modules:
  - lxc_console_cb_tty_stdin()
  - lxc_console_cb_tty_master()
  - lxc_setup_tios(int fd, struct termios *oldtios);
  - lxc_console_winsz(int srcfd, int dstfd);
  - lxc_console_cb_sigwinch_fd(int fd, uint32_t events, void *cbdata, struct lxc_epoll_descr *descr);
  - lxc_tty_state *lxc_console_sigwinch_init(int srcfd, int dstfd);
  - lxc_console_sigwinch_fini(struct lxc_tty_state *ts);
- rewrite lxc_console_set_stdfds()
  - Make lxc_console_set_stdfds useable by other callers that do not have
    access to lxc_handler.
- Use ssh settings for ptys.
- Remove all asserts from console.{c,h}.
- Adapt start.c to changes.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoFix opening wrong file in suggest_default_idmap
John Chen [Wed, 22 Mar 2017 03:03:59 +0000 (11:03 +0800)] 
Fix opening wrong file in suggest_default_idmap

Fixing the typo making `suggest_default_idmap` open `subuidfile`
instead of `subgidfile` to read subgid information.

Signed-off-by: Pochang Chen <johnchen902@gmail.com>
8 years agotests: Kill containers (don't wait for shutdown)
Stéphane Graber [Tue, 21 Mar 2017 20:35:44 +0000 (16:35 -0400)] 
tests: Kill containers (don't wait for shutdown)

We waste a lot of time waiting for Ubuntu containers to cleanly stop
right before we destroy them anyway.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agotests: Support running on IPv6 networks
Stéphane Graber [Tue, 21 Mar 2017 20:23:27 +0000 (16:23 -0400)] 
tests: Support running on IPv6 networks

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoChange variable check to match existing style
Tai Kedzierski [Sun, 19 Mar 2017 17:28:26 +0000 (17:28 +0000)] 
Change variable check to match existing style

Signed-off-by: Tai Kedzierski <dch.tai@gmail.com>
8 years agolxc-download.in / Document keyserver change in help
Tai Kedzierski [Sun, 19 Mar 2017 09:27:42 +0000 (09:27 +0000)] 
lxc-download.in / Document keyserver change in help

Signed-off-by: Tai Kedzierski <dch.tai@gmail.com>
8 years agolxc-download.in / allow setting keyserver from env
Tai Kedzierski [Sun, 19 Mar 2017 09:21:29 +0000 (09:21 +0000)] 
lxc-download.in / allow setting keyserver from env

Checks if DOWNLOAD_KEYSERVER has already been set in the environment before setting a value

Signed-off-by: Tai Kedzierski <dch.tai@gmail.com>
8 years agopython3: Deal with potential NULL char*
Stéphane Graber [Fri, 17 Mar 2017 08:52:41 +0000 (09:52 +0100)] 
python3: Deal with potential NULL char*

Closes #1466

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agolxc-checkconfig: verify new[ug]idmap are setuid-root
Serge Hallyn [Tue, 14 Mar 2017 18:16:48 +0000 (13:16 -0500)] 
lxc-checkconfig: verify new[ug]idmap are setuid-root

Signed-off-by: Serge Hallyn <serge@hallyn.com>
8 years agoseccomp: set SCMP_FLTATR_ATL_TSKIP if available
Serge Hallyn [Mon, 6 Mar 2017 19:36:19 +0000 (13:36 -0600)] 
seccomp: set SCMP_FLTATR_ATL_TSKIP if available

Newer libseccomp has a flag called SCMP_FLTATR_ATL_TSKIP which
allows syscall '-1' (nop) to be executed.  Without that flag,
debuggers cannot skip system calls inside containers.  For reference,
see the seccomp(2) manpage, which says:

The tracer can skip the system call by changing the system call  number  to  -1.

and see the seccomp issue #80

Signed-off-by: Serge Hallyn <serge@hallyn.com>
8 years agosqueeze is not a supported release anymore, drop the key
Evgeni Golov [Thu, 23 Feb 2017 21:03:40 +0000 (22:03 +0100)] 
squeeze is not a supported release anymore, drop the key

Signed-off-by: Evgeni Golov <evgeni@debian.org>
8 years agoseccomp: allow x32 guests on amd64 hosts.
Adam Borowski [Sun, 12 Feb 2017 06:26:54 +0000 (07:26 +0100)] 
seccomp: allow x32 guests on amd64 hosts.

Without this patch, x32 guests (and no others) worked "natively" with x32
host lxc, but not on regular amd64 hosts.  That was especially problematic
as a number of ioctls such as those needed by netfilter don't work in such
scenarios, thus you want to run amd64 on the host.

With the patch, you can use all three ABIs: i386 x32 amd64 on amd64 hosts.

Despite x32 being little used, there's no reason to deny it by default:
the admin needs to compile their own kernel with CONFIG_X86_X32=y or (on
Debian) boot with syscall.x32=y.  If they've done so, it is a reasonable
assumption they want x32 guests.

Signed-off-by: Adam Borowski <kilobyte@angband.pl>
8 years agoconfile: clear lxc.network.<n>.ipv{4,6} when empty
Christian Brauner [Mon, 6 Feb 2017 22:08:26 +0000 (23:08 +0100)] 
confile: clear lxc.network.<n>.ipv{4,6} when empty

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoCVE-2017-5985: Ensure target netns is caller-owned
Christian Brauner [Sat, 11 Feb 2017 12:27:06 +0000 (13:27 +0100)] 
CVE-2017-5985: Ensure target netns is caller-owned

Before this commit, lxc-user-nic could potentially have been tricked into
operating on a network namespace over which the caller did not hold privilege.

This commit ensures that the caller is privileged over the network namespace by
temporarily dropping privilege.

Launchpad: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1654676
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agosystemd: enable delegate in service file
Jörg Thalheim [Fri, 19 Dec 2014 11:22:11 +0000 (12:22 +0100)] 
systemd: enable delegate in service file

Signed-off-by: Jörg Thalheim <joerg@higgsboson.tk>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoMake lxc-start-ephemeral Python 3.2-compatible
Colin Watson [Thu, 26 Jan 2017 14:32:08 +0000 (14:32 +0000)] 
Make lxc-start-ephemeral Python 3.2-compatible

On Ubuntu 12.04 LTS with Python 3.2, `lxc-start-ephemeral` breaks as
follows:

    Traceback (most recent call last):
      File "/usr/bin/lxc-start-ephemeral", line 371, in attach_as_user
      File "/usr/lib/python3.2/subprocess.py", line 515, in check_output
      File "/usr/lib/python3.2/subprocess.py", line 732, in __init__
    LookupError: unknown encoding: ANSI_X3.4-1968

This is because `universal_newlines=True` causes `subprocess` to use
`io.TextIOWrapper`, and in versions of Python earlier than 3.3 that
fetched the preferred encoding using `locale.getpreferredencoding()`
rather than `locale.getpreferredencoding(False)`, thereby changing the
locale and causing codecs to be reloaded.  However, `attach_as_user`
runs inside the container and thus can't rely on having access to the
same Python standard library on disk.

The workaround is to decode by hand instead, avoiding the temporary
change of locale.

Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
8 years agoUse AC_HEADER_MAJOR to detect major()/minor()/makedev()
Sergei Trofimovich [Sat, 21 Jan 2017 11:57:13 +0000 (11:57 +0000)] 
Use AC_HEADER_MAJOR to detect major()/minor()/makedev()

Before the change build failed on Gentoo as:

  bdev/lxclvm.c: In function 'lvm_detect':
  bdev/lxclvm.c:140:4: error: implicit declaration of function 'major' [-Werror=implicit-function-declaration]
    major(statbuf.st_rdev), minor(statbuf.st_rdev));
    ^~~~~
  bdev/lxclvm.c:140:28: error: implicit declaration of function 'minor' [-Werror=implicit-function-declaration]
    major(statbuf.st_rdev), minor(statbuf.st_rdev));
                            ^~~~~

glibc plans to remove <sys/sysmacros.h> from glibc's <sys/types.h>:
    https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html

Gentoo already applied glibc patch to experimental glibc-2.24
to start preparingfor the change.

Autoconf has AC_HEADER_MAJOR to find out which header defines
reqiured macros:
    https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Headers.html

This change should also increase portability across other libcs.

Bug: https://bugs.gentoo.org/604360
Signed-off-by: Sergei Trofimovich <siarheit@google.com>
8 years agotests: skip unpriv tests on broken overlay module
Christian Brauner [Sun, 25 Dec 2016 11:26:17 +0000 (12:26 +0100)] 
tests: skip unpriv tests on broken overlay module

This mainly affects Trusty. The 3.13 kernel has a broken overlay module which
does not handle symlinks correctly. This is a problem for containers that use
an overlay based rootfs since safe_mount() uses /proc/<pid>/fd/<fd-number> in
its calls to mount().

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoAdd --enable-gnutls option
Fabrice Fontaine [Sun, 18 Dec 2016 20:39:24 +0000 (21:39 +0100)] 
Add --enable-gnutls option

Previously HAVE_LIBGNUTLS was never set in config.h even if gnutls was
detected as AC_CHECK_LIB default action-if-found was overriden by
enable_gnutls=yes
This patch adds an --enable-gnutls option and will call AC_CHECK_LIB
with the default action to write HAVE_LIBGNUTLS in config.h

Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
8 years agolxc-opensuse: rm poweroff.target -> sigpwr.target copy
Evgeni Golov [Thu, 15 Dec 2016 19:02:10 +0000 (20:02 +0100)] 
lxc-opensuse: rm poweroff.target -> sigpwr.target copy

Given commit 330ae3d350e060e5702a0e5ef5d0faeeeea8df6e:

    lxccontainer: detect if we should send SIGRTMIN+3

    This is required by systemd to cleanly shutdown. Other init systems should not
    have SIGRTMIN+3 in the blocked signals set.

we should stop poking around with sigpwr.target for systemd.

Signed-off-by: Evgeni Golov <evgeni@debian.org>
8 years agodon't try to get stuff from /usr/lib/systemd on the host
Evgeni Golov [Thu, 15 Dec 2016 18:59:13 +0000 (19:59 +0100)] 
don't try to get stuff from /usr/lib/systemd on the host

it might not even be there…

Signed-off-by: Evgeni Golov <evgeni@debian.org>
8 years agoFix regression in errno handling cherry-pick
Stéphane Graber [Thu, 15 Dec 2016 19:23:37 +0000 (14:23 -0500)] 
Fix regression in errno handling cherry-pick

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agotemplates/lxc-debian.in: handle ppc hostarch -> powerpc
Santiago Ruano Rincón [Mon, 12 Dec 2016 10:12:26 +0000 (11:12 +0100)] 
templates/lxc-debian.in: handle ppc hostarch -> powerpc

Signed-off-by: Santiago Ruano Rincón <santiago@debian.org>
Signed-off-by: Evgeni Golov <evgeni@debian.org>
8 years agotemplates/lxc-debian.in: Fix typo in calling dpkg with --print-foreign-architectures...
Santiago Ruano Rincón [Mon, 12 Dec 2016 10:00:39 +0000 (11:00 +0100)] 
templates/lxc-debian.in: Fix typo in calling dpkg with --print-foreign-architectures option

Signed-off-by: Santiago Ruano Rincón <santiago@debian.org>
Signed-off-by: Evgeni Golov <evgeni@debian.org>
8 years agoconf, attach: save errno across call to close
Wolfgang Bumiller [Sat, 10 Dec 2016 09:18:27 +0000 (10:18 +0100)] 
conf, attach: save errno across call to close

Save errno across some calls to close() since it can be
interrupted.

Signed-off-by: Wolfgang Bumiller <wry.git@bumiller.com>
8 years agoMerge pull request #1348 from brauner/2016-12-08/fix_attach_fd_leak_stable-1.0
Stéphane Graber [Fri, 9 Dec 2016 09:37:25 +0000 (10:37 +0100)] 
Merge pull request #1348 from brauner/2016-12-08/fix_attach_fd_leak_stable-1.0

attach: close lsm label file descriptor

8 years agoattach: close lsm label file descriptor 1348/head
Christian Brauner [Thu, 8 Dec 2016 22:26:17 +0000 (23:26 +0100)] 
attach: close lsm label file descriptor

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoconf: clearly report to either use drop or keep
Christian Brauner [Fri, 2 Dec 2016 18:41:11 +0000 (19:41 +0100)] 
conf: clearly report to either use drop or keep

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agotests; Don't cause test failures on cleanup errors
Stéphane Graber [Thu, 1 Dec 2016 23:34:00 +0000 (18:34 -0500)] 
tests; Don't cause test failures on cleanup errors

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoutils: add macro __LXC_NUMSTRLEN
Christian Brauner [Sun, 27 Nov 2016 22:41:06 +0000 (23:41 +0100)] 
utils: add macro __LXC_NUMSTRLEN

This macro can be used to set or allocate a string buffer that can hold any
64bit representable number.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agocommands: improve logging
Christian Brauner [Sat, 26 Nov 2016 08:16:25 +0000 (09:16 +0100)] 
commands: improve logging

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoattach: simplify lsm_openat()
Christian Brauner [Thu, 24 Nov 2016 06:58:01 +0000 (07:58 +0100)] 
attach: simplify lsm_openat()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agochange version to 1.0.9 in configure.ac lxc-1.0.9
Stéphane Graber [Wed, 23 Nov 2016 19:09:02 +0000 (14:09 -0500)] 
change version to 1.0.9 in configure.ac

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoattach: do not send procfd to attached process
Christian Brauner [Fri, 18 Nov 2016 15:46:42 +0000 (16:46 +0100)] 
attach: do not send procfd to attached process

So far, we opened a file descriptor refering to proc on the host inside the
host namespace and handed that fd to the attached process in
attach_child_main(). This was done to ensure that LSM labels were correctly
setup. However, by exploiting a potential kernel bug, ptrace could be used to
prevent the file descriptor from being closed which in turn could be used by an
unprivileged container to gain access to the host namespace. Aside from this
needing an upstream kernel fix, we should make sure that we don't pass the fd
for proc itself to the attached process. However, we cannot completely prevent
this, as the attached process needs to be able to change its apparmor profile
by writing to /proc/self/attr/exec or /proc/self/attr/current. To minimize the
attack surface, we only send the fd for /proc/self/attr/exec or
/proc/self/attr/current to the attached process. To do this we introduce a
little more IPC between the child and parent:

 * IPC mechanism: (X is receiver)
 *   initial process        intermediate          attached
 *        X           <---  send pid of
 *                          attached proc,
 *                          then exit
 *    send 0 ------------------------------------>    X
 *                                              [do initialization]
 *        X  <------------------------------------  send 1
 *   [add to cgroup, ...]
 *    send 2 ------------------------------------>    X
 * [set LXC_ATTACH_NO_NEW_PRIVS]
 *        X  <------------------------------------  send 3
 *   [open LSM label fd]
 *    send 4 ------------------------------------>    X
 *    [set LSM label]
 *   close socket                                 close socket
 *                                                run program

The attached child tells the parent when it is ready to have its LSM labels set
up. The parent then opens an approriate fd for the child PID to
/proc/<pid>/attr/exec or /proc/<pid>/attr/current and sends it via SCM_RIGHTS
to the child. The child can then set its LSM laben. Both sides then close the
socket fds and the child execs the requested process.

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
8 years agoMerge pull request #1310 from brauner/2016-11-22/tree_wide_replace_readdir_r
Stéphane Graber [Tue, 22 Nov 2016 06:19:52 +0000 (01:19 -0500)] 
Merge pull request #1310 from brauner/2016-11-22/tree_wide_replace_readdir_r

tree-wide: replace readdir_r() with readdir()

8 years agotree-wide: replace readdir_r() with readdir() 1310/head
Christian Brauner [Tue, 9 Aug 2016 19:05:19 +0000 (21:05 +0200)] 
tree-wide: replace readdir_r() with readdir()

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
8 years agoReplace 'index' by 'strchr' for Android build
Stéphane Graber [Fri, 18 Nov 2016 02:10:03 +0000 (21:10 -0500)] 
Replace 'index' by 'strchr' for Android build

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agodebian: Don't depend on libui-dialog-perl
Stéphane Graber [Mon, 14 Nov 2016 16:53:07 +0000 (11:53 -0500)] 
debian: Don't depend on libui-dialog-perl

This package doesn't exist in stretch anymore, and it's unclear why we
were depending on a library to begin with (as opposed to having it
brought by whatever needs it).

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoconf: do not use %m format specifier
Christian Brauner [Sun, 13 Nov 2016 16:10:41 +0000 (17:10 +0100)] 
conf: do not use %m format specifier

This is a GNU extension and some libcs might be missing it.

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
8 years agoinstall bash completion where pkg-config tells us to
Evgeni Golov [Sat, 12 Nov 2016 13:44:40 +0000 (14:44 +0100)] 
install bash completion where pkg-config tells us to

Signed-off-by: Evgeni Golov <evgeni@debian.org>
8 years agotemplates: add squashfs support to lxc-ubuntu-cloud.in
Po-Hsu Lin [Thu, 10 Nov 2016 08:48:29 +0000 (16:48 +0800)] 
templates: add squashfs support to lxc-ubuntu-cloud.in

Add squashfs format file support for lxc-ubuntu-cloud.in

Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
8 years agocgfs: explicitly check for NULL
Christian Brauner [Sun, 30 Oct 2016 13:44:33 +0000 (14:44 +0100)] 
cgfs: explicitly check for NULL

Somehow this implementation of a cgroupfs backend decided to use the hierarchy
numbers it detects in /proc/cgroups and /proc/self/cgroups as indices for
the hierarchy struct. Controller numbering usually starts at 1 but may start at
0 if:

    a) the controller is not mounted on a cgroups v1 hierarchy;
    b) the controller is bound to the cgroups v2 single unified hierarchy; or
    c) the controller is disabled

To avoid having to rework our fallback backend significantly, we should
explicitly check for each controller if hierarchy[i] != NULL.

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
8 years agocreate symlink for /var/run
mgariepy [Tue, 8 Nov 2016 16:42:34 +0000 (11:42 -0500)] 
create symlink for /var/run

this patch create /var/run link to point to /run.

This will fix various issue present when /var/run is persistent.

Signed-off-by: Marc Gariepy <gariepy.marc@gmail.com>
8 years agoconf: merge network namespace move & rename on shutdown
Wolfgang Bumiller [Wed, 17 Aug 2016 09:36:39 +0000 (11:36 +0200)] 
conf: merge network namespace move & rename on shutdown

On shutdown we move physical network interfaces back to the
host namespace and rename them afterwards as well as in the
later lxc_network_delete() step. However, if the device had
a name which already exists in the host namespace then the
moving fails and so do the subsequent rename attempts. When
the namespace ceases to exist the devices finally end up
in the host namespace named 'dev<ID>' by the kernel.

In order to avoid this, we do the moving and renaming in a
single step (lxc_netdev_move_by_*()'s move & rename happen
in a single netlink transaction).

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
8 years agotools: use correct exit code for lxc-stop
Christian Brauner [Sun, 30 Oct 2016 17:24:15 +0000 (18:24 +0100)] 
tools: use correct exit code for lxc-stop

When the container is already running our manpage promises to exit with 2.
Let's make it so.

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
8 years agocgfs: skip empty entries under /proc/self/cgroup
Christian Brauner [Sun, 30 Oct 2016 12:42:37 +0000 (13:42 +0100)] 
cgfs: skip empty entries under /proc/self/cgroup

If cgroupv2 is enabled either alone or together with legacy hierarchies
/proc/self/cgroup can contain entries of the form:

        0::/

These entries need to be skipped.

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
8 years agocgfs: add print_cgfs_init_debuginfo()
Christian Brauner [Sun, 30 Oct 2016 09:45:13 +0000 (10:45 +0100)] 
cgfs: add print_cgfs_init_debuginfo()

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
8 years agocgfs: fix invalid free()
Christian Brauner [Sat, 29 Oct 2016 20:47:51 +0000 (22:47 +0200)] 
cgfs: fix invalid free()

And let's be on the safe side by NULLing free()ed variables.

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
8 years agouse python3_sitearch for including the python code
Evgeni Golov [Sat, 29 Oct 2016 18:29:08 +0000 (20:29 +0200)] 
use python3_sitearch for including the python code

Closes: #502
Signed-off-by: Evgeni Golov <evgeni@debian.org>
8 years agoubuntu: Fix package upgrades requiring proc
Stéphane Graber [Mon, 24 Oct 2016 21:38:13 +0000 (17:38 -0400)] 
ubuntu: Fix package upgrades requiring proc

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agos390x: Fix seccomp handling of personalities
Stéphane Graber [Thu, 20 Oct 2016 20:35:36 +0000 (16:35 -0400)] 
s390x: Fix seccomp handling of personalities

There are no personalities for s390x, so don't list itself as one.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoDrop leftover references to lxc_strerror().
Jafar Al-Gharaibeh [Thu, 13 Oct 2016 23:35:29 +0000 (18:35 -0500)] 
Drop leftover references to lxc_strerror().

lxc_strerror() was dropped long time ago, in 2009 to be exact.

Related commit:
https://github.com/lxc/lxc/commit/7cee8789514fb42d6a48d50b904e24284f5526e3

Signed-off-by: Jafar Al-Gharaibeh <to.jafar@gmail.com>
8 years agoarchlinux: Fix resolving
Stéphane Graber [Thu, 13 Oct 2016 19:02:56 +0000 (15:02 -0400)] 
archlinux: Fix resolving

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoarchlinux: Do DHCP on eth0
Stéphane Graber [Thu, 13 Oct 2016 18:32:03 +0000 (14:32 -0400)] 
archlinux: Do DHCP on eth0

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agolog: sanity check the returned value from snprintf()
Lans Zhang [Mon, 10 Oct 2016 13:49:55 +0000 (21:49 +0800)] 
log: sanity check the returned value from snprintf()

The returned value from snprintf() should be checked carefully.

This bug can be leveraged to execute arbitrary code through carefully
constructing the payload, e.g,

lxc-freeze -n `python -c "print 'AAAAAAAA' + 'B'*959"` -P PADPAD -o /tmp/log

This command running on Ubuntu 14.04 (x86-64) can cause a segment fault.

Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
8 years agomark the python examples as having utf-8 encoding
Evgeni Golov [Sat, 8 Oct 2016 16:29:30 +0000 (18:29 +0200)] 
mark the python examples as having utf-8 encoding

this allows running them also under Python2, which otherwise
would choke on Stéphane's name and error out with
 SyntaxError: Non-ASCII character '\xc3' in file …

Signed-off-by: Evgeni Golov <evgeni@debian.org>
8 years agoFix spelling of CentOS in the templates
Roman Mueller [Wed, 28 Sep 2016 08:03:39 +0000 (10:03 +0200)] 
Fix spelling of CentOS in the templates

Signed-off-by: Roman Mueller <roman.mueller@gmail.com>
8 years agoutils: fix lxc_string_split()
Christian Brauner [Sun, 25 Sep 2016 14:51:24 +0000 (16:51 +0200)] 
utils: fix lxc_string_split()

Make sure we don't return uninitialized memory.

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
8 years agolxc-create -t debian fails on ppc64el arch
Thierry Fauck [Fri, 16 Sep 2016 13:34:41 +0000 (08:34 -0500)] 
lxc-create -t debian fails on ppc64el arch

Template catches arch from uname -m, but for ppc64el system, arch reports ppc64le
which doesn't match image repo.

Signed-off-by: Thierry Fauck <tfauck@free.fr>
Signed-off-by: Serge Hallyn <serge@hallyn.com>
8 years agomake rsync deal with sparse files efficiently
Lukas Pirl [Wed, 14 Sep 2016 15:40:16 +0000 (17:40 +0200)] 
make rsync deal with sparse files efficiently

Signed-off-by: Lukas Pirl <git@lukas-pirl.de>
8 years agolxczfs: small fixes
Christian Brauner [Tue, 13 Sep 2016 15:18:23 +0000 (17:18 +0200)] 
lxczfs: small fixes

- We expect destroy to fail in zfs_clone() so try to silence it so users are
  not irritated when they create zfs snapshots.
- Add -r recursive to zfs_destroy(). This code is only hit when a) the
  container has no snapshots or b) the user calls destroy with snapshots. So
  this should be safe. Without -r snapshots will remain.

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
8 years agoconsole: use correct log name
Christian Brauner [Sat, 3 Sep 2016 18:05:54 +0000 (20:05 +0200)] 
console: use correct log name

lxc_console is used with lxc_console.c

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
8 years agoset FULL_PATH_NAMES=NO in doc/api/Doxyfile
Evgeni Golov [Sat, 27 Aug 2016 10:14:53 +0000 (12:14 +0200)] 
set FULL_PATH_NAMES=NO in doc/api/Doxyfile

otherwise the generated docs have the full build path in them
and nonbody cares that the files were built in
 /build/lxc-_BVY2u/lxc-2.0.4/src/lxc/

Signed-off-by: Evgeni Golov <evgeni@debian.org>
8 years agotemplates: fedora requires openssl binary
Elan Ruusamäe [Tue, 23 Aug 2016 16:31:38 +0000 (19:31 +0300)] 
templates: fedora requires openssl binary

/usr/share/lxc/templates/lxc-fedora: line 1078: openssl: command not found

Signed-off-by: Elan Ruusamäe <glen@delfi.ee>
8 years agoseccomp: non functional changes
Christian Brauner [Fri, 19 Aug 2016 16:53:02 +0000 (18:53 +0200)] 
seccomp: non functional changes

- log more errnos
- adapt coding style

Signed-off-by: Christian Brauner <cbrauner@suse.de>
8 years agoseccomp: remove double include and order includes
Christian Brauner [Fri, 19 Aug 2016 13:20:22 +0000 (15:20 +0200)] 
seccomp: remove double include and order includes

Signed-off-by: Christian Brauner <cbrauner@suse.de>
8 years agoseccomp: add support for s390x
Christian Brauner [Fri, 19 Aug 2016 09:57:14 +0000 (11:57 +0200)] 
seccomp: add support for s390x

Signed-off-by: Christian Brauner <cbrauner@suse.de>
8 years agoconfile: add more archs to lxc_config_parse_arch()
Christian Brauner [Fri, 19 Aug 2016 09:15:30 +0000 (11:15 +0200)] 
confile: add more archs to lxc_config_parse_arch()

Signed-off-by: Christian Brauner <cbrauner@suse.de>
8 years agoseccomp: fix strerror()
James Cowgill [Thu, 18 Aug 2016 15:48:24 +0000 (16:48 +0100)] 
seccomp: fix strerror()

Signed-off-by: James Cowgill <james410@cowgill.org.uk>
8 years agoseccomp: Add mips and mips64 entries to lxc_config_parse_arch
James Cowgill [Thu, 18 Aug 2016 13:27:35 +0000 (14:27 +0100)] 
seccomp: Add mips and mips64 entries to lxc_config_parse_arch

Fixes "unsupported personality" warnings when starting containers.

Signed-off-by: James Cowgill <james410@cowgill.org.uk>
8 years agoseccomp: Implement MIPS seccomp handling
James Cowgill [Mon, 15 Aug 2016 16:09:44 +0000 (16:09 +0000)] 
seccomp: Implement MIPS seccomp handling

MIPS processors implement 3 ABIs: o32, n64 and n32 (similar to x32). The kernel
treats each ABI separately so syscalls disallowed on "all" arches should be
added to all three seccomp sets. This is implemented by expanding compat_arch
and compat_ctx to accept two compat architectures.

After this, the MIPS hostarch detection code and config section code is added.

Signed-off-by: James Cowgill <james410@cowgill.org.uk>
8 years agoutils: Add mips signalfd syscall numbers
James Cowgill [Fri, 12 Aug 2016 15:54:14 +0000 (15:54 +0000)] 
utils: Add mips signalfd syscall numbers

Signed-off-by: James Cowgill <james410@cowgill.org.uk>
8 years agoUse full GPG fingerprint instead of long IDs.
Stéphane Graber [Wed, 17 Aug 2016 19:42:34 +0000 (15:42 -0400)] 
Use full GPG fingerprint instead of long IDs.

With how easy it is to create a collision on a short ID nowadays and
given that the user doesn't actually have to remember or manually enter
the key ID, lets just use the full fingerprint from now on.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agotools: add missing newline in lxc-create output
Christian Brauner [Sat, 13 Aug 2016 14:04:44 +0000 (16:04 +0200)] 
tools: add missing newline in lxc-create output

Signed-off-by: Christian Brauner <cbrauner@suse.de>
8 years agoapparmor: Refresh generated file
Stéphane Graber [Tue, 28 Jun 2016 19:35:58 +0000 (15:35 -0400)] 
apparmor: Refresh generated file

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoconf: set pty_info to NULL after free
Wolfgang Bumiller [Thu, 28 Jul 2016 09:52:18 +0000 (11:52 +0200)] 
conf: set pty_info to NULL after free

This fixes a double free corruption on container-requested
reboots when lxc_spawn() fails before receiving the ttys, as
lxc_fini() (part of __lxc_start()'s cleanup) calls
lxc_delete_tty().

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
8 years agoAdd a prefix to the lxc.pc
Sergio Schvezov [Tue, 26 Jul 2016 07:41:47 +0000 (09:41 +0200)] 
Add a prefix to the lxc.pc

This allows installing to different locations and using
the lxc.pc to build using the generated includedir and
libdir.

Signed-off-by: Sergio Schvezov <sergio.schvezov@ubuntu.com>
8 years agotemplates: avoid noisy perl warnings caused by missing locales
Andreas Freudenberg [Tue, 12 Jul 2016 15:51:06 +0000 (17:51 +0200)] 
templates: avoid noisy perl warnings caused by missing locales

Signed-off-by: Andreas Freudenberg <andreas.freudenberg@licomonch.net>
8 years agoSet up MTU for vlan-type interfaces.
Vitaly Lavrov [Thu, 30 Jun 2016 17:04:49 +0000 (20:04 +0300)] 
Set up MTU for vlan-type interfaces.

Signed-off-by: Vitaly Lavrov <vel21ripn@gmail.com>
8 years agolxc-debian: fix regression when creating wheezy containers
Antonio Terceiro [Wed, 29 Jun 2016 17:58:35 +0000 (14:58 -0300)] 
lxc-debian: fix regression when creating wheezy containers

The regression was introduced by commit
3c39b0b7a2b445e08d2e2aecb05566075f4f3423 which makes it possible to
create working stretch containers by forcinig `init` to be in the
included package list.

However, `init` didn't exit before jessie, so now for wheezy we
explicitly include `sysvinit`; sysvinit on wheezy is essential,
so it would already be included anyway.

Signed-off-by: Antonio Terceiro <terceiro@debian.org>
8 years agoInclude all lxcmntent.h function declarations on Bionic
Preetam D'Souza [Tue, 28 Jun 2016 03:12:12 +0000 (23:12 -0400)] 
Include all lxcmntent.h function declarations on Bionic

Newer versions of Android (5.0+, aka API Level 21+) include mntent.h,
which declares setmntent and endmntent. This hits an edge
case with the preprocessor checks in lxcmntent.h because HAVE_SETMNTENT
and HAVE_ENDMNTENT are both defined (in Bionic's mntent.h), but conf.c
always includes lxcmntent.h on Bionic! As a result, we get compiler
warnings of implicit function declarations for setmntent endmntent.

This patch always includes setmntent/endmntent/hasmntopt function
declarations on Bionic, which gets rid of these warnings.

Signed-off-by: Preetam D'Souza <preetamjdsouza@gmail.com>
8 years agoAppArmor: add make-rslave to usr.bin.lxc-start
Wolfgang Bumiller [Mon, 27 Jun 2016 20:20:00 +0000 (16:20 -0400)] 
AppArmor: add make-rslave to usr.bin.lxc-start

The profile already contains
  mount options=(rw, make-slave) -> **,

Which allows going through all mountpoints with make-slave,
so it seems to make sense to also allow the directly
recursive variant with "make-rslave".

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoplamo: Improve Plamo template
KATOH Yasufumi [Tue, 21 Jun 2016 02:06:25 +0000 (11:06 +0900)] 
plamo: Improve Plamo template

* configure to start only the minimum of service
* add ntp, kmod to ignore packages

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
8 years agolxc-debian: make sure init is installed
Antonio Terceiro [Fri, 17 Jun 2016 22:00:56 +0000 (19:00 -0300)] 
lxc-debian: make sure init is installed

init 1.34 is not "Essential" anymore, in order to make it not required
on minimal chroots, docker containers, etc. Because of that we now need
to manually include it on systems that are expected to boot.

Signed-off-by: Antonio Terceiro <terceiro@debian.org>
8 years agoFix redefinition of struct in6_addr
Jörg Krause [Thu, 19 May 2016 19:51:27 +0000 (21:51 +0200)] 
Fix redefinition of struct in6_addr

struct in6_addr is both defined in the C library header <netinet/in.h>
and the Linux kernel header <linux/in6.h>.

lxc_user_nic.c includes both <netinet/in.h> and <linux/if_bridge.h>. The
later one includes <linux/in6.h>.

This breaks build with the musl libc:
  error: redefinition of ‘struct in6_addr’

As lxc_user_nic.c does not use any references from <linux/if_bridge.h> it
is safe to remove this header.

Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
8 years agoFix hostname in interface config for apline template
Andrey Kostin [Wed, 11 May 2016 20:32:40 +0000 (23:32 +0300)] 
Fix hostname in interface config for apline template

Signed-off-by: Andrey Kostin <andrey@kostin.email>
8 years agoAlso allow fstype=fuse for fuse filesystems
Stéphane Graber [Wed, 11 May 2016 16:59:23 +0000 (12:59 -0400)] 
Also allow fstype=fuse for fuse filesystems

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoAllow configuration file values to be quoted
Stewart Brodie [Tue, 10 May 2016 12:57:00 +0000 (13:57 +0100)] 
Allow configuration file values to be quoted

If the value starts and ends with matching quote characters, those
characters are stripped automatically.   Quote characters are the
single quote (') or double quote (").  The quote removal is done after
the whitespace trimming.

This is needed particularly in order that lxc.environment values may
have trailing spaces.  However, the quote removal is done for all values
in the parse_line function, as it has non-const access to the value.

Signed-off-by: Stewart Brodie <stewart@metahusky.net>
8 years agoUnshare netns after setting the userns mappings
Serge Hallyn [Mon, 9 May 2016 20:30:46 +0000 (15:30 -0500)] 
Unshare netns after setting the userns mappings

so that there is a root uid mapping for the /proc/net files.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoAdded OR statement for cases of ID = rhel in RHEL 7+
Hartnell Foster [Mon, 9 May 2016 11:42:56 +0000 (12:42 +0100)] 
Added OR statement for cases of ID = rhel in RHEL 7+

Signed-off-by: Hartnell Foster <hartnell.foster@bbc.co.uk>
8 years agosync.c: use correct types
Christian Brauner [Sat, 7 May 2016 05:40:33 +0000 (07:40 +0200)] 
sync.c: use correct types

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
8 years agosync: fail on unexpected message sizes
Tycho Andersen [Fri, 6 May 2016 16:21:39 +0000 (11:21 -0500)] 
sync: fail on unexpected message sizes

I think (?) this may be related to our hanging monitor bug. Let's do this
anyway, as it's probably a good idea.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
8 years agoForce DHCP client to send hostname
Lisio [Thu, 5 May 2016 04:35:36 +0000 (08:35 +0400)] 
Force DHCP client to send hostname

Required for proper applying dnsmasq config entries.

Signed-off-by: Andrey Kostin <andrey@kostin.email>
8 years agoAdded `type` to keys in lxc_list_nicconfigs
Aron Podrigal [Sun, 1 May 2016 16:13:39 +0000 (12:13 -0400)] 
Added `type` to keys in lxc_list_nicconfigs

Signed-off-by: Aron Podrigal <aronp@guaranteedplus.com>
8 years agoFixed - set PyErr when Container.__init__ fails
Aron Podrigal [Sun, 1 May 2016 15:06:53 +0000 (11:06 -0400)] 
Fixed - set PyErr when Container.__init__ fails

When container init failed for whatever reason, previously it resulted
in a `SystemError: NULL result without error in PyObject_Call`
This will now result in a RuntimeError with the error message
previously printed to stderr.

Signed-off-by: Aron Podrigal <aronp@guaranteedplus.com>
8 years agoCheck if stdout is a terminal in lxc-checkconfig
walkerning [Sat, 30 Apr 2016 17:06:29 +0000 (01:06 +0800)] 
Check if stdout is a terminal in lxc-checkconfig

Let lxc-checkconfig write to non-tty stdout without color control
characters
Signed-off-by: walkerning <foxdoraame@gmail.com>
8 years agoUpdate maintainers
Stéphane Graber [Sun, 24 Apr 2016 22:34:15 +0000 (18:34 -0400)] 
Update maintainers

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agodrop obsolete syslog.target from lxc.service.in
Evgeni Golov [Thu, 14 Apr 2016 16:03:29 +0000 (18:03 +0200)] 
drop obsolete syslog.target from lxc.service.in

the target is obsolete since systemd v38 which everybody should have.

original patch by Daniel Baumann

Signed-off-by: Evgeni Golov <evgeni@debian.org>