From f47a7164ee75aa609c507d3564a07bfb6ae2eac2 Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Jul 11 2011 12:14:14 +0000 Subject: opening for writing succeeds, writing fails -> reorder symlink check --- diff --git a/ecryptfs-utils-87-mtab.patch b/ecryptfs-utils-87-mtab.patch index d918a33..01e8f2c 100644 --- a/ecryptfs-utils-87-mtab.patch +++ b/ecryptfs-utils-87-mtab.patch @@ -1,16 +1,27 @@ 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-07-11 13:46:12.809240356 +0200 -+++ ecryptfs-utils-87/src/libecryptfs/main.c 2011-07-11 13:46:12.825240472 +0200 -@@ -427,9 +427,13 @@ int ecryptfs_mount(char *source, char *t +--- 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) { +- 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 */ -+ char dummy; -+ if (readlink("/etc/mtab", &dummy, 1) < 0) { ++ /* 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; @@ -28,8 +39,8 @@ diff -up ecryptfs-utils-87/src/libecryptfs/main.c.mtabfix ecryptfs-utils-87/src/ 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:45:54.927111621 +0200 -+++ ecryptfs-utils-87/src/utils/mount.ecryptfs_private.c 2011-07-11 13:45:54.946111757 +0200 +--- 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