]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
10 years agoshow additional info if btrfs subvolume deletion fails (issue #315)
S.Çağlar Onur [Fri, 22 Aug 2014 16:10:12 +0000 (12:10 -0400)] 
show additional info if btrfs subvolume deletion fails (issue #315)

Unprivileged users require "-o user_subvol_rm_allowed" mount option for btrfs.
Make the INFO level message to ERROR to make it clear, which now says following;

[caglar@qop:~] lxc-destroy -n rubik
lxc_container: Is the rootfs mounted with -o user_subvol_rm_allowed?
lxc_container: Error destroying rootfs for rubik
Destroying rubik failed

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
10 years agolxc_map_ids: don't do bogus chekc for newgidmap
Serge Hallyn [Fri, 22 Aug 2014 03:50:36 +0000 (22:50 -0500)] 
lxc_map_ids: don't do bogus chekc for newgidmap

If we didn't find newuidmap, then simply require the caller to be
root and write to /proc/self/uidmap manually.  Checking for
newgidmap to exist is bogus.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoUpdate plamo template
TAMUKI Shoichi [Tue, 19 Aug 2014 00:29:49 +0000 (09:29 +0900)] 
Update plamo template

- If "installpkg" command does not exist, lxc-plamo temporarily
  install the command with static linked tar command into the lxc
  cache directory.  The tar command does not refer to passwd/group
  files, which means that only a few files/directories are extracted
  with wrong user/group ownership.  To avoid this, the installpkg
  command now uses the standard tar command in the system.
- Change mode to 666 for $rootfs/dev/null to allow write access for
  all users.
- Small fix in usage message.

Signed-off-by: TAMUKI Shoichi <tamuki@linet.gr.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
10 years agodoc: Fix Japanese translation of lxc.containers.conf(5)
KATOH Yasufumi [Mon, 18 Aug 2014 11:51:53 +0000 (20:51 +0900)] 
doc: Fix Japanese translation of lxc.containers.conf(5)

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agotests: Call sync before testing a shutdown
Stéphane Graber [Mon, 18 Aug 2014 04:00:59 +0000 (00:00 -0400)] 
tests: Call sync before testing a shutdown

This should avoid tests failure when the machine running the tests has
either very slow disks or a lot of data waiting to be flushed.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agodo_mount_entry: add nexec, nosuid, nodev, rdonly flags if needed at remount
Serge Hallyn [Mon, 18 Aug 2014 03:28:21 +0000 (03:28 +0000)] 
do_mount_entry: add nexec, nosuid, nodev, rdonly flags if needed at remount

See http://lkml.org/lkml/2014/8/13/746 and its history.  The kernel now refuses
mounts if we don't add ro,nosuid,nodev,noexec flags if they were already there.

Also use the newly found info to skip remount if unneeded.  For background, if
you want to create a read-only bind mount, then you must first mount(2) with
MS_BIND to create the bind mount, then re-mount(2) again to get the new mount
options to apply.  So if this wasn't a bind mount, or no new mount options were
introduced, then we don't do the second mount(2).

null_endofword() and get_field() were not changed, only moved up in
the file.

(Note, while I can start containers inside a privileged container with
this patch, most of the lxc tests still fail with the kernel in question;
Andy's patch seems to still be needed - a kernel with which is available
at https://launchpad.net/~serge-hallyn/+archive/ubuntu/userns-natty
ppa:serge-hallyn/userns-natty)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agomonitor: fix sockname calculation for long lxcpaths
Serge Hallyn [Sat, 9 Aug 2014 00:30:12 +0000 (00:30 +0000)] 
monitor: fix sockname calculation for long lxcpaths

A long enough lxcpath (and small PATH_MAX through crappy defines) can cause
the creation of the string to be hashed to fail.  So just use alloca to
get the size string we need.

More importantly, while I can't explain it, if lxcpath is too long, setting
sockname[sizeof(addr->sun_path)-2] to \0 simply doesn't seem to work.  So set
sockname[sizeof(addr->sun_path)-3] to \0, which does work.

With this, and with

lxc.lxcpath = /opt/lxc0123456789/lxc0123456789/lxc0123456789/lxc0123456789/lxc0123456789/lxc0123456789/lxc0123456789/lxc0123456789/lxc0123456789/lxc0123456789

in /etc/lxc/lxc.conf, I can run lxc-wait just fine.  Without it, it fails
(as does lxc-start -d, which uses lxc_wait to verify the container started)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agocommand socket: use hash if needed
Serge Hallyn [Sat, 9 Aug 2014 00:28:18 +0000 (00:28 +0000)] 
command socket: use hash if needed

The container command socket is an abstract unix socket containing
the lxcpath and container name.  Those can be too long.  In that case,
use the hash of the lxcpath and lxcname.  Continue to use the path and
name if possible to avoid any back compat issues.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoRevert "chmod container dir to 0770"
Stéphane Graber [Sat, 16 Aug 2014 21:16:36 +0000 (17:16 -0400)] 
Revert "chmod container dir to 0770"

This commit broke the testsuite for unprivileged containers as the
container directory is now 0750 with the owner being the container root
and the group being the user's group, meaning that the parent user can
only enter the directory, not create entries in there.

This reverts commit c86da6a3ac517b78e6f710df7efe2f51d153b73c.

10 years agoFix typo in the previous commit...
Stéphane Graber [Sat, 16 Aug 2014 01:32:34 +0000 (21:32 -0400)] 
Fix typo in the previous commit...

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoAdd extra debugging
Micahel J. Evans [Fri, 11 Jul 2014 03:06:15 +0000 (20:06 -0700)] 
Add extra debugging

This is an hybrid between Micahel's original patch and me making the new
debugging statements look like our existing ones.

Signed-off-by: "Micahel J. Evans" <mjevans1983@gmail.com>
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoUpdated template for ALTLinux.
Denis Pynkin [Fri, 15 Aug 2014 19:06:10 +0000 (22:06 +0300)] 
Updated template for ALTLinux.

- Added predefined package list if /etc/lxc/profiles/default is absent.
- Fixed syntax mistake in options list.

Signed-off-by: Denis Pynkin <dans@altlinux.ru>
Acked-by: Stéphne Graber <stgraber@ubuntu.com>
10 years agodoc: language correction
Lars Wikberg [Fri, 15 Aug 2014 09:48:23 +0000 (12:48 +0300)] 
doc: language correction

Signed-off-by: Lars Wikberg <lars.wikberg@anvia.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoAs discussed on ML, do not clean autodev dir on reboot
Jean-Tiare LE BIGOT [Wed, 13 Aug 2014 08:30:56 +0000 (10:30 +0200)] 
As discussed on ML, do not clean autodev dir on reboot

Signed-off-by: Jean-Tiare LE BIGOT <jean-tiare.le-bigot@ovh.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoclean autodev dir on container exit
Jean-Tiare LE BIGOT [Wed, 13 Aug 2014 08:30:04 +0000 (10:30 +0200)] 
clean autodev dir on container exit

When "lxc.autodev = 1", LXC creates automatically a "/dev/.lxc/<name>.<hash>"
folder to put container's devices in so that they are visible from both
the host and the container itself.

On container exit (ne it normal or not), this folder was not cleaned
which made "/dev" folder grow continuously.

We fix this by adding a new `int lxc_delete_autodev(struct lxc_handler
*handler)` called from `static void lxc_fini(const char *name, struct
lxc_handler *handler)`.

Signed-off-by: Jean-Tiare LE BIGOT <jean-tiare.le-bigot@ovh.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agochmod container dir to 0770
Serge Hallyn [Thu, 14 Aug 2014 18:29:55 +0000 (18:29 +0000)] 
chmod container dir to 0770

This prevents u2 from going into /home/u1/.local/share/lxc/u1/rootfs
and running setuid-root applications to get write access to u1's
container rootfs.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
10 years agocgmanager get/set: clean up child (v2)
Serge Hallyn [Fri, 15 Aug 2014 19:22:02 +0000 (19:22 +0000)] 
cgmanager get/set: clean up child (v2)

(Thanks, Dwight, this one look right?)

Make sure we reap our child at cgm_{s,g}et.

Changelog: Fix change in behavior on empty read from the do_cgm_get()
           helper that was spotted by Dwight.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
10 years agointroduce --with-distro=raspbian
S.Çağlar Onur [Sat, 9 Aug 2014 03:13:27 +0000 (23:13 -0400)] 
introduce --with-distro=raspbian

Raspberry Pi kernel finally supports all the bits required by LXC [1]

This patch makes "./configure --with-distro=raspbian" to install lxcbr0
based config file and upstart jobs.
Also src/lxc/lxc.net now checks the existence of the lxc-dnsmasq user
(and fallbacks to dnsmasq)

RPI users still need to pass
"MIRROR=http://archive.raspbian.org/raspbian/" parameter to lxc-create
to pick the correct packages

MIRROR=http://archive.raspbian.org/raspbian/ lxc-create -t debian -n rpi

[Could be applied to stable-1.0 if you cherry-pick
7157a508ba3015b830877a5e4d6ca9debb3fd064]

[1] https://github.com/raspberrypi/linux/issues/176

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
10 years agolxc-test-unpriv: test lxc-clone -s
Serge Hallyn [Thu, 14 Aug 2014 21:36:01 +0000 (21:36 +0000)] 
lxc-test-unpriv: test lxc-clone -s

This would have caught a regression in Ubuntu's 3.16 kernel.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agocoverity: malloc the right size for btrs_node tree
Serge Hallyn [Mon, 11 Aug 2014 14:10:59 +0000 (14:10 +0000)] 
coverity: malloc the right size for btrs_node tree

We were allocating sizeof(tree) instead of sizeof(*tree).

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agocoverity: don't use newname after null check
Serge Hallyn [Mon, 11 Aug 2014 14:10:04 +0000 (14:10 +0000)] 
coverity: don't use newname after null check

Actually, get rid of the temporary variables, and set newname
and lxcpath to usable values if they were NULL.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agodoc: add lxc.console.logpath to Japanese lxc.container.conf(5)
KATOH Yasufumi [Mon, 11 Aug 2014 10:49:26 +0000 (19:49 +0900)] 
doc: add lxc.console.logpath to Japanese lxc.container.conf(5)

Update for commit 96f15ca

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoubuntu: Check that btrfs is actually available
Stéphane Graber [Fri, 15 Aug 2014 23:59:45 +0000 (19:59 -0400)] 
ubuntu: Check that btrfs is actually available

Before calling btrfs and playing with subvolumes, let's make sure the
btrfs command is available.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agolog_path: free on lxc_conf free (for master)
Serge Hallyn [Fri, 8 Aug 2014 18:27:24 +0000 (18:27 +0000)] 
log_path: free on lxc_conf free (for master)

This is for the master branch, to fix a memleak on conf free.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoEnsure /dev/pts directory exists on pts setup
Jean-Tiare LE BIGOT [Sat, 2 Aug 2014 13:27:13 +0000 (15:27 +0200)] 
Ensure /dev/pts directory exists on pts setup

When `lxc.autodev = 0` and empty tmpfs is mounted on /dev
and private pts are requested, we need to ensure '/dev/pts'
exists before attempting to mount devpts on it.

Signed-off-by: Jean-Tiare LE BIGOT <jean-tiare.le-bigot@ovh.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoFix a file descriptor leak in the monitord spawn
Vincent Giersch [Wed, 11 Jun 2014 14:23:27 +0000 (16:23 +0200)] 
Fix a file descriptor leak in the monitord spawn

Signed-off-by: Vincent Giersch <vincent.giersch@ovh.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoFix a file descriptor leak in the daemonization
Vincent Giersch [Fri, 23 May 2014 09:04:26 +0000 (11:04 +0200)] 
Fix a file descriptor leak in the daemonization

Especially when using the Python API, the child process inherits of
the file descriptiors of the script.

Signed-off-by: Vincent Giersch <vincent.giersch@ovh.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agofix '--log-priority' --> '--logpriority' in main
Jean-Tiare LE BIGOT [Mon, 4 Aug 2014 15:33:44 +0000 (17:33 +0200)] 
fix '--log-priority' --> '--logpriority' in main

Signed-off-by: Jean-Tiare LE BIGOT <jean-tiare.le-bigot@ovh.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoUse portageq to determine portage distdir
rabisg [Thu, 31 Jul 2014 13:10:25 +0000 (18:40 +0530)] 
Use portageq to determine portage distdir

Signed-off-by: Rabi Shanker Guha <guha.rabishankar@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoInclude hostname in DHCP requests
Kalman Olah [Tue, 22 Jul 2014 08:38:42 +0000 (10:38 +0200)] 
Include hostname in DHCP requests

With the current old CentOS template, dnsmasq was not able to resolve
the hostname of an lxc container after it had been created. This minor
change rectifies that.

Signed-off-by: Kalman Olah <hello@kalmanolah.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agossh: send hostname to dhcp server
Nikolay Martynov [Tue, 22 Jul 2014 00:12:01 +0000 (20:12 -0400)] 
ssh: send hostname to dhcp server

Send container's hostname to dhcp server when getting ip address.

Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agotemplates: switch from arch command to uname -m
Michael Werner [Mon, 21 Jul 2014 18:57:17 +0000 (20:57 +0200)] 
templates: switch from arch command to uname -m

Signed-off-by: Michael Werner <xaseron@googlemail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoDo not allow snapshots of LVM backed containers
Serge Hallyn [Fri, 8 Aug 2014 15:00:18 +0000 (15:00 +0000)] 
Do not allow snapshots of LVM backed containers

They don't work right now, so until we fix that, don't allow it.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoubuntu templates: don't check for $rootfs/run/shm
Serge Hallyn [Thu, 7 Aug 2014 03:23:48 +0000 (03:23 +0000)] 
ubuntu templates: don't check for $rootfs/run/shm

/dev/shm must be turned from a directory into a symlink to /run/shm.
The templates do this only if they find -d $rootfs/run/shm.  Since /run
will be a tmpfs, checking for it in the rootfs is silly.  It also is
currently broken as ubuntu cloud images have an empty /run.

(this should fix https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1353734)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoadd lxc.console.logpath
Serge Hallyn [Wed, 6 Aug 2014 22:39:45 +0000 (22:39 +0000)] 
add lxc.console.logpath

v2: add get_config_item

clear_config_item is not supported, as it isn't for lxc.console, bc
you can do 'lxc.console.logfile =' to clear it.  Likewise save_config
is not needed because the config is now just written through the
unexpanded char*.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoAdd lxc.net to the dist tarball
Stéphane Graber [Mon, 4 Aug 2014 20:15:46 +0000 (16:15 -0400)] 
Add lxc.net to the dist tarball

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agounexpanded config file: turn into a string
Serge Hallyn [Fri, 1 Aug 2014 23:34:16 +0000 (23:34 +0000)] 
unexpanded config file: turn into a string

Originally, we only kept a struct lxc_conf representing the current
container configuration.  This was insufficient because lxc.include's
were expanded, so a clone or a snapshot would contain the expanded
include file contents, rather than the original "lxc.include".  If
the host's include files are updated, clones and snapshots would not
inherit those updates.

To address this, we originally added a lxc_unexp_conf, which mirrored
the lxc_conf, except that lxc.include was not expanded.

This has its own cshortcomings, however,  In particular, if a lxc.include
has a lxc.cgroup setting, and you use the api to say:

c.clear_config_item("lxc.cgroup")

this is not representable in the lxc_unexp_conf.  (The original problem,
which was pointed out to me by stgraber, was slightly different, but
unlike this problem it was not unsolvable).

This patch changes the unexpanded configuration  to be a textual
representation of the configuration.  This allows us *order* the
configuration commands, which is what was not possible using the
struct lxc_conf *lxc_unexp_conf.

The write_config() now becomes a simple fwrite.  However, lxc_clone
is slightly complicated in parts, the worst of which is the need to
rewrite the network configuration if we are changing the macaddrs.

With this patch, lxc-clone and clear_config_item do the right thing.
lxc-test-saveconfig and lxc-test-clonetest both pass.

There is room for improvement - multiple calls to

c.append_config_item("lxc.network.link", "lxcbr0")

will result in multiple such lines in the configuration file.  In that
particular case it is harmless.  There may be cases where it is not.

Overall, this should be a huge improvement in terms of correctness.

Changelog: Aug 1: updated to current lxc git head.  All lxc-test* and
   python api test passed.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agobtrfs: support recursive subvolume deletion (v2)
Serge Hallyn [Fri, 1 Aug 2014 22:55:21 +0000 (22:55 +0000)] 
btrfs: support recursive subvolume deletion (v2)

Pull the #defines and struct definitions for btrfs into a separate
.h file to not clutter bdev.c

Implement btrfs recursive delete support

A non-root user isn't allow to do the ioctls needed for searching (as you can
verify with 'btrfs subvolume list').  So for an unprivileged user, if the
rootfs has subvolumes under it, deletion will fail.  Otherwise, it will
succeed.

Changelog: Aug 1:
  . Fix wrong objid passing when determining directory paths
  . In do_remove_btrfs_children, avoid dereferencing NULL dirid
  . Fix memleak in error case.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agodoc: Add 'zfs' to the parameter of -B option in lxc-create(1)
KATOH Yasufumi [Fri, 1 Aug 2014 10:37:57 +0000 (19:37 +0900)] 
doc: Add 'zfs' to the parameter of -B option in lxc-create(1)

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agodoc: Update the description of SELinux in Japanese lxc.container.conf(5)
KATOH Yasufumi [Fri, 1 Aug 2014 10:37:56 +0000 (19:37 +0900)] 
doc: Update the description of SELinux in Japanese lxc.container.conf(5)

Update for commit 719fae0

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agodoc: Add the description of lxc.environment to Japanese lxc.container.conf(5)
KATOH Yasufumi [Fri, 1 Aug 2014 10:37:55 +0000 (19:37 +0900)] 
doc: Add the description of lxc.environment to Japanese lxc.container.conf(5)

Update for commit 7c66172

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agodoc: Change default to "-d" in Japanese lxc-start(1)
KATOH Yasufumi [Fri, 1 Aug 2014 10:37:54 +0000 (19:37 +0900)] 
doc: Change default to "-d" in Japanese lxc-start(1)

Update for commit c00f3f3

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agodoc: Add -F option to Japanese lxc-start(1)
KATOH Yasufumi [Fri, 1 Aug 2014 10:37:53 +0000 (19:37 +0900)] 
doc: Add -F option to Japanese lxc-start(1)

Update for commit 476d302

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoInstall systemd units for Ubuntu
Martin Pitt [Thu, 31 Jul 2014 06:53:56 +0000 (08:53 +0200)] 
Install systemd units for Ubuntu

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agosystemd: Load AppArmor profiles if necessary/supported
Martin Pitt [Fri, 1 Aug 2014 05:00:34 +0000 (07:00 +0200)] 
systemd: Load AppArmor profiles if necessary/supported

On Ubuntu we need to set up the AppArmor profiles also under systemd.
Add a new helper "lxc-apparmor-load" and integrate it into lxc.service.

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agosystemd: Ensure action() is defined
Martin Pitt [Thu, 31 Jul 2014 06:53:54 +0000 (08:53 +0200)] 
systemd: Ensure action() is defined

If /etc/rc.d/init.d/functions is not present or does not define an action()
function, provide a simple fallback using "echo".

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoAdd systemd unit for lxc.net
Martin Pitt [Thu, 31 Jul 2014 06:53:53 +0000 (08:53 +0200)] 
Add systemd unit for lxc.net

This is the equivalent of the upstart lxc-net.conf to set up the LXC bridge.

This also drops "lxc.service" from tarballs. It is built source which depends
on configure options, so the statically shipped file will not work on most
systems.

https://launchpad.net/bugs/1312532

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoGet systemd unit dir from pkg-config
Martin Pitt [Thu, 31 Jul 2014 06:53:52 +0000 (08:53 +0200)] 
Get systemd unit dir from pkg-config

Don't install systemd unit files into $(prefix), they won't work there.
Instead, get them from systemd's pkg-config file.

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoMove lxcbr0 setup logic into lxc.net script
Martin Pitt [Thu, 31 Jul 2014 06:53:51 +0000 (08:53 +0200)] 
Move lxcbr0 setup logic into lxc.net script

Factor this out of the lxc-net.conf upstart job, so that it can be used by
init.d scripts and systemd units, too.

Part of https://launchpad.net/bugs/1312532

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agouse non-thread-safe getpwuid and getpwgid for android
Serge Hallyn [Thu, 31 Jul 2014 19:54:27 +0000 (19:54 +0000)] 
use non-thread-safe getpwuid and getpwgid for android

We only call it (so far) after doing a fork(), so this is fine.  If we
ever need such a thing from threaded context, we'll simply need to write
our own version for android.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoprint a helpful message if creating unpriv container with no idmap
Serge Hallyn [Tue, 29 Jul 2014 18:26:29 +0000 (18:26 +0000)] 
print a helpful message if creating unpriv container with no idmap

This gives me:

ubuntu@c-t1:~$ lxc-create -t download -n u1
lxc_container: No mapping for container root
lxc_container: Error chowning /home/ubuntu/.local/share/lxc/u1/rootfs to container root
lxc_container: You must either run as root, or define uid mappings
lxc_container: To pass uid mappings to lxc-create, you could create
lxc_container: ~/.config/lxc/default.conf:
lxc_container: lxc.include = /etc/lxc/default.conf
lxc_container: lxc.id_map = u 0 100000 65536
lxc_container: lxc.id_map = g 0 100000 65536
lxc_container: Error creating backing store type (none) for u1
lxc_container: Error creating container u1

when I create a container without having an id mapping defined.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoprovide an example SELinux policy for older releases
Dwight Engen [Thu, 24 Jul 2014 21:25:46 +0000 (17:25 -0400)] 
provide an example SELinux policy for older releases

The virtd_lxc_t type provided by the default RHEL/CentOS/Oracle 6.5
policy is an unconfined_domain(), so it doesn't really enforce anything.
This change will provide a link in the documentation to an example
policy that does confine containers.

On more recent distributions with new enough policy, it is recommended
not to use this sample policy, but to use the types already available
on the system from /etc/selinux/targeted/contexts/lxc_contexts, ie:

process = "system_u:system_r:svirt_lxc_net_t:s0"
file = "system_u:object_r:svirt_sandbox_file_t:s0"

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoAdd the remaining bits for lxc.environment
Stéphane Graber [Mon, 21 Jul 2014 16:20:58 +0000 (18:20 +0200)] 
Add the remaining bits for lxc.environment

This adds the few missing bits so that the new lxc.environment config
entry can be queried, cleared and saved as the others are.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoSupport providing env vars to container init
Matt Palmer [Tue, 1 Jul 2014 07:01:39 +0000 (17:01 +1000)] 
Support providing env vars to container init

It's quite useful to be able to configure containers by specifying
environment variables, which init (or initscripts) can use to adjust the
container's operation.

This patch adds one new configuration parameter, `lxc.environment`, which
can be specified zero or more times to define env vars to set in the
container, like this:

    lxc.environment = APP_ENV=production
    lxc.environment = SYSLOG_SERVER=192.0.2.42
    lxc.environment = SOMETHING_FUNNY=platypus

Default operation is unchanged; if the user doesn't specify any
lxc.environment parameters, the container environment will be what it is
today ('container=lxc').

Signed-off-by: Matt Palmer <mpalmer@hezmatt.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agodownload: Have wget retry 3 times
Stéphane Graber [Mon, 21 Jul 2014 10:25:20 +0000 (12:25 +0200)] 
download: Have wget retry 3 times

This forces wget to retry if it gets a network error.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-start: Daemonize by default
Stéphane Graber [Mon, 21 Jul 2014 09:52:19 +0000 (11:52 +0200)] 
lxc-start: Daemonize by default

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-start: Add -F (foreground) option
Stéphane Graber [Mon, 21 Jul 2014 09:50:49 +0000 (11:50 +0200)] 
lxc-start: Add -F (foreground) option

Introduce a new -F option (no-op for now) as an opposite of -d.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoMerge pull request #285 from martinpitt/master
hallyn [Wed, 30 Jul 2014 14:53:36 +0000 (09:53 -0500)] 
Merge pull request #285 from martinpitt/master

apparmor: Allow slave bind mounts

11 years agoapparmor: Allow slave bind mounts 285/head
Martin Pitt [Wed, 30 Jul 2014 14:43:10 +0000 (16:43 +0200)] 
apparmor: Allow slave bind mounts

Without this, if the system uses shared subtrees by default (like systemd), you
get a large stream of

  lxc-start: Permission denied - Failed to make /<mountpoint> rslave
  lxc-start: Continuing...

with

  apparmor="DENIED" operation="mount" info="failed flags match" error=-13
  profile="/usr/bin/lxc-start" name="/" pid=17284 comm="lxc-start" flags="rw, slave"

and eventual failure plus a lot of leftover mounts in the host.

https://launchpad.net/bugs/1325468

11 years agoadd help string for ubuntu templete
Trần Ngọc Quân [Mon, 28 Jul 2014 08:34:54 +0000 (15:34 +0700)] 
add help string for ubuntu templete

Signed-off-by: Trần Ngọc Quân <vnwildman@gmail.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agofix typo in btrfs error msg
Serge Hallyn [Sun, 27 Jul 2014 15:53:54 +0000 (10:53 -0500)] 
fix typo in btrfs error msg

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agofix typo
Serge Hallyn [Wed, 23 Jul 2014 15:19:24 +0000 (10:19 -0500)] 
fix typo

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoSupport openvswitch bridges
Serge Hallyn [Mon, 21 Jul 2014 22:48:55 +0000 (17:48 -0500)] 
Support openvswitch bridges

We detect whether ovs-vsctl is available.  If so, then we support
adding network interfaces to openvswitch bridges with it.

Note that with this patch, veths do not appear to be removed from the
openvswitch bridge.  This seems a bug in openvswitch, as the veths
in fact do disappear from the system.  If lxc is required to remove
the port from the bridge manually, that becomes more complicated
for unprivileged containers, as it would require a setuid-root
wrapper to be called at shutdown.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agounprivileged containers: use next available nic name if unspecified
Serge Hallyn [Mon, 21 Jul 2014 21:36:44 +0000 (16:36 -0500)] 
unprivileged containers: use next available nic name if unspecified

Rather than always using eth0.  Otherwise unpriv containers cannot have
multiple lxc.network.type = veth's without manually setting
lxc.network.name =.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoSysvinit script fixes
Ansa89 [Thu, 17 Jul 2014 08:53:30 +0000 (10:53 +0200)] 
Sysvinit script fixes

Signed-off-by: Stefano Ansaloni <ansalonistefano@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoAdd SIGPWR support to lxc_init
Nikolay Martynov [Sun, 20 Jul 2014 19:35:04 +0000 (15:35 -0400)] 
Add SIGPWR support to lxc_init

This patch adds SIGPWR support to lxc_init.
This helps to properly shutdown lxc_init based containers.

Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoremove mountcgroup hook entirely
Serge Hallyn [Thu, 17 Jul 2014 22:20:34 +0000 (17:20 -0500)] 
remove mountcgroup hook entirely

Also fix the comment in lxc-cirros template (which I overlooked last time).

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoRemove mention of mountcgroups in ubuntu.common config
Serge Hallyn [Thu, 17 Jul 2014 14:05:35 +0000 (09:05 -0500)] 
Remove mention of mountcgroups in ubuntu.common config

That mount hook predates the lxc.mount.auto = cgroup option.  So mention
that instead.

Perhaps we should simply drop the mountcgroup hook from the tree, but
I'm not doing that in this patch.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-test-{unpriv,usernic.in}: make sure to chgrp as well
Serge Hallyn [Thu, 17 Jul 2014 21:02:06 +0000 (16:02 -0500)] 
lxc-test-{unpriv,usernic.in}: make sure to chgrp as well

These tests are failing on new kernels because the container root is
not privileged over the directories, since privilege no requires
the group being mapped into the container.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agodoc: Add mention that veth.pair is ignored for unpriv in Japanese man
KATOH Yasufumi [Wed, 16 Jul 2014 16:32:38 +0000 (01:32 +0900)] 
doc: Add mention that veth.pair is ignored for unpriv in Japanese man

Update Japanese lxc.container.conf(5) for commit 8982c0f

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agodoc: Mention that veth.pair is ignored for unpriv
Stéphane Graber [Wed, 16 Jul 2014 01:32:46 +0000 (21:32 -0400)] 
doc: Mention that veth.pair is ignored for unpriv

veth.pair is ignore for unprivileged containers as allowing an
unprivileged user to set a specific device name would allow them to
trigger actions in tools like NetworkManager or other uevent based
handlers that may react based on specific names or prefixes being used.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agocentos template: prevent mingetty from calling vhangup(2)
Claudio Alarcon-Reyes [Fri, 11 Jul 2014 15:32:32 +0000 (11:32 -0400)] 
centos template: prevent mingetty from calling vhangup(2)

When using unprivileged containers, tty fails because of vhangup. Adding
--nohangup to nimgetty, it fixes the issue. This is the same problem
occurred for oracle template, commit 2e83f7201c5d402478b9849f0a85c62d5b9f1589

Signed-off-by: Claudio Alarcon clalarco@gmail.com
11 years agoFix typo in previous patch
Stéphane Graber [Mon, 14 Jul 2014 19:44:41 +0000 (15:44 -0400)] 
Fix typo in previous patch

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoconfile: sanity-check netdev->type before setting netdev->priv elements
Serge Hallyn [Mon, 14 Jul 2014 18:51:41 +0000 (18:51 +0000)] 
confile: sanity-check netdev->type before setting netdev->priv elements

The netdev->priv is shared for the netdev types.  A bad config file
could mix configuration for different types, resulting in a bad
netdev->priv when starting or even destroying a container.  So sanity
check the netdev->type before setting a netdev->priv element.

This should fix https://github.com/lxc/lxc/issues/254

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agorootfs_is_blockdev: don't run if no rootfs is specified
Serge Hallyn [Mon, 14 Jul 2014 18:22:53 +0000 (13:22 -0500)] 
rootfs_is_blockdev: don't run if no rootfs is specified

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agotests: lxc-test-ubuntu doesn't actually need bind9-host
Stéphane Graber [Wed, 9 Jul 2014 17:30:54 +0000 (13:30 -0400)] 
tests: lxc-test-ubuntu doesn't actually need bind9-host

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agotests: Clarify error message and fix return codes
Stéphane Graber [Wed, 9 Jul 2014 17:17:54 +0000 (13:17 -0400)] 
tests: Clarify error message and fix return codes

Reported-by: Michael J. Evans
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-debian: added support for package installation
Alexander Dreweke [Tue, 8 Jul 2014 05:17:37 +0000 (07:17 +0200)] 
lxc-debian: added support for package installation

- added --mirror, --security-mirror and --package parameters
- generate source.list
- install packages into final lxc instance

Signed-off-by: Alexander Dreweke <alexander@dreweke.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-debian: standardize formatting
Alexander Dreweke [Tue, 8 Jul 2014 05:16:54 +0000 (07:16 +0200)] 
lxc-debian: standardize formatting

Signed-off-by: Alexander Dreweke <alexander@dreweke.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-debian: fix formatting
Alexander Dreweke [Tue, 8 Jul 2014 05:15:31 +0000 (07:15 +0200)] 
lxc-debian: fix formatting

added space ">/" -> ">  /"

Signed-off-by: Alexander Dreweke <alexander@dreweke.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agochange version to 1.1.0.alpha1 in configure.ac lxc-1.1.0.alpha1
Stéphane Graber [Mon, 7 Jul 2014 16:49:12 +0000 (12:49 -0400)] 
change version to 1.1.0.alpha1 in configure.ac

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoAlso add --verison support to lxc-start-ephemeral
Stéphane Graber [Mon, 7 Jul 2014 16:48:07 +0000 (12:48 -0400)] 
Also add --verison support to lxc-start-ephemeral

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-ubuntu: update coding style
José Martínez [Sun, 6 Jul 2014 20:11:41 +0000 (22:11 +0200)] 
lxc-ubuntu: update coding style

Signed-off-by: José Martínez <xosemp@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-ubuntu: fix btrfs when rootfs == realrootfs
José Martínez [Sun, 6 Jul 2014 19:55:41 +0000 (21:55 +0200)] 
lxc-ubuntu: fix btrfs when rootfs == realrootfs

Fix btrfs support when lxc-create does not bind-mount the rootfs.

Signed-off-by: José Martínez <xosemp@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoAdd support for --version to lxc-ls and lxc-device
Stéphane Graber [Mon, 7 Jul 2014 14:17:28 +0000 (10:17 -0400)] 
Add support for --version to lxc-ls and lxc-device

This is based on the patch submitted by:
 Yuto KAWAMURA(kawamuray) <kawamuray.dadada@gmail.com>

Updated to use lxc.version rather than @LXC_VERSION@ and to apply to
both lxc-ls and lxc-device rather than just the former.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoFix attach_wait and threads
Dorian Eikenberg [Sun, 6 Jul 2014 17:44:19 +0000 (19:44 +0200)] 
Fix attach_wait and threads

Signed-off-by: Dorian Eikenberg <dorian.eikenberg@uni-duesseldorf.de>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoFix incorrect timeout handling of do_reboot_and_check()
Yuto KAWAMURA(kawamuray) [Fri, 4 Jul 2014 17:35:09 +0000 (02:35 +0900)] 
Fix incorrect timeout handling of do_reboot_and_check()

Currently do_reboot_and_check() is decreasing timeout variable even if
it is set to -1, so running 'lxc-stop --reboot --timeout=-1 ...' will
exits immediately at end of second iteration of loop, without waiting
container reboot.
Also, there is no need to call gettimeofday if timeout is set to -1, so
these statements should be evaluated only when timeout is enabled.

Signed-off-by: Yuto KAWAMURA(kawamuray) <kawamuray.dadada@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoChange find_fstype_cb to ignore blank lines and comments
Yuto KAWAMURA(kawamuray) [Fri, 4 Jul 2014 17:40:02 +0000 (02:40 +0900)] 
Change find_fstype_cb to ignore blank lines and comments

/etc/filesystems could be contain blank lines and comments.
Change find_fstype_cb() to ignore blank lines and comments which starts
with '#'.

Signed-off-by: Yuto KAWAMURA(kawamuray) <kawamuray.dadada@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-oracle: mount cgroup:mixed
Dwight Engen [Thu, 3 Jul 2014 19:32:12 +0000 (15:32 -0400)] 
lxc-oracle: mount cgroup:mixed

- Mounting cgroup:mixed prevents systemd inside the container from
  moving its children out of the cgroups lxc setup. This ensure the
  limits setup in the configuration or with lxc-cgroup are effective.

- Update for the OL7 channel name that will be used on
  public-yum.oracle.com.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agomake the container exit code propagate to lxc-start exit code when appropriate
Rodrigo Vaz [Thu, 3 Jul 2014 18:39:51 +0000 (15:39 -0300)] 
make the container exit code propagate to lxc-start exit code when appropriate

Signed-off-by: Rodrigo Sampaio Vaz <rodrigo@heroku.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agochown_mapped_root: don't try chgrp if we don't own the file
Serge Hallyn [Thu, 3 Jul 2014 18:57:57 +0000 (13:57 -0500)] 
chown_mapped_root: don't try chgrp if we don't own the file

New kernels require that to have privilege over a file, your
userns must have the old and new groups mapped into your userns.
So if a file is owned by our uid but another groupid, then we
have to chgrp the file to our primary group before we can try
(in a new user namespace) to chgrp the file to a group id in the
namespace.

But in some cases (when cloning) the file may already be mapped
into the container.  Now we cannot chgrp the file to our own
primary group - and we don't have to.

So detect that case.  Only try to chgrp the file to our primary
group if the file is owned by our euid (i.e. not by the container)
and the owning group is not already mapped into the container by
default.

With this patch, I'm again able to both create and clone containers
with no errors again.

Reported-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoEnable default seccomp profile for all distros
Stéphane Graber [Wed, 2 Jul 2014 01:38:18 +0000 (21:38 -0400)] 
Enable default seccomp profile for all distros

This updates the common config to include Serge's seccomp profile by
default for privileged containers.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoMerge pull request #244 from xose/btrfs
hallyn [Mon, 30 Jun 2014 21:18:35 +0000 (16:18 -0500)] 
Merge pull request #244 from xose/btrfs

lxc-ubuntu: use btrfs subvolumes and snapshots

11 years agoApparmor: allow hugetlbfs mounts everywhere
Jesse Tane [Mon, 30 Jun 2014 19:37:52 +0000 (15:37 -0400)] 
Apparmor: allow hugetlbfs mounts everywhere

Signed-off-by: Jesse Tane <jesse.tane@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoCast to gid_t to fix android build failure
Stéphane Graber [Mon, 30 Jun 2014 17:08:48 +0000 (13:08 -0400)] 
Cast to gid_t to fix android build failure

stat.st_gid is unsigned long in bionic instead of the expected gid_t, so
just cast it to gid_t.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoFix to work lxc-destroy with unprivileged containers on recent kernel
TAMUKI Shoichi [Sat, 28 Jun 2014 09:39:54 +0000 (18:39 +0900)] 
Fix to work lxc-destroy with unprivileged containers on recent kernel

Change idmap_add_id() to add both ID_TYPE_UID and ID_TYPE_GID entries
to an existing lxc_conf, not just an ID_TYPE_UID entry, so as to work
lxc-destroy with unprivileged containers on recent kernel.

Signed-off-by: TAMUKI Shoichi <tamuki@linet.gr.jp>
Acked-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoFix to work lxc-start with unprivileged containers on recent kernel
TAMUKI Shoichi [Fri, 27 Jun 2014 08:29:01 +0000 (17:29 +0900)] 
Fix to work lxc-start with unprivileged containers on recent kernel

Change chown_mapped_root() to map in both the root uid and gid, not
just the uid, so as to work lxc-start with unprivileged containers on
recent kernel.

Signed-off-by: TAMUKI Shoichi <tamuki@linet.gr.jp>
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoDon't call sig_name twice, use pointer instead
Alexander Vladimirov [Fri, 27 Jun 2014 17:32:30 +0000 (01:32 +0800)] 
Don't call sig_name twice, use pointer instead

Signed-off-by: Alexander Vladimirov <alexander.idkfa.vladimirov@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agocgm_get: make sure @value is null-terminated
Serge Hallyn [Fri, 27 Jun 2014 18:51:33 +0000 (13:51 -0500)] 
cgm_get: make sure @value is null-terminated

Previously this was done by strncpy, but now we just read
the len bytes - not including \0 - from a pipe, so pre-fill
@value with 0s to be safe.

This fixes the python3 api_test failure.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agocgmanager: have cgm_set and cgm_get use absolute path when possible
Serge Hallyn [Thu, 26 Jun 2014 21:44:46 +0000 (16:44 -0500)] 
cgmanager: have cgm_set and cgm_get use absolute path when possible

This allows users to get/set cgroup settings when logged into a different
session than that from which they started the container.

There is no cgmanager command to do an _abs variant of cgmanager_get_value
and cgmanager_set_value.  So we fork off a new task, which enters the
parent cgroup of the started container, then can get/set the value from
there.  The reason not to go straight into the container's cgroup is that
if we are freezing the container, or the container is already frozen, we'll
freeze as well :)  The reason to fork off a new task is that if we are
in a cgroup which is set to remove-on-empty, we may not be able to return
to our original cgroup after making the change.

This should fix https://github.com/lxc/lxc/issues/246

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>