Commit Graph

1795 Commits

Author SHA1 Message Date
Dwight Engen
7f95145833 fix building docs
Commit 69fe23ff added checking for the older docbook2man back into
configure, but this breaks building the docs on at least Oracle Linux and
Fedora when docbook2X is not installed as docbook2man will be found but the
docs don't actually build with that tool.

This change makes it so the docs can be built with either the older
docbook2man or the newer 2X tools by using configure to set the dtd
string to an appropriate value depending on use of docbook2man or
db2x_docbook2man.

Also fixed a small error in lxc-destroy.sgml.in that was noticed
by the old tools.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-04-30 08:19:37 -05:00
Serge Hallyn
33c2c3ec93 add zfs support to lxc-create and lxc-destroy
This is based on patch from Papp Tamas (thanks).  It also does some
reorganizing of lxc-create to commonize some of the backingstore handling.

I played with it using:

	sudo lvcreate -L 100G -n zfs vg0
	sudo zpool create lxc /dev/vg0/zfs
	sudo lxc-create -B zfs --zfsroot lxc -t ubuntu -n dir2

or you could

	qemu-img create zfs.img 100G
	sudo qemu-nbd -c /dev/nbd0 zfs.img
	sudo zpool create lxc /dev/nbd0
	sudo lxc-create -B zfs --zfsroot lxc -t ubuntu -n dir2

I'll write the bdev.c handler and hook up lxc-clone next.

This also fixses a bug in the sed expression to extract the rootfs from
container config, which prepended an extra '/' to the rootdev.  (That
caused the zfs list entry not to match at destroy)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Cc: Papp Tamas <tompos@martos.bme.hu>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-04-26 10:00:15 +02:00
Dwight Engen
f485f377a1 lxc_wait should start monitord
If lxc_wait is called before the container has started the socket will not
yet have been created and lxc_wait's connect to it will fail. Starting the
daemon will create the socket for lxc_wait to connect to.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-26 09:54:29 +02:00
Christian Seiler
4f43438c47
lxc_attach: Use clone() instead of second fork()
Because of an assertion in glibc's fork() wrapper that parent pid and
pid of child should never be the same, one should avoid fork() after
attaching to a PID namespace, since the pid inside the namespace may
coincide with the pid of the parent outside the namespace, thus hitting
the aforementioned assertion.

This patch just changes the code in the most simple manner to use
clone() instead of fork(). Since clone() requires a function to be
called instead of returning 0, we move the code of the child into a
function child_main.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-25 18:17:53 +02:00
Stéphane Graber
6320e49454
lxc.conf: Add reference to capabilities manpage
This adds a reference to capabilities(7) to the lxc.conf manpage.

Signed-off-by: Tomáš Pospíšek <tpo_deb@sourcepole.ch>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-04-25 17:31:34 +02:00
Peter Simons
69fe23ff07
configure: support for the "docbook2man" utility to build the documentation
This adds docbook2man as an alternative name for the docbook compiler.
As that name was used on Debian based systems for an older version of the tool,
this change also adds a check so that docbook2man is never used on Debian based
systems.

Reported-by: Peter Simons <simons@cryp.to>
Reported-by: Christian Bühler christian@cbuehler.de
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-25 15:29:51 +02:00
Serge Hallyn
f05699d19e Revert "monitor.c: sanity check on waitpid return value"
It's reported to errors in parallel starts.

Reported-by: "S.Çağlar Onur" <caglar@10ur.org>

This reverts commit 6b79166952.
2013-04-24 22:47:50 -05:00
Serge Hallyn
6b79166952 monitor.c: sanity check on waitpid return value
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-04-24 19:59:10 -05:00
Serge Hallyn
e8b9ac8fdf close fd on error path
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-04-24 19:49:59 -05:00
Serge Hallyn
4fa22bfca1
lxc-create: cleanup whenever exiting with error
Otherwise we leave bad containers sitting around and further confuse
things on retries.

Reported-by: Mukanyiligira Didacienne <siyana223@gmail.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-04-25 01:54:39 +02:00
Dwight Engen
e51d489512
Allow multiple monitor clients
This fixes a long standing issue that there could only be a single
lxc-monitor per container.

With this change, a new lxc-monitord daemon is spawned the first time
lxc-monitor is called against the container and will accept connections
from any subsequent lxc-monitor.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-25 01:38:26 +02:00
Stéphane Graber
dc7f65454e
ubuntu: Don't break when the locale is C.*
Update the code to also match C.* so that C.UTF-8 doesn't make the
container creation fail.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-25 01:31:11 +02:00
S.Çağlar Onur
0a9362f574
Support starting containers concurrently
Trying to start multiple containers concurrently may cause
lxc_monitor_read_timeout to fail as select call could be
interrupted by a signal, handle it.

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-04-25 01:30:42 +02:00
Stéphane Graber
15451ecf74
python: Make the code compatibly with 3.2
The previous change used some 3.3-specific functions.
We still support 3.2 so revert to 3.2-compatible calls.

Reported-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-24 18:47:42 +02:00
Stéphane Graber
6516ad8b01
python: Fix convert_tuple_to_char_pointer_array
This finally fixes a few issues with the magic
convert_tuple_to_char_pointer_array function.

This now clearly copies the char* from the python object so we don't
end up keeping reference to those.

Also add the few required free calls to free the content of the array.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-24 15:08:32 +02:00
Stéphane Graber
93d564edc5
cgroup: Remove unused mntent variables
Spotted by coverity, we were now assigning mntent but only every using
mntent_r, so drop those variables and assignation.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-04-24 11:41:45 +02:00
S.Çağlar Onur
fd37327f57
Support stopping containers concurrently
Trying to stop multiple containers concurrently ends up with "cgroup is not mounted" errors as multiple threads corrupts the shared variables.
Fix that stack corruption and start to use getmntent_r to support stopping multiple containers concurrently.

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-24 01:01:08 +02:00
Serge Hallyn
cf0f903326
detect APT_PROXY from host apt.conf
Introduce a new HTTP_PROXY variable in /etc/default/lxc.  If unset or
set to none, then behavior continues as before.  If set to 'apt', then
any http::proxy set in apt.conf will be used as http_proxy for
debootstrap, and specified in the container's
/etc/apt/apt.conf.d/70proxy.  If set to something else, then the
value of HTTP_PROXY will be used as http_proxy for debootstrap and
specified in the container's 70proxy.

Changelog: (apr 23) merge the two apt proxy detection functions.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-04-24 00:57:18 +02:00
Dwight Engen
051151de89
goto correct cleanup label to ensure fd is closed
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-23 13:49:06 +02:00
Serge Hallyn
bbb8a488ae remove needless check for 'line' which cannot be NULl there
(found by coverity)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-04-22 15:46:26 -05:00
Serge Hallyn
7e1667d76e cgpath test: don't check path len before checking if it is null
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-04-22 15:40:57 -05:00
Dwight Engen
ddb17f1f08
make lxc_af_unix_open() safely return error on long pathnames
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-22 17:48:02 +02:00
Stéphane Graber
599d425251
python: Fix get_ips and nesting with lxcpath
When using -P (lxcpath), the parameter path needs to be forwarded
to the various commands being run but not used by the nested lxc-ls
as it's relatively unlikely that both the host and the nested containers
use a custom path.

This isn't ideal but short of having a way to provide the container path
for every single of the nesting (with potential unlimited depth), it's
the best we can do.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-22 09:00:43 +02:00
Stéphane Graber
a2abaa9ec6
ubuntu: Various fixes
- Drop disabled entries from allowed devices list
 - Improve generated config layout a bit
 - Drop redundant uname call
 - Re-generate the SSH host keys on container creation

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-22 08:59:53 +02:00
Christian Bühler
ed4616b1cf Use "uname -m" instead of "arch"
According to "arch"'s manpage, it's identical to "uname -m".

Some distros ship uname but don't ship arch, however all distros ship uname,
therefore it makes sense to use "uname -m" whenever possible.

Signed-off-by: Christian Bühler <christian@cbuehler.de>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-04-21 20:23:40 +02:00
Stéphane Graber
6c5db2af1f python: Various fixes to the python scripts
This fixes a few issues uncovered by the recent C module fix.

In lxc-start-ephemeral, the hwaddr code wasn't actually working.
Replace by code that properly iterates through the network interfaces
and sets a new MAC address for each entry.

In the python overlay, catch the newly emitted KeyError when in
set_config_item (or setting any previously unset variable would fail).

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-18 22:37:10 +02:00
Stéphane Graber
2ebec36f27 python: Lots of fixes in C extension
Fixes a lot of issues found by a code review done by Barry Warsaw.

Those include:
 - Wrong signature for getters
 - Various memory leaks
 - Various optimizations
 - More consistent return values
 - Proper exception handling

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Reported-by: Barry Warsaw <barry@ubuntu.com>
Acked-by: Barry Warsaw <barry@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-18 21:52:54 +02:00
Richard Weinberger
860fc865b0 utils: reimplement/fix mkdir_p() (v2)
Reimplement mkdir_p() such that it:
 ...handles relativ paths correctly. (currently it crashes)
 ...does not rely on dirname().
 ...is not recursive.
 ...is shorter. ;-)

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-18 10:57:19 +02:00
Stéphane Graber
23154d5764 Revert "start: Detect early failure of the new child"
This reverts commit 5a5c35c3a0.

This commit was preventing startup of containers using lxc hooks and
shutdown of all other containers, requiring the use of a good old
kill -9 to get rid of lxc-start after a container shutdown.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-04-18 10:30:33 +02:00
Stéphane Graber
3763ee8591 Revert "utils: reimplement/fix mkdir_p()"
This reverts commit 8de4140644.

This commit was preventing container startup on my machine, making them
all fail with various "No such file or directory" errors.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-04-18 10:29:44 +02:00
Richard Weinberger
8de4140644 utils: reimplement/fix mkdir_p()
Reimplement mkdir_p() such that it:
 ...handles relativ paths correctly. (currently it crashes)
 ...does not rely on dirname().
 ...is not recursive.
 ...is shorter. ;-)

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-18 09:36:24 +02:00
Richard Weinberger
5a5c35c3a0 start: Detect early failure of the new child
If the process in the new namespace dies very early
we have currently no chance to detect this.
The parent process will just die due to SIGPIPE
if it write to the fd used for synchronisation and
nobody will notice the real cause of the problem.

Install a SIGCHLD handler to detect the death.
Later when the child does execve() to the init within
the new namespace the handler will be disabled automatically.

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-17 18:20:37 +02:00
Richard Weinberger
6b28a08631 init: Fix whitespace damage
While we are here, fix the whitespace damage.

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-17 18:20:34 +02:00
Richard Weinberger
a81bad13ec init: unnest interrupt_handler
There is no need to use nested functions voodoo.

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-17 18:20:31 +02:00
Dwight Engen
2c7d90ac6e quiet gcc 4.4.7 warning about saveptr use before initialization
The recent change to use strtok_r causes a build warning with this older
gcc version, so initialize saveptr to NULL to quiet the compiler and
unbreak the build. There was no warning with gcc 4.7.2 that I
originally tested with.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-04-16 18:16:11 +02:00
Serge Hallyn
98663823e4 fix spacing
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-04-16 07:41:17 -05:00
Serge Hallyn
883f4a1eae mkdir_p: account for '//foo/bar'
As Richard reported, dirname('//') returns //.  But mkdir_p only stops
when called with '/', resulting in infinite recursion when given a
pathname '//foo/bar'.

Reported-by: richard -rw- weinberger <richard.weinberger@gmail.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-04-16 07:40:57 -05:00
Bogdan Purcareata
ce4c4ca435 lxc-template: enable chroot + chpasswd functionality for Busybox hosts
This patch supports the scenario where a user wants to install a
busybox container on a busybox host.

When running the template, in order to change the root password,
the template needs to do the chroot. On busybox-powered hosts, chroot
is not part of the coreutils package - it's part of busybox. And the
busybox implementation or chroot only works if it has /lib in the new
root populated with the right binaries (or at least that's the
solution I found to make it work).

The temporarily bind-mounts /lib in the NEWROOT, chroots there,
changes the password, goes back and unmounts. This set of operations
is contained in a new MOUNT namespace, using the lxc-unshare call.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-16 12:21:25 +02:00
Dwight Engen
8e7da691af fix checking hook script exit code
pclose returns the exit status from wait, we need to check that to see if
the script itself failed or not. Tested a script that returned 0, 1, and
also one that did a sleep and then was killed by a signal.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-16 12:16:53 +02:00
Dwight Engen
2796cf790f fortify: use reentrant safe strtok_r
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-16 12:16:41 +02:00
Dwight Engen
e6a19d2683 fortify: minor cleanups for unused variables, stricter types
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-16 12:15:56 +02:00
Dwight Engen
0a2188544a fortify: check the value returned from write(2)
Also check that we wrote the amount we expected to. The write on the pty
is blocking but we could still get a short write on EINTR, so we should
SYSERROR it.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-16 12:15:29 +02:00
Dwight Engen
03027ad99f fix lxc-attach usage
This makes it match the manpage and be consistent with lxc-execute

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-16 12:12:23 +02:00
Serge Hallyn
4d44e274dc fix coverity-found errors.
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-04-14 22:57:46 -05:00
Serge Hallyn
00b6be440f coverity resource leak fixes
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-04-14 22:44:09 -05:00
Serge Hallyn
5371906219 fix coverity-found resource leaks on error paths.
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-04-14 22:22:10 -05:00
Serge Hallyn
2802732032 fix coverity-found resource leaks in config_network_ipv6
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-04-14 22:16:26 -05:00
Serge Hallyn
bb1d227404 fix free of alloca()d buffer (found by coverity)
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-04-14 22:02:03 -05:00
Serge Hallyn
022de5f317 fix resource leak of netdev on error path found by coverity
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-04-14 21:59:20 -05:00
Serge Hallyn
b6f24d54f5 fix resource leak of utsname in error path found by coverity
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-04-14 21:56:51 -05:00