Skip to content

Commit

Permalink
Added uclibc-compatbile version of util-linux-2.19.1
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Smirnov <civil.over@gmail.com>
  • Loading branch information
Civil committed Jan 22, 2012
1 parent 8cbd727 commit 2c34b60
Show file tree
Hide file tree
Showing 6 changed files with 387 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sys-apps/util-linux/Manifest
@@ -0,0 +1,7 @@
AUX crypto-loop.confd 412 RMD160 5e65febe9641a8362078fdae39b4ac955fb2e63b SHA1 2f881a24ff67115e74de7a11c66a34a745060864 SHA256 188c945e5e6c54cb14874057c625ff30b72fb33d3d5648e53de2f231a3375600
AUX crypto-loop.initd 1729 RMD160 fa53920677d793cf98cad994e4dabd53e53d8d04 SHA1 19d3b7c4aa95cdadde2f6fb81a391081eae04f42 SHA256 b8329250c865e79a1e761d713c2270c99d5fe96e0d5a7ca646946fab65c4b810
AUX util-linux-2.19.1-mount-a-segv.patch 2610 RMD160 67beca8dda0e48a80246c0904329944b978d445a SHA1 8eb682296c0b948a8931d71f0780f446bdd79027 SHA256 c24dc0ed811e6c0ebc69f15c818cf89aeb1dc12b5f2f62163402ad4479d7aec9
AUX util-linux-2.19.1-umount-l-nfs.patch 2721 RMD160 60e0ccf77633bec6b7a1576810aadd937e464b46 SHA1 ec611d245d42a4ec721fdcc0301f433577d4a45c SHA256 f889de8dba4cb412ec0afcd2605c4f97e0870c6325dd0200e8c8c06794b4bf64
DIST util-linux-2.19.1-20110510.diff.bz2 47865 RMD160 0983ac7a48031e4b3e0ddce213887526cfa17bc0 SHA1 e73c7bca691b5d83c1b2725d53a5b669fb268495 SHA256 e04f541ca48951284331e71cbf142d777750dbc9baa051ed9e9913c7dab32b7f
DIST util-linux-2.19.1.tar.bz2 4396543 RMD160 e4763d21a3a32029ccc525a0222e271f0946a4fd SHA1 96af5d4a37c42296dae5365ba533316216a6b347 SHA256 d3eac4afcc687b3ae1ffedcab2dc12df84c7ba7045cce31386d2b7040a011c7d
EBUILD util-linux-2.19.1-r1.ebuild 3720 RMD160 653f0231cd817c6c57dd8087997fba4bc5148ec1 SHA1 7915ae0806564703e3b7986b64d5e086edd463ef SHA256 d58c3a753c545ba876179ca218a34993625da0b4df6b80dba5da9e07aef4b6f2
9 changes: 9 additions & 0 deletions sys-apps/util-linux/files/crypto-loop.confd
@@ -0,0 +1,9 @@
# /etc/conf.d/crypto-loop: Configuration file for /etc/init.d/crypto-loop

# More info can be found in the init.d script

# Specify loopback configurations here. The format of this file is
# shown in the following commented-out example. One line per loopback
# configuration. For possible hash values, see `man hashalot`.

# loop=/dev/loop0 hash='' cipher=serpent keysize=256 device=/dev/system/test other=''
70 changes: 70 additions & 0 deletions sys-apps/util-linux/files/crypto-loop.initd
@@ -0,0 +1,70 @@
#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/util-linux/files/crypto-loop.initd,v 1.4 2008/10/26 03:16:48 vapier Exp $

depend() {
if [ -x /etc/init.d/root ]; then
need root
else
need checkroot
fi
need modules
before localmount
}

start() {
local status="0"

ebegin "Starting crypto loop devices"

if [ -e /etc/conf.d/crypto-loop ] ; then
egrep "^loop" /etc/conf.d/crypto-loop | \
while read loopline ; do
eval ${loopline}

local configured=$(awk -v MOUNT="${device}" \
'($2 == MOUNT) { print "yes" }' /proc/mounts)

if [ "${configured}" != "yes" ] ; then
einfo " Loop ${loop} on device ${device} (cipher ${cipher}, key size ${keysize}): "

if [ -n "${hash}" ] ; then
/usr/sbin/hashalot -n ${keysize} ${hash} </dev/tty|\
/sbin/losetup -p 0 -e ${cipher}-${keysize} ${loop} ${device} ${other}
else
/sbin/losetup -e ${cipher}-${keysize} ${loop} ${device} ${other}
fi

if [ $? -ne 0 ] ; then
ewarn "Failure configuring ${loop}. Skipping."
status=1
fi
else
ewarn " Loop ${loop} on device ${device} are already configured"
fi
done
fi
ewend ${status} "Failed to start some loop devices."

# We do not fail if some loop devices did not start ...
return 0
}

stop() {
local status="0"
for loop in $(ls /dev/loop[0-9] 2>/dev/null) ; do
losetup ${loop} > /dev/null 2>&1
if [ $? -eq 0 ] ; then
( umount ${loop} || swapoff "${loop}" ) >/dev/null 2>&1
if ! /sbin/losetup -d ${loop} > /dev/null 2>&1; then
ewarn "Failure deconfiguring ${loop}."
status=1
fi
fi
done
ewend ${status}
}


# vim:ts=4
86 changes: 86 additions & 0 deletions sys-apps/util-linux/files/util-linux-2.19.1-mount-a-segv.patch
@@ -0,0 +1,86 @@
https://bugs.gentoo.org/366213

From f53edda83ebcfd7015c3f35196d6cbd7bc2d8369 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 11 May 2011 16:57:27 +0200
Subject: [PATCH] mount: -a segfaults when 4th field is omitted (mount
options)

# echo 'tmpd /tmp/x tmpfs' >> /etc/fstab
# mkdir /tmp/x
# mount -a
segfault

Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
---
mount/mount.c | 8 +++++---
mount/mount_mntent.c | 5 +++--
mount/sundries.c | 2 ++
3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/mount/mount.c b/mount/mount.c
index ba71149..29963c2 100644
--- a/mount/mount.c
+++ b/mount/mount.c
@@ -1163,7 +1163,9 @@ is_mounted_same_loopfile(const char *node0, const char *loopfile, unsigned long
res = loopfile_used_with((char *) mnt->m.mnt_fsname,
loopfile, offset);

- else if ((p = strstr(mnt->m.mnt_opts, "loop="))) {
+ else if (mnt->m.mnt_opts &&
+ (p = strstr(mnt->m.mnt_opts, "loop=")))
+ {
char *dev = xstrdup(p+5);
if ((p = strchr(dev, ',')))
*p = '\0';
@@ -2052,8 +2054,8 @@ is_fstab_entry_mounted(struct mntentchn *mc, int verbose)
goto yes;

/* extra care for loop devices */
- if ((strstr(mc->m.mnt_opts, "loop=") ||
- (stat(mc->m.mnt_fsname, &st) == 0 && S_ISREG(st.st_mode)))) {
+ if ((mc->m.mnt_opts && strstr(mc->m.mnt_opts, "loop=")) ||
+ (stat(mc->m.mnt_fsname, &st) == 0 && S_ISREG(st.st_mode))) {

char *p = get_option_value(mc->m.mnt_opts, "offset=");
uintmax_t offset = 0;
diff --git a/mount/mount_mntent.c b/mount/mount_mntent.c
index d90def3..f42c0ad 100644
--- a/mount/mount_mntent.c
+++ b/mount/mount_mntent.c
@@ -70,7 +70,7 @@ my_addmntent (mntFILE *mfp, struct my_mntent *mnt) {
m1 = mangle(mnt->mnt_fsname);
m2 = mangle(mnt->mnt_dir);
m3 = mangle(mnt->mnt_type);
- m4 = mangle(mnt->mnt_opts);
+ m4 = mnt->mnt_opts ? mangle(mnt->mnt_opts) : "rw";

res = fprintf (mfp->mntent_fp, "%s %s %s %s %d %d\n",
m1, m2, m3, m4, mnt->mnt_freq, mnt->mnt_passno);
@@ -78,7 +78,8 @@ my_addmntent (mntFILE *mfp, struct my_mntent *mnt) {
free(m1);
free(m2);
free(m3);
- free(m4);
+ if (mnt->mnt_opts)
+ free(m4);
return (res < 0) ? 1 : 0;
}

diff --git a/mount/sundries.c b/mount/sundries.c
index ae4501a..2dec37f 100644
--- a/mount/sundries.c
+++ b/mount/sundries.c
@@ -217,6 +217,8 @@ matching_opts (const char *options, const char *test_opts) {

if (test_opts == NULL)
return 1;
+ if (options == NULL)
+ options = "";

len = strlen(test_opts);
q = alloca(len+1);
--
1.7.6

92 changes: 92 additions & 0 deletions sys-apps/util-linux/files/util-linux-2.19.1-umount-l-nfs.patch
@@ -0,0 +1,92 @@
https://bugs.gentoo.org/370051

From b3b0c657818aa6191e6494f88d671601dd9d837d Mon Sep 17 00:00:00 2001
From: Petr Uzel <petr.uzel@suse.cz>
Date: Wed, 29 Jun 2011 10:24:09 +0200
Subject: [PATCH] umount: do not hang with disconnected NFS mounts

Since util-linux commit f4612577c942a3683b97632ad0b49671897c2070,
umount stat(2)s its argument to check whether it can be associated
with some loop device. This could hang with broken NFS mounts.

Fix by first checking mtab if umount's argument is mounted and only if
we fail, check if there is a loop device associated.

http://marc.info/?l=util-linux-ng&m=130924963804836&w=2

Reported-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
mount/umount.c | 42 ++++++++++++++++++++++--------------------
1 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/mount/umount.c b/mount/umount.c
index 0349cb3..96c940e 100644
--- a/mount/umount.c
+++ b/mount/umount.c
@@ -600,6 +600,7 @@ umount_file (char *arg) {
int fstab_has_user, fstab_has_users, fstab_has_owner, fstab_has_group;
int ok, status = 0;
struct stat statbuf;
+ char *loopdev = NULL;

if (!*arg) { /* "" would be expanded to `pwd` */
die(2, _("Cannot unmount \"\"\n"));
@@ -608,26 +609,7 @@ umount_file (char *arg) {

file = canonicalize(arg); /* mtab paths are canonicalized */

- /* if file is a regular file, check if it is associated
- * with some loop device
- */
- if (!stat(file, &statbuf) && S_ISREG(statbuf.st_mode)) {
- char *loopdev = NULL;
- switch (find_loopdev_by_backing_file(file, &loopdev)) {
- case 0:
- if (verbose)
- printf(_("%s is associated with %s, trying to unmount it\n"),
- arg, loopdev);
- file = loopdev;
- break;
- case 2:
- if (verbose)
- printf(_("%s is associated with more than one loop device: not unmounting\n"),
- arg);
- break;
- }
- }
-
+try_loopdev:
if (verbose > 1)
printf(_("Trying to unmount %s\n"), file);

@@ -659,6 +641,26 @@ umount_file (char *arg) {
if (!mc && verbose)
printf(_("Could not find %s in mtab\n"), file);

+ /* not found in mtab - check if it is associated with some loop device
+ * (only if it is a regular file)
+ */
+ if (!mc && !loopdev && !stat(file, &statbuf) && S_ISREG(statbuf.st_mode)) {
+ switch (find_loopdev_by_backing_file(file, &loopdev)) {
+ case 0:
+ if (verbose)
+ printf(_("%s is associated with %s\n"),
+ arg, loopdev);
+ file = loopdev;
+ goto try_loopdev;
+ break;
+ case 2:
+ if (verbose)
+ printf(_("%s is associated with more than one loop device: not unmounting\n"),
+ arg);
+ break;
+ }
+ }
+
if (restricted) {
char *mtab_user = NULL;

--
1.7.6

123 changes: 123 additions & 0 deletions sys-apps/util-linux/util-linux-2.19.1-r1.ebuild
@@ -0,0 +1,123 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $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 $

EAPI="3"

EGIT_REPO_URI="git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git"
inherit eutils toolchain-funcs libtool flag-o-matic
[[ ${PV} == "9999" ]] && inherit git autotools

MY_PV=${PV/_/-}
MY_P=${PN}-${MY_PV}
S=${WORKDIR}/${MY_P}

DESCRIPTION="Various useful Linux utilities"
HOMEPAGE="http://www.kernel.org/pub/linux/utils/util-linux/"
if [[ ${PV} == "9999" ]] ; then
SRC_URI=""
#KEYWORDS=""
else
SRC_URI="mirror://kernel/linux/utils/util-linux/v${PV:0:4}/${MY_P}.tar.bz2
loop-aes? ( http://loop-aes.sourceforge.net/updates/util-linux-2.19.1-20110510.diff.bz2 )"
KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~x86-linux"
fi

LICENSE="GPL-2 GPL-3 LGPL-2.1 BSD-4 MIT public-domain"
SLOT="0"
IUSE="+cramfs crypt loop-aes ncurses nls old-linux perl selinux slang uclibc unicode"

RDEPEND="!sys-process/schedutils
!sys-apps/setarch
!<sys-libs/e2fsprogs-libs-1.41.8
!<sys-fs/e2fsprogs-1.41.8
cramfs? ( sys-libs/zlib )
ncurses? ( >=sys-libs/ncurses-5.2-r2 )
perl? ( dev-lang/perl )
selinux? ( sys-libs/libselinux )
slang? ( sys-libs/slang )"
DEPEND="${RDEPEND}
nls? ( sys-devel/gettext )
virtual/os-headers"

src_prepare() {
if [[ ${PV} == "9999" ]] ; then
autopoint --force
eautoreconf
else
use loop-aes && epatch "${WORKDIR}"/util-linux-*.diff
fi
sed -i 's/argp.h/errno.h/g' "${S}/configure"
epatch "${FILESDIR}"/${P}-mount-a-segv.patch #366213
if ! use loop-aes ; then
epatch "${FILESDIR}"/${P}-umount-l-nfs.patch #370051
else
ewarn "loop-aes is incompatible with current solution of #370051 bug!"
ewarn "Therefore you're vulnerable to that bug now!"
ewarn "Look at https://bugs.gentoo.org/show_bug.cgi?id=370051."
fi
use uclibc && sed -i -e s/versionsort/alphasort/g -e s/strverscmp.h/dirent.h/g mount/lomount.c
use uclibc && sed -i -e s/versionsort/alphasort/g -e s/strverscmp.h/dirent.h/g shlibs/mount/src/tab_parse.c
elibtoolize
}

lfs_fallocate_test() {
# Make sure we can use fallocate with LFS #300307
cat <<-EOF > "${T}"/fallocate.c
#define _GNU_SOURCE
#include <fcntl.h>
main() { return fallocate(0, 0, 0, 0); }
EOF
append-lfs-flags
$(tc-getCC) ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} "${T}"/fallocate.c -o /dev/null >/dev/null 2>&1 \
|| export ac_cv_func_fallocate=no
rm -f "${T}"/fallocate.c
}

usex() { use $1 && echo ${2:-yes} || echo ${3:-no} ; }
src_configure() {
lfs_fallocate_test
econf \
--enable-fs-paths-extra=/usr/sbin \
$(use_enable nls) \
--enable-agetty \
$(use_enable cramfs) \
$(use_enable old-linux elvtune) \
--with-ncurses=$(usex ncurses $(usex unicode auto yes) no) \
--disable-init \
--disable-kill \
--disable-last \
--disable-mesg \
--enable-partx \
--enable-raw \
--enable-rename \
--disable-reset \
--disable-login-utils \
--enable-schedutils \
--disable-wall \
--enable-write \
--without-pam \
$(use_with selinux) \
$(use_with slang) \
$(tc-has-tls || echo --disable-tls)
}

src_install() {
emake install DESTDIR="${D}" || die "install failed"
dodoc AUTHORS NEWS README* TODO docs/*

if ! use perl ; then #284093
rm "${ED}"/usr/bin/chkdupexe || die
rm "${ED}"/usr/share/man/man1/chkdupexe.1 || die
fi

# need the libs in /
gen_usr_ldscript -a blkid uuid
# e2fsprogs-libs didnt install .la files, and .pc work fine
rm -f "${ED}"/usr/$(get_libdir)/*.la

if use crypt ; then
newinitd "${FILESDIR}"/crypto-loop.initd crypto-loop || die
newconfd "${FILESDIR}"/crypto-loop.confd crypto-loop || die
fi
}

0 comments on commit 2c34b60

Please sign in to comment.