Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 662780
Collapse All | Expand All

(-)a/app-emulation/lxc/files/lxc-2.1.1-cve-2018-6556.patch (+118 lines)
Line 0 Link Here
1
From d183654ec1a2cd1149bdb92601ccb7246bddb14e Mon Sep 17 00:00:00 2001
2
From: Christian Brauner <christian.brauner@ubuntu.com>
3
Date: Wed, 25 Jul 2018 19:56:54 +0200
4
Subject: [PATCH] CVE 2018-6556: verify netns fd in lxc-user-nic
5
6
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7
---
8
 src/lxc/lxc_user_nic.c | 35 ++++++++++++++++++++++++++++++++---
9
 src/lxc/utils.c        | 12 ++++++++++++
10
 src/lxc/utils.h        |  5 +++++
11
 3 files changed, 49 insertions(+), 3 deletions(-)
12
13
ADDENDUM from vdupras@gentoo.org: Original patch from Christian didn't
14
include LXC_PROC_PID_FD_LEN define, but referenced it. This resulted in
15
code that doesn't compile. I fetched the definition from the stable-3.0
16
branch and included it to this patch. Also, this diff is regenerated
17
from lxc-2.1.1 tag instead of stable-2.0 branch.
18
19
diff --git a/src/lxc/lxc_user_nic.c b/src/lxc/lxc_user_nic.c
20
index 6f550f0d..09a342ac 100644
21
--- a/src/lxc/lxc_user_nic.c
22
+++ b/src/lxc/lxc_user_nic.c
23
@@ -1124,12 +1124,41 @@ int main(int argc, char *argv[])
24
 			exit(EXIT_FAILURE);
25
 		}
26
 	} else if (request == LXC_USERNIC_DELETE) {
27
-		netns_fd = open(args.pid, O_RDONLY);
28
+		char opath[LXC_PROC_PID_FD_LEN];
29
+
30
+		/* Open the path with O_PATH which will not trigger an actual
31
+		 * open(). Don't report an errno to the caller to not leak
32
+		 * information whether the path exists or not.
33
+		 * When stracing setuid is stripped so this is not a concern
34
+		 * either.
35
+		 */
36
+		netns_fd = open(args.pid, O_PATH | O_CLOEXEC);
37
 		if (netns_fd < 0) {
38
-			usernic_error("Could not open \"%s\": %s\n", args.pid,
39
-				      strerror(errno));
40
+			usernic_error("Failed to open \"%s\"\n", args.pid);
41
 			exit(EXIT_FAILURE);
42
 		}
43
+
44
+		if (!fhas_fs_type(netns_fd, NSFS_MAGIC)) {
45
+			usernic_error("Path \"%s\" does not refer to a network namespace path\n", args.pid);
46
+			close(netns_fd);
47
+			exit(EXIT_FAILURE);
48
+		}
49
+
50
+		ret = snprintf(opath, sizeof(opath), "/proc/self/fd/%d", netns_fd);
51
+		if (ret < 0 || (size_t)ret >= sizeof(opath)) {
52
+			close(netns_fd);
53
+			exit(EXIT_FAILURE);
54
+		}
55
+
56
+		/* Now get an fd that we can use in setns() calls. */
57
+		ret = open(opath, O_RDONLY | O_CLOEXEC);
58
+		if (ret < 0) {
59
+			usernic_error("Failed to open \"%s\": %s\n", args.pid, strerror(errno));
60
+			close(netns_fd);
61
+			exit(EXIT_FAILURE);
62
+		}
63
+		close(netns_fd);
64
+		netns_fd = ret;
65
 	}
66
 
67
 	if (!create_db_dir(LXC_USERNIC_DB)) {
68
diff --git a/src/lxc/utils.c b/src/lxc/utils.c
69
index e6a44a51..c2a08a9d 100644
70
--- a/src/lxc/utils.c
71
+++ b/src/lxc/utils.c
72
@@ -2380,6 +2380,18 @@ bool has_fs_type(const char *path, fs_type_magic magic_val)
73
 	return has_type;
74
 }
75
 
76
+bool fhas_fs_type(int fd, fs_type_magic magic_val)
77
+{
78
+	int ret;
79
+	struct statfs sb;
80
+
81
+	ret = fstatfs(fd, &sb);
82
+	if (ret < 0)
83
+		return false;
84
+
85
+	return is_fs_type(&sb, magic_val);
86
+}
87
+
88
 bool lxc_nic_exists(char *nic)
89
 {
90
 #define __LXC_SYS_CLASS_NET_LEN 15 + IFNAMSIZ + 1
91
diff --git a/src/lxc/utils.h b/src/lxc/utils.h
92
index e83ed49e..06ec74d7 100644
93
--- a/src/lxc/utils.h
94
+++ b/src/lxc/utils.h
95
@@ -46,11 +46,16 @@
96
 #define __S_ISTYPE(mode, mask) (((mode)&S_IFMT) == (mask))
97
 #endif
98
 
99
+#ifndef NSFS_MAGIC
100
+#define NSFS_MAGIC 0x6e736673
101
+#endif
102
+
103
 /* Useful macros */
104
 /* Maximum number for 64 bit integer is a string with 21 digits: 2^64 - 1 = 21 */
105
 #define LXC_NUMSTRLEN64 21
106
 #define LXC_LINELEN 4096
107
 #define LXC_IDMAPLEN 4096
108
+#define LXC_PROC_PID_FD_LEN (6 + LXC_NUMSTRLEN64 + 4 + LXC_NUMSTRLEN64 + 1)
109
 
110
 /* returns 1 on success, 0 if there were any failures */
111
 extern int lxc_rmdir_onedev(char *path, const char *exclude);
112
@@ -402,6 +407,7 @@ extern void *must_realloc(void *orig, size_t sz);
113
 /* __typeof__ should be safe to use with all compilers. */
114
 typedef __typeof__(((struct statfs *)NULL)->f_type) fs_type_magic;
115
 extern bool has_fs_type(const char *path, fs_type_magic magic_val);
116
+extern bool fhas_fs_type(int fd, fs_type_magic magic_val);
117
 extern bool is_fs_type(const struct statfs *fs, fs_type_magic magic_val);
118
 extern bool lxc_nic_exists(char *nic);
(-)a/app-emulation/lxc/files/lxc-3.0.1-cve-2018-6556.patch (+110 lines)
Line 0 Link Here
1
From f2314625c5702cfd25974929599fa439bdac8bdf Mon Sep 17 00:00:00 2001
2
From: Christian Brauner <christian.brauner@ubuntu.com>
3
Date: Wed, 25 Jul 2018 19:56:54 +0200
4
Subject: [PATCH] CVE 2018-6556: verify netns fd in lxc-user-nic
5
6
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7
---
8
 src/lxc/cmd/lxc_user_nic.c | 35 ++++++++++++++++++++++++++++++++---
9
 src/lxc/utils.c            | 12 ++++++++++++
10
 src/lxc/utils.h            |  5 +++++
11
 3 files changed, 49 insertions(+), 3 deletions(-)
12
13
diff --git a/src/lxc/cmd/lxc_user_nic.c b/src/lxc/cmd/lxc_user_nic.c
14
index ec9cd97e..c5beb6c8 100644
15
--- a/src/lxc/cmd/lxc_user_nic.c
16
+++ b/src/lxc/cmd/lxc_user_nic.c
17
@@ -1179,12 +1179,41 @@ int main(int argc, char *argv[])
18
 			exit(EXIT_FAILURE);
19
 		}
20
 	} else if (request == LXC_USERNIC_DELETE) {
21
-		netns_fd = open(args.pid, O_RDONLY);
22
+		char opath[LXC_PROC_PID_FD_LEN];
23
+
24
+		/* Open the path with O_PATH which will not trigger an actual
25
+		 * open(). Don't report an errno to the caller to not leak
26
+		 * information whether the path exists or not.
27
+		 * When stracing setuid is stripped so this is not a concern
28
+		 * either.
29
+		 */
30
+		netns_fd = open(args.pid, O_PATH | O_CLOEXEC);
31
 		if (netns_fd < 0) {
32
-			usernic_error("Could not open \"%s\": %s\n", args.pid,
33
-				      strerror(errno));
34
+			usernic_error("Failed to open \"%s\"\n", args.pid);
35
+			exit(EXIT_FAILURE);
36
+		}
37
+
38
+		if (!fhas_fs_type(netns_fd, NSFS_MAGIC)) {
39
+			usernic_error("Path \"%s\" does not refer to a network namespace path\n", args.pid);
40
+			close(netns_fd);
41
+			exit(EXIT_FAILURE);
42
+		}
43
+
44
+		ret = snprintf(opath, sizeof(opath), "/proc/self/fd/%d", netns_fd);
45
+		if (ret < 0 || (size_t)ret >= sizeof(opath)) {
46
+			close(netns_fd);
47
+			exit(EXIT_FAILURE);
48
+		}
49
+
50
+		/* Now get an fd that we can use in setns() calls. */
51
+		ret = open(opath, O_RDONLY | O_CLOEXEC);
52
+		if (ret < 0) {
53
+			usernic_error("Failed to open \"%s\": %s\n", args.pid, strerror(errno));
54
+			close(netns_fd);
55
 			exit(EXIT_FAILURE);
56
 		}
57
+		close(netns_fd);
58
+		netns_fd = ret;
59
 	}
60
 
61
 	if (!create_db_dir(LXC_USERNIC_DB)) {
62
diff --git a/src/lxc/utils.c b/src/lxc/utils.c
63
index 26f1b058..69d362dc 100644
64
--- a/src/lxc/utils.c
65
+++ b/src/lxc/utils.c
66
@@ -2548,6 +2548,18 @@ bool has_fs_type(const char *path, fs_type_magic magic_val)
67
 	return has_type;
68
 }
69
 
70
+bool fhas_fs_type(int fd, fs_type_magic magic_val)
71
+{
72
+	int ret;
73
+	struct statfs sb;
74
+
75
+	ret = fstatfs(fd, &sb);
76
+	if (ret < 0)
77
+		return false;
78
+
79
+	return is_fs_type(&sb, magic_val);
80
+}
81
+
82
 bool lxc_nic_exists(char *nic)
83
 {
84
 #define __LXC_SYS_CLASS_NET_LEN 15 + IFNAMSIZ + 1
85
diff --git a/src/lxc/utils.h b/src/lxc/utils.h
86
index 7d672b77..fedc395b 100644
87
--- a/src/lxc/utils.h
88
+++ b/src/lxc/utils.h
89
@@ -95,6 +95,10 @@
90
 #define CGROUP2_SUPER_MAGIC 0x63677270
91
 #endif
92
 
93
+#ifndef NSFS_MAGIC
94
+#define NSFS_MAGIC 0x6e736673
95
+#endif
96
+
97
 /* Useful macros */
98
 /* Maximum number for 64 bit integer is a string with 21 digits: 2^64 - 1 = 21 */
99
 #define LXC_NUMSTRLEN64 21
100
@@ -581,6 +585,7 @@ extern void *must_realloc(void *orig, size_t sz);
101
 /* __typeof__ should be safe to use with all compilers. */
102
 typedef __typeof__(((struct statfs *)NULL)->f_type) fs_type_magic;
103
 extern bool has_fs_type(const char *path, fs_type_magic magic_val);
104
+extern bool fhas_fs_type(int fd, fs_type_magic magic_val);
105
 extern bool is_fs_type(const struct statfs *fs, fs_type_magic magic_val);
106
 extern bool lxc_nic_exists(char *nic);
107
 extern int lxc_make_tmpfile(char *template, bool rm);
108
-- 
109
2.17.1
110
(-)a/app-emulation/lxc/lxc-2.1.1-r1.ebuild (+215 lines)
Line 0 Link Here
1
# Copyright 1999-2018 Gentoo Foundation
2
# Distributed under the terms of the GNU General Public License v2
3
4
EAPI=6
5
6
PYTHON_COMPAT=( python3_{4,5,6} )
7
DISTUTILS_OPTIONAL=1
8
9
inherit autotools bash-completion-r1 distutils-r1 linux-info versionator flag-o-matic systemd readme.gentoo-r1
10
DESCRIPTION="LinuX Containers userspace utilities"
11
HOMEPAGE="https://linuxcontainers.org/"
12
SRC_URI="https://linuxcontainers.org/downloads/lxc/${P}.tar.gz"
13
14
KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86"
15
16
LICENSE="LGPL-3"
17
SLOT="0"
18
IUSE="cgmanager examples lua python seccomp selinux"
19
20
RDEPEND="
21
	net-libs/gnutls
22
	sys-libs/libcap
23
	cgmanager? ( app-admin/cgmanager )
24
	lua? ( >=dev-lang/lua-5.1:= )
25
	python? ( ${PYTHON_DEPS} )
26
	seccomp? ( sys-libs/libseccomp )
27
	selinux? ( sys-libs/libselinux )"
28
29
DEPEND="${RDEPEND}
30
	app-text/docbook-sgml-utils
31
	>=sys-kernel/linux-headers-3.2"
32
33
RDEPEND="${RDEPEND}
34
	sys-apps/util-linux
35
	app-misc/pax-utils
36
	virtual/awk"
37
38
CONFIG_CHECK="~CGROUPS ~CGROUP_DEVICE
39
	~CPUSETS ~CGROUP_CPUACCT
40
	~CGROUP_SCHED
41
42
	~NAMESPACES
43
	~IPC_NS ~USER_NS ~PID_NS
44
45
	~NETLINK_DIAG ~PACKET_DIAG
46
	~INET_UDP_DIAG ~INET_TCP_DIAG
47
	~UNIX_DIAG ~CHECKPOINT_RESTORE
48
49
	~CGROUP_FREEZER
50
	~UTS_NS ~NET_NS
51
	~VETH ~MACVLAN
52
53
	~POSIX_MQUEUE
54
	~!NETPRIO_CGROUP
55
56
	~!GRKERNSEC_CHROOT_MOUNT
57
	~!GRKERNSEC_CHROOT_DOUBLE
58
	~!GRKERNSEC_CHROOT_PIVOT
59
	~!GRKERNSEC_CHROOT_CHMOD
60
	~!GRKERNSEC_CHROOT_CAPS
61
	~!GRKERNSEC_PROC
62
	~!GRKERNSEC_SYSFS_RESTRICT
63
"
64
65
ERROR_DEVPTS_MULTIPLE_INSTANCES="CONFIG_DEVPTS_MULTIPLE_INSTANCES:  needed for pts inside container"
66
67
ERROR_CGROUP_FREEZER="CONFIG_CGROUP_FREEZER:  needed to freeze containers"
68
69
ERROR_UTS_NS="CONFIG_UTS_NS:  needed to unshare hostnames and uname info"
70
ERROR_NET_NS="CONFIG_NET_NS:  needed for unshared network"
71
72
ERROR_VETH="CONFIG_VETH:  needed for internal (host-to-container) networking"
73
ERROR_MACVLAN="CONFIG_MACVLAN:  needed for internal (inter-container) networking"
74
75
ERROR_NETLINK_DIAG="CONFIG_NETLINK_DIAG:  needed for lxc-checkpoint"
76
ERROR_PACKET_DIAG="CONFIG_PACKET_DIAG:  needed for lxc-checkpoint"
77
ERROR_INET_UDP_DIAG="CONFIG_INET_UDP_DIAG:  needed for lxc-checkpoint"
78
ERROR_INET_TCP_DIAG="CONFIG_INET_TCP_DIAG:  needed for lxc-checkpoint"
79
ERROR_UNIX_DIAG="CONFIG_UNIX_DIAG:  needed for lxc-checkpoint"
80
ERROR_CHECKPOINT_RESTORE="CONFIG_CHECKPOINT_RESTORE:  needed for lxc-checkpoint"
81
82
ERROR_POSIX_MQUEUE="CONFIG_POSIX_MQUEUE:  needed for lxc-execute command"
83
84
ERROR_NETPRIO_CGROUP="CONFIG_NETPRIO_CGROUP:  as of kernel 3.3 and lxc 0.8.0_rc1 this causes LXCs to fail booting."
85
86
ERROR_GRKERNSEC_CHROOT_MOUNT="CONFIG_GRKERNSEC_CHROOT_MOUNT:  some GRSEC features make LXC unusable see postinst notes"
87
ERROR_GRKERNSEC_CHROOT_DOUBLE="CONFIG_GRKERNSEC_CHROOT_DOUBLE:  some GRSEC features make LXC unusable see postinst notes"
88
ERROR_GRKERNSEC_CHROOT_PIVOT="CONFIG_GRKERNSEC_CHROOT_PIVOT:  some GRSEC features make LXC unusable see postinst notes"
89
ERROR_GRKERNSEC_CHROOT_CHMOD="CONFIG_GRKERNSEC_CHROOT_CHMOD:  some GRSEC features make LXC unusable see postinst notes"
90
ERROR_GRKERNSEC_CHROOT_CAPS="CONFIG_GRKERNSEC_CHROOT_CAPS:  some GRSEC features make LXC unusable see postinst notes"
91
ERROR_GRKERNSEC_PROC="CONFIG_GRKERNSEC_PROC:  this GRSEC feature is incompatible with unprivileged containers"
92
ERROR_GRKERNSEC_SYSFS_RESTRICT="CONFIG_GRKERNSEC_SYSFS_RESTRICT:  this GRSEC feature is incompatible with unprivileged containers"
93
94
DOCS=(AUTHORS CONTRIBUTING MAINTAINERS NEWS README doc/FAQ.txt)
95
96
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
97
98
pkg_setup() {
99
	kernel_is -lt 4 7 && CONFIG_CHECK="${CONFIG_CHECK} ~DEVPTS_MULTIPLE_INSTANCES"
100
	linux-info_pkg_setup
101
}
102
103
src_prepare() {
104
	eapply "${FILESDIR}"/${PN}-2.0.6-bash-completion.patch
105
	#558854
106
	eapply "${FILESDIR}"/${PN}-2.0.5-omit-sysconfig.patch
107
	eapply "${FILESDIR}"/${PN}-2.1.1-fix-cgroup2-detection.patch
108
	eapply "${FILESDIR}"/${PN}-2.1.1-cgroups-enable-container-without-CAP_SYS_ADMIN.patch
109
	eapply "${FILESDIR}"/${PN}-2.1.1-cve-2018-6556.patch
110
	eapply_user
111
	eautoreconf
112
}
113
114
src_configure() {
115
	append-flags -fno-strict-aliasing
116
117
	if use python; then
118
		#541932
119
		python_setup "python3*"
120
		export PKG_CONFIG_PATH="${T}/${EPYTHON}/pkgconfig:${PKG_CONFIG_PATH}"
121
	fi
122
123
	# I am not sure about the --with-rootfs-path
124
	# /var/lib/lxc is probably more appropriate than
125
	# /usr/lib/lxc.
126
	# Note by holgersson: Why is apparmor disabled?
127
128
	# --enable-doc is for manpages which is why we don't link it to a "doc"
129
	# USE flag. We always want man pages.
130
	econf \
131
		--localstatedir=/var \
132
		--bindir=/usr/bin \
133
		--sbindir=/usr/bin \
134
		--with-config-path=/var/lib/lxc	\
135
		--with-rootfs-path=/var/lib/lxc/rootfs \
136
		--with-distro=gentoo \
137
		--with-runtime-path=/run \
138
		--disable-apparmor \
139
		--disable-werror \
140
		--enable-doc \
141
		$(use_enable cgmanager) \
142
		$(use_enable examples) \
143
		$(use_enable lua) \
144
		$(use_enable python) \
145
		$(use_enable seccomp) \
146
		$(use_enable selinux)
147
}
148
149
python_compile() {
150
	distutils-r1_python_compile build_ext -I.. -L../lxc/.libs --no-pkg-config
151
}
152
153
src_compile() {
154
	default
155
156
	if use python; then
157
		pushd "${S}/src/python-${PN}" > /dev/null
158
		distutils-r1_src_compile
159
		popd > /dev/null
160
	fi
161
}
162
163
src_install() {
164
	default
165
166
	mv "${ED}"/usr/share/bash-completion/completions/${PN} "${ED}"/$(get_bashcompdir)/${PN}-start || die
167
	# start-ephemeral is no longer a command but removing it here
168
	# generates QA warnings (still in upstream completion script)
169
	bashcomp_alias ${PN}-start \
170
		${PN}-{attach,cgroup,copy,console,create,destroy,device,execute,freeze,info,monitor,snapshot,start-ephemeral,stop,unfreeze,wait}
171
172
	if use python; then
173
		pushd "${S}/src/python-lxc" > /dev/null
174
		# Unset DOCS. This has been handled by the default target
175
		unset DOCS
176
		distutils-r1_src_install
177
		popd > /dev/null
178
	fi
179
180
	keepdir /etc/lxc /var/lib/lxc/rootfs /var/log/lxc
181
182
	find "${D}" -name '*.la' -delete
183
184
	# Gentoo-specific additions!
185
	newinitd "${FILESDIR}/${PN}.initd.7" ${PN}
186
187
	# Remember to compare our systemd unit file with the upstream one
188
	# config/init/systemd/lxc.service.in
189
	systemd_newunit "${FILESDIR}"/${PN}_at.service.4 "lxc@.service"
190
191
	DOC_CONTENTS="
192
	Starting from version ${PN}-1.1.0-r3, the default lxc path has been
193
	moved from /etc/lxc to /var/lib/lxc. If you still want to use /etc/lxc
194
	please add the following to your /etc/lxc/lxc.conf
195
196
	  lxc.lxcpath = /etc/lxc
197
198
	For openrc, there is an init script provided with the package.
199
	You _should_ only need to symlink /etc/init.d/lxc to
200
	/etc/init.d/lxc.configname to start the container defined in
201
	/etc/lxc/configname.conf.
202
203
	Correspondingly, for systemd a service file lxc@.service is installed.
204
	Enable and start lxc@configname in order to start the container defined
205
	in /etc/lxc/configname.conf.
206
207
	If you want checkpoint/restore functionality, please install criu
208
	(sys-process/criu)."
209
	DISABLE_AUTOFORMATTING=true
210
	readme.gentoo_create_doc
211
}
212
213
pkg_postinst() {
214
	readme.gentoo_print_elog
215
}
(-)a/app-emulation/lxc/lxc-3.0.1-r1.ebuild (-1 / +163 lines)
Line 0 Link Here
0
- 
1
# Copyright 1999-2018 Gentoo Foundation
2
# Distributed under the terms of the GNU General Public License v2
3
4
EAPI=6
5
6
inherit autotools bash-completion-r1 linux-info flag-o-matic systemd readme.gentoo-r1 pam
7
8
DESCRIPTION="LinuX Containers userspace utilities"
9
HOMEPAGE="https://linuxcontainers.org/"
10
SRC_URI="https://linuxcontainers.org/downloads/lxc/${P}.tar.gz"
11
12
KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86"
13
14
LICENSE="LGPL-3"
15
SLOT="0"
16
IUSE="examples pam python seccomp selinux +templates"
17
18
RDEPEND="
19
	net-libs/gnutls
20
	sys-libs/libcap
21
	pam? ( virtual/pam )
22
	seccomp? ( sys-libs/libseccomp )
23
	selinux? ( sys-libs/libselinux )"
24
25
DEPEND="${RDEPEND}
26
	>=app-text/docbook-sgml-utils-0.6.14-r2
27
	>=sys-kernel/linux-headers-3.2"
28
29
RDEPEND="${RDEPEND}
30
	sys-apps/util-linux
31
	app-misc/pax-utils
32
	virtual/awk"
33
34
PDEPEND="templates? ( app-emulation/lxc-templates )
35
	python? ( dev-python/python3-lxc )"
36
37
CONFIG_CHECK="~CGROUPS ~CGROUP_DEVICE
38
	~CPUSETS ~CGROUP_CPUACCT
39
	~CGROUP_SCHED
40
41
	~NAMESPACES
42
	~IPC_NS ~USER_NS ~PID_NS
43
44
	~CGROUP_FREEZER
45
	~UTS_NS ~NET_NS
46
	~VETH ~MACVLAN
47
48
	~POSIX_MQUEUE
49
	~!NETPRIO_CGROUP
50
51
	~!GRKERNSEC_CHROOT_MOUNT
52
	~!GRKERNSEC_CHROOT_DOUBLE
53
	~!GRKERNSEC_CHROOT_PIVOT
54
	~!GRKERNSEC_CHROOT_CHMOD
55
	~!GRKERNSEC_CHROOT_CAPS
56
	~!GRKERNSEC_PROC
57
	~!GRKERNSEC_SYSFS_RESTRICT
58
"
59
60
ERROR_DEVPTS_MULTIPLE_INSTANCES="CONFIG_DEVPTS_MULTIPLE_INSTANCES:  needed for pts inside container"
61
62
ERROR_CGROUP_FREEZER="CONFIG_CGROUP_FREEZER:  needed to freeze containers"
63
64
ERROR_UTS_NS="CONFIG_UTS_NS:  needed to unshare hostnames and uname info"
65
ERROR_NET_NS="CONFIG_NET_NS:  needed for unshared network"
66
67
ERROR_VETH="CONFIG_VETH:  needed for internal (host-to-container) networking"
68
ERROR_MACVLAN="CONFIG_MACVLAN:  needed for internal (inter-container) networking"
69
70
ERROR_POSIX_MQUEUE="CONFIG_POSIX_MQUEUE:  needed for lxc-execute command"
71
72
ERROR_NETPRIO_CGROUP="CONFIG_NETPRIO_CGROUP:  as of kernel 3.3 and lxc 0.8.0_rc1 this causes LXCs to fail booting."
73
74
ERROR_GRKERNSEC_CHROOT_MOUNT="CONFIG_GRKERNSEC_CHROOT_MOUNT:  some GRSEC features make LXC unusable see postinst notes"
75
ERROR_GRKERNSEC_CHROOT_DOUBLE="CONFIG_GRKERNSEC_CHROOT_DOUBLE:  some GRSEC features make LXC unusable see postinst notes"
76
ERROR_GRKERNSEC_CHROOT_PIVOT="CONFIG_GRKERNSEC_CHROOT_PIVOT:  some GRSEC features make LXC unusable see postinst notes"
77
ERROR_GRKERNSEC_CHROOT_CHMOD="CONFIG_GRKERNSEC_CHROOT_CHMOD:  some GRSEC features make LXC unusable see postinst notes"
78
ERROR_GRKERNSEC_CHROOT_CAPS="CONFIG_GRKERNSEC_CHROOT_CAPS:  some GRSEC features make LXC unusable see postinst notes"
79
ERROR_GRKERNSEC_PROC="CONFIG_GRKERNSEC_PROC:  this GRSEC feature is incompatible with unprivileged containers"
80
ERROR_GRKERNSEC_SYSFS_RESTRICT="CONFIG_GRKERNSEC_SYSFS_RESTRICT:  this GRSEC feature is incompatible with unprivileged containers"
81
82
DOCS=(AUTHORS CONTRIBUTING MAINTAINERS NEWS README doc/FAQ.txt)
83
84
pkg_setup() {
85
	kernel_is -lt 4 7 && CONFIG_CHECK="${CONFIG_CHECK} ~DEVPTS_MULTIPLE_INSTANCES"
86
	linux-info_pkg_setup
87
}
88
89
src_prepare() {
90
	eapply "${FILESDIR}"/${PN}-3.0.0-bash-completion.patch
91
	#558854
92
	eapply "${FILESDIR}"/${PN}-2.0.5-omit-sysconfig.patch
93
	eapply "${FILESDIR}"/${PN}-3.0.1-cve-2018-6556.patch
94
	eapply_user
95
	eautoreconf
96
}
97
98
src_configure() {
99
	append-flags -fno-strict-aliasing
100
101
	# I am not sure about the --with-rootfs-path
102
	# /var/lib/lxc is probably more appropriate than
103
	# /usr/lib/lxc.
104
	# Note by holgersson: Why is apparmor disabled?
105
106
	# --enable-doc is for manpages which is why we don't link it to a "doc"
107
	# USE flag. We always want man pages.
108
	econf \
109
		--localstatedir=/var \
110
		--bindir=/usr/bin \
111
		--sbindir=/usr/bin \
112
		--with-config-path=/var/lib/lxc	\
113
		--with-rootfs-path=/var/lib/lxc/rootfs \
114
		--with-distro=gentoo \
115
		--with-runtime-path=/run \
116
		--disable-apparmor \
117
		--disable-werror \
118
		--enable-doc \
119
		$(use_enable examples) \
120
		$(use_enable pam) \
121
		$(use_with pam pamdir $(getpam_mod_dir)) \
122
		$(use_enable seccomp) \
123
		$(use_enable selinux)
124
}
125
126
src_install() {
127
	default
128
129
	mv "${ED}"/usr/share/bash-completion/completions/${PN} "${ED}"/$(get_bashcompdir)/${PN}-start || die
130
	bashcomp_alias ${PN}-start \
131
		${PN}-{attach,cgroup,copy,console,create,destroy,device,execute,freeze,info,monitor,snapshot,stop,unfreeze,wait}
132
133
	keepdir /etc/lxc /var/lib/lxc/rootfs /var/log/lxc
134
	rmdir "${D}"/var/cache/lxc "${D}"/var/cache || die "rmdir failed"
135
136
	find "${D}" -name '*.la' -delete
137
138
	# Gentoo-specific additions!
139
	newinitd "${FILESDIR}/${PN}.initd.7" ${PN}
140
141
	# Remember to compare our systemd unit file with the upstream one
142
	# config/init/systemd/lxc.service.in
143
	systemd_newunit "${FILESDIR}"/${PN}_at.service.4 "lxc@.service"
144
145
	DOC_CONTENTS="
146
	For openrc, there is an init script provided with the package.
147
	You _should_ only need to symlink /etc/init.d/lxc to
148
	/etc/init.d/lxc.configname to start the container defined in
149
	/etc/lxc/configname.conf.
150
151
	Correspondingly, for systemd a service file lxc@.service is installed.
152
	Enable and start lxc@configname in order to start the container defined
153
	in /etc/lxc/configname.conf.
154
155
	If you want checkpoint/restore functionality, please install criu
156
	(sys-process/criu)."
157
	DISABLE_AUTOFORMATTING=true
158
	readme.gentoo_create_doc
159
}
160
161
pkg_postinst() {
162
	readme.gentoo_print_elog
163
}

Return to bug 662780