Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/lvm2/files/, sys-fs/lvm2/
Date: Sun, 02 Jun 2019 22:31:58
Message-Id: 1559514686.5280d91e79ababa0c952b703fb0f1e1146b68207.whissi@gentoo
1 commit: 5280d91e79ababa0c952b703fb0f1e1146b68207
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jun 2 22:31:26 2019 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Sun Jun 2 22:31:26 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5280d91e
7
8 sys-fs/lvm2: allow reading metadata with invalid creation_time
9
10 Closes: https://bugs.gentoo.org/682380
11 Package-Manager: Portage-2.3.67, Repoman-2.3.13
12 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
13
14 ...ading-metadata-with-invalid-creation_time.patch | 72 ++++++
15 sys-fs/lvm2/lvm2-2.02.184-r4.ebuild | 270 +++++++++++++++++++++
16 2 files changed, 342 insertions(+)
17
18 diff --git a/sys-fs/lvm2/files/lvm2-2.02.184-allow-reading-metadata-with-invalid-creation_time.patch b/sys-fs/lvm2/files/lvm2-2.02.184-allow-reading-metadata-with-invalid-creation_time.patch
19 new file mode 100644
20 index 00000000000..34968c7c2eb
21 --- /dev/null
22 +++ b/sys-fs/lvm2/files/lvm2-2.02.184-allow-reading-metadata-with-invalid-creation_time.patch
23 @@ -0,0 +1,72 @@
24 +From a397b69ce33d811aba7d64d54b5c8e0efb86fd15 Mon Sep 17 00:00:00 2001
25 +From: Zdenek Kabelac <zkabelac@××××××.com>
26 +Date: Fri, 10 May 2019 14:40:11 +0200
27 +Subject: [PATCH] metadata: allow reading metadata with invalid creation_time
28 +
29 +lvm2 till version 2.02.169 (commit 78d004efa8a1809cea68283e6204edfa9d7c1091)
30 +was printing invalid creation_time argument into metadata on 32bit arch.
31 +
32 +However with commit ba9820b14223b731125c83dbc9709aa44fdcdbf1 we started
33 +to properly validate all input numbers and thus we refused to accept
34 +invalid metadata with 'garbage' string - but this results in the
35 +situation where metadata produced on older lvm2 on 32 bit architecture
36 +will become unreadable after upgrade.
37 +
38 +To fix this case - extend libdm parser in a way, that whenever we
39 +find error integer value, we also check if the parsed value is not for
40 +creation_time node and in this case we let the metadata pass through
41 +with made-up date 2018-05-24 (release date of 2.02.169).
42 +---
43 + libdm/libdm-config.c | 18 +++++++++++++++---
44 + 1 file changed, 15 insertions(+), 3 deletions(-)
45 +
46 +diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c
47 +index 3f0d2510e..382f86bbf 100644
48 +--- a/libdm/libdm-config.c
49 ++++ b/libdm/libdm-config.c
50 +@@ -51,6 +51,8 @@ struct parser {
51 +
52 + struct dm_pool *mem;
53 + int no_dup_node_check; /* whether to disable dup node checking */
54 ++ const char *key; /* last obtained key */
55 ++ unsigned ignored_creation_time;
56 + };
57 +
58 + struct config_output {
59 +@@ -176,7 +178,7 @@ static int _do_dm_config_parse(struct dm_config_tree *cft, const char *start, co
60 + /* TODO? if (start == end) return 1; */
61 +
62 + struct parser *p;
63 +- if (!(p = dm_pool_alloc(cft->mem, sizeof(*p))))
64 ++ if (!(p = dm_pool_zalloc(cft->mem, sizeof(*p))))
65 + return_0;
66 +
67 + p->mem = cft->mem;
68 +@@ -615,6 +617,7 @@ static struct dm_config_node *_section(struct parser *p, struct dm_config_node *
69 + match(TOK_SECTION_E);
70 + } else {
71 + match(TOK_EQ);
72 ++ p->key = root->key;
73 + if (!(value = _value(p)))
74 + return_NULL;
75 + if (root->v)
76 +@@ -682,8 +685,17 @@ static struct dm_config_value *_type(struct parser *p)
77 + errno = 0;
78 + v->v.i = strtoll(p->tb, NULL, 0); /* FIXME: check error */
79 + if (errno) {
80 +- log_error("Failed to read int token.");
81 +- return NULL;
82 ++ if (errno == ERANGE && p->key &&
83 ++ strcmp("creation_time", p->key) == 0) {
84 ++ /* Due to a bug in some older 32bit builds (<2.02.169),
85 ++ * lvm was able to produce invalid creation_time string */
86 ++ v->v.i = 1527120000; /* Pick 2018-05-24 day instead */
87 ++ if (!p->ignored_creation_time++)
88 ++ log_warn("WARNING: Invalid creation_time found in metadata (repaired with next metadata update).");
89 ++ } else {
90 ++ log_error("Failed to read int token.");
91 ++ return NULL;
92 ++ }
93 + }
94 + match(TOK_INT);
95 + break;
96
97 diff --git a/sys-fs/lvm2/lvm2-2.02.184-r4.ebuild b/sys-fs/lvm2/lvm2-2.02.184-r4.ebuild
98 new file mode 100644
99 index 00000000000..9100bbfa3e2
100 --- /dev/null
101 +++ b/sys-fs/lvm2/lvm2-2.02.184-r4.ebuild
102 @@ -0,0 +1,270 @@
103 +# Copyright 1999-2019 Gentoo Authors
104 +# Distributed under the terms of the GNU General Public License v2
105 +
106 +EAPI=6
107 +inherit autotools linux-info multilib systemd toolchain-funcs udev flag-o-matic
108 +
109 +DESCRIPTION="User-land utilities for LVM2 (device-mapper) software"
110 +HOMEPAGE="https://sourceware.org/lvm2/"
111 +SRC_URI="ftp://sourceware.org/pub/lvm2/${PN/lvm/LVM}.${PV}.tgz
112 + ftp://sourceware.org/pub/lvm2/old/${PN/lvm/LVM}.${PV}.tgz"
113 +
114 +LICENSE="GPL-2"
115 +SLOT="0"
116 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux"
117 +IUSE="readline static static-libs systemd lvm2create_initrd sanlock selinux +udev +thin device-mapper-only"
118 +REQUIRED_USE="device-mapper-only? ( !lvm2create_initrd !sanlock !thin )
119 + systemd? ( udev )"
120 +
121 +DEPEND_COMMON="
122 + dev-libs/libaio[static-libs?]
123 + static? ( dev-libs/libaio[static-libs] )
124 + !static? ( dev-libs/libaio[static-libs?] )
125 + readline? ( sys-libs/readline:0= )
126 + sanlock? ( sys-cluster/sanlock )
127 + systemd? ( >=sys-apps/systemd-205:0= )
128 + udev? ( >=virtual/libudev-208:=[static-libs?] )"
129 +# /run is now required for locking during early boot. /var cannot be assumed to
130 +# be available -- thus, pull in recent enough baselayout for /run.
131 +# This version of LVM is incompatible with cryptsetup <1.1.2.
132 +RDEPEND="${DEPEND_COMMON}
133 + >=sys-apps/baselayout-2.2
134 + !<sys-apps/openrc-0.11
135 + !<sys-fs/cryptsetup-1.1.2
136 + !!sys-fs/lvm-user
137 + >=sys-apps/util-linux-2.16
138 + lvm2create_initrd? ( sys-apps/makedev )
139 + thin? ( >=sys-block/thin-provisioning-tools-0.3.0 )"
140 +# note: thin- 0.3.0 is required to avoid --disable-thin_check_needs_check
141 +# USE 'static' currently only works with eudev, bug 520450
142 +DEPEND="${DEPEND_COMMON}
143 + virtual/pkgconfig
144 + >=sys-devel/binutils-2.20.1-r1
145 + sys-devel/autoconf-archive
146 + static? (
147 + selinux? ( sys-libs/libselinux[static-libs] )
148 + udev? ( >=sys-fs/eudev-3.1.2[static-libs] )
149 + >=sys-apps/util-linux-2.16[static-libs]
150 + )"
151 +
152 +S=${WORKDIR}/${PN/lvm/LVM}.${PV}
153 +
154 +PATCHES=(
155 + # Gentoo specific modification(s):
156 + "${FILESDIR}"/${PN}-2.02.178-example.conf.in.patch
157 +
158 + # For upstream -- review and forward:
159 + "${FILESDIR}"/${PN}-2.02.63-always-make-static-libdm.patch
160 + "${FILESDIR}"/${PN}-2.02.56-lvm2create_initrd.patch
161 + "${FILESDIR}"/${PN}-2.02.67-createinitrd.patch #301331
162 + "${FILESDIR}"/${PN}-2.02.99-locale-muck.patch #330373
163 + "${FILESDIR}"/${PN}-2.02.178-asneeded.patch # -Wl,--as-needed
164 + "${FILESDIR}"/${PN}-2.02.178-dynamic-static-ldflags.patch #332905
165 + "${FILESDIR}"/${PN}-2.02.178-static-pkgconfig-libs.patch #370217, #439414 + blkid
166 + "${FILESDIR}"/${PN}-2.02.176-pthread-pkgconfig.patch #492450
167 + "${FILESDIR}"/${PN}-2.02.171-static-libm.patch #617756
168 + "${FILESDIR}"/${PN}-2.02.166-HPPA-no-O_DIRECT.patch #657446
169 + #"${FILESDIR}"/${PN}-2.02.145-mkdev.patch #580062 # Merged upstream
170 + "${FILESDIR}"/${PN}-2.02.184-dmeventd-no-idle-exit.patch
171 + "${FILESDIR}"/${PN}-2.02.184-allow-reading-metadata-with-invalid-creation_time.patch #682380
172 +)
173 +
174 +pkg_setup() {
175 + local CONFIG_CHECK="~SYSVIPC"
176 +
177 + if use udev; then
178 + local WARNING_SYSVIPC="CONFIG_SYSVIPC:\tis not set (required for udev sync)\n"
179 + if linux_config_exists; then
180 + local uevent_helper_path=$(linux_chkconfig_string UEVENT_HELPER_PATH)
181 + if [ -n "${uevent_helper_path}" ] && [ "${uevent_helper_path}" != '""' ]; then
182 + ewarn "It's recommended to set an empty value to the following kernel config option:"
183 + ewarn "CONFIG_UEVENT_HELPER_PATH=${uevent_helper_path}"
184 + fi
185 + fi
186 + fi
187 +
188 + check_extra_config
189 +
190 + # 1. Genkernel no longer copies /sbin/lvm blindly.
191 + if use static; then
192 + elog "Warning, we no longer overwrite /sbin/lvm and /sbin/dmsetup with"
193 + elog "their static versions. If you need the static binaries,"
194 + elog "you must append .static to the filename!"
195 + fi
196 +}
197 +
198 +src_prepare() {
199 + default
200 +
201 + sed -i \
202 + -e "1iAR = $(tc-getAR)" \
203 + -e "s:CC ?= @CC@:CC = $(tc-getCC):" \
204 + make.tmpl.in || die #444082
205 +
206 + sed -i -e '/FLAG/s:-O2::' configure{.ac,} || die #480212
207 +
208 + if use udev && ! use device-mapper-only; then
209 + sed -i -e '/use_lvmetad =/s:0:1:' conf/example.conf.in || die #514196
210 + elog "Notice that \"use_lvmetad\" setting is enabled with USE=\"udev\" in"
211 + elog "/etc/lvm/lvm.conf, which will require restart of udev, lvm, and lvmetad"
212 + elog "if it was previously disabled."
213 + fi
214 +
215 + sed -i -e "s:/usr/bin/true:$(type -P true):" scripts/blk_availability_systemd_red_hat.service.in || die #517514
216 +
217 + # Without thin-privision-tools, there is nothing to install for target install_man7:
218 + if ! use thin ; then
219 + sed -i -e '/^install_lvm2/s:install_man7::' man/Makefile.in || die
220 + fi
221 +
222 + eautoreconf
223 +}
224 +
225 +src_configure() {
226 + filter-flags -flto
227 + local myeconfargs=()
228 +
229 + # Most of this package does weird stuff.
230 + # The build options are tristate, and --without is NOT supported
231 + # options: 'none', 'internal', 'shared'
232 + myeconfargs+=(
233 + $(use_enable !device-mapper-only dmfilemapd)
234 + $(use_enable !device-mapper-only dmeventd)
235 + $(use_enable !device-mapper-only cmdlib)
236 + $(use_enable !device-mapper-only applib)
237 + $(use_enable !device-mapper-only fsadm)
238 + $(use_enable !device-mapper-only lvmetad)
239 + $(use_enable !device-mapper-only lvmpolld)
240 + $(usex device-mapper-only --disable-udev-systemd-background-jobs '')
241 +
242 + # This only causes the .static versions to become available
243 + $(usex static --enable-static_link '')
244 +
245 + # dmeventd requires mirrors to be internal, and snapshot available
246 + # so we cannot disable them
247 + --with-mirrors="$(usex device-mapper-only none internal)"
248 + --with-snapshots="$(usex device-mapper-only none internal)"
249 +
250 + # disable O_DIRECT support on hppa, breaks pv detection (#99532)
251 + $(usex hppa --disable-o_direct '')
252 + )
253 +
254 + if use thin; then
255 + myeconfargs+=( --with-thin=internal --with-cache=internal )
256 + local texec
257 + for texec in check dump repair restore; do
258 + myeconfargs+=( --with-thin-${texec}="${EPREFIX}"/sbin/thin_${texec} )
259 + myeconfargs+=( --with-cache-${texec}="${EPREFIX}"/sbin/cache_${texec} )
260 + done
261 + else
262 + myeconfargs+=( --with-thin=none --with-cache=none )
263 + fi
264 +
265 + myeconfargs+=( --with-clvmd=none --with-cluster=none )
266 +
267 + myeconfargs+=(
268 + $(use_enable readline)
269 + $(use_enable selinux)
270 + --enable-pkgconfig
271 + --with-confdir="${EPREFIX}"/etc
272 + --exec-prefix="${EPREFIX}"
273 + --sbindir="${EPREFIX}/sbin"
274 + --with-staticdir="${EPREFIX}"/sbin
275 + --libdir="${EPREFIX}/$(get_libdir)"
276 + --with-usrlibdir="${EPREFIX}/usr/$(get_libdir)"
277 + --with-default-dm-run-dir=/run
278 + --with-default-run-dir=/run/lvm
279 + --with-default-locking-dir=/run/lock/lvm
280 + --with-default-pid-dir=/run
281 + $(use_enable udev udev_rules)
282 + $(use_enable udev udev_sync)
283 + $(use_with udev udevdir "$(get_udevdir)"/rules.d)
284 + $(use_enable sanlock lvmlockd-sanlock)
285 + $(use_enable systemd udev-systemd-background-jobs)
286 + $(use_enable systemd notify-dbus)
287 + --with-systemdsystemunitdir="$(systemd_get_systemunitdir)"
288 + CLDFLAGS="${LDFLAGS}"
289 + )
290 + econf "${myeconfargs[@]}"
291 +}
292 +
293 +src_compile() {
294 + pushd include >/dev/null
295 + emake
296 + popd >/dev/null
297 +
298 + if use device-mapper-only ; then
299 + emake device-mapper
300 + else
301 + emake
302 + emake CC="$(tc-getCC)" -C scripts lvm2_activation_generator_systemd_red_hat
303 + fi
304 +}
305 +
306 +src_install() {
307 + local inst INSTALL_TARGETS
308 + INSTALL_TARGETS=( install install_tmpfiles_configuration )
309 + # install systemd related files only when requested, bug #522430
310 + use systemd && INSTALL_TARGETS+=( install_systemd_units install_systemd_generators )
311 + use device-mapper-only && INSTALL_TARGETS=( install_device-mapper )
312 + for inst in ${INSTALL_TARGETS[@]}; do
313 + emake DESTDIR="${D}" ${inst}
314 + done
315 +
316 + newinitd "${FILESDIR}"/device-mapper.rc-2.02.105-r2 device-mapper
317 + newconfd "${FILESDIR}"/device-mapper.conf-1.02.22-r3 device-mapper
318 +
319 + if use !device-mapper-only ; then
320 + newinitd "${FILESDIR}"/dmeventd.initd-2.02.184-r2 dmeventd
321 + newinitd "${FILESDIR}"/lvm.rc-2.02.184-r3 lvm
322 + newconfd "${FILESDIR}"/lvm.confd-2.02.184-r3 lvm
323 + if ! use udev ; then
324 + # We keep the variable but remove udev from it.
325 + sed -r -i \
326 + -e '/^rc_need=/s/\<udev\>//g' \
327 + "${ED}/etc/conf.d/lvm" || die "Could not drop udev from rc_need"
328 + fi
329 +
330 + newinitd "${FILESDIR}"/lvm-monitoring.initd-2.02.105-r2 lvm-monitoring
331 + newinitd "${FILESDIR}"/lvmetad.initd-2.02.116-r3 lvmetad
332 + newinitd "${FILESDIR}"/lvmpolld.initd-2.02.183 lvmpolld
333 + fi
334 +
335 + if use sanlock; then
336 + newinitd "${FILESDIR}"/lvmlockd.initd-2.02.166-r1 lvmlockd
337 + fi
338 +
339 + if use static-libs; then
340 + dolib.a libdm/ioctl/libdevmapper.a
341 + dolib.a libdaemon/client/libdaemonclient.a #462908
342 + #gen_usr_ldscript libdevmapper.so
343 + dolib.a daemons/dmeventd/libdevmapper-event.a
344 + #gen_usr_ldscript libdevmapper-event.so
345 + else
346 + rm -f "${ED%/}"/usr/$(get_libdir)/{libdevmapper-event,liblvm2cmd,liblvm2app,libdevmapper}.a
347 + fi
348 +
349 + if use lvm2create_initrd; then
350 + dosbin scripts/lvm2create_initrd/lvm2create_initrd
351 + doman scripts/lvm2create_initrd/lvm2create_initrd.8
352 + newdoc scripts/lvm2create_initrd/README README.lvm2create_initrd
353 + fi
354 +
355 + insinto /etc
356 + doins "${FILESDIR}"/dmtab
357 +
358 + dodoc README VERSION* WHATS_NEW WHATS_NEW_DM doc/*.{c,txt} conf/*.conf
359 +}
360 +
361 +pkg_postinst() {
362 + ewarn "Make sure the \"lvm\" init script is in the runlevels:"
363 + ewarn "# rc-update add lvm boot"
364 + ewarn
365 + ewarn "Make sure to enable lvmetad in /etc/lvm/lvm.conf if you want"
366 + ewarn "to enable lvm autoactivation and metadata caching."
367 +}
368 +
369 +src_test() {
370 + einfo "Tests are disabled because of device-node mucking, if you want to"
371 + einfo "run tests, compile the package and see ${S}/tests"
372 +}