Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/hardened-dev:uclibc commit in: sys-apps/util-linux/, sys-apps/util-linux/files/, ...
Date: Sat, 14 Jan 2012 03:00:43
Message-Id: 6735cb5e3c07838ad6247596e2848512e6fb73f1.blueness@gentoo
1 commit: 6735cb5e3c07838ad6247596e2848512e6fb73f1
2 Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jan 14 03:00:23 2012 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Sat Jan 14 03:00:23 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=6735cb5e
7
8 sys-apps/util-linux: pass -DHAVE_PROGRAM_INVOCATION_SHORT_NAME and unmask
9
10 (Portage version: 2.1.10.41/git/Linux x86_64, signed Manifest commit with key 0xD0455535)
11
12 ---
13 profiles/hardened/linux/uclibc/x86/package.mask | 1 -
14 profiles/vanilla/linux/uclibc/amd64/package.mask | 1 -
15 profiles/vanilla/linux/uclibc/x86/package.mask | 1 -
16 .../files/util-linux-2.19.1-mount-a-segv.patch | 86 +++++++++++++++++
17 .../files/util-linux-2.19.1-umount-l-nfs.patch | 92 +++++++++++++++++++
18 sys-apps/util-linux/metadata.xml | 13 +++
19 sys-apps/util-linux/util-linux-2.19.1-r1.ebuild | 97 ++++++++++++++++++++
20 7 files changed, 288 insertions(+), 3 deletions(-)
21
22 diff --git a/profiles/hardened/linux/uclibc/x86/package.mask b/profiles/hardened/linux/uclibc/x86/package.mask
23 index 208eaec..4f427dd 100644
24 --- a/profiles/hardened/linux/uclibc/x86/package.mask
25 +++ b/profiles/hardened/linux/uclibc/x86/package.mask
26 @@ -1,3 +1,2 @@
27 ->sys-apps/util-linux-2.18-r1
28 >sys-fs/udev-141
29 >sys-libs/pam-1.1.2
30
31 diff --git a/profiles/vanilla/linux/uclibc/amd64/package.mask b/profiles/vanilla/linux/uclibc/amd64/package.mask
32 index d372897..9298f3b 100644
33 --- a/profiles/vanilla/linux/uclibc/amd64/package.mask
34 +++ b/profiles/vanilla/linux/uclibc/amd64/package.mask
35 @@ -1,2 +1 @@
36 ->sys-apps/util-linux-2.18-r1
37 >sys-fs/udev-141
38
39 diff --git a/profiles/vanilla/linux/uclibc/x86/package.mask b/profiles/vanilla/linux/uclibc/x86/package.mask
40 index 208eaec..4f427dd 100644
41 --- a/profiles/vanilla/linux/uclibc/x86/package.mask
42 +++ b/profiles/vanilla/linux/uclibc/x86/package.mask
43 @@ -1,3 +1,2 @@
44 ->sys-apps/util-linux-2.18-r1
45 >sys-fs/udev-141
46 >sys-libs/pam-1.1.2
47
48 diff --git a/sys-apps/util-linux/files/util-linux-2.19.1-mount-a-segv.patch b/sys-apps/util-linux/files/util-linux-2.19.1-mount-a-segv.patch
49 new file mode 100644
50 index 0000000..1f358ba
51 --- /dev/null
52 +++ b/sys-apps/util-linux/files/util-linux-2.19.1-mount-a-segv.patch
53 @@ -0,0 +1,86 @@
54 +https://bugs.gentoo.org/366213
55 +
56 +From f53edda83ebcfd7015c3f35196d6cbd7bc2d8369 Mon Sep 17 00:00:00 2001
57 +From: Karel Zak <kzak@××××××.com>
58 +Date: Wed, 11 May 2011 16:57:27 +0200
59 +Subject: [PATCH] mount: -a segfaults when 4th field is omitted (mount
60 + options)
61 +
62 + # echo 'tmpd /tmp/x tmpfs' >> /etc/fstab
63 + # mkdir /tmp/x
64 + # mount -a
65 + segfault
66 +
67 +Reported-by: Mike Frysinger <vapier@g.o>
68 +Signed-off-by: Karel Zak <kzak@××××××.com>
69 +---
70 + mount/mount.c | 8 +++++---
71 + mount/mount_mntent.c | 5 +++--
72 + mount/sundries.c | 2 ++
73 + 3 files changed, 10 insertions(+), 5 deletions(-)
74 +
75 +diff --git a/mount/mount.c b/mount/mount.c
76 +index ba71149..29963c2 100644
77 +--- a/mount/mount.c
78 ++++ b/mount/mount.c
79 +@@ -1163,7 +1163,9 @@ is_mounted_same_loopfile(const char *node0, const char *loopfile, unsigned long
80 + res = loopfile_used_with((char *) mnt->m.mnt_fsname,
81 + loopfile, offset);
82 +
83 +- else if ((p = strstr(mnt->m.mnt_opts, "loop="))) {
84 ++ else if (mnt->m.mnt_opts &&
85 ++ (p = strstr(mnt->m.mnt_opts, "loop=")))
86 ++ {
87 + char *dev = xstrdup(p+5);
88 + if ((p = strchr(dev, ',')))
89 + *p = '\0';
90 +@@ -2052,8 +2054,8 @@ is_fstab_entry_mounted(struct mntentchn *mc, int verbose)
91 + goto yes;
92 +
93 + /* extra care for loop devices */
94 +- if ((strstr(mc->m.mnt_opts, "loop=") ||
95 +- (stat(mc->m.mnt_fsname, &st) == 0 && S_ISREG(st.st_mode)))) {
96 ++ if ((mc->m.mnt_opts && strstr(mc->m.mnt_opts, "loop=")) ||
97 ++ (stat(mc->m.mnt_fsname, &st) == 0 && S_ISREG(st.st_mode))) {
98 +
99 + char *p = get_option_value(mc->m.mnt_opts, "offset=");
100 + uintmax_t offset = 0;
101 +diff --git a/mount/mount_mntent.c b/mount/mount_mntent.c
102 +index d90def3..f42c0ad 100644
103 +--- a/mount/mount_mntent.c
104 ++++ b/mount/mount_mntent.c
105 +@@ -70,7 +70,7 @@ my_addmntent (mntFILE *mfp, struct my_mntent *mnt) {
106 + m1 = mangle(mnt->mnt_fsname);
107 + m2 = mangle(mnt->mnt_dir);
108 + m3 = mangle(mnt->mnt_type);
109 +- m4 = mangle(mnt->mnt_opts);
110 ++ m4 = mnt->mnt_opts ? mangle(mnt->mnt_opts) : "rw";
111 +
112 + res = fprintf (mfp->mntent_fp, "%s %s %s %s %d %d\n",
113 + m1, m2, m3, m4, mnt->mnt_freq, mnt->mnt_passno);
114 +@@ -78,7 +78,8 @@ my_addmntent (mntFILE *mfp, struct my_mntent *mnt) {
115 + free(m1);
116 + free(m2);
117 + free(m3);
118 +- free(m4);
119 ++ if (mnt->mnt_opts)
120 ++ free(m4);
121 + return (res < 0) ? 1 : 0;
122 + }
123 +
124 +diff --git a/mount/sundries.c b/mount/sundries.c
125 +index ae4501a..2dec37f 100644
126 +--- a/mount/sundries.c
127 ++++ b/mount/sundries.c
128 +@@ -217,6 +217,8 @@ matching_opts (const char *options, const char *test_opts) {
129 +
130 + if (test_opts == NULL)
131 + return 1;
132 ++ if (options == NULL)
133 ++ options = "";
134 +
135 + len = strlen(test_opts);
136 + q = alloca(len+1);
137 +--
138 +1.7.6
139 +
140
141 diff --git a/sys-apps/util-linux/files/util-linux-2.19.1-umount-l-nfs.patch b/sys-apps/util-linux/files/util-linux-2.19.1-umount-l-nfs.patch
142 new file mode 100644
143 index 0000000..72ec3aa
144 --- /dev/null
145 +++ b/sys-apps/util-linux/files/util-linux-2.19.1-umount-l-nfs.patch
146 @@ -0,0 +1,92 @@
147 +https://bugs.gentoo.org/370051
148 +
149 +From b3b0c657818aa6191e6494f88d671601dd9d837d Mon Sep 17 00:00:00 2001
150 +From: Petr Uzel <petr.uzel@××××.cz>
151 +Date: Wed, 29 Jun 2011 10:24:09 +0200
152 +Subject: [PATCH] umount: do not hang with disconnected NFS mounts
153 +
154 +Since util-linux commit f4612577c942a3683b97632ad0b49671897c2070,
155 +umount stat(2)s its argument to check whether it can be associated
156 +with some loop device. This could hang with broken NFS mounts.
157 +
158 +Fix by first checking mtab if umount's argument is mounted and only if
159 +we fail, check if there is a loop device associated.
160 +
161 +http://marc.info/?l=util-linux-ng&m=130924963804836&w=2
162 +
163 +Reported-by: Konstantin Khlebnikov <khlebnikov@××××××.org>
164 +Signed-off-by: Petr Uzel <petr.uzel@××××.cz>
165 +---
166 + mount/umount.c | 42 ++++++++++++++++++++++--------------------
167 + 1 files changed, 22 insertions(+), 20 deletions(-)
168 +
169 +diff --git a/mount/umount.c b/mount/umount.c
170 +index 0349cb3..96c940e 100644
171 +--- a/mount/umount.c
172 ++++ b/mount/umount.c
173 +@@ -600,6 +600,7 @@ umount_file (char *arg) {
174 + int fstab_has_user, fstab_has_users, fstab_has_owner, fstab_has_group;
175 + int ok, status = 0;
176 + struct stat statbuf;
177 ++ char *loopdev = NULL;
178 +
179 + if (!*arg) { /* "" would be expanded to `pwd` */
180 + die(2, _("Cannot unmount \"\"\n"));
181 +@@ -608,26 +609,7 @@ umount_file (char *arg) {
182 +
183 + file = canonicalize(arg); /* mtab paths are canonicalized */
184 +
185 +- /* if file is a regular file, check if it is associated
186 +- * with some loop device
187 +- */
188 +- if (!stat(file, &statbuf) && S_ISREG(statbuf.st_mode)) {
189 +- char *loopdev = NULL;
190 +- switch (find_loopdev_by_backing_file(file, &loopdev)) {
191 +- case 0:
192 +- if (verbose)
193 +- printf(_("%s is associated with %s, trying to unmount it\n"),
194 +- arg, loopdev);
195 +- file = loopdev;
196 +- break;
197 +- case 2:
198 +- if (verbose)
199 +- printf(_("%s is associated with more than one loop device: not unmounting\n"),
200 +- arg);
201 +- break;
202 +- }
203 +- }
204 +-
205 ++try_loopdev:
206 + if (verbose > 1)
207 + printf(_("Trying to unmount %s\n"), file);
208 +
209 +@@ -659,6 +641,26 @@ umount_file (char *arg) {
210 + if (!mc && verbose)
211 + printf(_("Could not find %s in mtab\n"), file);
212 +
213 ++ /* not found in mtab - check if it is associated with some loop device
214 ++ * (only if it is a regular file)
215 ++ */
216 ++ if (!mc && !loopdev && !stat(file, &statbuf) && S_ISREG(statbuf.st_mode)) {
217 ++ switch (find_loopdev_by_backing_file(file, &loopdev)) {
218 ++ case 0:
219 ++ if (verbose)
220 ++ printf(_("%s is associated with %s\n"),
221 ++ arg, loopdev);
222 ++ file = loopdev;
223 ++ goto try_loopdev;
224 ++ break;
225 ++ case 2:
226 ++ if (verbose)
227 ++ printf(_("%s is associated with more than one loop device: not unmounting\n"),
228 ++ arg);
229 ++ break;
230 ++ }
231 ++ }
232 ++
233 + if (restricted) {
234 + char *mtab_user = NULL;
235 +
236 +--
237 +1.7.6
238 +
239
240 diff --git a/sys-apps/util-linux/metadata.xml b/sys-apps/util-linux/metadata.xml
241 new file mode 100644
242 index 0000000..8a9b6a7
243 --- /dev/null
244 +++ b/sys-apps/util-linux/metadata.xml
245 @@ -0,0 +1,13 @@
246 +<?xml version="1.0" encoding="UTF-8"?>
247 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
248 +<pkgmetadata>
249 + <herd>base-system</herd>
250 + <maintainer restrict="sys-apps/util-linux[loop-aes]">
251 + <email>c1pher@g.o</email>
252 + <name>Dane Smith</name>
253 + </maintainer>
254 +<use>
255 + <flag name='cramfs'>build mkfs/fsck helpers for cramfs filesystems</flag>
256 + <flag name='perl'>install the chkdupexe helper script</flag>
257 +</use>
258 +</pkgmetadata>
259
260 diff --git a/sys-apps/util-linux/util-linux-2.19.1-r1.ebuild b/sys-apps/util-linux/util-linux-2.19.1-r1.ebuild
261 new file mode 100644
262 index 0000000..737bfae
263 --- /dev/null
264 +++ b/sys-apps/util-linux/util-linux-2.19.1-r1.ebuild
265 @@ -0,0 +1,97 @@
266 +# Copyright 1999-2012 Gentoo Foundation
267 +# Distributed under the terms of the GNU General Public License v2
268 +# $Header: /var/cvsroot/gentoo-x86/sys-apps/util-linux/util-linux-2.19.1-r1.ebuild,v 1.12 2012/01/07 20:54:37 vapier Exp $
269 +
270 +EAPI="3"
271 +
272 +EGIT_REPO_URI="git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git"
273 +inherit eutils toolchain-funcs libtool flag-o-matic
274 +
275 +MY_PV=${PV/_/-}
276 +MY_P=${PN}-${MY_PV}
277 +S=${WORKDIR}/${MY_P}
278 +
279 +DESCRIPTION="Various useful Linux utilities"
280 +HOMEPAGE="http://www.kernel.org/pub/linux/utils/util-linux/"
281 +SRC_URI="mirror://kernel/linux/utils/util-linux/v${PV:0:4}/${MY_P}.tar.bz2"
282 +KEYWORDS="~amd64 ~x86"
283 +
284 +LICENSE="GPL-2 GPL-3 LGPL-2.1 BSD-4 MIT public-domain"
285 +SLOT="0"
286 +IUSE="+cramfs crypt ncurses nls old-linux perl selinux slang uclibc unicode"
287 +
288 +RDEPEND="
289 + !<sys-libs/e2fsprogs-libs-1.41.8
290 + !<sys-fs/e2fsprogs-1.41.8
291 + cramfs? ( sys-libs/zlib )
292 + ncurses? ( >=sys-libs/ncurses-5.2-r2 )
293 + perl? ( dev-lang/perl )
294 + selinux? ( sys-libs/libselinux )
295 + slang? ( sys-libs/slang )"
296 +DEPEND="${RDEPEND}
297 + nls? ( sys-devel/gettext )
298 + virtual/os-headers"
299 +
300 +src_prepare() {
301 + epatch "${FILESDIR}"/${P}-mount-a-segv.patch #366213
302 + epatch "${FILESDIR}"/${P}-umount-l-nfs.patch #370051
303 + use uclibc && sed -i -e s/versionsort/alphasort/g -e s/strverscmp.h/dirent.h/g mount/lomount.c
304 + elibtoolize
305 +}
306 +
307 +lfs_fallocate_test() {
308 + # Make sure we can use fallocate with LFS #300307
309 + cat <<-EOF > "${T}"/fallocate.c
310 + #define _GNU_SOURCE
311 + #include <fcntl.h>
312 + main() { return fallocate(0, 0, 0, 0); }
313 + EOF
314 + append-lfs-flags
315 + $(tc-getCC) ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} "${T}"/fallocate.c -o /dev/null >/dev/null 2>&1 \
316 + || export ac_cv_func_fallocate=no
317 + rm -f "${T}"/fallocate.c
318 +}
319 +
320 +usex() { use $1 && echo ${2:-yes} || echo ${3:-no} ; }
321 +src_configure() {
322 + lfs_fallocate_test
323 + append-flags -DHAVE_PROGRAM_INVOCATION_SHORT_NAME
324 + econf \
325 + --enable-fs-paths-extra=/usr/sbin \
326 + $(use_enable nls) \
327 + --enable-agetty \
328 + $(use_enable cramfs) \
329 + $(use_enable old-linux elvtune) \
330 + --with-ncurses=$(usex ncurses $(usex unicode auto yes) no) \
331 + --disable-init \
332 + --disable-kill \
333 + --disable-last \
334 + --disable-mesg \
335 + --enable-partx \
336 + --enable-raw \
337 + --enable-rename \
338 + --disable-reset \
339 + --disable-login-utils \
340 + --enable-schedutils \
341 + --disable-wall \
342 + --enable-write \
343 + --without-pam \
344 + $(use_with selinux) \
345 + $(use_with slang) \
346 + $(tc-has-tls || echo --disable-tls)
347 +}
348 +
349 +src_install() {
350 + emake install DESTDIR="${D}" || die "install failed"
351 + dodoc AUTHORS NEWS README* TODO docs/*
352 +
353 + if ! use perl ; then #284093
354 + rm "${ED}"/usr/bin/chkdupexe || die
355 + rm "${ED}"/usr/share/man/man1/chkdupexe.1 || die
356 + fi
357 +
358 + # need the libs in /
359 + gen_usr_ldscript -a blkid uuid
360 + # e2fsprogs-libs didnt install .la files, and .pc work fine
361 + rm -f "${ED}"/usr/$(get_libdir)/*.la
362 +}