FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 06-01-2011, 03:11 PM
Corinna Vinschen
 
Default tmpfiles.d and spaces in filenames

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 /foo40bar 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

/foo40bar
/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?"


Corinna
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 06-01-2011, 03:21 PM
Patrick O'Callaghan
 
Default tmpfiles.d and spaces in filenames

On Wed, 2011-06-01 at 17:11 +0200, Corinna Vinschen wrote:
> - fstab style: d /foo40bar 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

Try:

/foo bar

Just a thought.

poc

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 06-01-2011, 04:05 PM
Corinna Vinschen
 
Default tmpfiles.d and spaces in filenames

On Jun 1 10:51, Patrick O'Callaghan wrote:
> On Wed, 2011-06-01 at 17:11 +0200, Corinna Vinschen wrote:
> > - fstab style: d /foo40bar 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
>
> Try:
>
> /foo bar

Uh, I forgot to mention it in my list. I tried that first, actually,
and this results in another error message:

d /foo bar 0755 root root

Invalid mode 'bar'.

> Just a thought.

Thanks,
Corinna
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 06-01-2011, 04:37 PM
Ian Malone
 
Default tmpfiles.d and spaces in filenames

On 1 June 2011 16:11, Corinna Vinschen <vinschen@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 /foo40bar 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
>
> */foo40bar
> */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
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 06-01-2011, 04:59 PM
JD
 
Default tmpfiles.d and spaces in filenames

On 06/01/11 09:37, Ian Malone wrote:
> On 1 June 2011 16:11, Corinna Vinschen<vinschen@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 /foo40bar 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
>>
>> /foo40bar
>> /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.

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 06-01-2011, 06:27 PM
Corinna Vinschen
 
Default tmpfiles.d and spaces in filenames

On Jun 1 09:59, JD wrote:
> On 06/01/11 09:37, Ian Malone wrote:
> > On 1 June 2011 16:11, Corinna Vinschen<vinschen@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 /foo40bar 0755 root root
> >> [...]
> >> 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?"
> >>
> > [...]
> > So the long answer is you either have to modify tmpfiles.c to deal
> > with this or write a similar daemon to do it.

I guess this should be converted into a bugzilla entry then.

> Since a space is Unix's and Linux's chosen field separator,

Just because the space is a field separator doesn't mean there are
no ways to define spaces in filenames.

> I think having a space in filenames should be avoided. there

That's not always possible and you can't ask all users to rename their
files. Filenames like "Expenses May 2011.odt" are just to be expected.
Another example is the default naming of CF or SD media formatted on
certain camera models. Yet another exmaple are customer request.

> are many situations where spaces in filenames cause problems.
> A simple example:
>
> for i in *; do
> [ -f $i ] && echo $i is a file
> done

Which is just an example of insufficient quoting. If this isn't part of
a script which exactly knows that no filename will have spaces, it's
broken by design. Spaces in filenames are perfectly valid and system
tools which may come into contact with user-defined content should be
able to deal with them.

The fact that even /etc/fstab (rather, mount(8)) deals with spaces in
mount points shows that there is a need and a way to handle them.

Having said that, using the space definition in /etc/fstab shouldn't
be too hard to do in tmpfiles.d as well.


Corinna
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 06-01-2011, 07:05 PM
Patrick O'Callaghan
 
Default tmpfiles.d and spaces in filenames

On Wed, 2011-06-01 at 09:59 -0700, JD wrote:
> 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.

No, each filename counts as one argument, even if it has spaces in it.
The problem arises when you *use* the argument. The above should read:

for i in *; do
[ -f "$i"] && echo "$i" is a file
done

(the quotes are optional in the echo case obviously).

poc

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 06-01-2011, 07:18 PM
JD
 
Default tmpfiles.d and spaces in filenames

On 06/01/11 12:05, Patrick O'Callaghan wrote:
> On Wed, 2011-06-01 at 09:59 -0700, JD wrote:
>> 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.
>
> No, each filename counts as one argument, even if it has spaces in it.
> The problem arises when you *use* the argument. The above should read:
>
> for i in *; do
> [ -f "$i"]&& echo "$i" is a file
> done
>
> (the quotes are optional in the echo case obviously).
>
> poc
>
The quotes are not optional.
Take a look at this example:

$ ls -1
a b c d
j
k
l
m

$ for i in *; do
> ls -l $i
> done
/bin/ls: cannot access a: No such file or directory
/bin/ls: cannot access b: No such file or directory
/bin/ls: cannot access c: No such file or directory
/bin/ls: cannot access d: No such file or directory
-rw-r--r-- 1 jd jd 0 Jun 1 12:10 j
-rw-r--r-- 1 jd jd 0 Jun 1 12:10 k
-rw-r--r-- 1 jd jd 0 Jun 1 12:10 l
-rw-r--r-- 1 jd jd 0 Jun 1 12:10 m

$ for i in *; do
ls -l "$i"
done
-rw-r--r-- 1 jd jd 0 Jun 1 12:10 a b c d
-rw-r--r-- 1 jd jd 0 Jun 1 12:10 j
-rw-r--r-- 1 jd jd 0 Jun 1 12:10 k
-rw-r--r-- 1 jd jd 0 Jun 1 12:10 l
-rw-r--r-- 1 jd jd 0 Jun 1 12:10 m

I have run into more scripts that had omitted the quotes
in the "use" of the variable, and thus failed.

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 06-01-2011, 07:30 PM
Mike Williams
 
Default tmpfiles.d and spaces in filenames

On Wed, Jun 1, 2011 at 3:18 PM, JD <jd1008@gmail.com> wrote:

On 06/01/11 12:05, Patrick O'Callaghan wrote:

> On Wed, 2011-06-01 at 09:59 -0700, JD wrote:

>> 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.

>

> No, each filename counts as one argument, even if it has spaces in it.

> The problem arises when you *use* the argument. The above should read:

>

> for i in *; do

> [ -f "$i"]&& *echo "$i" is a file

> done

>

> (the quotes are optional in the echo case obviously).

>

> poc

>

The quotes are not optional.*I think he meant that the quotes are optional for the echo $i - which is correct.

Personally I avoid spaces in filenames and usually use a perl one liner to substitute an underscore for spaces when I don't have to keep the original name for someone else.


zsh works without any quotes, the first example works fine for files with spaces in the names with zsh.

Mike


--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 06-01-2011, 07:39 PM
Patrick O'Callaghan
 
Default tmpfiles.d and spaces in filenames

On Wed, 2011-06-01 at 12:18 -0700, JD wrote:
> The quotes are not optional.

Read my message again.

poc

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 

Thread Tools




All times are GMT. The time now is 07:31 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org