开发者

Paperclip gives Permission denied error with samba mount

开发者 https://www.devze.com 2022-12-08 18:51 出处:网络
In my development environment the codebase is mounted on a ubuntu-server VM using a samba mount, it is mounted as root and I run mongrel as root.

In my development environment the codebase is mounted on a ubuntu-server VM using a samba mount, it is mounted as root and I run mongrel as root.

When I try and upload a file with Paperclip the file saves fine but then it seems to have problems creating the different styles.

I get the following error:

Errno::EACCES (Permission denied - /foo/some/file/path/file-name-style.jpg):
  /usr/lib/ruby/1.8/fileutils.rb:1272:in `chown'
  /usr/lib/ruby/1.8/fileutils.rb:1272:in `copy_metadata'
  /usr/li开发者_高级运维b/ruby/1.8/fileutils.rb:452:in `copy_entry'
  /usr/lib/ruby/1.8/fileutils.rb:1324:in `traverse'
  /usr/lib/ruby/1.8/fileutils.rb:448:in `copy_entry'
  /usr/lib/ruby/1.8/fileutils.rb:507:in `mv'
  /usr/lib/ruby/1.8/fileutils.rb:1395:in `fu_each_src_dest'
  /usr/lib/ruby/1.8/fileutils.rb:1411:in `fu_each_src_dest0'
  /usr/lib/ruby/1.8/fileutils.rb:1393:in `fu_each_src_dest'
  /usr/lib/ruby/1.8/fileutils.rb:494:in `mv'
  vendor/gems/thoughtbot-paperclip-2.3.0/lib/paperclip/storage.rb:43:in `flush_writes'
  vendor/gems/thoughtbot-paperclip-2.3.0/lib/paperclip/storage.rb:39:in `each'
  vendor/gems/thoughtbot-paperclip-2.3.0/lib/paperclip/storage.rb:39:in `flush_writes'
  vendor/gems/thoughtbot-paperclip-2.3.0/lib/paperclip/attachment.rb:142:in `save'
  vendor/gems/thoughtbot-paperclip-2.3.0/lib/paperclip.rb:331:in `send'
  vendor/gems/thoughtbot-paperclip-2.3.0/lib/paperclip.rb:331:in `save_attached_files'
  vendor/gems/thoughtbot-paperclip-2.3.0/lib/paperclip.rb:324:in `each_attachment'
  vendor/gems/thoughtbot-paperclip-2.3.0/lib/paperclip.rb:323:in `each'
  vendor/gems/thoughtbot-paperclip-2.3.0/lib/paperclip.rb:323:in `each_attachment'
  vendor/gems/thoughtbot-paperclip-2.3.0/lib/paperclip.rb:330:in `save_attached_files'

It works fine however if I remove /foo/ from the folder structure of the mounted code and instead make it a symbolic link to somewhere directly within the Ubuntu VM.


Because the error seems to be happening at the chown call, I'm guessing that the user that the file is being chown'd to/from doesn't have write permissions on the mount. It could be that the user on the VM isn't known on the other system, so when the chown happens it bails.

Check the user that the file is written as (chown'd to) when you remove /foo/ from the path, then see if you can write a file to the /foo/some/file/path/ directory as that user.


In fileutils.rb, in the copy_metadata method, the rescue block should be changed from:

rescue Errno::EPERM

to:

rescue Errno::EPERM, Errno::EACCES

or maybe even more thorough:

rescue

so that it catches any errno code.

0

精彩评论

暂无评论...
验证码 换一张
取 消