tmpfiles.d and spaces in filenames

Ian Malone ibmalone at gmail.com
Wed Jun 1 16:37:35 UTC 2011


On 1 June 2011 16:11, Corinna Vinschen <vinschen at redhat.com> wrote:
> Hi,
>
> How can I specify filenames with spaces in tmpfiles.d configuration
> files?  There's no hint in `man tmfiles.d'.  I tried
>
> - fstab style:      d /foo\040bar 0755 root root
> - web style:        d /foo%20bar 0755 root root
> - quoted style 1:   d "/foo bar" 0755 root root
> - quoted style 2:   d '/foo bar' 0755 root root
>
> This results in two directories
>
>  /foo\040bar
>  /foo%20bar
>
> and two error messages:
>
>  Path '"/foo' not absolute.
>  Path ''/foo' not absolute.
>
> So, do I have to take it that tmpfiles.d doesn't grok spaces in
> filenames at all?
>
> Please note, I'm not asking for the obvious answer "don't do this" and
> I'm also not asking for the counter question "why do you need this?"
>

As usual both of these might push in the direction of another way to
solve the problem. From checking the documentation it seems packages
are expected to define patterns here for their tmpfiles which they
should have control over. Which I guess is not the situation you're
dealing with. Looking at it I think the short answer is you can't as
tmpfiles.c is just using sscanf to parse this line:
http://cgit.freedesktop.org/systemd/tree/src/tmpfiles.c
Line 670:
 if (sscanf(buffer,
                   "%c "
                   "%ms "
                   "%ms "
                   "%ms "
                   "%ms "
                   "%ms",
                   &i->type,
                   &i->path,
                   &mode,
                   &user,
                   &group,
                   &age) < 2) {
                log_error("[%s:%u] Syntax error.", fname, line);
                r = -EIO;
                goto finish;
        }

So the long answer is you either have to modify tmpfiles.c to deal
with this or write a similar daemon to do it.

-- 
imalone


More information about the users mailing list