dsavell / docker-grav

Docker Container for GRAV CMS
MIT License
40 stars 18 forks source link

Chmod errors on startup because of topic names with spaces #22

Closed Miroka96 closed 3 years ago

Miroka96 commented 3 years ago

Hello!

In my docker logs I came across errors of the following style:

chmod: cannot access '/var/www/grav/user/pages/08.kochbuch/Das': No such file or directory
chmod: cannot access 'mittelgro'$'\303\237''e': No such file or directory

This error is caused by xargs's interpretation of its command line input: find /var/www/grav -type f | xargs chmod 664 should be find /var/www/grav -type f | xargs -d '\n' chmod 664, so xargs splits its input at linebreaks and not at spaces.

You can see the difference in the following tests:

$ find /home/mirko/test | xargs ls -lisah
ls: cannot access '/home/mirko/test/Hello': No such file or directory
ls: cannot access 'and': No such file or directory
ls: cannot access 'Welcome': No such file or directory
ls: cannot access '/home/mirko/test/sdf': No such file or directory
ls: cannot access 'sd': No such file or directory
ls: cannot access 'fs': No such file or directory
ls: cannot access 'ds': No such file or directory
ls: cannot access 'ds': No such file or directory
ls: cannot access 'sda': No such file or directory
ls: cannot access 'as': No such file or directory
/home/mirko/test:
total 20K
3801135 4.0K drwxrwxr-x  5 mirko mirko 4.0K Dec 25 13:12  .
3145730 4.0K drwxr-xr-x 62 mirko mirko 4.0K Dec 25 13:11  ..
3801136 4.0K drwxrwxr-x  2 mirko mirko 4.0K Dec 25 13:11 'Hello and Welcome'
3803540 4.0K drwxrwxr-x  2 mirko mirko 4.0K Dec 25 13:12 'sdf  sd fs ds ds sda as'
3801163 4.0K drwxrwxr-x  2 mirko mirko 4.0K Dec 25 13:12  test

/home/mirko/test/test:
total 8.0K
3801163 4.0K drwxrwxr-x 2 mirko mirko 4.0K Dec 25 13:12 .
3801135 4.0K drwxrwxr-x 5 mirko mirko 4.0K Dec 25 13:12 ..
$ find /home/mirko/test | xargs -d '\n' ls -lisah
/home/mirko/test:
total 20K
3801135 4.0K drwxrwxr-x  5 mirko mirko 4.0K Dec 25 13:12  .
3145730 4.0K drwxr-xr-x 62 mirko mirko 4.0K Dec 25 13:11  ..
3801136 4.0K drwxrwxr-x  2 mirko mirko 4.0K Dec 25 13:11 'Hello and Welcome'
3803540 4.0K drwxrwxr-x  2 mirko mirko 4.0K Dec 25 13:12 'sdf  sd fs ds ds sda as'
3801163 4.0K drwxrwxr-x  2 mirko mirko 4.0K Dec 25 13:12  test

'/home/mirko/test/Hello and Welcome':
total 8.0K
3801136 4.0K drwxrwxr-x 2 mirko mirko 4.0K Dec 25 13:11 .
3801135 4.0K drwxrwxr-x 5 mirko mirko 4.0K Dec 25 13:12 ..

'/home/mirko/test/sdf  sd fs ds ds sda as':
total 8.0K
3803540 4.0K drwxrwxr-x 2 mirko mirko 4.0K Dec 25 13:12 .
3801135 4.0K drwxrwxr-x 5 mirko mirko 4.0K Dec 25 13:12 ..

/home/mirko/test/test:
total 8.0K
3801163 4.0K drwxrwxr-x 2 mirko mirko 4.0K Dec 25 13:12 .
3801135 4.0K drwxrwxr-x 5 mirko mirko 4.0K Dec 25 13:12 ..

Best regards, Miroka

dsavell commented 3 years ago

Hey @Miroka96 happy new year!

Good spot I must admit I have always avoided the usage of empty spaces in file/folder/page names, linux habbit.

Intresting though, I am now thinking does this only need to be a one off (first time container starts), depends how your creating pages?

Scenario 1: create page from outside container then start container then it would make sense to run permissions everytime it starts. Scenario 2: create page using admin panel, therefor it should be the grav user that would auto set to the correct permission anyway.

dsavell commented 3 years ago

Merged current fix, however new issue is open based on my comment #26