wmluke / dokku-domains-plugin

Dokku plugin to create nginx vhost with multiple domains
MIT License
176 stars 21 forks source link

Permission Denied #2

Closed JoshuaNovak919 closed 10 years ago

JoshuaNovak919 commented 10 years ago

I keep getting this message when I try and push an update to the server:

remote: /var/lib/dokku/plugins/domains-plugin/commands: line 42: /home/dokku/ajd/DOMAINS: Permission denied

Other than pushing updates it runs and works perfect, i'm just not sure why pushing updates doesn't work properly. Anyone have any ideas?

wmluke commented 10 years ago

Hi @JoshuaNovak919,

Strange. Can you check the file permissions?

ls -lah /home/dokku/ajd/DOMAINS
JoshuaNovak919 commented 10 years ago

This is what it says:

-rw-r--r-- 1 root root 92 Mar  3 08:23 /home/dokku/ajd/DOMAINS
wmluke commented 10 years ago

Hmmm...that seems to be the issue. It should be owned and/or readable/writable by the dokku user. Specifically, it should have the same permissions as /home/dokku/ajd/PORT:

$ ls -lah /home/dokku/ajd/PORT
  -rw-rw-r-- 1 dokku dokku x xxx xx xx:xx PORT

You can correct this by running:

$ sudo chown dokku:dokku /home/dokku/ajd/DOMAINS

(assuming you have sudoers access)

How did you run dokku domains:set? Did you happen to run it as root or with sudo?

JoshuaNovak919 commented 10 years ago

I initially ran dokku domains:set as root, I tried sudo though too. I tried the command you said and it didn't work, but I eventually got it all working. This is the process I went through.

When I tried:

sudo chown dokku:dokku /home/dokku/ajd/DOMAINS

it still didn't work.

I had to run:

sudo chmod 664 /home/dokku/ajd/DOMAINS

Then I received the following error:

remote: /var/lib/dokku/plugins/domains-plugin/commands: line 45: /home/dokku/ajd/nginx-domains.conf: Permission denied

Then I ran:

sudo chmod 664 /home/dokku/ajd/nginx-domains.conf

And this:

sudo chown dokku:dokku /home/dokku/ajd/nginx-domains.conf

Now it works. Is there a way to have the script check the file permissions and do this automatically?

wmluke commented 10 years ago

I recommend that you run dokku domains:set as the dokku user.

If you run a process as root, then its typically the case that any files this process creates will be owned by root and not writable by other users. I feel that dokku domains:set should honor this same behavior.

If you feel that you must run dokku commands as root, then you'll have to be consistent and always run them as root. But generally speaking, many of the dokku commands should be run as the dokku user.