Commit Graph

2483 Commits

Author SHA1 Message Date
Stéphane Graber
21384986d2
Unset lxc.devttydir for userns CentOS
Without this, the container entirely fails to start.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-22 11:38:59 -05:00
Michael H. Warfield
1ecee40b7d Update Fedora and CentOS templates for common conf includes.
This updates the Fedora and CentOS templates to utilize a common
included config.  This is largely based on the changes in the Oracle
template with some exceptions.

Dropping of setpcap (present in the Oracle template) is commented out in
the Fedora template.  It seems to cause problems, such as large login
delays with Fedora 20 containers (but not Fedora 19 - strange).

The Fedora template is further modified to disable systemd-journald.service
as it is unnecessary in a container and causes serious problems when
running in a Fedora 20 container.

The Fedora template is also updated to default to Fedora 20 when running
on a non-Fedora host.

Regards,
Mike

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-21 20:25:55 -05:00
S.Çağlar Onur
ae22a22064 make lxcapi_get_interfaces and lxcapi_get_ips unprivileged container aware
Based on Stéphane's suggestion, those two API methods now;

* fork a new process,
* switch to appropriate namespace(s),
* do what we want,
* return the data over a pipe to the parent which returns the result to the original caller.

For the whole thread please see;

 https://lists.linuxcontainers.org/pipermail/lxc-devel/2014-January/007362.html

This patch also makes lxc-ls and lxc-info call those functions.

I'm adding Stéphane as an author here since both the idea as well as
the initial setns code come from him.

Author: S.Çağlar Onur <caglar@10ur.org>
Author: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-21 20:11:27 -05:00
KATOH Yasufumi
adf4b40833 plamo: Improve template
Allow to specify additional packages

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>
2014-01-21 09:51:25 -05:00
S.Çağlar Onur
c4b9dc3bdd remove no-longer neeeded check from lxcapi_attach_run_waitl
commit f436448445 introduced attach
functionality to unprivileged containers so remove this check like
the rest of the attach functions.

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 23:49:49 -05:00
Stéphane Graber
45e854dc86 Move lxc-user-nic and lxc-monitord to libexec
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-20 23:27:16 -05:00
Stéphane Graber
f407c5e4c1 utils: Drop trailing / in lxcpath
This fixes command line tools and functions which use
lxc_global_config_value o get lxcpath but don't strip the trailing /
leading to mismatching command path (as lxc_container_new does strip the
path).

As lxcpath is typically a const and so can't easily be changed by the
caller, add the trick directly into lxc_global_config_value (having to
juggle a bit in there too to avoid trying to alter a const).

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-20 23:11:54 -05:00
Stéphane Graber
f436448445 attach: Support unprivileged containers
This change makes lxc-attach and the matching API functions work
properly with unprivileged containers.

The trick needed to make that possible was to always start with the
userns when attaching and also relocate the cgroup management code so
that the intermediate process is moved to the cgroup before attaching to
the container's namespace as doing so later would fail due to missing
permissions.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-20 23:10:24 -05:00
Stéphane Graber
dbfa71289d
Add missing doxygen tag
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 22:01:08 -05:00
Dimitri John Ledkov
4b954f1217 lxc-ubuntu-cloud: Default to trying released channel
This adds a fallback to the daily channel if an image couldn't be found
in the released one.

Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 22:00:32 -05:00
Robert Vogelgesang
89addaa75d Don't forget network prefix information
Include the IPv4/IPv6 prefix if it's set.

Signed-off-by: Robert Vogelgesang <vogel@users.sourceforge.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 15:17:45 -05:00
S.Çağlar Onur
c868b261b2 handle unprivileged user calls more gracefully (v3)
Return an error if the function is not supposed to be called by an unprivileged user.
Otherwise those calls fail in the middle of their execution with different reasons.

changes since v2:
- am_unpriv is now a simple geteuid check,
- API functions are now providing error messages,
- lxc-info, lxc-attach are now checking geteuidi,
- lxc-ls is now calling get_ips only if the container is running

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 15:14:44 -05:00
Serge Hallyn
9daf6f5d01 cgmanager: implement setting of cgroup limits
Also replace a wrong free of nih-allocated variable with nih_free.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 15:14:41 -05:00
KATOH Yasufumi
755d8d03b1 Add Japanese lxc-usernsexec(1) and fix typo English lxc-usernsexec(1)
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 10:09:05 -05:00
KATOH Yasufumi
2bec0e1bc9 doc: Remove the description of lxc-kill in Japanese lxc-execute(1)
Update for commit 33ddfc2ade

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 10:09:03 -05:00
Stéphane Graber
05e5d7dc9b Revert "lxc-start: fix the container leak when daemonize"
This reverts commit c3f0f139e1.

Done as Serge Hallyn's request:
 Nacked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-19 12:31:57 -05:00
Serge Hallyn
ecc357ca08 cgmanager: &existed for remove+create now returns -1 on failure
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-19 11:17:22 -06:00
Qiang Huang
c3f0f139e1 lxc-start: fix the container leak when daemonize
When start container with daemon model, we'll have a new daemon
process in lxcapi_start, whose c->numthreads is 2, inherited
from his father. Even his father return to main(), the
lxc_container_put won't affect son's numthreads.

So when daemon stops, he should return to main and do
lxc_container_put again, rather than exit and leave the
container alone.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-18 19:57:39 -05:00
KATOH Yasufumi
7a49a081dd plamo: Improve template
* make simple
* change default download site to http://ftp.ring.gr.jp

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>
2014-01-18 10:17:33 -05:00
Stéphane Graber
33ddfc2ade Deprecate lxc-checkpoint, lxc-kill and lxc-restart
Checkpoint/restart isn't currently supported, so let's not carry those
binaries around until we have proper CRIU support in the API.

lxc-kill is redundant with lxc-stop -k and has been known to confuse user.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-18 10:13:50 -05:00
Serge Hallyn
adade80c7e lxc-usernsexec: add a manpage
and fix the help output in the program

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-17 18:47:01 -05:00
KATOH Yasufumi
348cb247db doc: Update Japanese lxc-ls(1) for -f and -F option
Update for commit c5afb6e455

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-17 11:14:27 -05:00
Stéphane Graber
87c7e080c8 init: Simplify Makefile somehow
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-16 17:49:29 -05:00
Stéphane Graber
8da250dad4 apparmor: Add profiles
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-16 17:49:23 -05:00
Stéphane Graber
dc0682900a init: Add upstart jobs and some more changes (v3)
This adds the 3 upstart jobs that we've had in Ubuntu for a while:
 - lxc.conf: Main upstart job, triggers lxc-net.conf based on config
 - lxc-instance.conf: Triggered by lxc.conf for each auto-started container
 - lxc-net.conf: Triggered by lxc.conf, sets up lxcbr0, NAT, mangling, ...

In addition, there are two extra config files in /etc/default:
 - lxc: Allows setting some values like http proxying, disabling autostart, ...
 - lxc-net: Network configuration for the lxcbr0 bridge

This change also disables the sysv script for all distros but Oracle as
the current script won't work on either Ubuntu nor Debian and I suspect
quite a few more distros, so it's not nearly as distro-agnostic as we
thought.

For Debian, only install the upstart jobs and systemd unit.
For Ubuntu, only install the upstart jobs.

This change also moves all the init related stuff to config/init/

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-16 17:18:38 -05:00
Stéphane Graber
ff6bf8d18f doc: Update no-netns for lxc.network.type = none
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-16 16:28:20 -05:00
S.Çağlar Onur
f303fbb21a exclude non-existing signals from the loop
32 and 33 are not defined and causing sigaction to fail. "kill -l" shows following
on my system

 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP
 6) SIGABRT      7) SIGBUS       8) SIGFPE       9) SIGKILL     10) SIGUSR1
11) SIGSEGV     12) SIGUSR2     13) SIGPIPE     14) SIGALRM     15) SIGTERM
16) SIGSTKFLT   17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP
21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU     25) SIGXFSZ
26) SIGVTALRM   27) SIGPROF     28) SIGWINCH    29) SIGIO       30) SIGPWR
31) SIGSYS      34) SIGRTMIN    35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3
38) SIGRTMIN+4  39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7
58) SIGRTMAX-6  59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2
63) SIGRTMAX-1  64) SIGRTMAX

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-16 16:25:05 -05:00
Stéphane Graber
5f71203473 python3: binding update
This adds rename(new_name) to the binding as well as two new const,
LXC_CLONE_KEEPBDEVTYPE and LXC_CLONE_MAYBE_SNAPSHOT.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-16 16:23:51 -05:00
Serge Hallyn
c0e0d2b299 cgmanager: fix obvious braindeadnesses
1. don't return bools for int-return functions
2. copy the filename to controller before using it
3. use full filename not just the key to pass to cgmanager

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-16 14:46:33 -06:00
Stéphane Graber
c5afb6e455 lxc-ls: Add -f and -F as aliases
Alias -f to --fancy and -F to --fancy-format.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-16 15:45:02 -05:00
Stéphane Graber
a539732721 python3: Don't fail in list_containers on ValueError
ValueError typically means that the user doesn't have permissions to
access the directory. Raising an exception there isn't consistent with
other error behaviour of list_containers which simple returns an empty
tuple.

So simply catch the exception and ignore it. An error message is already
printed by LXC itself anyway.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-16 15:44:45 -05:00
Serge Hallyn
378a572948 address coverity-found memleak of data on error case
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-16 10:26:18 -06:00
Qiang Huang
0291b5fa33 lxc_init.c: error handing for sigaction and sigprocmask
Look through all LXC code and seems like only here are missed.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-16 11:04:07 -05:00
KATOH Yasufumi
3dcb8ff3dd doc: Update Japanese man pages
* lxc-unshare(1): Update for commit c1bb25a831 and 13d8bde96f
* lxc.conf(5): Update for commit 04a243f11d

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-16 10:35:26 -05:00
S.Çağlar Onur
5e32a9901d skip rootfs pinning for unprivileged containers
This is perfectly safe since you cannot unmount the host fs from
a child userns.

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-16 08:47:44 -06:00
Serge Hallyn
e8d07ef205 shut up freezer_state
Not being able to get freezer state is perfectly valid - if the
container does not exist.  The old version of freezer_state
only reported an error on actually reading the cgroup file,
but not on not finding a cgroup file.  Leave it to the caller
to report the error if it is important, since we don't actually
know any useful info here anyway.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-16 08:41:44 -06:00
S.Çağlar Onur
3879935493 fix compilation error in cgmanager.c
Currently it fails like following

gcc -DHAVE_CONFIG_H -I. -I../../src   -D_FORTIFY_SOURCE=2 -fPIC -DPIC -I../../src -DLXCROOTFSMOUNT=\"/usr/lib/x86_64-linux-gnu/lxc/rootfs\" -DLXCPATH=\"/var/lib/lxc\" -DLXC_GLOBAL_CONF=\"/etc/lxc/lxc.conf\" -DLXCINITDIR=\"/usr/libexec\" -DLXCTEMPLATEDIR=\"/usr/share/lxc/templates\" -DLOGPATH=\"/var/log/lxc\" -DLXC_DEFAULT_CONFIG=\"/etc/lxc/default.conf\" -DLXC_USERNIC_DB=\"/run/lxc/nics\" -DLXC_USERNIC_CONF=\"/etc/lxc/lxc-usernet\" -DDEFAULT_CGROUP_PATTERN=\"/lxc/%n\" -DHAVE_APPARMOR -DHAVE_CGMANAGER -DHAVE_SELINUX  -DHAVE_SECCOMP  -pthread  -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include     -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -Werror -MT liblxc_so-cgmanager.o -MD -MP -MF .deps/liblxc_so-cgmanager.Tpo -c -o liblxc_so-cgmanager.o `test -f 'cgmanager.c' || echo './'`cgmanager.c
In file included from cgmanager.c:48:0:
cgmanager.c: In function ‘cgmanager_remove_cgroup’:
log.h:247:9: error: format ‘%s’ expects a matching ‘char *’ argument [-Werror=format=]
  struct lxc_log_locinfo locinfo = LXC_LOG_LOCINFO_INIT;  \
         ^
cgmanager.c:142:3: note: in expansion of macro ‘INFO’
   INFO("cgroup removal attempt: %s:%s did not exist");
   ^
log.h:247:9: error: format ‘%s’ expects a matching ‘char *’ argument [-Werror=format=]
  struct lxc_log_locinfo locinfo = LXC_LOG_LOCINFO_INIT;  \
         ^
cgmanager.c:142:3: note: in expansion of macro ‘INFO’
   INFO("cgroup removal attempt: %s:%s did not exist");
   ^
cc1: all warnings being treated as errors
make[3]: *** [liblxc_so-cgmanager.o] Error 1

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-16 08:30:16 -06:00
Serge Hallyn
0086f49995 stop cmd callback: unfreeze by path only
in particular, regular unfreeze uses the cmd api to request the cgroup
of the container.  If we are already in the lxc-start monitor, we can't
use the cmd api.

(I knew when I started this would be a problem but then as it didn't
reliably crash, I forgot to handle it)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-15 23:56:43 -05:00
Serge Hallyn
6873d6f078 implement cgmanager_remove_cgroup
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-15 23:56:41 -05:00
Serge Hallyn
d4ef7c50ae Initial support for cgmanager
This patch splits out most of the cgroupfs-specific code, so that
cgroup-manager versions can be plugged in.  The case I did
not handle is cgroup_enter at lxc_attach.  I'm hoping that case can
be greatly simplified, but will worry about it after fleshing out the
cgroup manager handlers.

This also simplify the freezer functions.

This seems to not regress my common tests when running without
cgmanager, but I'd like to do a bit more testing before pushing.
However I was hoping to get some more eyes on this so am sending it
out now.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-15 23:56:32 -05:00
Stéphane Graber
9cde0368fb lxc-ubuntu-cloud: Fix cache and lock location
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-15 23:49:02 -05:00
Stéphane Graber
3fefd6e6d5 ubuntu: Don't fail on invalid locale
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-15 23:48:59 -05:00
Stéphane Graber
19668d8b07 lxc-create: Don't print the help message twice
The forking logic was wrong, causing both the child and the parent to
call the template with -h.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-15 23:31:23 -05:00
Stéphane Graber
09ec76ceec
Add missing entry to dist target
Apparently this file has gone over 5 years without getting into a dist
tarball!

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-15 19:21:26 -05:00
Stéphane Graber
deccacff34
change version to 1.0.0.beta2 in configure.ac
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-15 19:07:33 -05:00
Stéphane Graber
7a40167939
Add local definition of sethostname to lxc_unshare
sethostname doesn't exist on bionic, so copy/paste the definition of it
we have in conf.c

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-15 18:29:57 -05:00
Serge Hallyn
31a1209de9 lxc-unshare: uid_t is unsigned.
so we can't use uid==-1 as "don't do setuid"

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-15 16:46:47 -06:00
Seth Robertson
c1bb25a831 Teach lxc_unshare about interfaces, mounts, hostname, daemonize
lxc_unshare now takes one or more '-i interfacename' arguments which
will move the named interfaces into the created container.

lxc_unshare now takes -M argument which will cause the standard mounts
(/proc /dev/shm /dev/mqueue) to be auto-mounted inside container.

lxc_unshare now takes '-H hostname' argument to automatically set
the hostname in the container.

lxc_unshare now takes -D argument to automatically daemonize and detach
from the created container, instead of waiting for the container to exit

Signed-off-by: Seth Robertson <srobertson@appcomsci.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-15 15:42:36 -06:00
Seth Robertson
13d8bde96f lxc_unshare -u argument useful even with USER namespace shared
Signed-off-by: Seth Robertson <srobertson@appcomsci.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-15 15:42:29 -06:00
Stéphane Graber
00fe5e1d19 debian: Switch to config includes
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-15 15:57:31 -05:00