]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
7 years agobdev: enable building with gcc7 1749/head
Christian Brauner [Tue, 15 Aug 2017 22:34:23 +0000 (00:34 +0200)] 
bdev: enable building with gcc7

We shouldn't ignore this anyway.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoadding warning for mtu ignoring
Shane Chen [Thu, 1 Jun 2017 05:36:41 +0000 (13:36 +0800)] 
adding warning for mtu ignoring

Signed-off-by: Shane Chen <ss1ha3tw@gmail.com>
7 years agoconf: improve write_id_mapping()
Christian Brauner [Sat, 27 May 2017 06:16:01 +0000 (08:16 +0200)] 
conf: improve write_id_mapping()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: non-functional changes
Christian Brauner [Sun, 28 May 2017 22:18:37 +0000 (00:18 +0200)] 
conf: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_utsname()
Christian Brauner [Mon, 29 May 2017 13:04:40 +0000 (15:04 +0200)] 
confile: config_utsname()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_stopsignal()
Christian Brauner [Mon, 29 May 2017 13:01:28 +0000 (15:01 +0200)] 
confile: config_stopsignal()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_haltsignal()
Christian Brauner [Mon, 29 May 2017 12:59:21 +0000 (14:59 +0200)] 
confile: config_haltsignal()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_haltsignal()
Christian Brauner [Mon, 29 May 2017 12:58:24 +0000 (14:58 +0200)] 
confile: config_haltsignal()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_start()
Christian Brauner [Mon, 29 May 2017 12:53:58 +0000 (14:53 +0200)] 
confile: config_start()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_cap_drop()
Christian Brauner [Mon, 29 May 2017 12:41:02 +0000 (14:41 +0200)] 
confile: config_cap_drop()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_cap_keep()
Christian Brauner [Mon, 29 May 2017 12:40:47 +0000 (14:40 +0200)] 
confile: config_cap_keep()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_mount()
Christian Brauner [Mon, 29 May 2017 12:40:32 +0000 (14:40 +0200)] 
confile: config_mount()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_mount_auto()
Christian Brauner [Mon, 29 May 2017 12:40:18 +0000 (14:40 +0200)] 
confile: config_mount_auto()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_fstab()
Christian Brauner [Mon, 29 May 2017 12:39:56 +0000 (14:39 +0200)] 
confile: config_fstab()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_idmap()
Christian Brauner [Mon, 29 May 2017 12:39:33 +0000 (14:39 +0200)] 
confile: config_idmap()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_cgroup()
Christian Brauner [Mon, 29 May 2017 12:38:50 +0000 (14:38 +0200)] 
confile: config_cgroup()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_loglevel()
Christian Brauner [Mon, 29 May 2017 12:38:26 +0000 (14:38 +0200)] 
confile: config_loglevel()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_group()
Christian Brauner [Mon, 29 May 2017 12:37:42 +0000 (14:37 +0200)] 
confile: config_group()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_hook()
Christian Brauner [Mon, 29 May 2017 12:37:18 +0000 (14:37 +0200)] 
confile: config_hook()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_network_ipv6_gateway()
Christian Brauner [Mon, 29 May 2017 12:36:36 +0000 (14:36 +0200)] 
confile: config_network_ipv6_gateway()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_network_ipv6()
Christian Brauner [Mon, 29 May 2017 12:36:12 +0000 (14:36 +0200)] 
confile: config_network_ipv6()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_network_ipv4_gateway()
Christian Brauner [Mon, 29 May 2017 12:35:55 +0000 (14:35 +0200)] 
confile: config_network_ipv4_gateway()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_network_ipv4()
Christian Brauner [Mon, 29 May 2017 12:35:13 +0000 (14:35 +0200)] 
confile: config_network_ipv4()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_network_hwaddr()
Christian Brauner [Mon, 29 May 2017 12:34:34 +0000 (14:34 +0200)] 
confile: config_network_hwaddr()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_network_type()
Christian Brauner [Mon, 29 May 2017 12:32:37 +0000 (14:32 +0200)] 
confile: config_network_type()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: config_string_item()
Christian Brauner [Mon, 29 May 2017 12:30:04 +0000 (14:30 +0200)] 
confile: config_string_item()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: add config_value_empty()
Christian Brauner [Mon, 29 May 2017 12:28:34 +0000 (14:28 +0200)] 
confile: add config_value_empty()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoREADME: reword id mapping restrictions when unpriv
Christian Brauner [Mon, 29 May 2017 04:02:24 +0000 (06:02 +0200)] 
README: reword id mapping restrictions when unpriv

Suggested-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agorepo: add new README
Christian Brauner [Sat, 27 May 2017 01:53:59 +0000 (03:53 +0200)] 
repo: add new README

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoFix the bug of 'ts->stdoutfd' did not fill with parameters 'stdoutfd'
Li Feng [Fri, 19 May 2017 14:40:07 +0000 (22:40 +0800)] 
Fix the bug of 'ts->stdoutfd' did not fill with parameters 'stdoutfd'

Signed-off-by: Li Feng <lifeng68@huawei.com>
7 years agoAdd cronie to the pkg list
mgariepy [Wed, 17 May 2017 19:03:20 +0000 (15:03 -0400)] 
Add cronie to the pkg list

Add cronie to have crond running in the containers.

Signed-off-by: Marc Gariepy <gariepy.marc@gmail.com>
7 years agoseccomp: print action name in log
0x0916 [Mon, 15 May 2017 10:05:09 +0000 (18:05 +0800)] 
seccomp: print action name in log

This patch add function `get_action_name`, so we can print action name
in the log file. for example:

```
lxc-start ubuntu 20170515095416.561 INFO     lxc_seccomp - seccomp.c:parse_config_v2:613 - Adding compat rule for reject_force_umount action 0(kill).
lxc-start ubuntu 20170515095416.562 INFO     lxc_seccomp - seccomp.c:parse_config_v2:613 - Adding compat rule for kexec_load action 327681(errno).
```

Signed-off-by: 0x0916 <w@laoqinren.net>
7 years agoseccomp: update comment for function `parse_config`
0x0916 [Mon, 15 May 2017 10:04:27 +0000 (18:04 +0800)] 
seccomp: update comment for function `parse_config`

Signed-off-by: 0x0916 <w@laoqinren.net>
7 years agoseccomp: s/n-new-privs/no-new-privs/g
0x0916 [Mon, 15 May 2017 10:03:41 +0000 (18:03 +0800)] 
seccomp: s/n-new-privs/no-new-privs/g

Signed-off-by: 0x0916 <w@laoqinren.net>
7 years agoconf: fix build without libcap
Dima Krasner [Sun, 14 May 2017 09:24:59 +0000 (12:24 +0300)] 
conf: fix build without libcap

Signed-off-by: Dima Krasner <samdima@securingsam.com>
8 years agochange version to 1.0.10 in configure.ac lxc-1.0.10
Stéphane Graber [Thu, 11 May 2017 17:02:58 +0000 (13:02 -0400)] 
change version to 1.0.10 in configure.ac

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agolxccontainer: avoid NULL pointer dereference
Christian Brauner [Sat, 6 May 2017 21:38:22 +0000 (23:38 +0200)] 
lxccontainer: avoid NULL pointer dereference

In case the lxc command socket is hashed and the socket was created for a
different path than the one we're currently querying
lxc_cmd_get_{lxcpath,name}() can return NULL. The command socket path is hashed
when len(lxcpath) > sizeof(sun_path) - 2.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agocommands: non-functional changes
Christian Brauner [Sat, 6 May 2017 21:37:53 +0000 (23:37 +0200)] 
commands: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agocommands: avoid NULL pointer dereference
Christian Brauner [Sat, 6 May 2017 21:35:57 +0000 (23:35 +0200)] 
commands: avoid NULL pointer dereference

lxc_cmd_get_lxcpath() and lxc_cmd_get_name() both pass a nil pointer to
fill_sock_name(). Make sure that they are not dereferenced.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoconf: order mount options
Christian Brauner [Tue, 2 May 2017 21:37:16 +0000 (23:37 +0200)] 
conf: order mount options

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoissue template: fix typo
Christian Brauner [Sun, 23 Apr 2017 20:04:54 +0000 (22:04 +0200)] 
issue template: fix typo

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agocreate ISSUE_TEMPLATE.md
Christian Brauner [Sat, 22 Apr 2017 16:38:44 +0000 (18:38 +0200)] 
create ISSUE_TEMPLATE.md

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoconf: less error prone pointer access
Wolfgang Bumiller [Fri, 23 Dec 2016 12:10:01 +0000 (13:10 +0100)] 
conf: less error prone pointer access

These functions define pointer to their key shifted by a
number and guard access to it later via another variable.
Let's make this more explicit (and additionally have the
pointer be NULL in the case where it is not supposed to be
used).

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
8 years agoremove obsolete note about api stability
Jakob Gillich [Sat, 8 Apr 2017 01:05:40 +0000 (03:05 +0200)] 
remove obsolete note about api stability

Signed-off-by: Jakob Gillich <jakob@gillich.me>
8 years agoIncreased buffer length in print_stats()
Denis Pynkin [Thu, 30 Mar 2017 15:31:48 +0000 (18:31 +0300)] 
Increased buffer length in print_stats()

Some "/sys" entries exceeds buffer size.
This results to some statistics loss ('BlkIO' in particular):

 wc -c /sys/fs/cgroup/blkio/lxc/alt/blkio.throttle.io_service_bytes
 318 /sys/fs/cgroup/blkio/lxc/alt/blkio.throttle.io_service_bytes

Signed-off-by: Denis Pynkin <dans@altlinux.org>
8 years agoMerge pull request #1386 from brauner/2017-01-16/fix_CVE-2016-10124_stable-1.0
Stéphane Graber [Tue, 4 Apr 2017 18:21:10 +0000 (14:21 -0400)] 
Merge pull request #1386 from brauner/2017-01-16/fix_CVE-2016-10124_stable-1.0

stable-1.0: backport fixes for CVE-2016-10124

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>