[systemd-devel] [PATCHv5] tmpfiles, man: Add xattr support to tmpfiles

Lennart Poettering lennart at poettering.net
Fri Jan 17 10:49:59 PST 2014


On Thu, 16.01.14 15:42, Maciej Wereski (m.wereski at partner.samsung.com) wrote:

> 
> 11.12.2013 at 15:15 Lennart Poettering <lennart at poettering.net> wrote:
> 
> >On Wed, 11.12.13 14:24, Maciej Wereski
> >(m.wereski at partner.samsung.com) wrote:
> >
> >>>>+        xattr = new0(char, strlen(i->argument)+1);
> >>>>+        if (!xattr)
> >>>>+                return log_oom();
> >>>>+
> >>>>+        tmp = strv_split(i->argument, WHITESPACE);
> >>>>+        if (!tmp)
> >>>>+                return log_oom();
> >>>>+
> >>>>+        strv_len = strv_length(tmp);
> >>>>+        for (n = 0; n < strv_len; ++n) {
> >>>
> >>>Sounds like a job for the STRV_FOREACH() macro. Since you don't
> >>actually
> >>>need the strv as strv here it sounds like you actually really want to
> >>>use FOREACH_WORD_QUOTED() for this, which will also do the
> >>unquoting for
> >>>you.
> >>
> >>Well, FOREACH_WORD_QUOTED() won't work properly, because quotation marks
> >>aren't first chars in strings (e.g. user.name="John Smith").
> >>Maybe better
> >>idea would be to introduce mandatory separator (e.g. semicolon)
> >>instead of
> >>quotation marks.
> >
> >Yeah, FOREACH_WORD_QUOTED() is quite badly designed. We should fix it to
> >do somewhat sane quoting and escaping. I'll look into it.
> 
> There is one problem with using it in this patch. In my case
> quotation mark isn't first char of the string, so using pointer and
> length won't get rid of it. String needs to be modified.

Yeah, this has been a long-standing issue actually, the unquoting logic
is pretty broken here, we should probably rework FOREACH_WORD_QUOTED()
to allocate a buffer for this and do proper unquoting. I have been
planning to do this for a while.

In fact, we should probably have a closer look that we implement similar
quoting rules for all file formats we define.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list