summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schlemmer <azarah@gentoo.org>2005-09-14 09:07:25 +0000
committerMartin Schlemmer <azarah@gentoo.org>2005-09-14 09:07:25 +0000
commit72eabf073bfbfc498e0e32a7949fbf21541eb882 (patch)
treed5f5c936979355701591118e6419012976147b7e /sys-apps
parentMark 1.5 stable on alpha (diff)
downloadgentoo-2-72eabf073bfbfc498e0e32a7949fbf21541eb882.tar.gz
gentoo-2-72eabf073bfbfc498e0e32a7949fbf21541eb882.tar.bz2
gentoo-2-72eabf073bfbfc498e0e32a7949fbf21541eb882.zip
Fix various issues with update_mtab(), causing 'mount -f' to not update mtab
as expected, bug #105641. (Portage version: 2.0.52-r1)
Diffstat (limited to 'sys-apps')
-rw-r--r--sys-apps/util-linux/ChangeLog8
-rw-r--r--sys-apps/util-linux/files/util-linux-2.12q-update_mtab-fixes.patch56
-rw-r--r--sys-apps/util-linux/util-linux-2.12q-r2.ebuild5
3 files changed, 67 insertions, 2 deletions
diff --git a/sys-apps/util-linux/ChangeLog b/sys-apps/util-linux/ChangeLog
index 965ee6569e8a..ff136f3ad650 100644
--- a/sys-apps/util-linux/ChangeLog
+++ b/sys-apps/util-linux/ChangeLog
@@ -1,6 +1,12 @@
# ChangeLog for sys-apps/util-linux
# Copyright 1999-2005 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-apps/util-linux/ChangeLog,v 1.111 2005/09/14 03:17:38 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/util-linux/ChangeLog,v 1.112 2005/09/14 09:07:25 azarah Exp $
+
+ 14 Sep 2005; Martin Schlemmer <azarah@gentoo.org>
+ +files/util-linux-2.12q-update_mtab-fixes.patch,
+ util-linux-2.12q-r2.ebuild:
+ Fix various issues with update_mtab(), causing 'mount -f' to not update mtab
+ as expected, bug #105641.
14 Sep 2005; Mike Frysinger <vapier@gentoo.org>
+files/util-linux-2.12q-umount-dont-write-mtab-with-remount.patch,
diff --git a/sys-apps/util-linux/files/util-linux-2.12q-update_mtab-fixes.patch b/sys-apps/util-linux/files/util-linux-2.12q-update_mtab-fixes.patch
new file mode 100644
index 000000000000..15969461f2f0
--- /dev/null
+++ b/sys-apps/util-linux/files/util-linux-2.12q-update_mtab-fixes.patch
@@ -0,0 +1,56 @@
+This fixes a few issues with update_mtab():
+- If it is a remount, and only mnt_opts needs updating, mc->m.mnt_opts is set
+ to point to instead->mnt_opts, rather than allocating a new string, which
+ would cause a double free if the caller actually freed the passed mnt_opts,
+ as we free mc->m.mnt_opts before returning to the caller.
+- Mostly the same issue as above. If mtab does not contain the new entry, then
+ absent->m is set to point to instead, which would have cause a double free
+ if absent was inserted properly into the linked list, since we free all
+ elements of absent before returning to the caller.
+- If mtab does not contain the new entry, then only mc0->prev is updated to
+ point to absent, but not the old mc0->prev's nxt pointer. Because we then
+ use the nxt pointers to write the new mtab, absent is not added to the new
+ mtab.
+- If mtab is empty, absent->prev should be set to mc0, and not mc0->prev, as
+ it will be NULL.
+
+Patch by Martin Schlemmer <azarah@gentoo.za.org>
+
+
+--- util-linux-2.12q/mount/fstab.c 2005-09-14 08:22:34.000000000 +0200
++++ util-linux-2.12q.az/mount/fstab.c 2005-09-14 10:37:54.000000000 +0200
+@@ -604,15 +604,30 @@ update_mtab (const char *dir, struct my_
+ free(mc);
+ }
+ } else {
+- /* A remount */
+- mc->m.mnt_opts = instead->mnt_opts;
++ /* A remount. Need to alloc memory, else we might
++ * run into issues if both we and the caller frees
++ * mnt_opts ... */
++ mc->m.mnt_opts = xstrdup(instead->mnt_opts);
+ }
+ } else if (instead) {
+ /* not found, add a new entry */
+ absent = xmalloc(sizeof(*absent));
+- absent->m = *instead;
++ /* Cannot just set absent->m to instead, as we free absent
++ * below, and the caller might free instead */
++ absent->m.mnt_fsname = xstrdup(instead->mnt_fsname);
++ absent->m.mnt_dir = xstrdup(instead->mnt_dir);
++ absent->m.mnt_type = xstrdup(instead->mnt_type);
++ absent->m.mnt_opts = xstrdup(instead->mnt_opts);
++ absent->m.mnt_freq = instead->mnt_freq;
++ absent->m.mnt_passno = instead->mnt_passno;
++
+ absent->nxt = mc0;
+- absent->prev = mc0->prev;
++ if (mc0->prev != NULL) {
++ absent->prev = mc0->prev;
++ mc0->prev->nxt = absent;
++ } else {
++ absent->prev = mc0;
++ }
+ mc0->prev = absent;
+ if (mc0->nxt == NULL)
+ mc0->nxt = absent;
diff --git a/sys-apps/util-linux/util-linux-2.12q-r2.ebuild b/sys-apps/util-linux/util-linux-2.12q-r2.ebuild
index 8a540f925655..57bd4839e636 100644
--- a/sys-apps/util-linux/util-linux-2.12q-r2.ebuild
+++ b/sys-apps/util-linux/util-linux-2.12q-r2.ebuild
@@ -1,6 +1,6 @@
# 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/util-linux-2.12q-r2.ebuild,v 1.3 2005/09/14 03:17:38 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/util-linux/util-linux-2.12q-r2.ebuild,v 1.4 2005/09/14 09:07:25 azarah Exp $
inherit eutils flag-o-matic toolchain-funcs
@@ -65,6 +65,9 @@ src_unpack() {
# Respect -n with -r and umount #98675
epatch "${FILESDIR}"/${PN}-2.12q-umount-dont-write-mtab-with-remount.patch
+ # A few fixes to beat update_mtab() into submission.
+ epatch "${FILESDIR}"/${PN}-2.12q-update_mtab-fixes.patch
+
# Fix unreadable df output when using devfs ... this check is kind of
# a hack, but whatever, the output isnt critical at all :P
[[ -e /dev/.devfsd ]] && epatch "${FILESDIR}"/no-symlink-resolve.patch