Fix various issues with update_mtab(), causing 'mount -f' to not update mtab
authorMartin Schlemmer <azarah@gentoo.org>
Wed, 14 Sep 2005 09:07:25 +0000 (09:07 +0000)
committerMartin Schlemmer <azarah@gentoo.org>
Wed, 14 Sep 2005 09:07:25 +0000 (09:07 +0000)
as expected, bug #105641.

Package-Manager: portage-2.0.52-r1

sys-apps/util-linux/ChangeLog
sys-apps/util-linux/Manifest
sys-apps/util-linux/files/util-linux-2.12q-update_mtab-fixes.patch [new file with mode: 0644]
sys-apps/util-linux/util-linux-2.12q-r2.ebuild

index 965ee6569e8a7498e292e302d79ca6ac18e83b81..ff136f3ad6505a5a53a0cfc99f956feeee09c9e5 100644 (file)
@@ -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,
index 1df1eef83bc0551f177c4b0eb93dd011a93988c0..51f81bfa2957cda5f2488bc98c8af2e729c4bdef 100644 (file)
@@ -1,45 +1,46 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-MD5 40353e338343ed2b6a8f23259c881e49 util-linux-2.12q.ebuild 4785
-MD5 9a09f8d531c582e78977dbfd96edc1f2 metadata.xml 164
 MD5 5497e9050dc8cde95a0e015edcd59c81 util-linux-2.12i-r1.ebuild 3960
-MD5 5f6bfcc9cec96a297071615eadca2dbc util-linux-2.12q-r2.ebuild 5579
-MD5 7ec017e092d564a2362a94271d03642d ChangeLog 19022
-MD5 519d6757067c4ee7c634c8b60f9abeb3 files/util-linux-2.12p-swapon-check-symlinks.patch 864
-MD5 e3697bc8fd6a344e8cba1c7d32e34790 files/util-linux-2.11z-parallel-make.patch 369
-MD5 28b1a8ed38823851eafadacef8ce11ec files/util-linux-2.12q-no-m68k-fdisk.patch 239
-MD5 33ddd96078cf91030b80f73eb70f5371 files/util-linux-2.12i-swapon-check-symlinks.patch 875
-MD5 8d4f1146f0699deb1e6872e1c81293e3 files/util-linux-2.12-selinux.diff.bz2 2558
+MD5 4ec337ef027b8e0f3c8ec6ad906821c0 ChangeLog 19263
+MD5 42a00cdd523f8facea7f10a9f4df86a1 util-linux-2.12q-r2.ebuild 5692
+MD5 9a09f8d531c582e78977dbfd96edc1f2 metadata.xml 164
+MD5 40353e338343ed2b6a8f23259c881e49 util-linux-2.12q.ebuild 4785
 MD5 e8c2796a3427138ca8a09a69db357a1f files/util-linux-2.12q-update-mtab-when-moving.patch 1031
+MD5 9d4c2454a6506ec913d901830ab06a22 files/util-linux-2.12-only-root-can-remount.patch 294
+MD5 519d6757067c4ee7c634c8b60f9abeb3 files/util-linux-2.12p-swapon-check-symlinks.patch 864
 MD5 65f42fbf981464410f7d5d84a429e920 files/util-linux-no-kill.patch 642
-MD5 a43d2b8c70c5f40a195721dc536abace files/util-linux-2.12-swapon-unistd.patch 289
-MD5 a33ff00c09f558d4273360a581880c23 files/digest-util-linux-2.12q-r2 292
+MD5 c9c2c92d7bba0652f22b638127c2107e files/util-linux-2.12i-pic.patch 2457
 MD5 570b9b148cbb60ec16de30940990ab53 files/util-linux-2.12q-i18n-update.patch 344
 MD5 73c0cb6f9aa5fa84e701fc68d0478aac files/util-linux-2.12i-nfsv4.patch 12854
-MD5 9d4c2454a6506ec913d901830ab06a22 files/util-linux-2.12-only-root-can-remount.patch 294
+MD5 7d35ae646b52391076f7a329af8265bc files/util-linux-2.11z-agetty-domainname-option.patch 1810
 MD5 4460875a6ebcf24a7ca5b41ed12f9fe5 files/util-linux-2.12-gcloop.patch 3806
-MD5 e2d566b683bb1b9b1c3e127b2bbd258b files/digest-util-linux-2.12q 294
-MD5 bc90959c4718e7dc5d53dcddac1172f5 files/util-linux-2.12q-debian-10cfdisk.patch 1888
+MD5 33ddd96078cf91030b80f73eb70f5371 files/util-linux-2.12i-swapon-check-symlinks.patch 875
 MD5 0be8df03dae23c81a0e929e58a4114e0 files/util-linux-2.11z-01-nfsv4.dif 13442
 MD5 99fa2ff2cb56217b6971e76e275923f9 files/util-linux-2.12q-more-fake-checks-v2.patch 1176
-MD5 7ce604460c5607e6eb5d894b6c8b2064 files/util-linux-2.12-fat-LABEL-support.patch 11583
-MD5 7d35ae646b52391076f7a329af8265bc files/util-linux-2.11z-agetty-domainname-option.patch 1810
-MD5 c9c2c92d7bba0652f22b638127c2107e files/util-linux-2.12i-pic.patch 2457
-MD5 6aa1c240dd789327ea92e36309052950 files/no-symlink-resolve.patch 316
-MD5 d20405e12353610b3ef8fbc2e1d57f2a files/crypto-loop.initd 1625
-MD5 61beee95fb4696a6af11ffb84ddb055c files/util-linux-2.12i-ignore-managed.patch 506
+MD5 d927611f34139a40f1fc9f4162c61f8a files/util-linux-2.12-kernel-2.6.patch 2964
 MD5 a9bc06c292401d6f2d27e8e4ebf7e6ae files/util-linux-2.12i-fat-LABEL-support.patch 2304
+MD5 8d4f1146f0699deb1e6872e1c81293e3 files/util-linux-2.12-selinux.diff.bz2 2558
+MD5 bc90959c4718e7dc5d53dcddac1172f5 files/util-linux-2.12q-debian-10cfdisk.patch 1888
+MD5 8a13c61b447c1533df4b919cf2646fea files/util-linux-2.12q-umount-dont-write-mtab-with-remount.patch 467
+MD5 6aa1c240dd789327ea92e36309052950 files/no-symlink-resolve.patch 316
+MD5 28b1a8ed38823851eafadacef8ce11ec files/util-linux-2.12q-no-m68k-fdisk.patch 239
+MD5 a33ff00c09f558d4273360a581880c23 files/digest-util-linux-2.12q-r2 292
 MD5 18371db840b08f5782e3f8f96c4efe8d files/util-linux-2.11z-pic.patch 3056
-MD5 d927611f34139a40f1fc9f4162c61f8a files/util-linux-2.12-kernel-2.6.patch 2964
-MD5 0b95e856fd2f375270cf2ec4eaa69c8a files/crypto-loop.confd 505
+MD5 7ce604460c5607e6eb5d894b6c8b2064 files/util-linux-2.12-fat-LABEL-support.patch 11583
+MD5 e62aa4a3faeb981c042f762d6ffe5743 files/util-linux-2.12q-update_mtab-fixes.patch 2281
 MD5 b360252f16d707f668b605d7a2abb791 files/util-linux-2.12q-dont-umask.patch 439
 MD5 cfa3960fd97ca16c85b0d1b87e6ba226 files/digest-util-linux-2.12i-r1 156
-MD5 8a13c61b447c1533df4b919cf2646fea files/util-linux-2.12q-umount-dont-write-mtab-with-remount.patch 467
+MD5 61beee95fb4696a6af11ffb84ddb055c files/util-linux-2.12i-ignore-managed.patch 506
+MD5 e2d566b683bb1b9b1c3e127b2bbd258b files/digest-util-linux-2.12q 294
+MD5 a43d2b8c70c5f40a195721dc536abace files/util-linux-2.12-swapon-unistd.patch 289
+MD5 e3697bc8fd6a344e8cba1c7d32e34790 files/util-linux-2.11z-parallel-make.patch 369
+MD5 0b95e856fd2f375270cf2ec4eaa69c8a files/crypto-loop.confd 505
+MD5 d20405e12353610b3ef8fbc2e1d57f2a files/crypto-loop.initd 1625
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.2 (GNU/Linux)
 
-iD8DBQFDJ5ZhgIKl8Uu19MoRAqcnAKCELR5+KqJao2LihGGCfdmCglOflQCfSErF
-UISx1CegpX9La5rUhixyNWM=
-=DZdM
+iD8DBQFDJ+ih1ZcsMnZjRyIRAsy3AJ0WMToOWLTN8otX1+Mwby5jW8DKrQCgjXOw
+5CHUa8VLiZCzZDT6Jtc3roQ=
+=JeNN
 -----END PGP SIGNATURE-----
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 (file)
index 0000000..1596946
--- /dev/null
@@ -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;
index 8a540f9256553ab75d77e63fa1968cf0bd9186f4..57bd4839e63675f88f6859bb977eeb823e658719 100644 (file)
@@ -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