]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mount-util: use EXTRACT_KEEP_QUOTE to handle mount options 19977/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 21 Jun 2021 12:12:49 +0000 (21:12 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 21 Jun 2021 12:34:50 +0000 (21:34 +0900)
Otherwise, the quotes which wrap SELinux options are dropped.

src/shared/mount-util.c
src/test/test-mount-util.c

index 4a8564d560535f3331133313f505cc60f37fe0d0..c4261b24944dade92424a37fc5934afec1baf44c 100644 (file)
@@ -679,7 +679,7 @@ int mount_option_mangle(
                 _cleanup_free_ char *word = NULL;
                 const struct libmnt_optmap *ent;
 
-                r = extract_first_word(&p, &word, ",", EXTRACT_UNQUOTE);
+                r = extract_first_word(&p, &word, ",", EXTRACT_KEEP_QUOTE);
                 if (r < 0)
                         return r;
                 if (r == 0)
index ab5184121c8e6998d0cb1d551a25ddf40049eb68..ac64e7505987122ff30b2d8d78b00c42eba02fff 100644 (file)
@@ -69,6 +69,11 @@ static void test_mount_option_mangle(void) {
         opts = mfree(opts);
 
         assert_se(mount_option_mangle("rw,relatime,fmask=0022,dmask=0022,\"hogehoge", MS_RDONLY, &f, &opts) < 0);
+
+        assert_se(mount_option_mangle("mode=1777,size=10%,nr_inodes=400k,uid=496107520,gid=496107520,context=\"system_u:object_r:svirt_sandbox_file_t:s0:c0,c1\"", 0, &f, &opts) == 0);
+        assert_se(f == 0);
+        assert_se(streq(opts, "mode=1777,size=10%,nr_inodes=400k,uid=496107520,gid=496107520,context=\"system_u:object_r:svirt_sandbox_file_t:s0:c0,c1\""));
+        opts = mfree(opts);
 }
 
 static void test_bind_remount_recursive(void) {