capistrano-3-rails-template icon indicating copy to clipboard operation
capistrano-3-rails-template copied to clipboard

Change upload behaviour that fix permission issue

Open Paprikas opened this issue 9 years ago • 4 comments

The problem happens when you, for example chown logrotate config files to root. Then permission issue will happen if deploy_user is not root.

Paprikas avatar Mar 25 '15 18:03 Paprikas

Thanks for the PR, the tricky thing is that the smart_template method is used for multiple files and this change would mean that every file ending up being owned by root which isn't the behaviour needed.

Potentially we need another way of indicating that certain files should be chowned to root after upload. I'll have a bit of a play over the weekend and see if I can come up with something. Any suggestions much appreciated!

TalkingQuickly avatar Mar 26 '15 18:03 TalkingQuickly

No. It's not chowned after upload. I mean if your file is ALREADY chowned. So upload! method will fail because of lack of permissions.

Here is what I did previously to chown logrotate config. After this line: https://github.com/TalkingQuickly/capistrano-3-rails-template/blob/master/lib/capistrano/tasks/setup_config.cap#L29 I've added this:

sudo :chown, symlink[:chown_source], "#{shared_path}/config/#{symlink[:source]}" if symlink[:chown_source]

Now in config/deploy.rb I've added needed option

set(:symlinks, [
    {
      source: "nginx.conf",
      link: "/etc/nginx/sites-enabled/{{full_app_name}}.conf"
    },
    {
      source: "log_rotation",
      link: "/etc/logrotate.d/{{full_app_name}}",
      chown_source: "root:root"
    }
])

So I can choose what user I need to be the owner. Yes, its not the universal method for every uploaded file. But I had problem with logrotate config permissions. So it works perfectly for me. I get the idea.

Paprikas avatar Apr 02 '15 18:04 Paprikas

Facing the same issue. Trying out this solution.

ziazek avatar Sep 09 '16 08:09 ziazek

Still not working.

ziazek avatar Sep 09 '16 09:09 ziazek