diff -up ecryptfs-utils-90/src/libecryptfs/main.c.mtabfix ecryptfs-utils-90/src/libecryptfs/main.c
--- ecryptfs-utils-90/src/libecryptfs/main.c.mtabfix 2011-02-22 18:35:26.000000000 +0100
+++ ecryptfs-utils-90/src/libecryptfs/main.c 2011-08-11 10:24:24.274245958 +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-90/src/utils/mount.ecryptfs_private.c.mtabfix ecryptfs-utils-90/src/utils/mount.ecryptfs_private.c