On 1 June 2011 16:11, Corinna Vinschen<vinschen(a)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.
Since a space is Unix's and Linux's chosen field separator,
I think having a space in filenames should be avoided. there
are many situations where spaces in filenames cause problems.
A simple example:
for i in *; do
[ -f $i ] && echo $i is a file
done
you will see that the file with spaces in it's name
will not be recognized as a file because each
space-separated member of that file name
becomes a separate argument
when * is expanded by the shell.
There are probably other more serious
problems posed by spaces in filenames.