1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-21 02:50:18 +03:00

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).
This commit is contained in:
Pawel Zmarzly 2024-10-17 18:54:10 +00:00
parent 49fd31df58
commit b3c5a35509
2 changed files with 6 additions and 1 deletions

View File

@ -812,7 +812,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) {