Natanael Copa [Wed, 29 Jan 2014 14:23:46 +0000 (14:23 +0000)]
Include limits.h for NAME_MAX
This fixes compile error with musl libc:
In file included from start.c:66:0:
monitor.h:38:12: error: 'NAME_MAX' undeclared here (not in a function)
char name[NAME_MAX+1];
^
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Natanael Copa [Wed, 29 Jan 2014 14:23:45 +0000 (14:23 +0000)]
Include strings.h for strcasecmp
This fixes the following error with musl libc:
In file included from start.c:59:0:
log.h: In function 'lxc_log_priority_to_int':
log.h:136:2: error: implicit declaration of function 'strcasecmp' [-Werror=implicit-function-declaration]
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Natanael Copa [Wed, 29 Jan 2014 14:23:43 +0000 (14:23 +0000)]
Include poll.h instead of sys/poll.h
poll.h is defined in POSIX:
http://pubs.opengroup.org/onlinepubs/009695399/functions/poll.html
This fixes a compile warning when building with musl libc:
In file included from start.c:46:0:
/usr/include/sys/poll.h:1:2: error: #warning redirecting incorrect #include <sys
/poll.h> to <poll.h> [-Werror=cpp]
#warning redirecting incorrect #include <sys/poll.h> to <poll.h>
^
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Serge Hallyn [Wed, 29 Jan 2014 15:17:06 +0000 (15:17 +0000)]
userns_exec_1: catch errors in the spawned process.
lxc_map_ids can call system(3), which on error from the
spawned process returns > 0. No path should return > 0
when it meant success. So check the lxc_map_ids() value
to be != rather than just < 0.
lxc-monitord.log should not be created with mode 0666
lxc_monitord_spawn() in src/lxc/monitor.c contained "umask(0);", and
because of this, lxc-monitord created lxc-monitord.log with mode 0666.
World-writeable log files are bad, so remove this umask(0).
Serge Hallyn [Wed, 29 Jan 2014 09:40:39 +0000 (09:40 +0000)]
cgroups: adjust previous commit
Remove a memory leak on error path.
Only try to initialize cpuset if cgroup.clonechildren does not exist.
Bump the max value we read from cpuset.{cpus,mems} to 1024.
If cpuset.cpus or .mems is already initialized but is too long, don't fail.
If parent's cpuset.cpus or .mems is too long, record an error and fail.
If anyone actually runs into this, we can simply allocate the required
length as needed, but we don't expect anyone to run into this.
cgroupfs: cpuset support for kernels without cgroup.clone_children
Hi,
as promised last week, here's my patch for cpuset cgroup support for
kernels without the cgroup.clone_children feature.
My initial patch used "#include <linux/version.h>" and the macros defined
there to decide if cgroup.clone_children should be used or not. After
having seen Serge Hallyn's patch which he posted to the list last Wednesday,
where he used stat() to check if the cgroup.clone_children file is there,
I rewrote my patch to do the same.
The patch is against 1.0.0.beta3, and it is tested successfully with
RHEL-6's kernel version 2.6.32-431.3.1.el6, compiled without cgmanager
(I've so far not tried to use cgmanager in RHEL-6).
In addition to fixing the cpuset cgroup setup, this patch also fixes a
wrong argument in a call to handle_cgroup_settings() in the same context.
Robert
Signed-off-by: Robert Vogelgesang <vogel@users.sourceforge.net> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Serge Hallyn [Sat, 25 Jan 2014 22:28:24 +0000 (16:28 -0600)]
lxcapi_clone: exit early on snapshot clones
If the user explicitly asks for a snapshot clone (in which
case maybe_snap is not set), we cannot abide this currently.
Rather than exit later with more cryptic error messages, exit
out early.
Serge Hallyn [Fri, 24 Jan 2014 05:56:15 +0000 (23:56 -0600)]
cgmanager: chown cgroups to the container root
After this patch, starting an unprivileged container using
cgmanager gets the cgroup chown to the container root, so
that it can install the cgmanager (proxy) and make cgroup
requests.
(Still desirable and not in this patch is the automatic setup of
/sys/fs/cgroup/manager/sock, which you can currently do with
two lxc.mount.entries)
Update CentOS and Fedora templates to support archtectures option.
Added code to the CentOS and Fedora templates so that x86 32 bit containers
may be built on x86_64 platforms. Like archectectures may also be trivially
used as well.
Option added is "-a {arch}".
Additionally cleaned up some bash specific logic.
Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com> Acked-by: Stéphane Graber <stgraber@ubuntu.com>
Serge Hallyn [Fri, 24 Jan 2014 04:23:24 +0000 (22:23 -0600)]
idmap_add_id: fix broken behavior
The geteuid() addition is being made the first element of the lxc_list,
but the first element is just a head whose entry is ignored. Therefore
userns_exec_1() was starting its tasks without the caller's uid mapped
into the namespace.
Qiang Huang [Thu, 23 Jan 2014 06:56:54 +0000 (14:56 +0800)]
cgroupfs: need the full path to setup cpuset
Function file_exists() needs a absolute full path, but we are using
current_entire_path which is not. It will get the wrong result from
file_exists() and case Segmentation fault when we fopen a non-exist
file and try to fscanf from it.
Qiang Huang [Wed, 22 Jan 2014 04:11:38 +0000 (12:11 +0800)]
daemon: fix the wrong pid in daemon model
When you start a container in daemon model, you have at least
3 processes:
1. The command the user start (lxc-start -d)
2. The backgrounded fork of that command after start() is done
3. The container init process
In PID file, we need (2), but currently we are writing (1),
this is wrong because (1) exits as soon as the container is
started, it's complately useless.
So we write pid after daemonize, so that we'll always write
the right pid to PID file.
Stéphane Graber [Tue, 21 Jan 2014 17:16:04 +0000 (12:16 -0500)]
Remove lxc-version, lxc-ps and lxc-netstat
lxc-ps and lxc-netstat have an unfortunate tendency to break every so
often, produce mostly unreadable output and should be replaced by a
lxc-attach call in 99% of the cases.
In an effort to cleanup the lxc-* namespace, I think those two should
go, so this patch gets rid of them as well as any reference to them in
our documentation.
I also think that lxc-version should disappear as it's only a one line
shell script printing the version string, so having a whole command just
for that seems to be a bit of a waste.
Instead, this patch introduces a new --version common option which all
binaries will automatically inherit and that'll print LXC_VERSION on
stdout and exit 0.
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Stéphane Graber [Tue, 21 Jan 2014 04:49:19 +0000 (23:49 -0500)]
Add bash auto completion
This adds a basic bash auto-completion profile.
It supports 3 things at this time:
- Auto-complete of container name (-n or -o)
- Auto-complete of template name (-t)
- Auto-complete of state names (-s)
It's configured in a way to be as little disruptive as possible, any
argument that's not explicitly handled by the profile will fallack to
bash's default completion.
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
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>
S.Çağlar Onur [Tue, 21 Jan 2014 00:57:28 +0000 (19:57 -0500)]
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.
S.Çağlar Onur [Tue, 21 Jan 2014 04:43:35 +0000 (23:43 -0500)]
remove no-longer neeeded check from lxcapi_attach_run_waitl
commit f4364484454c754ed905bfb85bd2727a0a5d0475 introduced attach
functionality to unprivileged containers so remove this check like
the rest of the attach functions.
Stéphane Graber [Mon, 20 Jan 2014 20:57:16 +0000 (15:57 -0500)]
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>
Stéphane Graber [Mon, 20 Jan 2014 20:26:15 +0000 (15:26 -0500)]
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>