]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: deduplicate SELinux mount options
authorKarel Zak <kzak@redhat.com>
Wed, 1 Aug 2012 15:52:22 +0000 (17:52 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 1 Aug 2012 15:52:22 +0000 (17:52 +0200)
We already have a clue about SELinux specific mount options in libmount, so
it makes sense to deduplicate the options as Linux kernel does not
support duplicate SELinux options. (SELinux kernel stuff somehow
ignores standard Linux mount conventions...)

Requested-by: Niels de Vos <ndevos@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context_mount.c

index 36dc414aea21bbc3110abacb02f2c62ac12811fa..f3d8ff103b0153a4f0f96005eef63dcce1a778c2 100644 (file)
@@ -117,6 +117,15 @@ static int fix_optstr(struct libmnt_context *cxt)
        else
                /* For normal mount we have translate the contexts */
                se_fix = 1;
+
+       if (!se_rem) {
+               /* de-duplicate SELinux options */
+               mnt_optstr_deduplicate_option(&fs->fs_optstr, "context");
+               mnt_optstr_deduplicate_option(&fs->fs_optstr, "fscontext");
+               mnt_optstr_deduplicate_option(&fs->fs_optstr, "defcontext");
+               mnt_optstr_deduplicate_option(&fs->fs_optstr, "rootcontext");
+               mnt_optstr_deduplicate_option(&fs->fs_optstr, "seclabel");
+       }
 #endif
        while (!mnt_optstr_next_option(&next, &name, &namesz, &val, &valsz)) {