← Back to team overview

ecryptfs-devel team mailing list archive

[PATCH] Don't duplicate provided mount options

 

The mount helper duplicates provided mount options, such as
ecryptfs_sig=x.  As more features are added, this can result in a
very long mount options string.

This patch enables the mount helper to detect supplied mount options and
prevent any duplication.

Signed-off-by: Tyler Hicks <tyhicks@xxxxxxxxxxxxxxxxxx>
---
 src/utils/mount.ecryptfs.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/utils/mount.ecryptfs.c b/src/utils/mount.ecryptfs.c
index b881d47..dd3f851 100644
--- a/src/utils/mount.ecryptfs.c
+++ b/src/utils/mount.ecryptfs.c
@@ -471,14 +471,16 @@ static int ecryptfs_do_mount(int argc, char **argv, struct val_node *mnt_params,
 				goto out;
 			}
 		}
-		rc = asprintf(&new_opts, "%s,%s", val, temp);
-		if (rc == -1) {
-			new_opts = NULL;
-			rc = -ENOMEM;
-			goto out;
+		if (!strstr(temp, val)) {
+			rc = asprintf(&new_opts, "%s,%s", val, temp);
+			if (rc == -1) {
+				new_opts = NULL;
+				rc = -ENOMEM;
+				goto out;
+			}
+			free(temp);
 		}
 		rc = 0;
-		free(temp);
 	}
 	if ((rc = ecryptfs_validate_mount_opts(new_opts)) != 0) {
 		printf("Invalid mount options; aborting. rc = [%d]\n",
-- 
1.5.3.7