Compare commits

...

2 Commits

Author SHA1 Message Date
Paweł Zmarzły 6e59641376
Merge b3c5a35509 into 94eacb9329 2024-11-24 19:48:18 +00:00
Pawel Zmarzly b3c5a35509 mount-util: preserve colons as-is (for overlayfs)
We need to preserve escaped colons in mount options, as they make
significant difference, for example in overlayfs (where unescaped
colons delimit paths, while escaped colons are treated as part of
a path).
2024-10-17 23:37:11 +01:00
2 changed files with 6 additions and 1 deletions

View File

@ -813,7 +813,7 @@ int mount_option_mangle(
_cleanup_free_ char *word = NULL;
const struct libmnt_optmap *ent;
r = extract_first_word(&p, &word, ",", EXTRACT_KEEP_QUOTE);
r = extract_first_word(&p, &word, ",", EXTRACT_KEEP_QUOTE | EXTRACT_RETAIN_ESCAPE);
if (r < 0)
return r;
if (r == 0)

View File

@ -82,6 +82,11 @@ TEST(mount_option_mangle) {
assert_se(f == 0);
ASSERT_STREQ(opts, "mode=01777,size=10%,nr_inodes=400k,uid=496107520,gid=496107520,context=\"system_u:object_r:svirt_sandbox_file_t:s0:c0,c1\"");
opts = mfree(opts);
assert_se(mount_option_mangle("lower=/path/one/with/some\\:colons:/path/two", 0, &f, &opts) == 0);
assert_se(f == 0);
ASSERT_STREQ(opts, "lower=/path/one/with/some\\:colons:/path/two");
opts = mfree(opts);
}
static void test_mount_flags_to_string_one(unsigned long flags, const char *expected) {