Commit Graph

907 Commits

Author SHA1 Message Date
Serge Hallyn
2e44ed1e64 lxc-ubuntu: use release-updates and release-security
Particularly for LTS releases, which many people will want to use in
their containers, it is not wise to not use -security and -updates.
Furthermore the fix allowing ssh to allow the container to shut down
is in lucid-updates only.

With this patch, after debootstrapping a container, we add -updates
and -security to sources.list and do an apt-get upgrade under chroot.
Unfortunately we need to do this because debootstrap doesn't know how
to.

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-26 10:44:40 +01:00
Serge Hallyn
2407e68ef2 lxc-ubuntu: add /dev/full, /dev/hpet, and /dev/kvm to devices whitelist
Thanks for Scott Moser for these, which allows qemu to run inside a container.

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-26 10:44:40 +01:00
Serge Hallyn
e226883316 drop mac_admin and mac_override
mac_admin stops the container from loading LSM policy.  Neither
selinux nor apparmor currently will do well with automatic namespacing
of policy (though it's coming in apparmor, after which we can re-enable
this).

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-26 10:44:40 +01:00
Serge Hallyn
fdcde5b653 Add new 'precise' release to ubuntu template
Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-26 10:44:40 +01:00
Kevin Cernekee
c75083d7f3 Add MIPS as a supported architecture
The issue is similar to what was fixed in commit e7eb632c for ARM:
the "configure" script errors out because it is unable to set
LINUX_SRCARCH.  Fix is to add MIPS to the list.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-26 00:49:48 +01:00
Jon Nordby
ce6ce9d662 fix-automake-1.13
## 0001-Replace-pkglib_PROGRAMS-with-pkglibexec_PROGRAMS.patch [diff]
From 95c566740bba899acc7792c11fcdb3f4d32dcfc9 Mon Sep 17 00:00:00 2001
From: Jon Nordby <jononor@gmail.com>
Date: Fri, 10 Feb 2012 11:38:35 +0100
Subject: [PATCH] Replace pkglib_PROGRAMS with pkglibexec_PROGRAMS

Without this change, autogen.sh fails with automake 1.11.3

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:26 +01:00
Christian Seiler
49ee6cdcbf Add man page for lxc-attach
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:14 +01:00
Christian Seiler
cb014488ee lxc-attach: Drop privileges when attaching to container unless requested otherwise
lxc-attach will now put the process that is attached to the container into
the correct cgroups corresponding to the container, set the correct
personality and drop the privileges.

The information is extracted from entries in /proc of the init process of
the container. Note that this relies on the (reasonable) assumption that the
init process does not in fact drop additional capabilities from its bounding
set.

Additionally, 2 command line options are added to lxc-attach: One to prevent
the capabilities from being dropped and the process from being put into the
cgroup (-e, --elevated-privileges) and a second one to explicitly state the
architecture which the process will see, (-a, --arch) which defaults to the
container's current architecture.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:14 +01:00
Christian Seiler
99d509541d Move lxc_attach from namespace.c to attach.c and rename it to lxc_attach_to_ns
Since lxc-attach helper functions now have an own source file, lxc_attach is
moved from namespace.c to attach.c and is renamed to lxc_attach_to_ns,
because that better reflects what the function does (attaching to a
container can also contain the setting of the process's personality, adding
it to the corresponding cgroups and dropping specific capabilities).

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:14 +01:00
Christian Seiler
e073270504 Add attach.[ch]: Helper functions for lxc-attach
The following helper functions for lxc-attach are added to a new file
attach.c:
 - lxc_proc_get_context_info: Get cgroup memberships, personality and
   capability bounding set from /proc for a given process.
 - lxc_proc_free_context_info: Free the data structure responsible
 - lxc_attach_proc_to_cgroups: Add the process specified by the pid
   parameter to the cgroups given by the ctx parameter.
 - lxc_attach_drop_privs: Drop capabilities to the capability mask given in
   the ctx parameter.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:14 +01:00
Christian Seiler
525f000257 Add lxc_config_parse_arch to parse architecture strings
Add the function lxc_config_parse_arch that parses an architecture string
(x86, i686, x86_64, amd64) and returns the corresponding personality. This
is required for lxc-attach, which accepts architectures independently of
lxc.arch. The parsing of lxc.arch now also uses the same function to ensure
consistency.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:14 +01:00
Christian Seiler
28f2ae839d cgroup: Make cgroup_attach a public function
lxc-attach needs to be able to attach a process to specific cgroup, so
cgroup_attach is renamed to lxc_cgroup_attach and now also defined in the
header file.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:14 +01:00
Christian Seiler
3ea24eb8e6 Enable get_cgroup_mount to search for mount points satisfying multiple subsystems at once
lxc-attach functionality reads /proc/init_pid/cgroup to determine the cgroup
of the container for a given subsystem. However, since subsystems may be
mounted together, we want to be on the safe side and be sure that we really
find the correct mount point, so we allow get_cgroup_mount to check for
*all* the subsystems; the subsystem parameter may now be a comma-separated
list.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:13 +01:00
Christian Seiler
e16dad1063 Add missing double-include #ifndef/#define/#endif to confile.h
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:13 +01:00
Christian Seiler
d79579e874 Add missing 'extern' keyword to functions defined in cgroup.h
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:13 +01:00
Christian Seiler
d55bc1adad Accept numeric values for capabilities to drop
lxc.cap.drop now also accepts numeric values for capabilities. This allows
the user to specify capabilities LXC doesn't know about yet or capabilities
that were not part of the kernel headers LXC was compiled against.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:13 +01:00
Christian Seiler
5170c71633 Add CAP_SYSLOG and CAP_WAKE_ALARM to list of capabilities
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:13 +01:00
Christian Seiler
20d816599f Add function to determine CAP_LAST_CAP of the current kernel dynamically
The function lxc_caps_last_cap() determines CAP_LAST_CAP of the current kernel
dynamically. It first tries to read /proc/sys/kernel/cap_last_cap. If that
fails, because the kernel does not support this interface yet, it loops
through all capabilities and tries to determine whether the current capability
is part of the bounding set. The first capability for which prctl() fails is
considered to be CAP_LAST_CAP.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:13 +01:00
Jian Xiao
5781a74a8a correctly install signal handler for lxc-init
This patch is to correct the manipulation of signal masks when
installing signal handlers for lxc-init. 

Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Greg Kurz <gkurz@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:13 +01:00
Jian Xiao
307cf2a670 remove redundent LXC_TTY_HANDLER
All the signals (except fatal ones) are redirected to signalfd at lxc_init,
so the LXC_TTY_HANDLERs are redundant. This patch removes them.

Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:13 +01:00
andrea rota
aa198728a8 limit rm to rootfs, avoiding nuking of any bind mounts from
the host

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-01-05 23:35:26 +01:00
Greg Kurz
d73ef6ec75 lxc: add Bugs section to lxc-monitor(1)
This lxc-monitor limitation deserves some lines in the manpage, until
something is done to allow several monitors to run concurrently.

Signed-off-by: Greg Kurz <gkurz@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-01-05 23:34:46 +01:00
Greg Kurz
65b6a86da2 lxc: line buffered output for lxc-monitor
A typical usage is to start lxc-monitor in popen() and parse the ouput.
Unfortunately, glibc defaults to block buffering for pipes and you may
have to wait several lines before anything is written to stdout... this
prevent the use of lxc-monitor to implement automatons. Let's go line
buffered !

Signed-off-by: Greg Kurz <gkurz@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-01-05 23:34:46 +01:00
Serge Hallyn
15da01b393 ubuntu template: use -updates and -security (v3)
Particularly for LTS releases, which many people will want to use in
their containers, it is not wise to not use release-security and
release-updates.  Furthermore the fix allowing ssh to allow the container
to shut down is in lucid-updates only.

With this patch, after debootstrapping a container, we add -updates and
-security to sources.list and do an upgrade under chroot.  Unfortunately
we need to do this because debootstrap doesn't know how to.

Changelog:
	Nov 14: as Stéphane Graber suggested, make sure no daemons start on
		the host while doing dist-upgrade from chroot.
	Nov 15: use security.ubuntu.com, not mirror. (stgraber)

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-01-05 23:34:46 +01:00
Daniel Lezcano
92c64f7ed5 Fix ia64 clone
Fix the stack address for ia64.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-01-05 22:45:32 +01:00
Daniel Lezcano
d8f8e35202 Fix network cleanup on error
Network cleanup does not cleanup correctly the virtual interfaces
in case of an error.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-01-05 22:45:32 +01:00
Daniel Lezcano
f0e64b8b66 give explicit error when the cgroup are not found
When the cgroup is not mounted, we silently exit without giving
some clues to the user with what is happening.

Give some info and an explicit error.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-01-05 22:45:31 +01:00
Daniel Lezcano
7ad84da79b fix indentation of the previous patch
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-01-05 22:45:31 +01:00
Christian Seiler
49684c0b43 Set high byte of mac addresses for host veth devices to 0xfe
When used in conjunction with a bridge, veth devices with random addresses
may change the mac address of the bridge itself if the mac address of the
interface newly added is numerically lower than the previous mac address
of the bridge. This is documented kernel behavior. To avoid changing the
host's mac address back and forth when starting and/or stopping containers,
this patch ensures that the high byte of the mac address of the veth
interface visible from the host side is set to 0xfe.

A similar logic is also implemented in libvirt.

Fixes SF bug #3411497
See also: <http://thread.gmane.org/gmane.linux.kernel.containers.lxc.general/2709>

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
2012-01-05 22:45:31 +01:00
Daniel Lezcano
9c7c90377c Revert "lxc: use -iquote instead of -I"
This reverts commit a2dea4ea20.
2011-11-18 16:09:47 +01:00
Stéphane Graber
5ddd950537 Ubuntu template: some tweaks
Allow mknod (fixing udev upgrades) and drop mac_override and mac_admin 
from lxc.cap.drop as apparmor has/will have support for namespaces

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-11-10 09:45:52 +01:00
Greg Kurz
a2dea4ea20 lxc: use -iquote instead of -I
To avoid name collisions between local and system header
files. For example, if you try to include the <pty.h>
system file, you end up including the one from lxc...

Signed-off-by: Greg Kurz <gkurz@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-11-10 09:41:46 +01:00
Greg Kurz
f549edcc73 lxc: fix erroneous includes
The "" notation is preferrable if the header file is local.

Signed-off-by: Greg Kurz <gkurz@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-11-10 09:41:46 +01:00
Alexander Vladimirov
f6267d9011 add lxc-archlinux template
Hi, here's the patch which adds Arch linux container template

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-11-10 09:41:46 +01:00
Daniel Lezcano
93718f95af fix lxc-destroy
Add missing 'localstatedir' directory definition.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-11-10 09:41:46 +01:00
Tuomas Suutari
7bd44bf6f6 lxc-fedora.in: Fix fetching of the fedora-release rpm
The hardcoded URL seems to be broken and 404 error was not
checked. Now the mirror is selected from mirrorlist (instead of
hardcoding to funet.fi) and fetch errors are checked.

Also added a retry loop (with 3 tries) to find a working mirror, since
some of the mirrors are not OK.

Signed-off-by: Tuomas Suutari <tuomas.suutari@gmail.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-10-28 23:55:38 +02:00
Tuomas Suutari
7d303dea7d lxc-fedora.in: Use i386 instead of i686
There is no i686 variant of Fedora, but Ubuntu seems to return i686
from the arch command.

Signed-off-by: Tuomas Suutari <tuomas.suutari@gmail.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-10-28 23:55:38 +02:00
Tuomas Suutari
de6a471a1c lxc-fedora.in: Add missing default release variable
The text says that 14 is default, but release=14 was not set anywhere
in the script.

Signed-off-by: Tuomas Suutari <tuomas.suutari@gmail.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-10-28 23:55:38 +02:00
Frederic Crozat
44ee8a102e templates: update openSUSE template for openSUSE 12.1
rely on "build" package, to ensure chroot can be created with
distribution older than 12.1

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-10-28 23:55:38 +02:00
Serge E. Hallyn
5fe95ad112 Drop resolvconf from oneiric container package list
It prevents containers from getting a good resolv.conf without doing
ifdown eth0; ifup eth0.

(see pad.lv/880020)

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-10-25 00:02:33 +02:00
Cedric Le Goater
e788178af4 extend the struct lxc_arguments
This patch adds a private argument to extend the struct
lxc_arguments. This is useful to develop custom lxc commands
outside mainline lxc.

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-10-24 14:56:30 +02:00
Greg Kurz
0ae4f887a4 lxc: introduce lxc_execute()
This patch allows to create application containers with liblxc.so directly.

Some code cleanups on the way:
- separate ops for lxc_execute() and lxc_start(): the factorisation is wrong
  here as we may have specific things to do if we're running an application
  container. It deserves separate ops.
- lxc_arguments_dup() is merged in the pre-exec operation: this is a first
  use for the execute op introduced just above. It's better to build the
  arguments to execvp() where they're really used.

Signed-off-by: Greg Kurz <gkurz@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Cc: Cedric Le Goater <clg@fr.ibm.com>
2011-10-24 14:56:30 +02:00
Frederic Crozat
e4c0cf9212 handle kernel 3.x in lxc-checkconfig
Make sure to correctly detect kernel 3.x for file capabilities.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-10-24 14:55:13 +02:00
Alexey Shabalin
b031f0d2ca alt linux template
Updates.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
--
2011-10-24 14:55:13 +02:00
Serge E. Hallyn
8565ea1c6f lxc-ubuntu: stop early if a bad user is specified in -b option
Otherwise we end up with a bad container fstab and a container
that won't boot.  See
https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/879052

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-10-24 14:47:58 +02:00
Rainer Weikusat
bc71b5c54f Don't list containers w/ active console sessions multiple times
The lxc-ls shell script uses netstat -xa to get a listing of AF_UNIX
sockets it then parses in order to determine the names of presently
running containers. This is wrong because it will list the
listening socket and all sockets created by accepting connections on
that. This causes the script to display the names of containers with
active lxc-console sessions 1 + n times, n being the number of active
console sessions. The patch below fixes this by using netstat -xl
instead which only displays the listening sockets.

Signed-off-by: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-10-24 14:47:58 +02:00
Serge E. Hallyn
b145c6ef5e ubuntu template: allow containers to create tap devices
Thought I had sent this before, but I don't find it anywhere.

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-10-24 14:38:30 +02:00
Serge E. Hallyn
3e2981d459 Accurately detect whether a system supports clone_children
If multiple cgroups are mounted under /sys/fs/cgroup, then the
original check ends up looking for /sys/fs/cgroup/cgroup.clone_children,
which does not exist because that is just a tmpfs.

So make sure to check an actual cgroupfs.

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-10-24 14:38:30 +02:00
Serge E. Hallyn
b91b1cd79c Let sshd template work on ubuntu systems.
/dev/shm is a symlink to /run/shm, so we need /run/shm
to exist in the container rootfs.  Also, /dev/mqueue does
not exist on the host, and can't be created by the container.
But we don't really need it so ignore that.

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-10-24 14:38:30 +02:00
Serge E. Hallyn
cdcee3c7ff ubuntu template: disallow cap_sys_module (by popular demand)
This isn't particularly reassuring, and will be moot with user
namespaces, but as people are asking for it, turn off sys_module.
While we're at it, turn off mac_admin and mac_override.

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-10-24 14:38:30 +02:00