diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-09-24 14:55:57 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-09-25 13:36:34 +0200 |
commit | 7bb553bb98a57b4e03804f8192bdc5a534325582 (patch) | |
tree | 3040cd663b06af6e92f57ef8b1100956469a9f40 /src/test/test-fstab-util.c | |
parent | 48904c8bfd4b71086630a35f56a977183bd6d208 (diff) | |
download | systemd-7bb553bb98a57b4e03804f8192bdc5a534325582.tar.gz |
fstab,crypttab: allow escaping of commas
Fixes #17035. We use "," as the separator between arguments in fstab and crypttab
options field, but the kernel started using "," within arguments. Users will need
to escape those nested commas.
Diffstat (limited to 'src/test/test-fstab-util.c')
-rw-r--r-- | src/test/test-fstab-util.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/test/test-fstab-util.c b/src/test/test-fstab-util.c index 187be69d15..f3506045a1 100644 --- a/src/test/test-fstab-util.c +++ b/src/test/test-fstab-util.c @@ -13,12 +13,11 @@ int fstab_filter_options(const char *opts, const char *names, */ static void do_fstab_filter_options(const char *opts, - const char *remove, - int r_expected, - const char *name_expected, - const char *value_expected, - const char *filtered_expected) { - + const char *remove, + int r_expected, + const char *name_expected, + const char *value_expected, + const char *filtered_expected) { int r; const char *name; _cleanup_free_ char *value = NULL, *filtered = NULL; @@ -34,7 +33,7 @@ static void do_fstab_filter_options(const char *opts, /* also test the malloc-less mode */ r = fstab_filter_options(opts, remove, &name, NULL, NULL); - log_info("\"%s\" → %d, \"%s\", expected %d, \"%s\"", + log_info("\"%s\" → %d, \"%s\", expected %d, \"%s\"\n-", opts, r, name, r_expected, name_expected); assert_se(r == r_expected); @@ -54,6 +53,12 @@ static void test_fstab_filter_options(void) { do_fstab_filter_options("opt,other", "x-opt\0opt\0", 1, "opt", NULL, "other"); do_fstab_filter_options("x-opt,other", "opt\0x-opt\0", 1, "x-opt", NULL, "other"); + do_fstab_filter_options("opt=0\\,1,other", "opt\0x-opt\0", 1, "opt", "0,1", "other"); + do_fstab_filter_options("opt=0,other,x-opt\\,foobar", "x-opt\0opt\0", 1, "opt", "0", "other,x-opt\\,foobar"); + do_fstab_filter_options("opt,other,x-opt\\,part", "opt\0x-opt\0", 1, "opt", NULL, "other,x-opt\\,part"); + do_fstab_filter_options("opt,other,part\\,x-opt", "x-opt\0opt\0", 1, "opt", NULL, "other,part\\,x-opt"); + do_fstab_filter_options("opt,other\\,\\,\\,opt,x-part", "opt\0x-opt\0", 1, "opt", NULL, "other\\,\\,\\,opt,x-part"); + do_fstab_filter_options("opto=0,other", "opt\0x-opt\0", 0, NULL, NULL, NULL); do_fstab_filter_options("opto,other", "opt\0x-opt\0", 0, NULL, NULL, NULL); do_fstab_filter_options("x-opto,other", "opt\0x-opt\0", 0, NULL, NULL, NULL); |