* [PATCH] mke2fs: Escape double quotes when parsing mke2fs.conf
@ 2020-11-02 14:26 Lukas Czerner
2020-11-02 21:37 ` Andreas Dilger
2021-01-20 4:56 ` Theodore Ts'o
0 siblings, 2 replies; 4+ messages in thread
From: Lukas Czerner @ 2020-11-02 14:26 UTC (permalink / raw)
To: linux-ext4
Currently, when constructing the <default> configuration pseudo-file using
the profile-to-c.awk script we will just pass the double quotes as they
appear in the mke2fs.conf.
This is problematic, because the resulting default_profile.c will either
fail to compile because of syntax error, or leave the resulting
configuration invalid.
It can be reproduced by adding the following line somewhere into
mke2fs.conf configuration and forcing mke2fs to use the <default>
configuration by specifying nonexistent mke2fs.conf
MKE2FS_CONFIG="nonexistent" ./misc/mke2fs -T ext4 /dev/device
default_mntopts = "acl,user_xattr"
^ this will fail to compile
default_mntopts = ""
^ this will result in invalid config file
Syntax error in mke2fs config file (<default>, line #4)
Unknown code prof 17
Fix it by escaping the double quotes with a backslash in
profile-to-c.awk script.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
misc/profile-to-c.awk | 1 +
1 file changed, 1 insertion(+)
diff --git a/misc/profile-to-c.awk b/misc/profile-to-c.awk
index f964efd6..814f7236 100644
--- a/misc/profile-to-c.awk
+++ b/misc/profile-to-c.awk
@@ -4,6 +4,7 @@ BEGIN {
}
{
+ gsub("\"","\\\"",$0);
printf(" \"%s\\n\"\n", $0);
}
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] mke2fs: Escape double quotes when parsing mke2fs.conf 2020-11-02 14:26 [PATCH] mke2fs: Escape double quotes when parsing mke2fs.conf Lukas Czerner @ 2020-11-02 21:37 ` Andreas Dilger 2020-11-03 7:20 ` Lukas Czerner 2021-01-20 4:56 ` Theodore Ts'o 1 sibling, 1 reply; 4+ messages in thread From: Andreas Dilger @ 2020-11-02 21:37 UTC (permalink / raw) To: Lukas Czerner; +Cc: linux-ext4 [-- Attachment #1: Type: text/plain, Size: 1674 bytes --] On Nov 2, 2020, at 7:26 AM, Lukas Czerner <lczerner@redhat.com> wrote: > > Currently, when constructing the <default> configuration pseudo-file using > the profile-to-c.awk script we will just pass the double quotes as they > appear in the mke2fs.conf. > > This is problematic, because the resulting default_profile.c will either > fail to compile because of syntax error, or leave the resulting > configuration invalid. > > It can be reproduced by adding the following line somewhere into > mke2fs.conf configuration and forcing mke2fs to use the <default> > configuration by specifying nonexistent mke2fs.conf > > MKE2FS_CONFIG="nonexistent" ./misc/mke2fs -T ext4 /dev/device > > default_mntopts = "acl,user_xattr" > ^ this will fail to compile > > default_mntopts = "" > ^ this will result in invalid config file > > Syntax error in mke2fs config file (<default>, line #4) > Unknown code prof 17 > > Fix it by escaping the double quotes with a backslash in > profile-to-c.awk script. What about using single quotes for this? That avoids the need to escape the double quotes, and avoids significant issues (IMHO) when the number of escapes grows over time as they are swallowed by various levels of processing. Cheers, Andreas > > Signed-off-by: Lukas Czerner <lczerner@redhat.com> > --- > misc/profile-to-c.awk | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/misc/profile-to-c.awk b/misc/profile-to-c.awk > index f964efd6..814f7236 100644 > --- a/misc/profile-to-c.awk > +++ b/misc/profile-to-c.awk > @@ -4,6 +4,7 @@ BEGIN { > } > > { > + gsub("\"","\\\"",$0); > printf(" \"%s\\n\"\n", $0); > } > > -- > 2.26.2 > Cheers, Andreas [-- Attachment #2: Message signed with OpenPGP --] [-- Type: application/pgp-signature, Size: 873 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mke2fs: Escape double quotes when parsing mke2fs.conf 2020-11-02 21:37 ` Andreas Dilger @ 2020-11-03 7:20 ` Lukas Czerner 0 siblings, 0 replies; 4+ messages in thread From: Lukas Czerner @ 2020-11-03 7:20 UTC (permalink / raw) To: Andreas Dilger; +Cc: linux-ext4 On Mon, Nov 02, 2020 at 02:37:38PM -0700, Andreas Dilger wrote: > On Nov 2, 2020, at 7:26 AM, Lukas Czerner <lczerner@redhat.com> wrote: > > > > Currently, when constructing the <default> configuration pseudo-file using > > the profile-to-c.awk script we will just pass the double quotes as they > > appear in the mke2fs.conf. > > > > This is problematic, because the resulting default_profile.c will either > > fail to compile because of syntax error, or leave the resulting > > configuration invalid. > > > > It can be reproduced by adding the following line somewhere into > > mke2fs.conf configuration and forcing mke2fs to use the <default> > > configuration by specifying nonexistent mke2fs.conf > > > > MKE2FS_CONFIG="nonexistent" ./misc/mke2fs -T ext4 /dev/device > > > > default_mntopts = "acl,user_xattr" > > ^ this will fail to compile > > > > default_mntopts = "" > > ^ this will result in invalid config file > > > > Syntax error in mke2fs config file (<default>, line #4) > > Unknown code prof 17 > > > > Fix it by escaping the double quotes with a backslash in > > profile-to-c.awk script. > > What about using single quotes for this? That avoids the need to escape > the double quotes, and avoids significant issues (IMHO) when the number > of escapes grows over time as they are swallowed by various levels of > processing. Hi Andreas, I am not sure I understand what issues you have in mind. The way I see it, the profile-to-c.awk is used just during compile time to generate a mke2fs_default_profile string and that's consumed by mke2fs in the case no external config file can be found. There is only one level, or am I missing something ? Regardless it is possible to use a single quote by changing the code in parse_line(). However I don't think we can just stop supporting double quotes since that would technically change the mke2fs.conf format so it would not solve the problem. Thanks -Lukas > > Cheers, Andreas > > > > > Signed-off-by: Lukas Czerner <lczerner@redhat.com> > > --- > > misc/profile-to-c.awk | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/misc/profile-to-c.awk b/misc/profile-to-c.awk > > index f964efd6..814f7236 100644 > > --- a/misc/profile-to-c.awk > > +++ b/misc/profile-to-c.awk > > @@ -4,6 +4,7 @@ BEGIN { > > } > > > > { > > + gsub("\"","\\\"",$0); > > printf(" \"%s\\n\"\n", $0); > > } > > > > -- > > 2.26.2 > > > > > Cheers, Andreas > > > > > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mke2fs: Escape double quotes when parsing mke2fs.conf 2020-11-02 14:26 [PATCH] mke2fs: Escape double quotes when parsing mke2fs.conf Lukas Czerner 2020-11-02 21:37 ` Andreas Dilger @ 2021-01-20 4:56 ` Theodore Ts'o 1 sibling, 0 replies; 4+ messages in thread From: Theodore Ts'o @ 2021-01-20 4:56 UTC (permalink / raw) To: Lukas Czerner; +Cc: linux-ext4 On Mon, Nov 02, 2020 at 03:26:31PM +0100, Lukas Czerner wrote: > Currently, when constructing the <default> configuration pseudo-file using > the profile-to-c.awk script we will just pass the double quotes as they > appear in the mke2fs.conf. > > This is problematic, because the resulting default_profile.c will either > fail to compile because of syntax error, or leave the resulting > configuration invalid. Applied, thanks. - Ted ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-01-20 5:00 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-11-02 14:26 [PATCH] mke2fs: Escape double quotes when parsing mke2fs.conf Lukas Czerner 2020-11-02 21:37 ` Andreas Dilger 2020-11-03 7:20 ` Lukas Czerner 2021-01-20 4:56 ` Theodore Ts'o
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox