Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 516050 - /etc/sysctl.conf not processed in lxc containers
Summary: /etc/sysctl.conf not processed in lxc containers
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: OpenRC Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 481182
  Show dependency tree
 
Reported: 2014-07-02 09:01 UTC by Kaarle Ritvanen
Modified: 2014-07-04 15:32 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Proposed correction (0001-sysctl.Linux.in-remove-lxc-from-exclusion-list.patch,661 bytes, patch)
2014-07-02 09:02 UTC, Kaarle Ritvanen
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kaarle Ritvanen 2014-07-02 09:01:52 UTC
Currently, the sysctl init script contains keyword -lxc.

However, certain kernel parameters, such as net.ipv4.ip_forward, can be set independently for each lxc container. Therefore, the init script should execute by default in lxc environments.

Reproducible: Always
Comment 1 Kaarle Ritvanen 2014-07-02 09:02:44 UTC
Created attachment 380066 [details, diff]
Proposed correction

Proposed correction
Comment 2 William Hubbs gentoo-dev 2014-07-02 13:47:14 UTC
Since the guest and host share the same kernel, what happens if the guest
sysctl tries to change settings it shouldn't? Is the kernel smart enough to
block those changes?
Comment 3 Kaarle Ritvanen 2014-07-02 20:02:36 UTC
The kernel will block the changes if the container's configuration file contains "lxc.cap.drop = sys_admin".

In my opinion, it is the responsibility of the distro's lxc template or the system administrator to configure the capabilities correctly or ensure that the container's /etc/sysctl.conf does not define global parameters. Otherwise, there is no easy way to automatically set container-specific parameters.
Comment 4 Thomas Deutschmann (RETIRED) gentoo-dev 2014-07-03 16:35:00 UTC
I agree with Kaarle that sometimes you want to use sysctl in lxc. Well, there are other workarounds like you could use the local service to call sysctl... but why should you workaround if you could use the sysctl service? :)

I also agree that's the administrator responsibility to take action against unwanted configuration like a modified host kernel from a lxc.

From William's mail:
> My understanding is that this is not a good idea since an lxc container
> actually changes settings in the host's kernel.

Right, but "keyword -lxc" is not a real protection against this problem. You could overwrite the keyword in conf.d/sysctl in the lxc.

Currently we only hide a "problem"... but the problem is still there and can only be addressed by the host administrator. So we are only adding burden for those who want to use sysctl in lxc because they need to overwrite the keyword at the moment.

=> I would enable the sysctl service for lxc environments per default, too.
Comment 5 William Hubbs gentoo-dev 2014-07-04 15:32:29 UTC
This was applied in commit 143f1c6 and will be included in OpenRC-0.13.