summaryrefslogtreecommitdiff
path: root/community/ecryptfs-utils/symlinked_mtab.patch
blob: 2ba0aa8bf429f2792c8a666ac8c4c9210c9df2d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
--- ecryptfs-utils/src/ecryptfs-utils-96/src/libecryptfs/main.c.orig
+++ ecryptfs-utils/src/ecryptfs-utils-96/src/libecryptfs/main.c
@@ -387,6 +387,8 @@
 	char *fullpath_source = NULL;
 	char *fullpath_target = NULL;
 	int rc;
+	char dummy;
+	int useMtab;
 
 	mountent.mnt_opts = NULL;
 	if (!source) {
@@ -425,6 +427,13 @@
 		syslog(LOG_ERR, "Failed to perform eCryptfs mount: [%m]\n");
 		goto out;
 	}
+	/* Check if mtab is a symlink */
+	useMtab = (readlink("/etc/mtab", &dummy, 1) < 0);
+	if (!useMtab) {
+		/* No need updating mtab */
+		rc = 0;
+		goto out;
+	}
 	mtab_fd = setmntent("/etc/mtab", "a");
 	if (!mtab_fd) {
 		rc = -EACCES;