[ecryptfs-utils/f15] fix mtab handling everywhere

Michal Hlavinka mhlavink at fedoraproject.org
Mon Jul 11 12:33:11 UTC 2011


commit 56a8b2e7311512886997aaedd52b72945569eef2
Author: Michal Hlavinka <mhlavink at redhat.com>
Date:   Mon Jul 11 14:32:56 2011 +0200

    fix mtab handling everywhere

 ecryptfs-utils-87-mtab.patch |   64 ++++++++++++++++++++++++++++-------------
 ecryptfs-utils.spec          |    9 ++++--
 2 files changed, 50 insertions(+), 23 deletions(-)
---
diff --git a/ecryptfs-utils-87-mtab.patch b/ecryptfs-utils-87-mtab.patch
index bebbec1..01e8f2c 100644
--- a/ecryptfs-utils-87-mtab.patch
+++ b/ecryptfs-utils-87-mtab.patch
@@ -1,19 +1,47 @@
-From eed8b4e5f7635f67ac68be426ade7964086e8fa0 Mon Sep 17 00:00:00 2001
-From: Christophe Dumez <christophe.dumez at intel.com>
-Date: Sun, 29 May 2011 17:23:53 +0300
-Subject: [PATCH] Do not update mtab if it is a symlink
-
-mount.ecryptfs_private: Do not attempt to update
-mtab if it is a symbolic link.
----
- src/utils/mount.ecryptfs_private.c |   11 ++++++++++-
- 1 files changed, 10 insertions(+), 1 deletions(-)
-
-diff --git a/src/utils/mount.ecryptfs_private.c b/src/utils/mount.ecryptfs_private.c
-index c19fa84..0fa02e6 100644
---- a/src/utils/mount.ecryptfs_private.c
-+++ b/src/utils/mount.ecryptfs_private.c
-@@ -264,9 +264,18 @@ int is_mounted(char *dev, char *mnt, char *sig, int mounting) {
+diff -up ecryptfs-utils-87/src/libecryptfs/main.c.mtabfix ecryptfs-utils-87/src/libecryptfs/main.c
+--- ecryptfs-utils-87/src/libecryptfs/main.c.mtabfix	2011-03-09 14:30:32.000000000 +0100
++++ ecryptfs-utils-87/src/libecryptfs/main.c	2011-07-11 14:10:40.525812683 +0200
+@@ -382,6 +382,7 @@ out:
+ 
+ int ecryptfs_mount(char *source, char *target, unsigned long flags, char *opts)
+ {
++	char dummy;
+ 	FILE *mtab_fd = NULL;
+ 	struct mntent mountent;
+ 	char *fullpath_source = NULL;
+@@ -425,11 +426,14 @@ int ecryptfs_mount(char *source, char *t
+ 		syslog(LOG_ERR, "Failed to perform eCryptfs mount: [%m]\n");
+ 		goto out;
+ 	}
+-	mtab_fd = setmntent("/etc/mtab", "a");
+-	if (!mtab_fd) {
+-		rc = -EACCES;
+-		syslog(LOG_ERR, "Failed to update the mount table\n");
+-		goto out;
++	/* it's possible that /etc/mtab is just a symlink to /proc/mounts */
++	if (readlink("/etc/mtab", &dummy, 1) < 0) {
++		mtab_fd = setmntent("/etc/mtab", "a");
++		if (!mtab_fd) {
++			rc = -EACCES;
++			syslog(LOG_ERR, "Failed to update the mount table\n");
++			goto out;
++		}
+ 	}
+ 	mountent.mnt_fsname = fullpath_source;
+ 	mountent.mnt_dir = fullpath_target;
+@@ -464,7 +468,7 @@ int ecryptfs_mount(char *source, char *t
+ 	}
+ 	mountent.mnt_freq = 0;
+ 	mountent.mnt_passno = 0;
+-	if (addmntent(mtab_fd, &mountent)) {
++	if (mtab_fd && addmntent(mtab_fd, &mountent)) {
+ 		rc = -EIO;
+ 		syslog(LOG_ERR, "Failed to write to the mount "
+ 		       "table\n");
+diff -up ecryptfs-utils-87/src/utils/mount.ecryptfs_private.c.mtabfix ecryptfs-utils-87/src/utils/mount.ecryptfs_private.c
+--- ecryptfs-utils-87/src/utils/mount.ecryptfs_private.c.mtabfix	2011-07-11 13:53:36.942438496 +0200
++++ ecryptfs-utils-87/src/utils/mount.ecryptfs_private.c	2011-07-11 13:53:36.954438583 +0200
+@@ -219,9 +219,18 @@ int check_ownerships(int uid, char *path
  
  
  int update_mtab(char *dev, char *mnt, char *opt) {
@@ -33,7 +61,3 @@ index c19fa84..0fa02e6 100644
  	FILE *fh;
  	struct mntent m;
  	fh = setmntent("/etc/mtab", "a");
--- 
-1.7.5.2
-
-
diff --git a/ecryptfs-utils.spec b/ecryptfs-utils.spec
index 6dc189f..8351d72 100644
--- a/ecryptfs-utils.spec
+++ b/ecryptfs-utils.spec
@@ -5,7 +5,7 @@
 
 Name: ecryptfs-utils
 Version: 87
-Release: 4%{?dist}
+Release: 5%{?dist}
 Summary: The eCryptfs mount helper and support libraries
 Group: System Environment/Base
 License: GPLv2+
@@ -35,7 +35,7 @@ Patch8: ecryptfs-utils-86-manpage.patch
 # autoload ecryptfs module in ecryptfs-setup-private when needed, rhbz#707608
 Patch9: ecryptfs-utils-87-autoload.patch
 
-# sent upstream, for e-u < 88, rhbz#706911
+# upstream patch is incomplete, rhbz#706911
 Patch10: ecryptfs-utils-87-mtab.patch
 
 # fedora/rhel specific, check for pam ecryptfs module before home migration
@@ -93,7 +93,7 @@ the interface supplied by the ecryptfs-utils library.
 %patch999 -p1 -b .werror
 
 %build
-export CFLAGS="$RPM_OPT_FLAGS -ggdb -O2 -Werror -Wtype-limits"
+export CFLAGS="$RPM_OPT_FLAGS -Werror -Wtype-limits"
 #we're modifing Makefile.am
 autoreconf -fiv
 %configure --disable-rpath --enable-tspi --enable-nss --enable-pkcs11-helper
@@ -218,6 +218,9 @@ rm -rf $RPM_BUILD_ROOT
 %{python_sitearch}/ecryptfs-utils/_libecryptfs.so
 
 %changelog
+* Mon Jul 11 2011 Michal Hlavinka <mhlavink at redhat.com> - 87-5
+- fix mtab handling everywhere
+
 * Thu Jun 09 2011 Michal Hlavinka <mhlavink at redhat.com> - 87-4
 - check for ecryptfs pam module before home dir migration
 


More information about the scm-commits mailing list