Commit Graph

6536 Commits

Author SHA1 Message Date
Christian Brauner
0577a33d33
README: add coverity
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-17 13:07:14 +01:00
Serge Hallyn
3d7868ae53
Merge pull request #2171 from brauner/2018-02-16/rework_hooks
conf: fix run_script_argv()
2018-02-16 18:51:56 -06:00
Christian Brauner
c06a0555e9
console: ensure that fd is marked EBADF
If the handler closes the file descriptor for the peer or master fd it is
crucial that we mark it as -EBADF. This will prevent lxc_console_delete()
from calling close() on an already closed file descriptor again. I've
observed the double close in the attach code.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-17 00:13:10 +01:00
Christian Brauner
0d0d365516
start: don't call close on invalid file descriptor
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-16 23:18:54 +01:00
Christian Brauner
941138edba
Merge pull request #2172 from stgraber/master
Sabayon fixes
2018-02-16 23:16:19 +01:00
Stéphane Graber
59ee28f21d
lxc-sabayon: Fix handling of eth0
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2018-02-16 16:50:45 -05:00
Stéphane Graber
9bf5cd8dbb
lxc-sabayon: Remove broken/unused code
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2018-02-16 16:49:02 -05:00
Christian Brauner
586b1ce72b
conf: s/argsin/argv/ in run_script_argv()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-16 22:11:19 +01:00
Christian Brauner
6f8d00d279
conf: use malloc() in run_script_argv()
It seems dangerous to use alloca() as the arguments can be of indeterminate
length and we might blow up the stack.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-16 22:10:06 +01:00
Christian Brauner
327cce76ad
conf: fix run_script_argv()
Make sure that we allocate the buffer **after** we determined how much space we
need in total.
This fixes a SIGBUS/SIGSEGV Stéphane reported on aarch64 and armf.

Reported-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-16 22:04:35 +01:00
Stéphane Graber
47d4e397da
Merge pull request #2170 from brauner/2018-02-16/cgfsng_force_cgroup_mount
confile: add "force" to cgroup:{mixed,ro,rw}
2018-02-16 14:47:54 -05:00
Christian Brauner
7e50ec0b5f
utils: fix lxc_p{close,open}()
If a file descriptor fd is opened by fdopen() and associated with a stream f
will **not** have been dup()ed. This means that fclose(f) will also close the
fd. So never call close(fd) after fdopen(fd) succeeded.
This fixes a double close() Stéphane and I observed when debugging on aarch64
and armf.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-16 20:06:48 +01:00
Christian Brauner
e99cf4acfd
tests: remove lxc-test-ubuntu
This is really taking a long time for not a lot of benefit.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-16 16:02:09 +01:00
Christian Brauner
ed06b69ce6
CODING_STYLE: add section for str{n}cmp()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-16 16:02:08 +01:00
Christian Brauner
8353b4c90e
conf: non-functional changes
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-16 16:02:08 +01:00
Shukui Yang
3f69fb12c1
confile: add "force" to cgroup:{mixed,ro,rw}
This lets users specify

        lxc.mount.auto = cgroup:mixed:force
or
        lxc.mount.auto = cgroup:ro:force
or
        lxc.mount.auto = cgroup:rw:force

When cgroup namespaces are supported LXC will not mount cgroups for the
container since it assumes that the init system will mount cgroups itself if it
wants to. This assumption already broke when users wanted to run containers
without CAP_SYS_ADMIN. For example, systemd based containers wouldn't start
since systemd needs to mount cgroups (named systemd hierarchy for legacy
cgroups and the unified hierarchy for unified cgroups) to track processes. This
problem was solved by detecting whether the container had CAP_SYS_ADMIN. If it
didn't we performed the cgroup mounts for it.
However, there are more cases when we should be able to mount cgroups for the
container when cgroup namespaces are supported:
- init systems not mounting cgroups themselves:
  A init system that doesn't mount cgroups would not have cgroups available
  especially when combined with custom LSM profiles to prevent cgroup
  {u}mount()ing inside containers.
- application containers:
  Application containers will usually not mount by cgroups themselves.
- read-only cgroups:
  It is useful to be able to mount cgroups read-only to e.g. prevent
  changing cgroup limits from inside the container while at the same time
  allowing the applications to perform introspection on their own cgroups. This
  again is mostly useful for application containers. System containers running
  systemd will usually not work correctly when cgroups are mounted read-only.
To be fair, all of those use-cases could be covered by custom hooks or
lxc.mount.entry entries but exposing it through lxc.mount.auto takes care of
setting correct mount options and adding the necessary logic to e.g. mount
filesystem read-only correctly.

Currently we only extend this to cgroup:{mixed,ro,rw} but technically there's
no reason not to enable the same behavior for cgroup-full:{mixed,ro,rw} as
well. If someone requests this we can simply treat it as a bug and add "force"
for cgroup-full.

Replaces #2136.

Signed-off-by: Shukui Yang <yangshukui@huawei.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-16 16:01:53 +01:00
Stéphane Graber
f3793175d6
Merge pull request #2166 from brauner/2018-02-15/fix_cgfsng_chown
cgroups: use correct mask for chmod()
2018-02-14 18:30:38 -05:00
Christian Brauner
63e42fee6e
cgroups: use correct mask for chmod()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-15 00:28:42 +01:00
Serge Hallyn
80c1390dff
Merge pull request #2165 from brauner/2018-02-14/coding_style
CODING_STYLE: add coding style file
2018-02-14 13:03:18 -06:00
Christian Brauner
4a308d6693
CODING_STYLE: add CODING_STYLE.md
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-14 19:58:05 +01:00
Christian Brauner
b706b2eee7
CONTRIBUTING: update
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-14 13:04:48 +01:00
Stéphane Graber
bb540ac370
Merge pull request #2163 from brauner/2018-02-13/fix_cgroup_chown
cgfsng: simplifications and fixes
2018-02-14 00:20:51 -05:00
Christian Brauner
df3c5314d2
start: s/||/&&/ when mapping ids
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-14 00:19:42 +01:00
Christian Brauner
6efacf80e8
cgfsng: simplifications and fixes
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-13 21:09:16 +01:00
Stéphane Graber
2b0991f10a
Merge pull request #2162 from brauner/2018-02-10/remove_openpty_lock
lxclock: remove atfork handlers
2018-02-13 13:53:03 -05:00
Christian Brauner
0e7ff52c92
tree-wide: remove cgmanager
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-13 05:39:58 +01:00
Christian Brauner
e3f0e4368f
lxclock: remove pthread_atfork_handlers
They shouldn't be needed anymore.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-13 05:39:13 +01:00
Christian Brauner
5b9912ab9b
Merge branch 'tanyifeng-support_mount_propagation' into lxc/master 2018-02-12 10:58:24 +01:00
Yifeng Tan
d840039ecf
conf: support mount propagation
Closes #810.

Signed-off-by: Yifeng Tan <tanyifeng1@huawei.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-12 10:57:17 +01:00
Christian Brauner
b251b0fe43
Merge pull request #2158 from lifeng68/Fix_lxc-console
Fix lxc-console hang
2018-02-12 08:41:51 +01:00
LiFeng
a54585adf7 Fix lxc-console hang
The variable 'descr' is mistakenly covered with 'descr_console'.

Signed-off-by: LiFeng <lifeng68@huawei.com>
2018-02-12 07:26:40 -05:00
Christian Brauner
35896049c0
Merge pull request #2159 from lifeng68/modify_gitignore
Modify .gitignore
2018-02-12 07:27:37 +01:00
LiFeng
18fff5e30e Modify .gitignore
add:
src/lxc/cmd/lxc-checkconfig
src/lxc/cmd/lxc-update-config

Signed-off-by: LiFeng <lifeng68@huawei.com>
2018-02-12 09:45:22 -05:00
Serge Hallyn
4d46764248
Merge pull request #2155 from brauner/2018-02-10/remove_legacy_items
tree-wide: remove legacy codepaths
2018-02-11 21:30:28 -06:00
Christian Brauner
6fba98b524
tree-wide: remove legacy codepaths
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-11 23:56:56 +01:00
Stéphane Graber
f704a070d4
Merge pull request #2090 from brauner/2018-01-12/tools_remove_non_api_symbols
tools: remove non api symbols
2018-02-11 17:52:01 -05:00
Stéphane Graber
a3533a4980
Merge pull request #2150 from brauner/2018-02-10/cgfsng_fix_unpriv_devices
conf: fix clearing cgroup settings
2018-02-10 15:32:14 -05:00
Stéphane Graber
de0cd2004b
Merge pull request #2151 from brauner/2018-02-10/remove_openpty_lock
console: they are really not necessary
2018-02-10 15:31:34 -05:00
Christian Brauner
8d81a3c87f
console: they are really not necessary
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-10 12:54:31 +01:00
Christian Brauner
ab1a6cacaf
conf: fix clearing cgroup settings
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-10 12:16:41 +01:00
Stéphane Graber
ba2861ff76
Merge pull request #2144 from brauner/2018-02-08/coverity_bug_smash
coverity: bug smash
2018-02-09 10:36:34 -05:00
Christian Brauner
056fec39f7
Merge pull request #2149 from tych0/fix-userns-error-handling
fix userns helper error handling
2018-02-09 14:49:11 +01:00
Tycho Andersen
ee1b16bcbd fix userns helper error handling
In both of these cases if there is actually an error, we won't close the
pipe and the api call will hang. Instead, let's be sure to close the pipe
before waiting, so that it doesn't hang.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
2018-02-09 13:26:31 +00:00
Christian Brauner
2df70fba94
Merge branch 'duguhaotian-new' into lxc/master 2018-02-09 12:12:10 +01:00
duguhaotian
90f2046676
conf: fix log message
Signed-off-by: duguhaotian <duguhaotian@gmail.com>
2018-02-09 12:11:53 +01:00
Christian Brauner
287df277ff
coverity: #1425971
Dereference after null check

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-09 10:37:53 +01:00
Christian Brauner
f38cf5b8f4
coverity: #1426083
Dereference after null check

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-09 10:37:53 +01:00
Christian Brauner
cb8ff4d033
lxccontainer: satisfy coverity
The container name can't be NULL so don't give coverity the impression that it
could be.

Silences coverity #1426123.
Silences coverity #1426124.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-09 10:37:53 +01:00
Christian Brauner
341ed84c47
start: use goto instead of simple return
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-09 10:37:52 +01:00
Christian Brauner
5b7f756a67
coverity: #1426126
Unchecked return value

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-09 10:37:49 +01:00