silverstripe / sspak

Tool for managing bundles of db/assets from Silverstripe environments
http://silverstripe.github.io/sspak/
BSD 3-Clause "New" or "Revised" License
47 stars 34 forks source link

Issue with assets when running under sudo #65

Closed NZI closed 6 years ago

NZI commented 6 years ago

I have an issue where the folder ownership of assets was not being respected.

example:

sspak load --sudo=www-data restore.sspak /var/www/mysite.com

error:

if [ -d /var/www/mysite.com/shared/assets.old ]; then rm -rf /var/www/mysite.com/shared/assets.old; fi

Among other issues in the surrounding code

NZI commented 6 years ago

https://github.com/silverstripe/sspak/pull/66/

NZI commented 6 years ago

I'll try to describe the situation where this is an issue. Sensitive data replaced.

Machine has two users, backup and www-data.

User backup is in groups backup and www-data, and is also a sudoer

User www-data is only in the group www-data

Execute sudo chown -R www-data:www-data /var/www/mysite.com

Initial assets folder:

backup@machine:~$ ls -la /var/www/mysite.com/assets/
total 20
drwxrwxr-x 3 www-data www-data 4096 Dec 15 15:51 .
drwxrwxr-x 4 www-data www-data 4096 Jan 22 10:31 ..
-rw-rw-r-- 1 www-data www-data 3711 Nov 24 09:31 error-404.html
-rw-rw-r-- 1 www-data www-data 3707 Nov 24 09:31 error-500.html
drwxr-xr-x 2 www-data www-data 4096 Dec 21 15:41 Uploads

Execute sspak load --sudo=www-data restore.sspak /var/www/mysite.com as user backup

Folder structure now:

backup@machine:~$ ls -la /var/www/mysite.com/assets/
total 20
drwxrwxr-x 3 backup   backup   4096 Dec 15 15:51 .
drwxrwxr-x 4 www-data www-data 4096 Jan 22 10:33 ..
-rw-rw-r-- 1 backup   backup   3711 Nov 24 09:31 error-404.html
-rw-rw-r-- 1 backup   backup   3707 Nov 24 09:31 error-500.html
drwxr-xr-x 2 backup   backup   4096 Dec 21 15:41 Uploads
andrewandante commented 6 years ago

Thanks @NZI - much better explanation of the problem, appreciated!

NZI commented 6 years ago

Fixed in https://github.com/silverstripe/sspak/pull/66