]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
11 years agolxc-ubuntu-cloud: pass --numeric-owner and -p to untar
Scott Moser [Tue, 8 Oct 2013 00:41:23 +0000 (20:41 -0400)] 
lxc-ubuntu-cloud: pass --numeric-owner and -p to untar

Just following up here, Serge raised the question of whether or not the
other two invocations of 'tar' in this script need '--numeric-owner'.
They probably should have it, although its of little concern because the
'build_root_tgz' path is only taken if there is no '-root.tar.gz' file for
download, and the only supported ubuntu release without the -root.tar.gz
download is 10.04 at this point.

Anyway, below is a more complete diff, also including a fix as
'--numeric-uid' is not a valid option to tar.  The name is
'--numeric-owner'.

Signed-off-by: Scott Moser <smoser@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agocoverity: free dent_buf on error path (cgroup.c)
Serge Hallyn [Mon, 7 Oct 2013 19:10:29 +0000 (14:10 -0500)] 
coverity: free dent_buf on error path (cgroup.c)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agofree cgroup_tasks_fn after use
Serge Hallyn [Mon, 7 Oct 2013 19:07:43 +0000 (14:07 -0500)] 
free cgroup_tasks_fn after use

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agocoverity: closedir on error path
Serge Hallyn [Mon, 7 Oct 2013 19:03:20 +0000 (14:03 -0500)] 
coverity: closedir on error path

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoalways include the ja manpage sources in make dist
Dwight Engen [Fri, 4 Oct 2013 17:45:59 +0000 (13:45 -0400)] 
always include the ja manpage sources in make dist

These need to be in the dist tarball even if the host packaging system
doesn't have docbook2x, otherwise configure will fail to find them. Also,
the build system may have docbook2x, even if the packaging system does not.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agofix errors when using docbook2man
Dwight Engen [Fri, 4 Oct 2013 17:46:05 +0000 (13:46 -0400)] 
fix errors when using docbook2man

docbook2man picks up some errors that docbook2x does not, fixing them
isn't harmful to docbook2x. The only real change is adding <para> and
<citerefentry> tags.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agooracle template: add openssh-clients to enable scp in/out of container
Dwight Engen [Fri, 4 Oct 2013 17:45:53 +0000 (13:45 -0400)] 
oracle template: add openssh-clients to enable scp in/out of container

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agotemplates/lxc-fedora Network startup w/o Network Manager
Michael H. Warfield [Fri, 4 Oct 2013 17:39:05 +0000 (13:39 -0400)] 
templates/lxc-fedora Network startup w/o Network Manager

This patches the Fedora template to insure that the legacy network
startup scripts are enabled when NetworkManager has not been installed
in the container (default).

It also fixes a login problem with pam_loginuid.so in a container.
https://bugzilla.redhat.com/show_bug.cgi?id=966807

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
--
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agotrivial: remove trailing whitespce from lxc-fedora
Serge Hallyn [Fri, 4 Oct 2013 19:54:54 +0000 (14:54 -0500)] 
trivial: remove trailing whitespce from lxc-fedora

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-fedora: remove 4:0 and 4:1 from devices whitelist
Serge Hallyn [Fri, 4 Oct 2013 15:53:21 +0000 (10:53 -0500)] 
lxc-fedora: remove 4:0 and 4:1 from devices whitelist

They are the real /dev/tty{0,1}, which are physical consoles.  Lxc
bind-mounts over them.  Don't let the container use these!

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agocall lxc_container_put when appropriate
S.Çağlar Onur [Fri, 4 Oct 2013 03:54:50 +0000 (23:54 -0400)] 
call lxc_container_put when appropriate

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-ubuntu: Remove trim option
Stéphane Graber [Fri, 4 Oct 2013 02:41:59 +0000 (22:41 -0400)] 
lxc-ubuntu: Remove trim option

Container trimming is a bad idea in general, Ubuntu since 12.04 allows
standard systems to run in containers and we've got separate code to
deal with 10.04, so let's just drop trim.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agotemplates/lxc-fedora Rework for distro independence.
Michael H. Warfield [Wed, 2 Oct 2013 20:22:45 +0000 (16:22 -0400)] 
templates/lxc-fedora Rework for distro independence.

This patch reworks the Fedora template to operate in the most "distro
agnostic" manner possible.  It should even run on distros where rpm and
yum are not present and not available or may be incompatible.  It
depends on the most basic set of system facilities like rsync but does
require squashfs support also be available to mount a LiveOS runtime.

Based on comments at Linux Plumbers, what I had been referring to as a
"run time environment" or RTE has been renamed in the code to refer to
it as a "bootstrap".  It has been tested on Fedora (of course),
OpenSuse, Ubuntu, and Oracle (latest host versions of each) building
Fedora containers of F19 back through F9.  Varying levels of database
problems were encountered from F11 and back and are "will not fix" due
to versions being long EOL.  F15 and F16 build but do not run "out of
the box" due to systemd version issues and those are also "will not fix"
for the same reasons.

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoadd basic lxc-test-ubuntu (v3)
Serge Hallyn [Thu, 3 Oct 2013 03:30:31 +0000 (22:30 -0500)] 
add basic lxc-test-ubuntu (v3)

Some features of lxc - networking and LSM configuration for instance -
are generally configured by the distro packages.  This program
tests the Ubuntu configuration.

changelog v2:
  Switch to lxc-info -i to detect ip address as stgraber suggested
  Don't look for 'expect' as I'm not using it yet.
changelog v3:
  Make sure to only read one ip address from container.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoconfile.c: cast size_t to prevent compile failure on 386
Serge Hallyn [Thu, 3 Oct 2013 17:10:07 +0000 (12:10 -0500)] 
confile.c: cast size_t to prevent compile failure on 386

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoImprove behaviour for unprivileged users
Stéphane Graber [Wed, 2 Oct 2013 22:25:37 +0000 (18:25 -0400)] 
Improve behaviour for unprivileged users

This mostly changes two things:
 - Only log to the container's logfile on start/stop/restart/execute
 - Call may_control() every time we use the API and return
   "Insufficient privileges" on failure.

NOTE: I didn't test every single one of those but I'm fairly confident
      in my copy/paste abilities and I confirmed they all build fine at least.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoadd new tests to .gitignore
Serge Hallyn [Wed, 2 Oct 2013 04:15:36 +0000 (23:15 -0500)] 
add new tests to .gitignore

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoadd reboot test
Serge Hallyn [Wed, 2 Oct 2013 04:15:01 +0000 (23:15 -0500)] 
add reboot test

It's really more of a kernel check, but worth having.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-checkconfig: suggest modprobe configs
Stéphane Graber [Wed, 2 Oct 2013 21:22:52 +0000 (17:22 -0400)] 
lxc-checkconfig: suggest modprobe configs

 give hint to user to modprobe configs (altho could just modprobe it?)

Signed-off-by: Elan Ruusamäe <glen@delfi.ee>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoCheck return value of ifa_get_local_ip
Stéphane Graber [Wed, 2 Oct 2013 21:18:48 +0000 (17:18 -0400)] 
Check return value of ifa_get_local_ip

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-fedora: Show usage when no name is passed
Stéphane Graber [Wed, 2 Oct 2013 17:11:24 +0000 (13:11 -0400)] 
lxc-fedora: Show usage when no name is passed

Reported-by: Anatoly Techtonik
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc_init: Use sig_atomic_t for was_interrupted
Stéphane Graber [Wed, 2 Oct 2013 16:32:52 +0000 (12:32 -0400)] 
lxc_init: Use sig_atomic_t for was_interrupted

Suggested-by: Markus Elfring
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoAvoid ldconfig due to cross-compilation problems.
Andrey Mazo [Fri, 18 May 2012 17:11:22 +0000 (21:11 +0400)] 
Avoid ldconfig due to cross-compilation problems.

Otherwise, it cases problems on cbuild endianness != ctarget endianness
setups because /sbin/ldconfig expects elf header in the wrong endianness.

Signed-off-by: Andrey Mazo <ahippo@yandex.ru>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agofix lxc-info segv on stopped container
Dwight Engen [Wed, 2 Oct 2013 16:14:58 +0000 (12:14 -0400)] 
fix lxc-info segv on stopped container

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agofedora: Use consistent tab/space indent
Stéphane Graber [Wed, 2 Oct 2013 15:47:12 +0000 (11:47 -0400)] 
fedora: Use consistent tab/space indent

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoUpdate lxc-fedora.in
Renich Bon Ciric [Wed, 25 Sep 2013 03:45:17 +0000 (22:45 -0500)] 
Update lxc-fedora.in

Fedora 19's release has no -1 revision; it's a -2 revision actually:
ftp://mirrors.kernel.org/fedora/releases/19/Fedora/x86_64/os/Packages/f/

Signed-off-by: Renich Bon Ciric <renich@woralelandia.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agodoc: Fix some typos
KATOH Yasufumi [Tue, 1 Oct 2013 04:19:43 +0000 (13:19 +0900)] 
doc: Fix some typos

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agodoc: Remove unnecessary Diagnostic entry in lxc-stop(1)
KATOH Yasufumi [Tue, 1 Oct 2013 04:16:42 +0000 (13:16 +0900)] 
doc: Remove unnecessary Diagnostic entry in lxc-stop(1)

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agodoc: Update lxc-monitor(1) man page
KATOH Yasufumi [Wed, 2 Oct 2013 07:02:15 +0000 (16:02 +0900)] 
doc: Update lxc-monitor(1) man page

- Update to commit 'fbf050e4c211030eb343008583f76605dfaaef38'
- Improve translation

Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-monitor default name to .* to monitor all containers
Dwight Engen [Tue, 1 Oct 2013 15:25:46 +0000 (11:25 -0400)] 
lxc-monitor default name to .* to monitor all containers

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agogitignore doc/ja/legacy/*.1
Dwight Engen [Tue, 1 Oct 2013 14:04:18 +0000 (10:04 -0400)] 
gitignore doc/ja/legacy/*.1

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agodoc: Update Japanese lxc.conf(5) man page
KATOH Yasufumi [Mon, 30 Sep 2013 08:30:45 +0000 (17:30 +0900)] 
doc: Update Japanese lxc.conf(5) man page

Add description of automatic mounting options

11 years agodoc: Update Japanese lxc-info(1) man page
KATOH Yasufumi [Mon, 30 Sep 2013 08:29:24 +0000 (17:29 +0900)] 
doc: Update Japanese lxc-info(1) man page

Add description of '-i' option

11 years agodoc: Update Japanese man pages translation
KATOH Yasufumi [Fri, 27 Sep 2013 07:09:57 +0000 (16:09 +0900)] 
doc: Update Japanese man pages translation

* sync current English man pages on master branch
* delete lxc-shutdown.sgml.in
* add lxc-snapshot.sgml.in
* update FSF address (same as 250b1eec71b074acdff1c5f6b5a1f0d7d2c20b77)
* remove trailing whitespaces in legacy/lxc-ls.sgml.in (same as 8900b9eb2514c07047541833286428572493a9fd)

11 years agorefactor string conf items into common function
Dwight Engen [Mon, 30 Sep 2013 15:17:06 +0000 (11:17 -0400)] 
refactor string conf items into common function

- When doing the selinux change, I noticed that there was a lot of
  duplication of code in handing string configuration items, so I
  refactored this into a common function.

- Added a config_string_max that can be passed a maximum acceptable
  length, used to limit ttydir to NAME_MAX.

- The behavior of config_seccomp was different than other strings: if the
  item was already defined, then the second attempt to set it would fail
  instead of just replacing the value. Changed to just replace the value.

- Remove unused key and lxc_conf arguments to config_path_item().

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoRFC: lxclock: drop the chown+chmod of lockdir
Serge Hallyn [Mon, 30 Sep 2013 21:23:34 +0000 (16:23 -0500)] 
RFC: lxclock: drop the chown+chmod of lockdir

The original rationale for this was to make sure that if
lxcpath was /home/serge/lxcbase, then then lockdir
(/run/user/serge/lock/lxc/home/serge/lxcbase) would be
owned by the same user as /home/serge/lxcbase.

The only user who can chown to other uids (without CAP_CHOWN
added to fP) is root, who shouldn't be mucking with non-root
owned containers anyway.  In the meantime this causes a bunch
of noise for arguably no benefit.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agotests/getkeys: return 0 on success
Serge Hallyn [Mon, 30 Sep 2013 20:52:49 +0000 (15:52 -0500)] 
tests/getkeys: return 0 on success

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoadd c->may_control
Serge Hallyn [Sat, 28 Sep 2013 02:01:07 +0000 (21:01 -0500)] 
add c->may_control

This is an api function which will return false if the container
is running, and the caller may not talk to its monitor over its
command socket.  Otherwise - if the container is not running, or
the caller may access it - it returns true.

We can use this in several tools early on to prevent the segvs
etc which we currently get.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoFix crasher in get_ips
Stéphane Graber [Sun, 29 Sep 2013 23:41:52 +0000 (19:41 -0400)] 
Fix crasher in get_ips

Check that the interface structure is not NULL before trying to access
its members.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoFix typo
Stéphane Graber [Fri, 27 Sep 2013 20:00:40 +0000 (16:00 -0400)] 
Fix typo

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agovalgrind: fix small leak in cgroup
Dwight Engen [Fri, 27 Sep 2013 16:14:05 +0000 (12:14 -0400)] 
valgrind: fix small leak in cgroup

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoAutomatic mounting: document options in lxc.conf(5) manpage
Christian Seiler [Tue, 24 Sep 2013 20:45:09 +0000 (22:45 +0200)] 
Automatic mounting: document options in lxc.conf(5) manpage

Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoAutomatic mounting: add more ways to mount the cgroup filesystem
Christian Seiler [Tue, 24 Sep 2013 20:45:08 +0000 (22:45 +0200)] 
Automatic mounting: add more ways to mount the cgroup filesystem

This adds quite a few more ways to mount the cgroup filesystem
automatically:

 - Specify ro/rw/mixed:
       - ro: everything mounted read-only
       - rw: everything mounted read-write
       - mixed: only container's own cgroup is rw, rest ro
                (default)
 - Add cgroup-full that mounts the entire cgroup tree to the
   corresponding directories. ro/rw/mixed also apply here.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoAutomatic mounting: write lxc.mount.auto in write_config
Christian Seiler [Tue, 24 Sep 2013 20:45:07 +0000 (22:45 +0200)] 
Automatic mounting: write lxc.mount.auto in write_config

Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoAutomatic mounts: improvements for /proc and /sys
Christian Seiler [Tue, 24 Sep 2013 20:45:06 +0000 (22:45 +0200)] 
Automatic mounts: improvements for /proc and /sys

Improve lxc.mount.auto code: allow the user to specify whether to mount
certain things read-only or read-write. Also make the code much more
easily extensible for the future.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-info: Allow printing IP addresses
Stéphane Graber [Fri, 27 Sep 2013 04:23:09 +0000 (00:23 -0400)] 
lxc-info: Allow printing IP addresses

This adds a new -i flag to lxc-info to print the container's IP
addresses using get_ips().

Example:
$ lxc-info -n lxc-dev -s -p -i
state:  RUNNING
pid:    21331
ip:     10.0.3.165
ip:     2607:f2c0:f00f:2751:e9ca:842f:efa9:97d1
ip:     2607:f2c0:f00f:2751:216:3eff:fe3a:f1c1

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-info: Port to LXC API
Stéphane Graber [Fri, 27 Sep 2013 04:07:23 +0000 (00:07 -0400)] 
lxc-info: Port to LXC API

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agodrop now-useless have_tpath bool
Serge Hallyn [Thu, 26 Sep 2013 13:14:50 +0000 (08:14 -0500)] 
drop now-useless have_tpath bool

(Which will also break failure-to-build in the !HAVE_LIBGNUTLS
case)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agofix segfault on lxc-create with bad template name
Dwight Engen [Wed, 25 Sep 2013 22:18:28 +0000 (18:18 -0400)] 
fix segfault on lxc-create with bad template name

- change get_template_path() to only return NULL or non-NULL since one of
  the callers was doing a free(-1) which caused the segfault. Handle the
  NULL template case in the lxcapi_create() caller.

- make sure to free(tpath) in the sha1sum_file() failure case

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agorefactor AppArmor into LSM backend, add SELinux support
Dwight Engen [Tue, 24 Sep 2013 15:13:02 +0000 (11:13 -0400)] 
refactor AppArmor into LSM backend, add SELinux support

Currently, a maximum of one LSM within LXC will be initialized and
used. If in the future stacked LSMs become a reality, we can support it
without changing the configuration syntax and add support for more than
a single LSM at a time to the lsm code.

Generic LXC code should note that lsm_process_label_set() will take
effect "now" for AppArmor, and upon exec() for SELinux.

- fix Oracle template mounting of proc and sysfs, needed when using SELinux

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agofree kernel_subsystems in success case
Serge Hallyn [Wed, 25 Sep 2013 20:23:49 +0000 (15:23 -0500)] 
free kernel_subsystems in success case

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoREALLY always free(line)
Serge Hallyn [Wed, 25 Sep 2013 20:05:52 +0000 (15:05 -0500)] 
REALLY always free(line)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agofix up a few snafu's in forward-port of last commit
Serge Hallyn [Wed, 25 Sep 2013 20:01:54 +0000 (15:01 -0500)] 
fix up a few snafu's in forward-port of last commit

Make sure to free line.

Don't free 'info' when freeing base_info will later free info.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agofix some larger memory leaks in cgroup code
Dwight Engen [Tue, 24 Sep 2013 23:46:44 +0000 (18:46 -0500)] 
fix some larger memory leaks in cgroup code

Don't worry about saved_errno since none of the *_free routines will set it

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agosplit up lxc_cgroup_load_meta2
Serge Hallyn [Tue, 24 Sep 2013 23:45:56 +0000 (18:45 -0500)] 
split up lxc_cgroup_load_meta2

This one's easier to review by looking at the before and after files.  It
splits up lxc_cgroup_load_meta2() by adding 3 helpers.

The result seems easier to reason about.  A question I had, is, should
the kernel_subsystems ** be freed in the success case?  I assumed it was
being used elsewhere but I can't find where.  Currently it is only being
freed in the error case.  I suspect we want to free it in the success
case as well.

Cc: Christian Seiler <christian@iwakd.de>
Cc: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agodoc: Japanese man pages is not generated when docbook-utils is used
KATOH Yasufumi [Wed, 25 Sep 2013 10:36:30 +0000 (19:36 +0900)] 
doc: Japanese man pages is not generated when docbook-utils is used

Character encoding of Japanese man pages is UTF-8. But docbook-utils
can't treat it (and don't have --encoding option that use in
Makefile). So change to Japanese man pages is not generated when
docbook-utils is used.

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoutils: move remove_trailing_slashes to utils
Qiang Huang [Tue, 24 Sep 2013 07:27:53 +0000 (15:27 +0800)] 
utils: move remove_trailing_slashes to utils

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoarguments: remove trailing slashes for the input lxcpath
Qiang Huang [Tue, 24 Sep 2013 07:27:55 +0000 (15:27 +0800)] 
arguments: remove trailing slashes for the input lxcpath

In lxc_cmd(), we use
snprintf(path, len, "%s/%s/command", lxcpath ? lxcpath : inpath, name);
to fill sock name, this assume lxcpath have no trailing slashes, so
if we use
lxc-info -n test -P /usr/local/var/lib/lxc_anon/
to get a running container's state, we will get state: STOPPED which
is wrong, because we combine a wrong sock name.

To fix this, just remove trailing slashes when parsing arguments.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agodoc: Fixed my first name
Stéphane Graber [Sat, 21 Sep 2013 22:43:48 +0000 (17:43 -0500)] 
doc: Fixed my first name

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agodoc: Make everything use the @docdtd@ variable
Stéphane Graber [Sat, 21 Sep 2013 22:43:47 +0000 (17:43 -0500)] 
doc: Make everything use the @docdtd@ variable

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoAdd some missing comments to configure.ac
Stéphane Graber [Sat, 21 Sep 2013 22:43:46 +0000 (17:43 -0500)] 
Add some missing comments to configure.ac

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoConsistently use <lxc/lxccontainer.h> for the API
Stéphane Graber [Sat, 21 Sep 2013 22:43:45 +0000 (17:43 -0500)] 
Consistently use <lxc/lxccontainer.h> for the API

The API header was included in a variety of ways before, standardize
those to "include <lxc/lxccontainer.h>" as this will always work both in
tree and on a system with the headers installed.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoWhen callback of one config line fail, we'd better give the exactly
Qiang Huang [Mon, 23 Sep 2013 16:23:27 +0000 (11:23 -0500)] 
When callback of one config line fail, we'd better give the exactly
info to help users locate the misconfig.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoreturn the result of the lxcapi_want_close_all_fds call to the caller
S.Çağlar Onur [Sat, 21 Sep 2013 17:00:15 +0000 (13:00 -0400)] 
return the result of the lxcapi_want_close_all_fds call to the caller

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoExpose underlying close_all_fds config value via API
S.Çağlar Onur [Fri, 20 Sep 2013 22:45:21 +0000 (18:45 -0400)] 
Expose underlying close_all_fds config value via API

Being able to set close_all_fds via API would be usefull for the
situations like running an application (let's say web server)
that controls the lifecycle of the container using the LXC API.
We don't want forked process to inherit parent's resource (file, socket, ...)

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agofix console deadlocks
Serge Hallyn [Fri, 20 Sep 2013 19:24:36 +0000 (21:24 +0200)] 
fix console deadlocks

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-create: add -P to --lxcpath option help text
Serge Hallyn [Wed, 18 Sep 2013 19:00:02 +0000 (14:00 -0500)] 
lxc-create: add -P to --lxcpath option help text

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoRemove trailing whitespaces
Stéphane Graber [Wed, 18 Sep 2013 19:40:20 +0000 (14:40 -0500)] 
Remove trailing whitespaces

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoAdd get_interfaces to the API
S.Çağlar Onur [Wed, 18 Sep 2013 19:13:22 +0000 (15:13 -0400)] 
Add get_interfaces to the API

get_ips accepts an interface name as a parameter but there was no
way to get the interfaces names from the container. This patch
introduces a new get_interfaces call to the API so that users
can obtain the name of the interfaces.

Support for python bindings also introduced as a part of this version.

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agomake heavier use of process_lock (v2)
Serge Hallyn [Mon, 16 Sep 2013 23:28:41 +0000 (18:28 -0500)] 
make heavier use of process_lock (v2)

pthread_mutex_lock() will only return an error if it was set to
PTHREAD_MUTEX_ERRORCHECK and we are recursively calling it (and
would otherwise have deadlocked).  If that's the case then log a
message for future debugging and exit.  Trying to "recover" is
nonsense at that point.

process_lock() was held over too long a time in lxcapi_start()
in the daemonize case.  (note the non-daemonized case still needs a
check to enforce that it must NOT be called while threaded).  Add
process_lock() at least across all open/close/socket() calls.

Anything done after a fork() doesn't need the locks as it is no
longer threaded - so some open/close/dups()s are not locked for
that reason.  However, some common functions are called from both
threaded and non-threaded contexts.  So after doing a fork(), do
a possibly-extraneous process_unlock() to make sure that, if we
were forked while pthread mutex was held, we aren't deadlocked by
nobody.

Tested that lp:~serge-hallyn/+junk/lxc-test still works with this
patch.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Tested-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoadd arguments with getopt to concurrent tester
Dwight Engen [Mon, 16 Sep 2013 20:17:54 +0000 (16:17 -0400)] 
add arguments with getopt to concurrent tester

- add ability to run for multiple iterations
- can also run non-threaded for comparison to threaded case

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years ago.gitignore generated Japanese manpages
Dwight Engen [Mon, 16 Sep 2013 20:25:38 +0000 (16:25 -0400)] 
.gitignore generated Japanese manpages

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoubuntu templates: make pstore fstab entry optional
Serge Hallyn [Mon, 16 Sep 2013 16:48:38 +0000 (11:48 -0500)] 
ubuntu templates: make pstore fstab entry optional

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agocgroup: add bdev.h to fix the build error
Qiang Huang [Sat, 14 Sep 2013 08:36:27 +0000 (16:36 +0800)] 
cgroup: add bdev.h to fix the build error

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoRevert "api_create and api_start: work toward making them thread-safe"
Serge Hallyn [Sat, 14 Sep 2013 18:09:53 +0000 (13:09 -0500)] 
Revert "api_create and api_start: work toward making them thread-safe"

This should deadlock with daemonized start due to af_unix changes.

Do this later, but do it more carefully.

This reverts commit 002f3cff4d83c0666cfda40599eded8e0d638c6c.

11 years agoapi_create and api_start: work toward making them thread-safe
Serge Hallyn [Sat, 14 Sep 2013 02:19:42 +0000 (21:19 -0500)] 
api_create and api_start: work toward making them thread-safe

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoconcurrent: take lxc template to use as argument
Serge Hallyn [Sat, 14 Sep 2013 17:54:46 +0000 (12:54 -0500)] 
concurrent: take lxc template to use as argument

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoadd pstore to container fstab
Serge Hallyn [Fri, 13 Sep 2013 20:43:56 +0000 (15:43 -0500)] 
add pstore to container fstab

Otherwise user-namespace containers will hang on mountall.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agouse busybox instead of ubuntu to test as it's much more lightweight, also wait contai...
S.Çağlar Onur [Fri, 13 Sep 2013 18:41:48 +0000 (14:41 -0400)] 
use busybox instead of ubuntu to test as it's much more lightweight, also wait containers to enter desired state

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agotests: Introduce lxc-test-concurrent for testing basic actions concurrently
S.Çağlar Onur [Thu, 12 Sep 2013 21:13:15 +0000 (17:13 -0400)] 
tests: Introduce lxc-test-concurrent for testing basic actions concurrently

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agosnapshots: add man page and fix up help info a bit.
Serge Hallyn [Thu, 12 Sep 2013 20:07:11 +0000 (15:07 -0500)] 
snapshots: add man page and fix up help info a bit.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoChange rootfs pinning mechnism
Christian Seiler [Thu, 12 Sep 2013 20:00:34 +0000 (22:00 +0200)] 
Change rootfs pinning mechnism

Chane pinning mechanism: Use $rootfs/lxc.hold instead of $rootfs.hold
(in case $rootfs is a mountpoint itself), but delete the file
immediately after creating it (but keep it open). This will keep the
root filesystem busy but does not leave any unnecessary files lying
around.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoSupport for automatic mounting of filesystems
Christian Seiler [Wed, 11 Sep 2013 23:44:44 +0000 (01:44 +0200)] 
Support for automatic mounting of filesystems

This patch adds the lxc.mount.auto configuration option that allows the
user to specify that certain standard filesystems should be
automatically pre-mounted when the container is started.

Currently, four things are implemented:

 - /proc          (mounted read-write)
 - /sys           (mounted read-only)
 - /sys/fs/cgroup (special logic, see mailing list discussions)
 - /proc/sysrq-trigger (see below)

/proc/sysrq-trigger may be used from within a container to trigger a
forced host reboot (echo b > /proc/sysrq-trigger) or do other things
that a container shouldn't be able to do. The logic here is to
bind-mount /dev/null over /proc/sysrq-trigger, so that that cannot
happen. This obviously only protects fully if CAP_SYS_ADMIN is not
available inside the container (otherwise that bind-mount could be
removed).

Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agocgroup: Add lxc_setup_mount_cgroup to setup /sys/fs/cgroup inside the container
Christian Seiler [Wed, 11 Sep 2013 23:44:43 +0000 (01:44 +0200)] 
cgroup: Add lxc_setup_mount_cgroup to setup /sys/fs/cgroup inside the container

Add funbction to mount cgroup filesystem hierarchy into the container,
allowing only access to the parts that the container should have access
to, but none else.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agocgroup: Split legacy 'ns' cgroup handling off from main cgroup handling
Christian Seiler [Wed, 11 Sep 2013 23:44:42 +0000 (01:44 +0200)] 
cgroup: Split legacy 'ns' cgroup handling off from main cgroup handling

This patch splits off ns legacy cgroup handling from main cgroup
handling. It moves the creation of the cgroups before clone(), so that
the child will easily know which cgroups it will later belong to. Since
this is not possible for the renaming of the 'ns' cgroup, keep that
part after clone.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoutils: Add lxc_append_paths to join two paths.
Christian Seiler [Wed, 11 Sep 2013 23:44:41 +0000 (01:44 +0200)] 
utils: Add lxc_append_paths to join two paths.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoUpdate .gitignore
S.Çağlar Onur [Thu, 12 Sep 2013 16:06:28 +0000 (12:06 -0400)] 
Update .gitignore

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoignore ability to init /lxc-monitord.log
Serge Hallyn [Thu, 12 Sep 2013 16:17:11 +0000 (11:17 -0500)] 
ignore ability to init /lxc-monitord.log

We may long-term want to instead decide on a convention under
/var/log, but for now just ignore it.  This will only happen
if lxcpath is read-only.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agohash lxcname for use in monitor unix socket sun_path[108]
Dwight Engen [Wed, 11 Sep 2013 22:16:15 +0000 (18:16 -0400)] 
hash lxcname for use in monitor unix socket sun_path[108]

- Also convert to unix abstract socket
- A simple FNV hash is used instead of SHA-1 since we may not HAVE_GNUTLS

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agocgroup: address some style+safety issues
Serge Hallyn [Wed, 11 Sep 2013 21:58:12 +0000 (16:58 -0500)] 
cgroup: address some style+safety issues

three issues raised by Christian Seiler: use pid_t, use snprintf,
and use const.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agomove monitor-fifo and monitor-sock to /run
Dwight Engen [Wed, 11 Sep 2013 15:44:19 +0000 (11:44 -0400)] 
move monitor-fifo and monitor-sock to /run

Moving these files should allow $lxcpath to be a read-only fs.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agocgroup: re-introduce ns cgroup support
Serge Hallyn [Wed, 11 Sep 2013 16:50:54 +0000 (11:50 -0500)] 
cgroup: re-introduce ns cgroup support

If a cgroup hierarchy has ns cgroup composed, then we need to treat
that differently:

1. The container init will have already been switched to a new cgroup
called after its pid.
2. We can't move the container init to new deeper cgroup directories.

So, if we detect an ns cgroup, don't bother trying to construct a new
name according to the pattern.  Just rename the current one to the
container name, and save that path for us to later enter and remove.

Note I'm not dealing with the subpaths so nested containers probably
won't work.  However as ns cgroup is very much legacy, that should be
ok.  Eventually we should be able to drop ns cgroup support altogether,
but not just yet.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoapparmor.c: drop newline when reading current profile
Serge Hallyn [Tue, 10 Sep 2013 22:23:22 +0000 (17:23 -0500)] 
apparmor.c: drop newline when reading current profile

Otherwise we fail to recognize if we are already unconfined.  Then,
if we want to *start* unconfined, and /proc is readonly, start fails
even though it should be able to proceed.

With this patch, that situation works.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Reported-by: Andre nathan <andre@digirati.com.br>
11 years agoFix some typos
Stéphane Graber [Wed, 11 Sep 2013 14:01:16 +0000 (10:01 -0400)] 
Fix some typos

Signed-off-by: KATOH Yasufumi karma@jazz.email.ne.jp
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agopin_rootfs: be quiet and don't fail container start
Serge Hallyn [Wed, 11 Sep 2013 04:17:46 +0000 (23:17 -0500)] 
pin_rootfs: be quiet and don't fail container start

It's a legitimate use case to use read-only $lxcpath.  If we can't
create the pin file, then we're not worried about marking the fs
readonly on exit.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc_cgroup_process_info_free_and_remove should recursively call itself
Serge Hallyn [Tue, 10 Sep 2013 19:33:40 +0000 (14:33 -0500)] 
lxc_cgroup_process_info_free_and_remove should recursively call itself

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agodon't use cgroup_path_components un-initialized
Serge Hallyn [Tue, 10 Sep 2013 19:33:00 +0000 (14:33 -0500)] 
don't use cgroup_path_components un-initialized

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agocgroup: Major rewrite of cgroup logic
Christian Seiler [Sun, 8 Sep 2013 18:50:03 +0000 (20:50 +0200)] 
cgroup: Major rewrite of cgroup logic

This patch rewrites most of the cgroup logic. It creates a set of data
structures to store the kernel state of the cgroup hierarchies and
their mountpoints.

Mainly, everything is now grouped with respect to the hierarchies of
the system. Multiple controllers may be mounted together or separately
to different hierarchies, the data structures reflect this.

Each hierarchy may have multiple mount points (that were created
previously using the bind mount method) and each of these mount points
may point to a different prefix inside the cgroup tree. The current
code does not make any assumptions regarding the mount points, it just
parses /proc/self/mountinfo to acquire the relevant information.

The only requirement is that the current cgroup of either init (if
cgroup.pattern starts with '/' and the tools are executed as root) or
the current process (otherwise) are accessible. The root cgroup need
not be accessible.

The configuration option cgroup.pattern is introduced. For
root-executed containers, it specifies which format the cgroups should
be in. Example values may include '/lxc/%n', 'lxc/%n', '%n' or
'/machine/%n.lxc'. Any occurrence of '%n' is replaced with the name of
the container (and if clashes occur in any hierarchy, -1, -2, etc. are
appended globally). If the pattern starts with /, new containers'
cgroups will be located relative to init's cgroup; if it doesn't, they
will be located relative to the current process's cgroup.

Some changes to the cgroup.h API have been done to make it more
consistent, both with respect to naming and with respect to the
parameters. This causes some changes in other parts of the code that
are included in the patch.

There has been some testing of this functionality, but there are
probably still quite a few bugs in there, especially for people with
different configurations.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoremove unused lxc_read_line_from_file()
Serge Hallyn [Tue, 10 Sep 2013 19:30:43 +0000 (14:30 -0500)] 
remove unused lxc_read_line_from_file()

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoutils: Add utility functions that write/read to entire files
Christian Seiler [Sun, 8 Sep 2013 12:14:48 +0000 (14:14 +0200)] 
utils: Add utility functions that write/read to entire files

Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>