File permissions for Dropbox, Panel, and sFTP

Try as I might, I can’t get this figured out. I have Kirby running on a Digital Ocean Ubuntu server, with a user account I use for sFTP and SSH—and that user has Dropbox running in the background to sync files to the server. Apache then is serving the site, using the default www-data user.

If I add a file with Dropbox, I can edit it with my normal user login via FTP or SSH, but can’t edit it in the panel (get a “The page is not writable” error there). If I add a new post via Panel, I can’t edit the file via FTP, and have to use sudo to edit it via SSH.

I’ve added both my normal user and www-data to the same group, to no avail.

Any ideas on what can help here, other than having Apache run as using my default user, which doesn’t seem smart?

1 Like

I guess you followed the guide here on setting up Dropbox. It actually makes no mention of being able to use the panel to edit the files.

My guess is maybe its a file lock - if the Dropbox process is using the files at the same time as the panel trying to use them. I think the Dropbox process needs to let go of the file before the panel can edit it. I dont think that will ever happen, because dropbox is continually watching for changes. In other words the same file is “open” in two programs at once and the first program (probably Dropbox) can read and write but the panel can only read it because dropbox opened it first.

Does the site work in the browser? You don’t get 404 or any errors on a page synced from your local machine? You would see an error i think if the file permissions were wrong after they went through dropbox.

Try syncing files with dropbox, then SSH onto the box and stop the dropbox process, then try editing the files in the panel. Does it let you save? If it does then thats my theory probably proved :slight_smile:

Seems to be more about Linux user permissions. When I add something via Dropbox or FTP, they are owned by my default user and group. When something’s added by the panel, it’s owned by www-data:www-data. And both panel and Dropbox create files that are editable only by their user, not their group, keeping each other from editing them.

Seems some way to automatically set permissions for new files and folders no matter what makes them would do the trick.

i don’t know if Dropbox has some kind of API you can tap into. If it was Git you could use hooks to kick off a script to set the permissions after commit. I wonder if theres a way to know that dropbox has finished a sync, and do something.

A Cron job might be way, too.

Edit: Google is your friend. Give this a shot. Its a python script that will fix the perms via cron in a dropbox folder. Just tweak it to suit you. There is also this which might be useful.

1 Like

Woah that just might work—will give it a shot. Thanks!