]> git.proxmox.com Git - mirror_lxc.git/log
mirror_lxc.git
11 years agoconfigure: replace deprecated AM_CONFIG_HEADER
Natanael Copa [Tue, 19 Feb 2013 09:17:41 +0000 (10:17 +0100)]
configure: replace deprecated AM_CONFIG_HEADER

Replace deprecated AM_CONFIG_HEADER with AC_CONFIG_HEADERS.

This is needed for automake-1.13.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolegacy ls: only output appropriate directories/containers
Dwight Engen [Tue, 12 Feb 2013 20:54:47 +0000 (15:54 -0500)]
legacy ls: only output appropriate directories/containers

For lxc-ls without --active, only output a directory in lxc_path if it
contains a file named config. This avoids extra directories that may
exist in lxc_path, for example .snapshot if lxc_path is an nfs mount.

For lxc-ls with --active, don't output . if there are no active
containers.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-alpine: autodetect standard bridges and set hwaddress
Natanael Copa [Wed, 13 Feb 2013 13:47:11 +0000 (14:47 +0100)]
lxc-alpine: autodetect standard bridges and set hwaddress

Check for lxcbr0, virbr0 and br0 and use one of those if they exist.

Set mac address if network type is veth.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoonly INFO rcfile if asprintf successfully allocates it
Dwight Engen [Tue, 12 Feb 2013 17:52:25 +0000 (12:52 -0500)]
only INFO rcfile if asprintf successfully allocates it

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoversion 0.9.0-alpha2
Daniel Lezcano [Mon, 18 Feb 2013 07:48:32 +0000 (08:48 +0100)]
version 0.9.0-alpha2

Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
11 years agoMerge git://github.com/lxc/lxc
Daniel Lezcano [Wed, 13 Feb 2013 08:50:27 +0000 (09:50 +0100)]
Merge git://github.com/lxc/lxc

Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
11 years agoUpdate Lua API
Dwight Engen [Mon, 11 Feb 2013 22:31:39 +0000 (17:31 -0500)]
Update Lua API

Add [gs]et_config_path from API to Lua binding. Add additional optional
parameter to container_new(). Add tests for these new Lua API bindings.
Commit 2a59a681 changed the meaning of lxc_path_get() in the binding,
causing lua script breakage. Reinstate original behavior of
lxc_path_get() and rename it to lxc_default_config_path_get() to make
its intent clearer.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agopass lxcpath to lxc_command
Serge Hallyn [Mon, 11 Feb 2013 20:43:41 +0000 (14:43 -0600)]
pass lxcpath to lxc_command

The previous lxcpath patches added support for a custom LXCPATH set
through a system-wide configuration file.

This was also exposed through the C api, so that a custom lxcpath could
be set at the container object instanciation time, or set at runtime.

However the command sock filename was always located under the global
lxcpath, which could be confusing, and would be a problem for users
with insufficient perms to the system-wide lxc path (i.e. if setting
lxcpath to $HOME/lxcbase).  This patch changes that by passing the
lxcpath to all callers of lxc_command().

It remains to add an lxcpath command line argument to most of the
command line tools (which are not using the C api) - lxc-start,
lxc-info, lxc-stop, etc.

At this point it becomes tempting to do something like

c = lxc.Container("r1", "/var/lib/lxc")
c2 = lxc.Container("r1", "$HOME/lxcbase")

However, that's problematic - those two will use the same directory
names for cgroup directories.

What would be the best way to handle this?  One way (which I kind
of like) is to give up on naming the cgroups after the container.
use mkstemp for the cgroup name, let lxc keep track of the cgroup
name based on the command socket, and make users use lxc-cgroup to get
and change settings.

Other ideas?

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agopython-lxc: Update for new calls
Stéphane Graber [Mon, 11 Feb 2013 18:45:20 +0000 (13:45 -0500)]
python-lxc: Update for new calls

Add the two new calls to the API and add the new container_path
parameter to the constructor (optional).

This also extends list_containers to support the config_path parameter.
At this point none of the actual tools are changed to make use of those
as we'll probably want to make sure all the tools get the extra option
at once.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Tested-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc api: fix some config_path oddities
Serge Hallyn [Fri, 8 Feb 2013 22:06:32 +0000 (16:06 -0600)]
lxc api: fix some config_path oddities

1. When calling c->set_config_path(), update configfile.  I.e. if we
are setting the config_path to /var/lib/lxc, then the configfile should
be changed to /var/lib/lxc/$container/config

2. Add an optional configpath argument to lxc_container_new.  If NULL,
then the default will be used (as before).  If set, then the passed-in
path will be used.  This way you can do

c1 = lxc.Container("r1", "/var/lib/lxc");
c2 = lxc.Container("r2", "/home/user/lxcbase");

(Note I did *not* implement the python or lua binding to pass that
argument along)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-create: Improve the layout of the config
Stéphane Graber [Sat, 9 Feb 2013 19:52:12 +0000 (14:52 -0500)]
lxc-create: Improve the layout of the config

This simply adds an extra blank line between the original lxc config
and the template generated options.

In typical use cases, this means that we'll now get the header, then
a blank line, then default.conf content, then a blank line and finally
the template generated config.

The wording of the header is also changed slightly so that it fits in
the usual 80 columns.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoAdd missing manpages
Stéphane Graber [Fri, 8 Feb 2013 23:49:52 +0000 (18:49 -0500)]
Add missing manpages

This introduces manpages for:
 - lxc-checkconfig
 - lxc-device
 - lxc-info
 - lxc-netstat
 - lxc-shutdown (wasn't in Makefile)
 - lxc-start-ephemeral
 - lxc-version

This commit also sorts configure.ac and Makefile.am.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoadd lxc-unshare man page, and make 'lxc-unshare -h' work.
Serge Hallyn [Fri, 8 Feb 2013 23:32:32 +0000 (17:32 -0600)]
add lxc-unshare man page, and make 'lxc-unshare -h' work.

Also fix some tabs-as-spaces in lxc_unshare.c itself.
lxc-unshare: run usage() on '-h'

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoAdd man page for lxc-clone
Serge Hallyn [Fri, 8 Feb 2013 22:58:01 +0000 (16:58 -0600)]
Add man page for lxc-clone

And doing so pointed out a bug in lxc-clone itself - it claims
default fssize is 2G.  It's not.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc.functions isn't a shell script
Stéphane Graber [Fri, 8 Feb 2013 21:01:02 +0000 (16:01 -0500)]
lxc.functions isn't a shell script

lxc.functions.in is meant to be sourced, not to be called as a script.
So as it's not executable and not meant to be, it shouldn't have
a /bin/sh shebang.

This fixes an error reported by lintian.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoDrop lxc-setcap and lxc-setuid
Stéphane Graber [Fri, 8 Feb 2013 16:07:53 +0000 (11:07 -0500)]
Drop lxc-setcap and lxc-setuid

As discussed earlier this week, lxc-setcap and lxc-setuid have been
in pretty bad shape lately. Most if not all distros recommend against
using them or don't ship them at all.

With the ongoing work to get user namespaces working in upstream LXC,
we think it's best to drop those two now as we prepare to land proper
setuid helpers to deal with user namespaces.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoUpdate lxc-archlinux template.
Alexander Vladimirov [Thu, 7 Feb 2013 08:13:56 +0000 (16:13 +0800)]
Update lxc-archlinux template.

Add mknod to lxc.cap.drop since udev is conditioned on CAP_MKNOD capability.
Update base package list.

Signed-off-by: Alexander Vladimirov <alexander.idkfa.vladimirov@gmail.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoSwitch from use of LXCPATH to a configurable default_lxc_path
Serge Hallyn [Wed, 6 Feb 2013 21:11:19 +0000 (15:11 -0600)]
Switch from use of LXCPATH to a configurable default_lxc_path

Here is a patch to introduce a configurable system-wide
lxcpath.  It seems to work with lxc-create, lxc-start,
and basic python3 lxc usage through the api.

For shell functions, a new /usr/share/lxc/lxc.functions is
introduced which sets some of the basic global variables,
including evaluating the right place for lxc_path.

I have not converted any of the other python code, as I was
not sure where we should keep the common functions (i.e.
for now just default_lxc_path()).

configure.ac: add an option for setting the global config file name.
utils: add a default_lxc_path() function
Use default_lxc_path in .c files
define get_lxc_path() and set_lxc_path() in C api
use get_lxc_path() in lua api
create sh helper for getting default path from config file
fix up scripts to use lxc.functions

Changelog:
  feb6:
fix lxc_path in lxc.functions
utils.c: as Dwight pointed out, don't close a NULL fin.
utils.c: fix the parsing of lxcpath line
lxc-start: print which rcfile we are using
commands.c: As Dwight alluded to, the sockname handling was just
   ridiculous.  Clean that up.
use Dwight's recommendation for lxc.functions path: $datadir/lxc
make lxccontainer->get_config_path() return const char *
Per Dwight's suggestion, much nicer than returning strdup.
  feb6 (v2):
        lxccontainer: set c->config_path before using it.
convert legacy lxc-ls

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agooracle template: improve compatibility with old ol4, 5
Dwight Engen [Mon, 4 Feb 2013 23:51:47 +0000 (18:51 -0500)]
oracle template: improve compatibility with old ol4, 5

Reported-by: Alvaro Miranda <mirandaa@redrock.net.nz>
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoRename /etc/lxc/lxc.conf to /etc/lxc/default.conf.
Dwight Engen [Mon, 4 Feb 2013 21:53:25 +0000 (16:53 -0500)]
Rename /etc/lxc/lxc.conf to /etc/lxc/default.conf.

This will soon be followed by the introduction of a "real" system wide
/etc/lxc/lxc.conf storing global LXC settings.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoAdd missing option -t/--fstype.
Tomohiro Matsuyama [Sun, 27 Jan 2013 11:54:17 +0000 (20:54 +0900)]
Add missing option -t/--fstype.

Signed-off-by: Tomohiro Matsuyama <tomo@cx4a.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoadd lua binding for the lxc API
Dwight Engen [Thu, 24 Jan 2013 16:42:22 +0000 (11:42 -0500)]
add lua binding for the lxc API

The lua binding is based closely on the python binding. Also included are
a test program for excercising the binding, and an lxc-top utility for
showing statistics on running containers.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agosetup_mount_entries: ignore mount failure if 'optional'
Serge Hallyn [Mon, 28 Jan 2013 22:57:24 +0000 (16:57 -0600)]
setup_mount_entries: ignore mount failure if 'optional'

If 'optional' is in the mount options, then avoid failure in
mount().

Experiments suggest we could just do this checking data at
mount_entry(), but that feels less proper than using
hasmntopt() against the mntent.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agouse a default per-container logfile
Serge Hallyn [Thu, 24 Jan 2013 18:04:54 +0000 (12:04 -0600)]
use a default per-container logfile

Until now, if a lxc-* (i.e. lxc-start) command did not specify a logfile
(with -o logfile), the default was effectively 'none'.  With this patch,
the default becomes a per-container log file.

If a container config file specifies 'lxc.logfile', that will override
the default.  If a '-o logfile' argument is specifed at lxc-start,
then that will override both the default and the configuration file
entry.  Finally, '-o none' can be used to avoid having a logfile at
all (in other words, the previous default), and that will override
a lxc.logfile entry in the container configuration file.

If the user does not have rights to open the default, then 'none' will
be used.  However, in that case an error will show up on console.  (We
can work on removing that if it annoys people, but I think it is
helpful, at least while we're still ironing this set out)  If the user
or container configuration file specified a logfile, and the user does
not have rights to open the default, then the action will fail.

One slight "mis-behavior" which I have not fixed (and may not fix) is
that if a lxc.logfile is specified, the default logfile will still
get created before we read the configuration file to find out there
is a lxc.logfile entry.

changelog:  Jan 24:

 add --enable-configpath-log configure option

 When we log to /var/lib/lxc/$container/$container.log, several things
 need to be done differently than when we log into /var/log/lxc (for
 instance).  So give it a configure option so we know what to do

 When the user specifies a logfile, we bail if we can't open it.  But
 when opening the default logfile, the user may not have rights to
 open it, so in that case ignore it and continue as if using 'none'.

 When using /var/lib/lxc/$c/$c.log, we use $LOGPATH/$name/$name.log.
 Otherwise, we use $LOGPATH/$name.log.

 When using /var/lib/lxc/$c/$c.log, don't try to create the log path
 /var/lib/lxc/$c.  It can only not exist if the container doesn't
 exist.  We don't want to create the directory in that case.  When
 using /var/log/lxc, then we do want to create the path if it does
 not exist.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agooracle template: fix sudo lxc-create on ubuntu
Dwight Engen [Fri, 25 Jan 2013 22:41:34 +0000 (17:41 -0500)]
oracle template: fix sudo lxc-create on ubuntu

rpm on ubuntu puts the rpm db under $HOME, which wont be /root if
sudo is used

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoinclude python files in make dist and rpm
Dwight Engen [Wed, 23 Jan 2013 17:59:21 +0000 (12:59 -0500)]
include python files in make dist and rpm

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoRevert "use a default per-container logfile"
Stéphane Graber [Wed, 23 Jan 2013 22:20:11 +0000 (17:20 -0500)]
Revert "use a default per-container logfile"

The logfile changes broke lxc-info and possibly more command line
tools. Revert for now until we get those issues addressed.

This reverts commit 74476cf144523530022d76cef3a558b0662b592f.

11 years agoRevert "use a default per-container logfile"
Stéphane Graber [Wed, 23 Jan 2013 22:19:40 +0000 (17:19 -0500)]
Revert "use a default per-container logfile"

The logfile changes broke lxc-info and possibly more command line
tools. Revert for now until we get those issues addressed.

This reverts commit b8e0503a1d1dbf3a508bf6f34521606ba231b1fe.

11 years agouse a default per-container logfile
Serge Hallyn [Wed, 16 Jan 2013 22:37:46 +0000 (16:37 -0600)]
use a default per-container logfile

log_open: make sure the parent directory for logfiles

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agouse a default per-container logfile
Serge Hallyn [Wed, 16 Jan 2013 05:02:20 +0000 (23:02 -0600)]
use a default per-container logfile

[ Thanks to Stéphane and Dwight for the feedback on the previous patch ]

Until now, if a lxc-* (i.e. lxc-start) command did not specify a logfile
(with -o logfile), the default was effectively 'none'.  With this patch,
the default becomes $LOGPATH/<container>/<container>.log.  LOGPATH is
specified at configure time with '--with-log-path='.  If unspecified, it
is $LXCPATH, so that logs for container r2 will show up at
/var/lib/lxc/r2/r2/log.  LOGPATH must exist, while lxc will make sure to
create $LOGPATH/<name>.  As another example, Ubuntu will likely specify
--with-log-path=/var/log/lxc (and place /var/log/lxc into
debian/lxc.dirs), placing r2's logs in /var/log/lxc/r2/r2.log.

If a container config file specifies 'lxc.logfile', that will override
the default.  If a '-o logfile' argument is specifed at lxc-start,
then that will override both the default and the configuration file
entry.  Finally, '-o none' can be used to avoid having a logfile at
all (in other words, the previous default), and that will override
a lxc.logfile entry in the container configuration file.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-setcap.in: Set path to lxc-init
Matthias Brugger [Tue, 22 Jan 2013 18:00:41 +0000 (19:00 +0100)]
lxc-setcap.in: Set path to lxc-init

In lxc-setcap the path to lxc-init wasn't set right, so that
a call to the script failed with an error. This patch sets
the path to the right directory.

Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agouse which instead of type
Dwight Engen [Tue, 22 Jan 2013 20:59:44 +0000 (15:59 -0500)]
use which instead of type

This is for consistency with the rest of lxc, and also because type checks for
shell builtins, a behavior that we do not want in these cases. Ensure stderr
for which is redirected to /dev/null also.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agodon't leak the rootfs.pin fd into the container
Serge Hallyn [Thu, 17 Jan 2013 15:53:33 +0000 (09:53 -0600)]
don't leak the rootfs.pin fd into the container

Only the container parent needs to keep that fd open.  Close it
as soon as the container's first task is spawned.  Else it can
show up in /proc/$$/fd in the container.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoconf.c: Cast st_uid and st_gid to int
Stéphane Graber [Tue, 15 Jan 2013 17:44:50 +0000 (12:44 -0500)]
conf.c: Cast st_uid and st_gid to int

In eglibc st_uid and st_gid are defined as unsigned integers, in bionic those
are defined as unsigned long (which is inconsistent with the kernel's
defintion that's uint_32).

To workaround this problem, simply cast those two to int.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-oracle.in: Clear trailing whitespaces
Stéphane Graber [Tue, 15 Jan 2013 17:20:51 +0000 (12:20 -0500)]
lxc-oracle.in: Clear trailing whitespaces

A quick scan through the code showed that lxc-oracle.in is the only
file in the branch containing trailing whitespaces, this clears them.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoAdd Dropbear SSH support for lxc-busybox template
Purcareata Bogdan-B43198 [Mon, 14 Jan 2013 14:21:41 +0000 (14:21 +0000)]
Add Dropbear SSH support for lxc-busybox template

Dropbear implements lightweight SSH2 server and client functionality and
is likely to be included in embedded Linux distros.

Signed-off-by: Purcareata Bogdan <B43198@freescale.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoImplement userid mappings (enable user namespaces)
Serge Hallyn [Tue, 15 Jan 2013 00:03:06 +0000 (18:03 -0600)]
Implement userid mappings (enable user namespaces)

The 3.8 kernel now supporst uid mappings, so I believe it's appropriate
to proceed with this patchset.
The container config supports new entries of the form:
 lxc.id_map = U 100000 0 10000
 lxc.id_map = G 100000 0 10000
meaning map 'virtual' uids (in the container) 0-10000 to uids
100000-110000 on the host, and same for gids.  So long as there are
mappings specified in the container config, then CONFIG_NEWUSER will
be used when the container is cloned.  This means that container
setup is no longer done with root privilege on the host, only root
privilege in the container.  Therefore cgroup setup is moved from the
init task to the monitor task.

To use this patchset, you currently need to either use the raring
kernel at ppa:serge-hallyn/usern-natty, or build your own kernel
from either git://kernel.ubuntu.com/serge/quantal-userns.git.
(Alternatively you can use Eric's tree at the latest userns-always-map-*
branch at
git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git
but you will likely want to at least enable tmpfs mounts in user namespaces)

You also need to chown the files in the container rootfs into the
mapped range.  There is a utility at
https://code.launchpad.net/~serge-hallyn/+junk/nsexec to do this.
uidmapshift does the chowning, while the container-userns-convert
script nicely wraps that program.  So I simply

sudo lxc-create -t ubuntu -n r1
sudo container-userns-convert r1 200000

will create a container which is shifted so uid 0 in the container
is uid 200000 on the host.

TODO: when doing setuid(0), need to only do that if 0 is one of the
ids we map to.  Similarly, when dropping capabilities, need to only
not do that if 0 is one of the ids we map to.  However, the question
of what to do for 'weird' containers in private user namespaces is
one I'm punting for later.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agosetup cgroups from parent
Serge Hallyn [Mon, 14 Jan 2013 23:32:44 +0000 (23:32 +0000)]
setup cgroups from parent

This is a first step to enabling user namespaces.  When starting a
container in a new user namespace, the child will not have the
rights to write to the cgroup fs.  (We can give it that right, but
don't always want to have to).

At the parent, we don't want to setup_cgroups() before the child
has set itself up.  But we also don't want to wait until it has
started running it's init, since that is racy.

Therefore introduce a new sync point.  The child will let the
parent know when it is ready to be confined, and wait for the
parent to respond that it has done so.  Then the child will finish
constraining itself with LSM and seccomp and execute init.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoclean up syncs
Serge Hallyn [Mon, 14 Jan 2013 23:32:43 +0000 (23:32 +0000)]
clean up syncs

Always unblock parent when child setup fails, rather than just
exiting.

Also remove a duplicate call to setup_cgroup().  We'll want it
close to there for userns, but not right there - that's too late,
and could happen after container init has done something bad
without cgroup restrictions.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoMultiple IP addresses: add them in the correct order
Christian Seiler [Tue, 15 Jan 2013 13:44:25 +0000 (14:44 +0100)]
Multiple IP addresses: add them in the correct order

Make sure that when configuring containers that have interfaces containing
multiple IP addresses they are added in the order of the configuration file
(i.e. the first being the primary one) and not the reverse order.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoMAKEDEV call, add autodev hooks, add environment variables for hook scripts.
Michael H. Warfield [Mon, 14 Jan 2013 16:59:36 +0000 (11:59 -0500)]
MAKEDEV call, add autodev hooks, add environment variables for hook scripts.

Ok...  Here's the patch again.  Since Serge is removing the loglevel
structure member, this patch no longer references that element.

From the original description:

1) Removes run_makedev() and the call to it from conf.c per discussion.

2) Adds an lxc.hook.autodev hook.

Note: This hook is very close (one routine level abstracted) from where
the run_makedev was called.  Anyone really rrreeeaaalllyyy needing
MAKEDEV can add it in with a small shim script to do whatever they want
under whatever distro they're using, so no functionality is lost there.

3) Added a number of environment variables for all the hook scripts to
reference to assist in execution.  Things like LXC_ROOTFS_MOUNT could be
very useful but others were added as well.  Room for more if anyone has
an itch.  All in one spot in lxc_start.c.

4) clearenv and putenv( "container=lxc" ) calls were moved to just after
the "start" hook in the container just prior to actually firing up the
container so we could use environment variables prior to that and have
them flushed them before firing up init.  Nice side effect is that you
can define environment variables and then call lxc-start and have them
show up in those hooks scripts.

5) I actually DID update the man page for lxc.conf!  I guess I lied when
I said I wouldn't get that done.

[... and ...]

I added the rcfile to the lxc_conf structure as suggested and moved the
setenv bundle from lxc-start.c over to start.c just prior to calling
run_lxc_hooks for the pre-start hook.

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoremove logfile and loglevel from struct lxc_conf
Serge Hallyn [Fri, 11 Jan 2013 18:39:31 +0000 (12:39 -0600)]
remove logfile and loglevel from struct lxc_conf

The options are still supported in the lxc configuration file.
However they are stored only in local variables in src/lxc/log.c,
which can be read using two new functions:
int lxc_log_get_level(void);
const char *lxc_log_get_file(void);

Changelog: jan 14:
 have lxc_log_init use lxc_log_set_file(), have lxc_log_set_file() take
 a const char *, and have it keep its own strdup'd copy of the filename.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxcutmp.c: Fix typo causing build failure
Stéphane Graber [Sun, 13 Jan 2013 20:29:26 +0000 (15:29 -0500)]
lxcutmp.c: Fix typo causing build failure

In a previous change I added an ifdef for HAVE_SYS_TIMERFD_h
rather than HAVE_SYS_TIMERFD_H, leading to a missing include of
sys/timerfd.h on platforms that support it and ultimately to a build
failure.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoFix check for openpty
Stéphane Graber [Fri, 11 Jan 2013 20:53:14 +0000 (15:53 -0500)]
Fix check for openpty

The previous implementation of the openpty check was always returning
'no' as openpty is typically defined in util.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoBuild lxcutmp.c without timerfd.h or utmpx.h
Stéphane Graber [Fri, 11 Jan 2013 17:29:55 +0000 (12:29 -0500)]
Build lxcutmp.c without timerfd.h or utmpx.h

This adds a local implementation of the bits we need form timerfd.h and
utmpx.h so that the LXC utmp watch can be used with libc that don't implement
the same functions as eglibc.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoRename utmp.c/utmp.h to lxcutmp.c/lxcutmp.h
Stéphane Graber [Fri, 11 Jan 2013 17:29:54 +0000 (12:29 -0500)]
Rename utmp.c/utmp.h to lxcutmp.c/lxcutmp.h

This avoids conflict with the system header utmp.h.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoAdd check for sys/timerfd.h
Stéphane Graber [Fri, 11 Jan 2013 17:29:53 +0000 (12:29 -0500)]
Add check for sys/timerfd.h

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoFix header name in lxcmntent.h
Stéphane Graber [Fri, 11 Jan 2013 17:29:52 +0000 (12:29 -0500)]
Fix header name in lxcmntent.h

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agouse pkg-config to ensure python3-devel is installed
Dwight Engen [Thu, 10 Jan 2013 20:45:22 +0000 (15:45 -0500)]
use pkg-config to ensure python3-devel is installed

The Python.h header varies in location by distribution, so instead use
pkg-config to ensure the python3 devel package is installed. Tested with
Ubuntu 12.04 and Fedora 17. Fixes --enable-python on Fedora 17.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoAdd 'config' option to lxc-archlinux template and fix getopt string
Alexander Vladimirov [Fri, 11 Jan 2013 10:36:23 +0000 (18:36 +0800)]
Add 'config' option to lxc-archlinux template and fix getopt string

This option allows user to control installation repository and options
using alternative pacman configuration file.
Also remove unnecessary sed invocation during container configuration.

Signed-off-by: Alexander Vladimirov <alexander.idkfa.vladimirov@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoutmp.h: Don't fail when utmpx.h isn't present
Stéphane Graber [Thu, 10 Jan 2013 22:10:51 +0000 (17:10 -0500)]
utmp.h: Don't fail when utmpx.h isn't present

Following a comment on the mailing-list, I made utmp.h return -1
when it's disabled, the problem with that is that it prevents the
container from starting completely, which isn't quite what I wanted.

This change makes the function succeed, the container will therefore
start but without utmp handler.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoDefine PR_CAPBSET_READ when missing
Stéphane Graber [Thu, 10 Jan 2013 20:22:30 +0000 (15:22 -0500)]
Define PR_CAPBSET_READ when missing

PR_CAPBSET_READ isn't defined in bionic, so define it if it's not.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agooracle template: fix lxc-shutdown with upstart SIGPWR handler
Dwight Engen [Wed, 9 Jan 2013 19:09:55 +0000 (14:09 -0500)]
oracle template: fix lxc-shutdown with upstart SIGPWR handler

OL6 uses upstart init and needs a handler for the SIGPWR that
lxc-shutdown sends it so that a container can shut down cleanly.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agofix lxc-shutdown argument parsing
Dwight Engen [Wed, 9 Jan 2013 19:09:33 +0000 (14:09 -0500)]
fix lxc-shutdown argument parsing

processing of -w or -r shifts an argument that isn't there, messing up
other argument processing

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoMakefile.am: Add missing liblxc symlink
Stéphane Graber [Mon, 7 Jan 2013 22:46:16 +0000 (17:46 -0500)]
Makefile.am: Add missing liblxc symlink

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoDon't call setup_mount_entries if the list is empty
Stéphane Graber [Fri, 4 Jan 2013 18:56:13 +0000 (13:56 -0500)]
Don't call setup_mount_entries if the list is empty

There's no good reason to call setup_mount_entries if we don't have any
lxc.mount.entry. This also avoids an issue on bionic where the tmpfile()
call in setup_mount_entries requires the presence of /tmp which isn't the
case by default.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agotests/Makefile.am: Update for bionic
Stéphane Graber [Thu, 3 Jan 2013 19:04:48 +0000 (14:04 -0500)]
tests/Makefile.am: Update for bionic

-lpthread doesn't exist and isn't necessary on bionic.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc_unshare: Replace getpw*_r by getpw*
Stéphane Graber [Thu, 3 Jan 2013 16:51:52 +0000 (11:51 -0500)]
lxc_unshare: Replace getpw*_r by getpw*

Bionic and maybe some other libc implementations lack the _r nss functions.
This replaces our current getpwnam_r and getpwuid_r calls by getpwnam and
getpwuid.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoconf.c: Cleanup __S_ISTYPE
Stéphane Graber [Thu, 3 Jan 2013 17:24:20 +0000 (12:24 -0500)]
conf.c: Cleanup __S_ISTYPE

__S_ISTYPE doesn't exist in all C libraries, so define it if it's missing.
Additionaly, replace one occurence where it wasn't actually needed.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoAdd local implementation of mntent.h
Stéphane Graber [Thu, 3 Jan 2013 17:24:19 +0000 (12:24 -0500)]
Add local implementation of mntent.h

Bionic (at least) is missing some of the usual mntent functions.
This adds code defining those that we need when they're missing from the C
library.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agocaps.h: Rename __errno to ___errno
Stéphane Graber [Thu, 3 Jan 2013 17:24:18 +0000 (12:24 -0500)]
caps.h: Rename __errno to ___errno

At least bionic defines __errno, so this was causing a conflict in caps.h
leading to build failure. Renaming to ___errno avoids that conflicting
definition.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoReplace strdupa call by standard strdup
Stéphane Graber [Wed, 26 Dec 2012 14:47:37 +0000 (15:47 +0100)]
Replace strdupa call by standard strdup

strdupa appears to only exist in the standard glibc but at least not in bionic.
Replace the two strdupa calls we have by a standard strdup.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoAdd a bionic_alphasort function on bionic
Stéphane Graber [Thu, 3 Jan 2013 17:24:16 +0000 (12:24 -0500)]
Add a bionic_alphasort function on bionic

alphasort doesn't have the right signature on bionic which causes the build to
fail. This implements a new bionic_alphasort function when building on bionic
providing the right signature and a functional equivalent of glibc's alphasort.

This signature problem with alphasort was fixed in upstream bionic but hasn't
been released yet. This commit can therefore be reverted as soon as the
following commit hits the Android NDK: 40e467ec668b59be25491bd44bf348a884d6a68d

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoMake utmpx.h optional
Stéphane Graber [Thu, 3 Jan 2013 17:24:15 +0000 (12:24 -0500)]
Make utmpx.h optional

This adds code detecting the presence of utmpx.h and in its absence, turns the
utmp related functions into no-ops.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoWorkaround missing functions in other libc
Stéphane Graber [Thu, 3 Jan 2013 17:24:14 +0000 (12:24 -0500)]
Workaround missing functions in other libc

Some libc implementation (bionic) is lacking some of the syscall functions
that are present in the glibc.

For those, detect at build time the they are missing and implement a minimal
syscall() wrapper that will essentially give the same result as the glibc
function.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agopersonality.h: Make the personality code optional
Stéphane Graber [Thu, 3 Jan 2013 17:24:13 +0000 (12:24 -0500)]
personality.h: Make the personality code optional

Some platforms don't have personality.h in their C library, this change
adds buildtime detection for the header and turns off the personality setting
code in those cases.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoDon't hard depend on capability.h and libcap
Stéphane Graber [Thu, 20 Dec 2012 15:11:03 +0000 (16:11 +0100)]
Don't hard depend on capability.h and libcap

In the effort to make LXC work with non-standard Linux distros, this change
allows for the user to build LXC without capability support through a new
--disable-capabilities option to configure.

This effectively will cause LXC not to link against libcap and will turn all
the _cap_ functions into no-ops.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agotty.h: Ship our own minimal openpty.h
Stéphane Graber [Thu, 3 Jan 2013 17:24:11 +0000 (12:24 -0500)]
tty.h: Ship our own minimal openpty.h

bionic is missing an openpty() function, so ship our own and only
build it and use it on bionic.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoclone: Support bionic's clone() defintion
Stéphane Graber [Thu, 3 Jan 2013 17:24:10 +0000 (12:24 -0500)]
clone: Support bionic's clone() defintion

The clone() call in bionic is very slightly different.
This updates namespace.h to support both glibc and bionic.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoconf.c: Define LO_FLAGS_AUTOCLEAR if it's not
Stéphane Graber [Thu, 3 Jan 2013 17:24:09 +0000 (12:24 -0500)]
conf.c: Define LO_FLAGS_AUTOCLEAR if it's not

LO_FLAGS_AUTOCLEAR isn't defined on bionic, so add an extra ifndef
and set it to its usual value if it's not.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoAdd/remove extra includes
Stéphane Graber [Thu, 20 Dec 2012 13:17:09 +0000 (14:17 +0100)]
Add/remove extra includes

While cross-building with bionic, a number of failures were triggered by some
missing includes and in a few cases by extra unused includes.

This commit updates the various headers based on those observations.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoReplace get_current_dir_name by getcwd
Stéphane Graber [Thu, 3 Jan 2013 17:24:07 +0000 (12:24 -0500)]
Replace get_current_dir_name by getcwd

get_current_dir_name appears to be specific to glibc. Replace that call
by an equivalent getcwd call.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoNo need to link against rt and util on bionic
Stéphane Graber [Thu, 3 Jan 2013 17:24:06 +0000 (12:24 -0500)]
No need to link against rt and util on bionic

When building on bionic, -lrt and -lutil only cause a build failure.
Dropping those fixes the build, so it appears that the symbols are defined
in the main library.

This commit moves -lrt and -lutil under a !IS_BIONIC check.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoSupport both getline and fgetln
Stéphane Graber [Thu, 20 Dec 2012 12:46:57 +0000 (13:46 +0100)]
Support both getline and fgetln

Some libc implementations don't have the getline function but instead
have an equivalent fgetln function.

Add code to detect both and use whatever is available.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoReplace all reference to ushort by unsigned short
Stéphane Graber [Tue, 8 Jan 2013 17:02:53 +0000 (12:02 -0500)]
Replace all reference to ushort by unsigned short

ushort appears to be a glibc specific type which doesn't exist in
bionic, this commit simply replace all occurences by the equivalent
unsigned short type.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoconfigure.ac: Cleanup, comments, indent, ...
Stéphane Graber [Tue, 8 Jan 2013 17:02:52 +0000 (12:02 -0500)]
configure.ac: Cleanup, comments, indent, ...

This commit doesn't do any functional change to configure.ac but does a fair
amount of cleaning up.

It re-orders the various blocks by type (options, checks, expands, ...).
It also consistently uses tabs for indents.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoconfigure.ac: Add code to detect bionic C library
Stéphane Graber [Tue, 8 Jan 2013 17:02:51 +0000 (12:02 -0500)]
configure.ac: Add code to detect bionic C library

This adds a new IS_BIONIC define that can be used to detect whether we are
building with eglibc or with bionic.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoSet umask before populating /dev and restore it after.
Alexander Vladimirov [Tue, 8 Jan 2013 01:08:54 +0000 (09:08 +0800)]
Set umask before populating /dev and restore it after.

According to docs, mknod clears each permission bit whose
corresponding bit in the process umask is set, so we should fix it
before creating device nodes.

Signed-off-by: Alexander Vladimirov <alexander.idkfa.vladimirov@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agooracle template: use url arg to wget repo file
Dwight Engen [Mon, 7 Jan 2013 19:02:39 +0000 (14:02 -0500)]
oracle template: use url arg to wget repo file

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agooracle template: drop additional capabilities
Dwight Engen [Mon, 7 Jan 2013 19:02:31 +0000 (14:02 -0500)]
oracle template: drop additional capabilities

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agodocument lxc-console escape sequence and argument
Dwight Engen [Fri, 4 Jan 2013 20:23:23 +0000 (15:23 -0500)]
document lxc-console escape sequence and argument

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agofixed RELEASE_URL for fedora releases higher than 16
Maximilian Seesslen [Fri, 4 Jan 2013 15:36:07 +0000 (16:36 +0100)]
fixed RELEASE_URL for fedora releases higher than 16

The Url for the fedora-release RPM changed in release 17.

Signed-off-by: Maximilian Seesslen <mes@seesslen.net>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-ps: fix order of output and fix --lxc opt
Natanael Copa [Fri, 4 Jan 2013 08:39:04 +0000 (09:39 +0100)]
lxc-ps: fix order of output and fix --lxc opt

We must output the lines from 'ps' in same order for tree views.

Fix also --lxc option to only show processes from containers.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-checkconfig: fix colors when using dash
Natanael Copa [Tue, 25 Dec 2012 15:50:54 +0000 (16:50 +0100)]
lxc-checkconfig: fix colors when using dash

The \e did not work as expected on dash. Replace with proper posix \033

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agofix lxc-wait waiting forever for FREEZING, FROZEN, THAWED states
Dwight Engen [Wed, 19 Dec 2012 00:15:33 +0000 (19:15 -0500)]
fix lxc-wait waiting forever for FREEZING, FROZEN, THAWED states

These states are kept by the kernel in the freezer.state cgroup item, and
are never set in handler->state with lxc_set_state(). If lxc transitions
a container to/from the freezer after an lxc-wait for one of the above
states has already started, the lxc-wait will never see the new state. This
change has lxc send the new state to the lxc-monitor socket.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agooracle template: add support for creating ol4 container from ovm template
Dwight Engen [Fri, 14 Dec 2012 20:38:35 +0000 (15:38 -0500)]
oracle template: add support for creating ol4 container from ovm template

Also: disable the interactive part of ovmd so ol5,6 containers won't
hang if started for the first time with -d. Don't let containers do rawio,
or have access to /dev/rtc0, they can mess up the hosts system clock among
other things.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoseparate console device from console log
Dwight Engen [Thu, 27 Dec 2012 22:01:26 +0000 (17:01 -0500)]
separate console device from console log

lxc-start -c makes the named file/device the container's console, but using
this with a regular file in order to get a log of the console output does
not work very well if you also want to login on the console. This change
implements an additional option (-L) to simply log the console's output to
a file.

Both options can be used separately or together. For example to get a usable
console and log: lxc-start -n name -c /dev/tty8 -L console.log

The console state is cleaned up more when lxc_delete_console is called, and
some of the clean up paths in lxc_create_console were fixed.

The lxc_priv and lxc_unpriv macros were modified to make use of gcc's local
label feature so they can be expanded more than once in the same function.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agokill -s expects the signal name without SIG
Stéphane Graber [Wed, 2 Jan 2013 18:47:18 +0000 (13:47 -0500)]
kill -s expects the signal name without SIG

The previous lxc-shutdown change replaced 'kill SIG<name>' by
'kill -s SIG<name>'. Although this works with busybox where it was tested,
this doesn't actually work with all kill implementations. Some requiring just
the signal name without the prefix.

This changes "-s SIG<name>" by just "-s <name>". Tested with busybox and
standard kill.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-alpine: add support for installing optional packages
Natanael Copa [Mon, 31 Dec 2012 19:49:19 +0000 (20:49 +0100)]
lxc-alpine: add support for installing optional packages

Let users append a list of packages they want install in the container

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-alpine: add support for setting arch from command line
Natanael Copa [Mon, 31 Dec 2012 19:49:18 +0000 (20:49 +0100)]
lxc-alpine: add support for setting arch from command line

This allows us to lxc-create 32 bit guests on x86_64 hosts.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-alpine: add --repository option
Natanael Copa [Mon, 31 Dec 2012 19:49:17 +0000 (20:49 +0100)]
lxc-alpine: add --repository option

This allows specifying what repository to use for the container.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-alpine: indent fixes
Natanael Copa [Mon, 31 Dec 2012 19:49:16 +0000 (20:49 +0100)]
lxc-alpine: indent fixes

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agotemplates: install lxc-alpine
Natanael Copa [Mon, 31 Dec 2012 19:49:15 +0000 (20:49 +0100)]
templates: install lxc-alpine

Make sure we actually install lxc-alpine

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-ps: use posix shell and awk instead of bash
Natanael Copa [Wed, 26 Dec 2012 21:31:56 +0000 (22:31 +0100)]
lxc-ps: use posix shell and awk instead of bash

Use awk to parse the output pf 'ps' and the tasks files for the
containers.

Use awk fields to find PID column rather than assume that the PID field
is exactly 5 chars wide and has a leading space ' PID'. This works as
long as the PID field is before the command or other field that include
spaces. This also makes it work with busybox 'ps'.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-shutdown: use posix shell instead of bash
Natanael Copa [Thu, 27 Dec 2012 08:52:30 +0000 (09:52 +0100)]
lxc-shutdown: use posix shell instead of bash

- avoid getopt --longoptions
- use 'which' instead of 'type' to detect existance of tools
- specify -s SIG<signame> with kill

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agofix open check (0 is a valid fd)
Dwight Engen [Mon, 31 Dec 2012 19:02:49 +0000 (14:02 -0500)]
fix open check (0 is a valid fd)

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agocleanup: use lxc-info --state-is
Natanael Copa [Fri, 28 Dec 2012 08:24:55 +0000 (09:24 +0100)]
cleanup: use lxc-info --state-is

We now have the possibility to test for a given state. Use this feature
instead of parsing output with grep or awk

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolegacy/lxc-ls: improve finding fs mountpoint of hierarchy
Natanael Copa [Wed, 26 Dec 2012 09:07:04 +0000 (10:07 +0100)]
legacy/lxc-ls: improve finding fs mountpoint of hierarchy

We cannot assume that the mount source name always starts with 'cgroup'
so we check the filesystem type instead.

Use 'awk' instead of 'grep -E' and  as it is a better tool for this job.

This fixes the tool on systems using openrc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-netstat: improve finding fs mountpoint of hierarchy
Natanael Copa [Wed, 26 Dec 2012 09:07:03 +0000 (10:07 +0100)]
lxc-netstat: improve finding fs mountpoint of hierarchy

We cannot assume that the mount source name always starts with 'cgroup'
so we check the filesystem type instead.

Use 'awk' instead of 'grep -E' and  as it is a better tool for this job.

This fixes the tool on systems using openrc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoUpdate lxc-archlinux template to work with systemd
Alexander Vladimirov [Thu, 13 Dec 2012 08:00:55 +0000 (16:00 +0800)]
Update lxc-archlinux template to work with systemd

Use arch-install-scripts for installation.

Signed-off-by: Alexander Vladimirov <alexander.idkfa.vladimirov@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>