Commit Graph

2861 Commits

Author SHA1 Message Date
Serge Hallyn
5135b555bb cppcheck: fix unchecked realloc in lxc_info.c
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-15 16:10:35 -05:00
Serge Hallyn
ccab6c6029 cgmanager: don't call nih_dbus_setup
it actually sets us up to run the nih_mainloop, but we will never run
that.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-11 11:07:02 -04:00
Dwight Engen
f6d5cecc19 lxc-oracle: use db_load from container
This makes it so that the host doesn't need to have an old, compat
version of db43_load installed by using the db_load from the just
installed container. Some newer distributions do not even have an old
enough compat-db4 package available.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-04-09 14:30:15 -05:00
Dwight Engen
30ecf66929 lxc-oracle: only create media repo when --baseurl is specified
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-04-09 14:30:08 -05:00
Dwight Engen
c937991e1f lxc-oracle: update to support OL7
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-04-09 10:34:33 -05:00
Dwight Engen
e120d0575b lxc-oracle: allow installing from arbitrary yum repo
With this change, you can install a container from a mounted .iso, or any
yum repo with the necessary packages. Unlike the --url option, the repo
does not need to be a mirror of public-yum, but the arch and release must
be specified. For example to install OL6.5 from an .iso image:

mount -o loop OracleLinux-R6-U5-Server-x86_64-dvd.iso /mnt
lxc-create -n OL6.5 -t oracle -- --baseurl=file:///mnt -a x86_64 -R 6.5

The template will create two yum .repo files within the container such that
additional packages can be installed from local media, or the container can
be updated from public-yum, whichever is available. Local media must be bind
mounted from the host onto the containers' /mnt for the former .repo to work:

mount --bind /mnt $LXCPATH/OL6.5/rootfs/mnt

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-04-09 10:34:32 -05:00
Stéphane Graber
c2997f9e6b Fix typo in previous commit
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-08 17:23:31 -04:00
Stéphane Graber
48356bbfdf
tests; Bump wait delay for shutdown to 120s
On very busy boards with slow IO, the shutdown process can take over 60s
as the disk is syncing.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-08 17:12:00 -04:00
Stéphane Graber
524505b971 apparmor: Use more generic allow rule for pivot
Recent fixes in the apparmor kernel code is now making at least the CI
environment and quite possibly some others fail due to an invalid path
in the pivot_root stanza.

So update both lines to allow a more generic pivot_root call for
anything in LXC's work directory.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-04-08 14:45:00 -04:00
KATOH Yasufumi
bb8eca54d6 doc: Update Japanese lxc-stop(1) to describe about exit value
Update for commit 13bc2fd237

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-08 10:13:57 -04:00
Serge Hallyn
6d35844184 cgmanager: cgm_get: len = 0 is a query for length only
The caller might (like lxc-test-startone does) pass in a valid
(or invalid) buffer and 0 length.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-07 17:19:19 -04:00
Serge Hallyn
13bc2fd237 lxc_*.c: don't exit with -1
In this patch I tried to stick with each file's coding style, however I
think we should probably change that.  Every main() should always not
return and only exit;  they should always return EXIT_SUCCESS or EXIT_FAILURE
with the only exceptions being cases where we are returning a child's
exit status (lxc_execute, lxc_attach, lxc_init).

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-07 17:19:14 -04:00
Ryan Mulligan
8dac6e74c4 archlinux: add debugging info for missing network link
Signed-off-by: Ryan Mulligan <ryan@ryantm.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-07 17:05:35 -04:00
Serge Hallyn
a7440c15c1 lxc_start: return 1 not -1 on error
So that exit status doesn't show up as 255.

Reported-by: Andrey Khozov <avkhozov@googlemail.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-07 10:21:49 -05:00
Serge Hallyn
2f2623ec2b lxc_spawn: initialize netpipe
When rebooting an unprivileged container, netpipe starts out
as not -1.  If count_veths somehow changed this could lead
to trying to send data over nonexistent pipe.  (Ok can't
*really* happen, as it currently stands, but it's an open
end)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-04-04 21:26:16 -05:00
Leonid Isaev
21ca73b980 archlinux: Code cleanups (v2)
Cleanups:
1. Do not modify container's /etc/hosts (archlinux uses /etc/nsswitch.conf)
2. Remove duplicate lines from config
3. Print a nicer final message
4. Get rid of some grep's

Signed-off-by: Leonid Isaev <lisaev@umail.iu.edu>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-04 19:29:58 -04:00
Stéphane Graber
6ee795d2e3 Revert "archlinux: Code cleanups"
This reverts commit 34fd08f87b.
2014-04-04 19:27:18 -04:00
Leonid Isaev
34fd08f87b archlinux: Code cleanups
Cleanups:
1. Do not modify container's /etc/hosts (archlinux uses /etc/nsswitch.conf)
2. Remove duplicate lines from config
3. Print a nicer final message
4. Get rid of some grep's in favor of bash regex

Signed-off-by: Leonid Isaev <lisaev@umail.iu.edu>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-04 19:04:34 -04:00
Leonid Isaev
44b036309b archlinux: Create per-container pacman host key
Do not copy the pacman master key from the host, as this opens it to
attacks; generate a new secret hostkey.

Signed-off-by: Leonid Isaev <lisaev@umail.iu.edu>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-04 19:04:30 -04:00
Leonid Isaev
b7b7d3884e archlinux: Fix default package selection
Do not cherry-pick packages for the default install to avoid dependency
issues. Instead, install the base group modulo blacklisted packages.

Signed-off-by: Leonid Isaev <lisaev@umail.iu.edu>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-04 19:04:23 -04:00
Robert Vogelgesang
6a7f2dcdb8 Move lxc-monitord.log out of /var/lib/lxc/
Place log file into LOGPATH instead of LXCPATH (but still use the
given lxcpath if the latter differs from LXCPATH).

Signed-off-by: Robert Vogelgesang <vogel@users.sourceforge.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-04 17:45:35 -04:00
Robert Vogelgesang
3d3bc9ed7b Fix wait_for_bridge() in sysvinit script
Fix parsing of /etc/lxc/default.conf, i. e. ignore comments, and don't
require whitespace left and right of the equal sign.

Make the early return actually work.

Signed-off-by: Robert Vogelgesang <vogel@users.sourceforge.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-04 17:45:35 -04:00
S.Çağlar Onur
bfd483d43a add init.lxc to .gitignore
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-04 17:45:35 -04:00
Stéphane Graber
2a31251cc5 apparmor: Update profiles for current upstream parser
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-04-04 17:45:35 -04:00
Dwight Engen
e2426f0bb0 fix lxc-info printing duplicate lines
When lxc-info's stdout is not line buffered (ie. "lxc-info -n foo |more")
the first three lines will be duplicated. This is because c->get_ips()
comes next and it forks and the child will exit() causing its fds to be
closed which flushes out its (fork duplicated) stdio buffers. The lines are
then duplicated when the parent actually gets around to flushing out its
stdio. This causes problems for programs (such as the lxc-webpanel) which
are popen()ing lxc-info.

The fix here isn't necessarily the right one, but does show what the
problem is. Seems like maybe we should fix this inside of get_ips(), for
other API callers as well.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-04-03 18:37:19 -05:00
Michael H. Warfield
e13923c711 Added lxc.arch to configuration files for CentOS and Fedora
Added lxc.arch to the resulting container configuration files
to support i686 on x86_64 cross arch containers.

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-04-02 18:07:45 -05:00
Dwight Engen
8bf1e61ea3 make monitor/monitord more resilient to unexpected termination
Reported-by: Florian Klink <flokli@flokli.de>
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-04-02 12:30:29 -05:00
Serge Hallyn
94a77f3fd8 apparmor: deny writes to most of /proc/sys (v2)
Allow writes to kernel.shm*, net.*, kernel/domainname and
kernel/hostname,

Also fix a bug in the lxc-generate-aa-rules.py script in a
path which wasn't being exercised before, which returned a
path element rather than its child.

Changelog (v2): remove trailing / from block path

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-02 09:54:54 -05:00
Guillaume ZITTA
84ad17ede0 enable sshd by default like other templates
Signed-off-by: Guillaume ZITTA <lxc@zitta.fr>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-02 10:53:13 -04:00
Guillaume ZITTA
3a74e9097a lxc-gentoo, fix lack of any generated locale
fix lack of any generated locale

Signed-off-by: Guillaume ZITTA <lxc@zitta.fr>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-02 10:50:59 -04:00
Stéphane Graber
cf0c72d3c5 tests: Try to make shutdowntest a bit more robust
This should help it run better on slow test environment like the LXC CI
armhf builder.
 - Wait longer for the container to start
 - Wait longer for the container to shutdown
 - On failure to shutdown, kill the container
 - Always destroy the container if it's around

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-04-02 10:42:50 -04:00
Guillaume ZITTA
982b59592e fix lxc-console not working by default
fix lxc-console not working by default

Signed-off-by: Guillaume ZITTA <lxc@zitta.fr>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-04-01 14:58:39 -05:00
Serge Hallyn
198b363fff apparmor: auto-generate the blacklist rules
This uses the generate-apparmor-rules.py script I sent out some time
ago to auto-generate apparmor rules based on a higher level set of
block/allow rules.

Add apparmor policy testcase to make sure that some of the paths we
expect to be denied (and allowed) write access to are in fact in
effect in the final policy.

With this policy, libvirt in a container is able to start its
default network, which previously it could not.

v2: address feedback from stgraber
	  put lxc-generate-aa-rules.py into EXTRA_DIST
	  add lxc-test-apparmor, container-base and container-rules to .gitignore
	  take lxc-test-apparmor out of EXTRA_DIST
	  make lxc-generate-aa-rules.py pep8-compliant
	  don't automatically generate apparmor rules
	  This is only bc we can't be guaranteed that python3 will be
	  available.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-01 13:49:43 -04:00
Serge Hallyn
dc8114afd7 apparmor: don't allow mounting cgroupfs by default
Leave the line to do it (commented out) as some users may not be
using cgmanager, and may in fact still need those mounts.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-04-01 13:49:39 -04:00
Stéphane Graber
e6ee584a15 download: Set a 30s timeout for wget request
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-04-01 09:54:37 -05:00
Stéphane Graber
198a3f10d2 tests: Also propagate the https proxy
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-04-01 09:54:35 -05:00
Stéphane Graber
8afb3e612e Use on_path to find init.lxc
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-03-31 19:56:16 -04:00
Dwight Engen
ba5783a56a lxc.spec: adjust for move of libexecdir/lxc-init to sbin/lxc.init
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-03-31 18:24:21 -05:00
Dwight Engen
7ceebfd12a add yum plugin to repatch rootfs on yum update
oracle-template: Split patching rootfs vs one time setup into separate
shell functions so the template can be run with --patch.

oracle-template: Update to install the yum plugin and itself (as lxc-patch)
into a container. The plugin just runs lxc-patch --patch <path> so it is
fairly generic, but in this case it is running a copy of the template inside
the container.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-03-29 10:37:48 -05:00
Bogdan Purcareata
261658e800 config_network_type: set macvlan default mode to private
If a default mode is not set, the container requires an explicit
mode specified in the config file, otherwise creating the
container fails.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-03-28 19:09:28 -05:00
Serge Hallyn
718e4f4842 move lxc-init to /sbin/init.lxc
Using the multiarch dir causes problems when running lxc-execute
on amd64 with an i386 container.  /sbin/lxc-init is a more confusing
name and will show up in 'lxc<tab>'.  /sbin/init.lxc should be quite
obvious as an init for lxc.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-03-27 14:23:55 -04:00
Florian Klink
cd698bdd40 check whether rootfs is shared before running pre-mount hooks
this expands c597baa8f9 and 2c6f3fc932.

Also move the block using detect_ramfs_rootfs() from setup_rootfs() to
lxc_setup()

Signed-off-by: Florian Klink <flokli@flokli.de>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-03-27 14:19:31 -04:00
Bogdan Purcareata
b343592b45 network.c: Add missing LXC_NET_NONE option + refactor
Add LXC_NET_NONE to known lxc_network_types, so parsing a config
file with lxc.network.type = none does not result in failure
(e.g. doc/examples/lxc-no-netns.conf). Options have also been
reordered to match the enum in conf.h.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-03-26 09:41:04 -05:00
Serge Hallyn
6168ff15aa commands: handle epipe
If we start a lxc_wait on a container while it is exiting, it is
possible that we open the command socket, then the command socket
monitor closes all its mainloop sockets and exit, then we send our
credentials. Then we get killed by SIGPIPE.

Handle that case, recognizing that if we get sigpipe then the
container is (now) stopped.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-03-25 18:38:39 -04:00
Stéphane Graber
70084daff6 userns: Update bind-mounted devices
This updates all configs to include the exact same set of 7 bind-mounted
devices:
 - console
 - full
 - null
 - random
 - tty
 - urandom
 - zero

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-03-24 18:29:36 -04:00
Stéphane Graber
3f09d6d887 lxc-ls: Optimize things a bit
Don't bother access information that the user didn't request.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-03-24 18:29:34 -04:00
Stéphane Graber
fe9baa4c87 lxc-ls: Fix memory reporting
This resolves the memory math when memsw is enabled and fixes reporting
of nested containers memory when using cgmanager.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-03-24 18:29:23 -04:00
Bogdan Purcareata
50dbb8209b lxc-busybox: follow symlinks when inspecting busybox binary
Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-03-24 14:19:27 -05:00
Michael H. Warfield
826cde7c21 Added root_password_expired password control tuning knob.
Added the environment variable "root_password_expired" to
control if the initial, temporary, root password is initially
set up as "expired".  If set to "yes" (default), the root password
is set as "expired" and the user must change it at first login.

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-03-22 20:58:08 -04:00
Michael H. Warfield
779b47fdca Support SIGPWR in Fedora and Centos containers.
Added code to catch SIGPWR for Upstart in Fedora and CentOS
containers as well as for Systemd in Fedora containers.

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-03-22 20:58:03 -04:00