]> git.proxmox.com Git - mirror_lxc.git/log
mirror_lxc.git
10 years agolxc-autostart: don't set timeout if user requested -s
KATOH Yasufumi [Tue, 24 Dec 2013 14:33:04 +0000 (23:33 +0900)]
lxc-autostart: don't set timeout if user requested -s

same as the commit 25070b660187b61aa4e969db01b55d1360639543

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agocoverity: make sure not to close file handle twice
Serge Hallyn [Tue, 24 Dec 2013 16:03:43 +0000 (10:03 -0600)]
coverity: make sure not to close file handle twice

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoUse getmntent_r() for thread-safety
Andrey Mazo [Tue, 24 Dec 2013 10:44:54 +0000 (14:44 +0400)]
Use getmntent_r() for thread-safety

Signed-off-by: Andrey Mazo <mazo@telum.ru>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoRemove process_lock() except where actually needed
Andrey Mazo [Tue, 24 Dec 2013 10:44:53 +0000 (14:44 +0400)]
Remove process_lock() except where actually needed

Functions like open(), close(), socket(), socketpair(), pipe() and mkdir()
are generally thin wrappers around kernel-provided system calls.
It's the kernel not libc, who ensures race-free handling of file
descriptors.
Thus locking around these functions is unnecessary even on somewhat buggy libcs.

fopen(), fclose() and other stdio functions may maintain internal lists
of open file handles and thus can be prone to race-conditions.
Hopefully, most libcs utilize proper locking or other ways to ensure
thread-safety of these functions.
Bionic used to have non-thread-safe stdio [2] but that must be fixed
since android 4.3 [3, 4].

S.Çağlar Onur showed [1] that openpty() (because of nsswitch) is not thread-safe though.
So we workaround it by protecting openpty() calls with process_lock()/process_unlock().

Because of the need to guard openpty() with process_lock()/process_unlock(),
process_unlock() is still used after fork().

This commit reverts most of 025ed0f3911836b71f498d8368725c77a7e1932a.

[1] https://github.com/lxc/lxc/pull/106#issuecomment-31077269
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=687367
[3] https://android.googlesource.com/platform/bionic/+/f582340a6a48588aa50da17e1620e8f91b146941
[4] https://android.googlesource.com/platform/bionic/+/6b3f49a5374305ce9690c3c5ca2aadc90f54c521

Signed-off-by: Andrey Mazo <mazo@telum.ru>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agodoc: Fix the description of -n option in lxc-info(1)
KATOH Yasufumi [Tue, 24 Dec 2013 06:56:23 +0000 (15:56 +0900)]
doc: Fix the description of -n option in lxc-info(1)

Commit 5444216 revised -n option from allowing to specify multiple
containers using regex to specifying only one container. But
lxc-info(1) remains original. so
- mark -n required
- remove the description of -n that is included in common options

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agodoc: Update Japanese lxc-stop(1) for -s option
KATOH Yasufumi [Tue, 24 Dec 2013 04:46:35 +0000 (13:46 +0900)]
doc: Update Japanese lxc-stop(1) for -s option

Update for commit 25070b660187b61aa4e969db01b55d1360639543

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoconfigure: Disable python3 builds with clang
Stéphane Graber [Mon, 23 Dec 2013 21:11:58 +0000 (22:11 +0100)]
configure: Disable python3 builds with clang

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoconfigure: Add GnuTLS to configure overview
Stéphane Graber [Mon, 23 Dec 2013 21:12:17 +0000 (22:12 +0100)]
configure: Add GnuTLS to configure overview

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoFix invalid free() in lxc_global_config_value().
Andrey Mazo [Mon, 23 Dec 2013 17:17:10 +0000 (21:17 +0400)]
Fix invalid free() in lxc_global_config_value().

Commit 4878dac496543dae0a26f5c1156bbfda63c8ea62 introduced possible
incorrect usage of free().
Also remove unneeded strdup().

Signed-off-by: Andrey Mazo <mazo@telum.ru>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoRevert "coverity-detected bug: don't free "/""
Serge Hallyn [Mon, 23 Dec 2013 18:32:23 +0000 (12:32 -0600)]
Revert "coverity-detected bug: don't free "/""

This reverts commit 5cad2f04bec614a84e872f68697b5092a409d5a1.

10 years agoRevert "remove static_lock()/static_unlock() and start to use thread local storage...
Serge Hallyn [Mon, 23 Dec 2013 18:27:32 +0000 (12:27 -0600)]
Revert "remove static_lock()/static_unlock() and start to use thread local storage (v2)"

This reverts commit 95b422fccfed6e6f5973c768c0cfdbca65c68e67.

Conflicts:
src/lxc/utils.c

10 years agocoverity-detected bug: don't free "/"
Serge Hallyn [Mon, 23 Dec 2013 17:14:58 +0000 (11:14 -0600)]
coverity-detected bug: don't free "/"

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agolxc-stop: don't set timeout if user requested -s
Serge Hallyn [Mon, 23 Dec 2013 16:23:38 +0000 (10:23 -0600)]
lxc-stop: don't set timeout if user requested -s

A timeout means wait this long before killing the container.
-s means don't kill the container.  timeout defaults to 60
seconds.  So if a shutdown is requested, then set timeout to
0.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoSet default paths for unprivileged use (v2)
Stéphane Graber [Fri, 20 Dec 2013 13:28:32 +0000 (14:28 +0100)]
Set default paths for unprivileged use (v2)

When running unprivileged (euid != 0), LXC will now use the following paths:
 - Default lxc path: ~/.local/share/lxc/
 - Default config path: ~/.config/lxc/lxc.conf

Those two paths are based on standard XDG paths (though ignoring all the
possible override paths for now at least) and so probably don't need to
be configurable at build time.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoremove LXC_CLONE_COPYHOOKS and make lxcapi_clone to copy hooks unconditionally (v3)
S.Çağlar Onur [Sat, 21 Dec 2013 19:48:41 +0000 (14:48 -0500)]
remove LXC_CLONE_COPYHOOKS and make lxcapi_clone to copy hooks unconditionally (v3)

changes since v1;
incorporated Serge's changes
changes since v2;
added missing Signed-off-by

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoplamo: Update template since rc script of plamo was updated
KATOH Yasufumi [Sun, 22 Dec 2013 12:02:05 +0000 (21:02 +0900)]
plamo: Update template since rc script of plamo was updated

Signed-off-by: TAMUKI Shoichi <tamuki@linet.gr.jp>
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agodoc: Improve Japanese translation of lxc-stop(1)
KATOH Yasufumi [Sat, 21 Dec 2013 12:00:18 +0000 (21:00 +0900)]
doc: Improve Japanese translation of lxc-stop(1)

Signed-off-by: Kouhei Maeda <mkouhei@gmail.com>
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoFix coverity-detected memory leak
Stéphane Graber [Fri, 20 Dec 2013 15:09:07 +0000 (16:09 +0100)]
Fix coverity-detected memory leak

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agodoc: Add Japanese lxc-autostart(1) and update lxc.conf(5)
KATOH Yasufumi [Fri, 20 Dec 2013 12:27:45 +0000 (21:27 +0900)]
doc: Add Japanese lxc-autostart(1) and update lxc.conf(5)

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoconf.c: fix unprivileged network case
Serge Hallyn [Thu, 19 Dec 2013 21:33:22 +0000 (15:33 -0600)]
conf.c: fix unprivileged network case

If unprivileged users are using a veth nic, then ifindex is still 0
at lxc_assign_network() (because lxc_create_network() was skipped).
So check for that case before we use lxc->ifindex to decide if we
have an empty network namespace.

We probably should change the !netdev->ifindex check to a
netdev->type == LXC_NET_EMPTY check, but I've been making enough
mistakes today not to risk that.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agocgroup: don't set clone_children when it is already 1
Serge Hallyn [Thu, 19 Dec 2013 21:18:24 +0000 (15:18 -0600)]
cgroup: don't set clone_children when it is already 1

In particular, if it's already 1, and we can't change it, we currently
fail out.  That's silly.

I was going to just always continue, but if clone_children is not 1,
then the container *will* fail to start later on, so I'd rather stop
earlier on so the original cause doesn't get lost in the noise.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoCatch the python packages when building them.
Michael H. Warfield [Thu, 19 Dec 2013 16:38:53 +0000 (11:38 -0500)]
Catch the python packages when building them.

If we have "with_python" we want to add the resulting packages to
the resulting rpm.

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoAdd lxc-autostart
Stéphane Graber [Mon, 16 Dec 2013 20:32:47 +0000 (15:32 -0500)]
Add lxc-autostart

This introduces a new lxc-autostart binary (and associated manpage)
which will let you start/shutdown/kill/restart any container that's
marked as lxc.start.auto=1. It respects the lxc.start.delay value,
sorts by lxc.start.order and filters by lxc.group.

By default it'll affect all containers that DO NOT have lxc.group
set. If -g is specified, ONLY containers in those group will be
affected. To have a command applied to all containers, the -a
argument can be used.

A -L flag is also offered for distributions wishing to start the
containers themselves while still using LXC's calculated order and
wait delays. Instead of performing the action, it'll print the container
name and (if relevant for the action) the wait time.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
10 years agolxc-ls: Add workaround for nested containers
Stéphane Graber [Mon, 16 Dec 2013 20:09:07 +0000 (15:09 -0500)]
lxc-ls: Add workaround for nested containers

When accessing nested containers, hardcode the path to their config.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
10 years agolxc-ls: Add lxc.start.auto and lxc.group support
Stéphane Graber [Mon, 16 Dec 2013 19:51:37 +0000 (14:51 -0500)]
lxc-ls: Add lxc.start.auto and lxc.group support

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
10 years agoautostart: Define lxc.start.* and lxc.group
Stéphane Graber [Sun, 22 Sep 2013 01:30:06 +0000 (21:30 -0400)]
autostart: Define lxc.start.* and lxc.group

First patch in the set of changes required for container autostart.

This commit adds the new configuration keys and parsers that will then
be used by lxc-start and lxc-stop.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
10 years agofix lxc-usernsexec regression
Serge Hallyn [Thu, 19 Dec 2013 19:59:30 +0000 (13:59 -0600)]
fix lxc-usernsexec regression

In what should have been a straightforward fix for a bug found by
priority, I sent 1 instead of '1' from parent to child, while the
child checked for '1'.  Fix.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoremove static_lock()/static_unlock() and start to use thread local storage (v2)
S.Çağlar Onur [Thu, 19 Dec 2013 05:08:51 +0000 (00:08 -0500)]
remove static_lock()/static_unlock() and start to use thread local storage (v2)

While testing https://github.com/lxc/lxc/pull/106, I found that concurrent starts
are hanging time to time. I then reproduced the same problem in master and got following;

 [caglar@oOo:~] sudo gdb -p 16221
 (gdb) bt
 #0  __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
 #1  0x00007f495526515c in _L_lock_982 () from /lib/x86_64-linux-gnu/libpthread.so.0
 #2  0x00007f4955264fab in __GI___pthread_mutex_lock (mutex=0x7f49556d4600 <static_mutex>) at pthread_mutex_lock.c:64
 #3  0x00007f49554b27a6 in lock_mutex (l=l@entry=0x7f49556d4600 <static_mutex>) at lxclock.c:78
 #4  0x00007f49554b2dac in static_lock () at lxclock.c:330
 #5  0x00007f4955498f71 in lxc_global_config_value (option_name=option_name@entry=0x7f49554c02cf "cgroup.use") at utils.c:273
 #6  0x00007f495549926c in default_cgroup_use () at utils.c:366
 #7  0x00007f49554953bd in lxc_cgroup_load_meta () at cgroup.c:94
 #8  0x00007f495548debc in lxc_spawn (handler=handler@entry=0x7f49200af300) at start.c:783
 #9  0x00007f495548e7a7 in __lxc_start (name=name@entry=0x7f49200b48a0 "lxc-test-concurrent-4", conf=conf@entry=0x7f49200b2030, ops=ops@entry=0x7f49556d3900 <start_ops>, data=data@entry=0x7f495487db90,
    lxcpath=lxcpath@entry=0x7f49200b2010 "/var/lib/lxc") at start.c:951
 #10 0x00007f495548eb9c in lxc_start (name=0x7f49200b48a0 "lxc-test-concurrent-4", argv=argv@entry=0x7f495487dbe0, conf=conf@entry=0x7f49200b2030, lxcpath=0x7f49200b2010 "/var/lib/lxc") at start.c:1048
 #11 0x00007f49554b68f1 in lxcapi_start (c=0x7f49200b1dd0, useinit=<optimized out>, argv=0x7f495487dbe0) at lxccontainer.c:648
 #12 0x0000000000401317 in do_function (arguments=0x1aa80b0) at concurrent.c:94
 #13 0x0000000000401499 in concurrent (arguments=<optimized out>) at concurrent.c:130
 #14 0x00007f4955262f6e in start_thread (arg=0x7f495487e700) at pthread_create.c:311
 #15 0x00007f4954f8d9cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

It looks like both parent and child end up with locked mutex thus deadlocks.

I ended up placing values in the thread local storage pool, instead of doing "unlock the lock in the child" dance

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
10 years agosshd: Don't bind-mount /sbin/init read-write
Stéphane Graber [Wed, 18 Dec 2013 22:06:25 +0000 (23:06 +0100)]
sshd: Don't bind-mount /sbin/init read-write

lxc-sshd was mounting itself (the template script) as /sbin/init in the
container using a writable bind-mount.

This shouldn't be needed and could lead to quite a few problems should
one of those containers overwrite /sbin/init for some reason.

Instead simply move to a read-only bind-mount which should prevent any
accidental dammage.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoAdd Japanese man pages for lxc-user-nic
KATOH Yasufumi [Wed, 18 Dec 2013 07:25:45 +0000 (16:25 +0900)]
Add Japanese man pages for lxc-user-nic

Update for commit df3415e02282317348bbd5f9ce66d03e1c81eeec

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agointroduce lxcapi_rename for renaming containers
S.Çağlar Onur [Sat, 14 Dec 2013 05:41:25 +0000 (00:41 -0500)]
introduce lxcapi_rename for renaming containers

lxcapi_rename implemented as a convenience function as lately
I find myself in a need to rename a container due to a
typo in its name. I could have started over but didn't want
to spend more time (to installing extra packages and changing
their configuration) on it.

c->clone() followed by c->destroy() did the trick for me and I
though it could be helpful to the other people, so here it is.

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agochange version to 1.0.0.beta1 in configure.ac
Stéphane Graber [Tue, 17 Dec 2013 19:25:02 +0000 (14:25 -0500)]
change version to 1.0.0.beta1 in configure.ac

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agomake lxc.network.script.down consistent with lxc.network.script.up
Dwight Engen [Wed, 11 Dec 2013 21:04:37 +0000 (16:04 -0500)]
make lxc.network.script.down consistent with lxc.network.script.up

- add missing print in lxc_list_nicconfigs() and in write_config() which
  fixes lxc-clone so it will propagate the script.down config value

- add missing "script.down" to lxc_get_item_nic(). change "upscript" to
  "script.up" to match actual key in config

- refactor to use config_string_item()

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acled-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoMark lxc-user-nic setuid root
Stéphane Graber [Tue, 17 Dec 2013 17:30:01 +0000 (12:30 -0500)]
Mark lxc-user-nic setuid root

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoadd manpages for lxc-user-nic
Serge Hallyn [Tue, 17 Dec 2013 17:02:44 +0000 (11:02 -0600)]
add manpages for lxc-user-nic

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agolxc_user_nic changes
Serge Hallyn [Tue, 17 Dec 2013 16:34:25 +0000 (10:34 -0600)]
lxc_user_nic changes

1. catch a case if allowed number of nics is 0 (as opposed to no entry),
which previously would have allowed the user to sneak in one entry.

2. return false, not true, if something went heywire with creating the
/sys/class/net/$nic path to open.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agodoc: Update lxc-stop(1) for nolock option
KATOH Yasufumi [Tue, 17 Dec 2013 06:42:33 +0000 (15:42 +0900)]
doc: Update lxc-stop(1) for nolock option

update for commit 8face1de22e8cf3bab2d6cdf33cdcc7476f9217b

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agolxc_conf_free: free rootfs.pivot and log_file if not null
Serge Hallyn [Tue, 17 Dec 2013 03:56:22 +0000 (21:56 -0600)]
lxc_conf_free: free rootfs.pivot and log_file if not null

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agostop: add nolock option
Serge Hallyn [Mon, 16 Dec 2013 13:50:58 +0000 (07:50 -0600)]
stop: add nolock option

If the system gets into a bad state, it may become impossible to get
the lxc container locks.  We should still be able to stop containers
in that case.  Add a -L/--nolock option to specify this behavior.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agomake mountcgroups hook to lxc.include aware (v2)
S.Çağlar Onur [Sun, 15 Dec 2013 05:06:30 +0000 (00:06 -0500)]
make mountcgroups hook to lxc.include aware (v2)

[resending the patch from correct branch]

commit 09ad624693cb0ef41cf246e2876b5f356783b34d introduced lxc.include option
to include other config files. This patch uses it in mountcgroups hook otherwise
lxc-start fails with following error message for the nested containers;

root@oOo:/var/lib/lxc/raring# lxc-start -l debug -o l -n raring -d
lxc-start: command get_cgroup failed to receive response

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoconfigure.ac: Make our configure more consistent
Stéphane Graber [Sun, 15 Dec 2013 23:48:38 +0000 (18:48 -0500)]
configure.ac: Make our configure more consistent

This commit does the following changes:
 - Disable rpath by default
 - Switch all of our options to --enable-FEATURE in the help
 - Add auto-detection of libcap availability
 - Add auto-detection of python3 availability
 - Always specify the default value in --help
 - Add a configuration overview at the end

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoubuntu: Fix initial container creation
Stéphane Graber [Fri, 13 Dec 2013 22:56:13 +0000 (17:56 -0500)]
ubuntu: Fix initial container creation

The list of packages must be comma separated, not space separated.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agocoverity: remove logically dead code
Serge Hallyn [Fri, 13 Dec 2013 22:15:10 +0000 (16:15 -0600)]
coverity: remove logically dead code

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoMerge pull request #101 from ahippo/master
hallyn [Fri, 13 Dec 2013 21:13:19 +0000 (13:13 -0800)]
Merge pull request #101 from ahippo/master

run_buffer(): unblock all signals for spawned scripts.

10 years agomake 'empty network' the default
Serge Hallyn [Fri, 13 Dec 2013 18:46:28 +0000 (12:46 -0600)]
make 'empty network' the default

Currently if no lxc.network.type section is in the container
configuration, the container ends up sharing the host's network.
This is a dangerous default.

Instead, add 'lxc.network.type = none' as a valid type, and make
en empty network the default.

If none as well as another network type are specified, then the
none type will be ignored.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agolxc-user-nic: fix the wrong use of realloc
Libo Chen [Fri, 13 Dec 2013 03:52:17 +0000 (11:52 +0800)]
lxc-user-nic: fix the wrong use of realloc

fix the wrong use of realloc

Signed-off-by: Libo Chen <clbchenlibo.chen@huawei.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agocoverity: drop gratuitous null check
Serge Hallyn [Thu, 12 Dec 2013 20:02:00 +0000 (14:02 -0600)]
coverity: drop gratuitous null check

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agocoverity: don't deref null c
Serge Hallyn [Thu, 12 Dec 2013 19:58:50 +0000 (13:58 -0600)]
coverity: don't deref null c

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agocoverity: an int is not 1 byte
Serge Hallyn [Thu, 12 Dec 2013 19:56:35 +0000 (13:56 -0600)]
coverity: an int is not 1 byte

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agocoverity: fix mix of bool and int
Serge Hallyn [Thu, 12 Dec 2013 19:47:24 +0000 (13:47 -0600)]
coverity: fix mix of bool and int

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agocoverity: avoid deref of explicitly NULL variable on error path
Serge Hallyn [Thu, 12 Dec 2013 18:57:21 +0000 (12:57 -0600)]
coverity: avoid deref of explicitly NULL variable on error path

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agocoverity: fix use before null check
Serge Hallyn [Thu, 12 Dec 2013 18:51:35 +0000 (12:51 -0600)]
coverity: fix use before null check

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agocoverity: change flow to safely free in all exit paths
Serge Hallyn [Thu, 12 Dec 2013 18:47:14 +0000 (12:47 -0600)]
coverity: change flow to safely free in all exit paths

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agocoverity: fix memleak in userns_exec_1
Serge Hallyn [Thu, 12 Dec 2013 18:30:13 +0000 (12:30 -0600)]
coverity: fix memleak in userns_exec_1

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agocoverity : fix memleak on error path
Serge Hallyn [Thu, 12 Dec 2013 18:23:34 +0000 (12:23 -0600)]
coverity : fix memleak on error path

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agodon't run lxc-user-nic for empty netns
Serge Hallyn [Thu, 12 Dec 2013 18:12:06 +0000 (12:12 -0600)]
don't run lxc-user-nic for empty netns

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agotypo fix: create $rootfs/dev/pts
Serge Hallyn [Thu, 12 Dec 2013 18:07:36 +0000 (12:07 -0600)]
typo fix: create $rootfs/dev/pts

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agopython3: Support unpriv containers
Stéphane Graber [Wed, 11 Dec 2013 19:46:34 +0000 (14:46 -0500)]
python3: Support unpriv containers

This removes any existing uid check in the python3 binding and tools,
replacing those by .controllable where appropriate.

Extra checks are also added to make lxc-ls work as a user, returning as
much information as can possibly be retrieved.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
10 years agoinitialize stopped at top of lxc_cmd
Serge Hallyn [Wed, 11 Dec 2013 21:15:31 +0000 (15:15 -0600)]
initialize stopped at top of lxc_cmd

and don't do it at all the callers

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoFix uninitialized value in lxc_try_cmd
Stéphane Graber [Wed, 11 Dec 2013 20:51:14 +0000 (15:51 -0500)]
Fix uninitialized value in lxc_try_cmd

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agolxc-ls: Detect missing setns support
Stéphane Graber [Wed, 11 Dec 2013 19:02:20 +0000 (14:02 -0500)]
lxc-ls: Detect missing setns support

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
10 years agoplamo: Update because rc script of plamo was updated
KATOH Yasufumi [Wed, 11 Dec 2013 07:19:23 +0000 (16:19 +0900)]
plamo: Update because rc script of plamo was updated

Signed-off-by: TAMUKI Shoichi <tamuki@linet.gr.jp>
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoubuntu: Make vim part of base template
Stéphane Graber [Tue, 10 Dec 2013 23:04:07 +0000 (18:04 -0500)]
ubuntu: Make vim part of base template

This moves vim back to the default list of packages, drops the duplicate
ssh entry which means that unless extra packages are passed through
--packages, container creation won't invoke apt-get anymore.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
10 years agoMake public API string method parameters const where possible.
James Hunt [Tue, 10 Dec 2013 10:29:59 +0000 (10:29 +0000)]
Make public API string method parameters const where possible.

Signed-off-by: James Hunt <james.hunt@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agolxc-test-concurrent: initialize saveptr before use
Qiang Huang [Tue, 10 Dec 2013 11:37:46 +0000 (19:37 +0800)]
lxc-test-concurrent: initialize saveptr before use

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoubuntu: Add comment about the mounting profile
Stéphane Graber [Mon, 9 Dec 2013 22:05:26 +0000 (17:05 -0500)]
ubuntu: Add comment about the mounting profile

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoubuntu: add comments about running unconfined or nested containers
S.Çağlar Onur [Sat, 7 Dec 2013 23:04:10 +0000 (18:04 -0500)]
ubuntu: add comments about running unconfined or nested containers

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agouse $LOCALSTATEDIR/lock/subsys/lxc-ubuntu$release as lock filename
S.Çağlar Onur [Sat, 7 Dec 2013 22:52:14 +0000 (17:52 -0500)]
use $LOCALSTATEDIR/lock/subsys/lxc-ubuntu$release as lock filename

Otherwise one cannot create two containers with different releases
(let's say saucy [cached] and raring [not caced]) if both are not
cached on the local filesystem already. The lock blocks cached
one to move forward until not cached one finishes it's downloads.

Fix that by seperating locks using release names

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agouse /var/lock/subsys/lxc-centos instead of /var/lock/subsys/lxc as a lock name
S.Çağlar Onur [Sat, 7 Dec 2013 22:46:22 +0000 (17:46 -0500)]
use /var/lock/subsys/lxc-centos instead of /var/lock/subsys/lxc as a lock name

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agocall fclose() for pid_fp on failure
S.Çağlar Onur [Sat, 7 Dec 2013 19:16:46 +0000 (14:16 -0500)]
call fclose() for pid_fp on failure

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agolxc-busybox: make securityfs bind-mount optional
Bogdan Purcareata [Mon, 9 Dec 2013 12:10:15 +0000 (14:10 +0200)]
lxc-busybox: make securityfs bind-mount optional

Prevent container start from failing when running Busybox containers on hosts without securityfs support.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agolxc-clone: proper type for getopt_long result
Bogdan Purcareata [Mon, 9 Dec 2013 14:39:46 +0000 (16:39 +0200)]
lxc-clone: proper type for getopt_long result

While char is a signed type and should have no trouble
storing a "-1" value, getopt_long() will return a value of 255
instead of -1. This has been noticed on powerpc; there's also
some upstream talk about it at [1].

Change variable type from char to int, since it's also the
documented use.

[1] http://stackoverflow.com/questions/17070958/c-why-does-getopt-return-255-on-linux

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agodoc: Update Japanese lxc-monitor(1)
KATOH Yasufumi [Mon, 9 Dec 2013 07:45:10 +0000 (16:45 +0900)]
doc: Update Japanese lxc-monitor(1)

Update for commit 2afd1dc05ba38eacdfe5a9c79addaf3a7d182dbf

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoaltlinux: Use relative paths and fix rootfs variable.
Serge Logvinov [Sun, 8 Dec 2013 12:15:29 +0000 (16:15 +0400)]
altlinux: Use relative paths and fix rootfs variable.

Change paths in fstab to be relative to the root and fix a wrong
rootfs_path value.

Signed-off-by: Serge Logvinov <serge.logvinov@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoUpdate mailing-list addresses
Stéphane Graber [Sun, 8 Dec 2013 22:51:28 +0000 (17:51 -0500)]
Update mailing-list addresses

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agolxc_monitor: Add missing include (errno.h)
Stéphane Graber [Fri, 6 Dec 2013 23:24:41 +0000 (18:24 -0500)]
lxc_monitor: Add missing include (errno.h)

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agolxc_monitor: Check return value of write
Stéphane Graber [Fri, 6 Dec 2013 22:19:23 +0000 (17:19 -0500)]
lxc_monitor: Check return value of write

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
10 years agobusybox template: set mode when creating device nodes
Dwight Engen [Fri, 6 Dec 2013 21:47:26 +0000 (16:47 -0500)]
busybox template: set mode when creating device nodes

Ensure mode 666 is set for tty1 and tty5

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agolet lxc-monitor command ask a lxc-monitord instance to quit
Dwight Engen [Fri, 6 Dec 2013 20:36:50 +0000 (15:36 -0500)]
let lxc-monitor command ask a lxc-monitord instance to quit

Once lxc-monitord receives a quit request from lxc-monitor, it will then
return from the mainloop every time an event occurs on any of its fds and
check if it has any clients left. When there are no more it exits. This
allows lxc-monitord to quit immediately instead of waiting the normal 30
seconds for more clients, potentially freeing up lxcpath for unmounting.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoadd epoll events to mainloop callback handlers
Dwight Engen [Fri, 6 Dec 2013 20:36:44 +0000 (15:36 -0500)]
add epoll events to mainloop callback handlers

Adding the epoll events allows the handler to determine what events
happened on the fd.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agooracle: fix chcon warning when selinux disabled
Dwight Engen [Fri, 6 Dec 2013 14:46:19 +0000 (09:46 -0500)]
oracle: fix chcon warning when selinux disabled

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoconfile: Fix invalid lxc.network.ipv6 address
Stéphane Graber [Fri, 6 Dec 2013 20:28:55 +0000 (15:28 -0500)]
confile: Fix invalid lxc.network.ipv6 address

The writer code was using AF_INET instead of AF_INET6 when converting
the address to ascii.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoMove some common Ubuntu config
Stéphane Graber [Sat, 30 Nov 2013 00:19:09 +0000 (19:19 -0500)]
Move some common Ubuntu config

This introduces a new /usr/share/lxc/config directory containing common
configuration snippets.

The two Ubuntu templates are then simplified to just include the
relevant entries avoiding a whole lot of hardcoded cgroup, capabilities
and mount points configuration.

An extra comment is also added at the top of all generated configuration
files telling the user to look at lxc.conf(5) for more information.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
10 years agoAdd support for new create=(dir,file) mount option
Stéphane Graber [Thu, 5 Dec 2013 20:37:56 +0000 (15:37 -0500)]
Add support for new create=(dir,file) mount option

Just like we already had "optional", this adds two new LXC-specific
mount flags:
 - create=dir (will do a mkdir_p on the path)
 - create=file (will do a mkdir_p on the dirname + a fopen on the path)

This was motivated by some of the needed bind-mounts for the
unprivileged containers.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
10 years agoconffile.c: Also clear text entries with no value
Stéphane Graber [Thu, 5 Dec 2013 22:13:18 +0000 (17:13 -0500)]
conffile.c: Also clear text entries with no value

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
10 years agodoc: Update Japanese lxc.conf(5)
KATOH Yasufumi [Fri, 6 Dec 2013 06:08:10 +0000 (15:08 +0900)]
doc: Update Japanese lxc.conf(5)

translate the untranslated paragraph

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoMake lxc-user-nic use mkifname
Stéphane Graber [Thu, 5 Dec 2013 19:29:37 +0000 (14:29 -0500)]
Make lxc-user-nic use mkifname

NetworkManager at least expects all veth devices to be called veth*
otherwise it'll consider them as physical interface and try to do DHCP
on them.

This change makes lxc-user-nic use the same function that we use for LXC
itself which will give us standard vethXXXXX kind of interfaces.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
10 years agoadd destroy option to lxc-snapshot
S.Çağlar Onur [Tue, 3 Dec 2013 20:13:22 +0000 (15:13 -0500)]
add destroy option to lxc-snapshot

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoFix Makefile.am to produce usable dist tarball
Stéphane Graber [Tue, 3 Dec 2013 22:04:03 +0000 (17:04 -0500)]
Fix Makefile.am to produce usable dist tarball

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agopython3: Drop duplicate add_device_node function
Stéphane Graber [Tue, 3 Dec 2013 21:45:13 +0000 (16:45 -0500)]
python3: Drop duplicate add_device_node function

It is now natively implemented in C, the new function takes the same
arguments (same order, different names) and has been confirmed to work
with lxc-device.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agopython3: Fix PEP8 and avoid crash when listing
Stéphane Graber [Tue, 3 Dec 2013 21:39:46 +0000 (16:39 -0500)]
python3: Fix PEP8 and avoid crash when listing

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agolxc-ubuntu: Replace the hostname in ssh pubkey
Stéphane Graber [Tue, 3 Dec 2013 20:15:41 +0000 (15:15 -0500)]
lxc-ubuntu: Replace the hostname in ssh pubkey

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agorun_buffer(): unblock all signals for spawned scripts.
Andrey Mazo [Thu, 28 Nov 2013 12:45:47 +0000 (16:45 +0400)]
run_buffer(): unblock all signals for spawned scripts.

Currently, all scripts, specified as "lxc.network.script.up", inherit
lxc-execute's signal mask.
This, for example, includes blocked SIGALRM signal which, in turn, makes
alarm(2), sleep(3) and setitimer(2) functions silently unusable in all programs,
invoked in turn by the "lxc.network.script.up".
To fix this, run_buffer() should restore default signal mask prior to
executing "lxc.network.script.up".

A naive implementation would temprorary unblock all signals just before
calling popen() and block them back immediately after it.
But that would result in an immediate delivery of all pending signals just
after their unblocking.
Thus, we should restore default signal mask exactly in child (after fork())
just before calling exec().
To achieve this, a home-brewed popen() alternative is needed.
The added lxc_popen() and lxc_pclose() are mostly taken from glibc with
several simplifications (as we currently need only "re" mode).
The implementation uses Linux-specific pipe2() system-call,
which is only available since Linux 2.6.27 and supported by glibc since
version 2.9 (according to pipe(2) man-page), but this shouldn't be a
problem as lxc requires a fairly recent kernel too.

lxc_popen()/lxc_pclose() are meant to be direct replacements for their
stdio counterparts, so they perform no process_lock() locking
themselves. (as fopen_cloexec() does)
All existing users of popen()/pclose() are converted to the new
lxc_popen()/lxc_pclose().

(mazo: don't clear close-on-exec flag for parent's end;
place the new functions in utils.c;
convert bdev.c to use the new functions;
coding style fixes;
comments fixes;
commit message tweaks)

Signed-off-by: Ivan Bolsunov <bolsunov@telum.ru>
Signed-off-by: Andrey Mazo <mazo@telum.ru>
10 years agoReduce public API (V2)
Stéphane Graber [Mon, 2 Dec 2013 18:58:02 +0000 (13:58 -0500)]
Reduce public API (V2)

This removes all but the following headers from our includes:
 - attach_options.h
 - lxccontainer.h
 - version.h

This also removes the duplicate lxc_version function (lxc_get_version
has been preferred for a while).

lxclock.h is now considered private.

As a result quite a lot of files needed addition of extra includes
previously inherited from lxclock.h.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
10 years agoAdd LXC version information to version.h
S.Çağlar Onur [Mon, 2 Dec 2013 04:14:17 +0000 (23:14 -0500)]
Add LXC version information to version.h

So that applications can get the LXC version number at compile time.

This can be used to make applications/bindings that support compiling against
multiple versions of LXC.

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoSome tweak on previous change (timezone)
Stéphane Graber [Mon, 2 Dec 2013 22:42:48 +0000 (17:42 -0500)]
Some tweak on previous change (timezone)

This adds the same code to the Debian-based templates (Ubuntu and Ubuntu
Cloud) and also avoids a needless fork.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agolxc-debian: Make timezone match the host
funditus [Mon, 25 Nov 2013 15:03:43 +0000 (21:03 +0600)]
lxc-debian: Make timezone match the host

Set timezone in container as on the host

Signed-off-by: funditus <funditus@mail.ru>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoconfile.c: clear entries if no value
Serge Hallyn [Mon, 2 Dec 2013 19:17:34 +0000 (13:17 -0600)]
confile.c: clear entries if no value

For list configuration entries like capabilities and cgroups
entries, if there is a 'key =' value (i.e. "lxc.cap.drop =")
then clear any loaded entries.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
10 years agoubuntu: Actually attempt to remove /dev/shm
Stéphane Graber [Sat, 30 Nov 2013 00:22:53 +0000 (19:22 -0500)]
ubuntu: Actually attempt to remove /dev/shm

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
10 years agodoc: Update Japanese lxc-start(1)
KATOH Yasufumi [Mon, 2 Dec 2013 08:13:25 +0000 (17:13 +0900)]
doc: Update Japanese lxc-start(1)

Update for commit 7faa7f52004943f339199bcbad1848cdf50d5f4c

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