define list container api (v2)

Two new commands are defined: list_defined_containers() and
list_active_containers().  Both take an lxcpath (NULL means
use the default lxcpath) and return the number of containers
found.  If a lxc_container ** is passed in, then an array of
lxc_container's is returned, one for each container found.
The caller must then lxc_container_put() each container and
free the array, as shown in the new list testcase.
If a char ** is passed in, then an array of container names
is returned, after which the caller must free all the names
and the name array, as showsn in the testcase.

Changelog:
	Check for the container config file before trying to
	create an lxc_container *, to save some work. [ per
	stgraber comments]
	Add names ** argument to return only container names.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
doc: Improve Japanese lxc.conf(5) to be easy to read

Change the location of linefeed for improving to be read lxc.conf(5) in
Japanese environment.

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
lxc-debian: Add support for --release

Signed-off-by: Laurent Vallar <val@zbla.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
lxc-debian: Add --arch option

Signed-off-by: Laurent Vallar <val@zbla.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
Make 'make dist' match git content

This fixes a few obvious issues when comparing the make dist output with
the git tree.

 - Make all templates non-executable in git
 - Remove unused files:
   - src/lxc/list.c (empty, only includes the list.h header)
   - src/lxc/lxc-destroy.in (replace by lxc_destroy.c)
 - Add missing files to dist tarball:
   - src/python-lxc/examples/pyconsole.py
   - src/python-lxc/examples/pyconsole-vte.py
 - Mark all the python API tests executable
 - Mark lxc-test-ubuntu executable

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
add more detail in automount error message

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Improper pty permissions - missing mode=0620, gid=5

This fix is coming from Debian bug:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=720122

The reason for the hardcoded gid= and mode= is because of the fix for
CVE-2013-2207 which removes pt_chown from glibc and so requires proper
write access to devpts.

It looks like the "tty" group is guaranteed to be gid=5 on at least all
RedHat based and Debian based systems. So this hardcode gid shouldn't be
a big problem. If we however support any distro where that's not the
case, we'll need to implement an extra lxc.conf option and matching
template changes.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
oracle template: fix selinux context on symlinks in /dev

This fixes sshd getting an avc on traversing the /dev/ptmx symlink
(was default_t)

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
fix busybox template for use with AppArmor

Ensure /proc and /sys are mounted in the container, otherwise
apparmor_enabled() will fail to find
/sys/module/apparmor/parameters/enabled

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
add lsm op for checking if an lsm is present/enabled

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
lxc-attach: fixed typo: privleges -> privileges

Signed-off-by: Dmitry Yu Okunev <dyokunev@ut.mephi.ru>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
lxc-debian: Force locales generation

Signed-off-by: Laurent Vallar <val@zbla.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
lxc-debian: Remove perl, use sed instead

Signed-off-by: Laurent Vallar <val@zbla.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
Change configure, replacing mandriva by openmandriva

The latest Mandriva distro release was in 2011 and nowadays distro named
OpenMandriva Lx.

Signed-off-by: Alexander Khryukin <alexander@mezon.ru>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
parse.c: don't print error message on callback rv > 0

A callback return value < 0 means there was an error, so print
out an error message.  But a rv > 0 is used by the mount_unknown_fs
functions to say "we found the one we want, stop here."

Document this, and only print an error message if rv < 0.  Otherwise,

	lxc-create -B lvm --fstype ext3 -t ubuntu -n u1

will print an (innocuous) error message about being unable to parse
the config value 'ext3'.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
lxc-test-ubuntu: also allow the standard non-nested apparmor policy

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
lxc-start-ephemeral: Fix broken mount logic

This reworks the mount logic for lxc-start-ephemeral to be as follow:
 - Any real (non-bind) entry gets copied to the target fstab
 - Any bind-mount from a virtual fs gets copied to the target fstab
 - Any remaining bind-mount if confirmed to be valid gets setup as an
   overlay.

Extra bind-mounts passed through the -b option are mounted by the
pre-mount script and don't need processing by the fstab generator.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
lxc-alpine: enable loopback interface by default

It was probably disabled by a mistake

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
add lsm op for getting name of enabled lsm

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
support setting lsm label at exec or immediately

- Add attach test cases

- Moved setting of LSM label later to avoid failure of IPC between parent
  and child during attach

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>