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

Maciej Wereski m.wereski at partner.samsung.com
Wed Dec 11 05:24:48 PST 2013


10.12.2013 at 20:48 Lennart Poettering <lennart at poettering.net> wrote:

> On Wed, 04.12.13 15:27, Maciej Wereski (m.wereski at partner.samsung.com)  
> wrote:
>
>>
>> +#ifdef HAVE_XATTR
>> +static int get_xattrs_from_arg(Item *i){
>> +        _cleanup_free_ char *xattr = NULL;
>> +        _cleanup_strv_free_ char **tmp = NULL;
>> +        char *p;
>> +        unsigned n, len, strv_len;
>> +
>> +        assert(i);
>> +        if (i->type != SET_XATTR)
>> +                return 0;
>> +
>> +        if (!i->argument) {
>> +                log_error("%s: Argument can't be empty!", i->path);
>> +                return -EBADMSG;
>> +        }
>> +        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.

regards,

-- 
Maciej Wereski
Samsung R&D Institute Poland
Samsung Electronics
m.wereski at partner.samsung.com


More information about the systemd-devel mailing list