Errno::EACCES (Permission Denied) error on ubuntu

755 views
Skip to first unread message

gordon yeong

unread,
Jun 27, 2010, 11:47:00 PM6/27/10
to Paperclip Plugin
hi guys,
For some strange reason, my app stopped working whenever I tried to
upload a new image.

production environment: -ubuntu karmic koala running Passenger.
Paperclip plugin : 2.1.3. Upgraded to 2.3.3 and issue still persists.


I got the following error: "
Errno::EACCES in CatalogueController#update
Permission denied - /home/ct9a/myApp/public/system/infos/145
"

Anyway, I looked at the permissions of /home/ct9a/myApp/public/system/
infos and it was "drwxr-xr-x".

I changed the permissions of /home/ct9a/myApp/public/system/infos to
"rwxrwxrwx". Voila! It works. Then again, I swapped it back to "drwxr-
xr-x" because it's a security hazard.


I went to my development server and ran the same app in "production"
mode.
Managed to upload pictures with no issues.


Any ideas, guys?

Matt Powell

unread,
Jun 27, 2010, 11:57:42 PM6/27/10
to papercli...@googlegroups.com
On your development machine, you're running the server as the same user as the owner of the folder.

Try changing the ownership of the uploads folder to the user that your webserver is running as. You can find this out by running the following command:

ps aux | grep apache | cut -f 1,1 -d " "

...assuming you're running Apache. nginx is a bit trickier, since its worker processes run as different users from master, but it's the same principle.

Anyway, once you have that, you can do:

sudo chown -R nobody /home/ct9a/myApp/public/system/infos

(assuming that "nobody" is the correct user)

Hope this helps: let me know if you need more info and I'll mail you off-list.

M

> --
> Individuals over processes. Interactions over tools.
>
> Agile Rails training from thoughtbot, the makers of Paperclip, Clearance, Shoulda, & Factory Girl:
> http://thoughtbot.com/services/training
>
> The Paperclip group:
> http://groups.google.com/group/paperclip-plugin
>
> To post to this group, send email to
> papercli...@googlegroups.com
>
> To unsubscribe from this group, send email to
> paperclip-plug...@googlegroups.com

Gordon Yeong

unread,
Jun 28, 2010, 12:50:20 AM6/28/10
to papercli...@googlegroups.com
Hello, Matt,

 On the development machine, I am running the webserver as root.


Here's what "ps-ef |grep nginx" returned:
root      5330     1  0 13:39 ?        00:00:00 nginx: master process /opt/nginx/sbin/nginx
nobody    5336  5330  0 13:39 ?        00:00:00 nginx: worker process
nobody    5351  5330  0 13:39 ?        00:00:00 nginx: worker process

  This is the same setup in the production machine.

Here's what "ps-ef |grep nginx" returned:
root     13676     1  0 13:06 ?        00:00:00 nginx: master process /opt/nginx/sbin/nginx
nobody   13728 13676  0 13:06 ?        00:00:00 nginx: worker process
nobody   13766 13676  0 13:06 ?        00:00:00 nginx: worker process
1001     22194 22178  0 14:45 pts/2    00:00:00 grep --color=auto nginx


Since root is running my webserver, why couldn't it write to any given directory (which in this case is "home/ct9a/myApp/public/
system/infos"?

It's weird.







Regards,
Gordon Yeong

Matt Powell

unread,
Jun 28, 2010, 12:56:19 AM6/28/10
to papercli...@googlegroups.com
Ah! But root isn't running the process that's trying to write to the disk.

When you run nginx as root, it starts a bunch of worker processes, in your case "nobody", which doesn't have the same access permissions as root does.

Did you try changing the owner of the folders?

M

Gordon Yeong

unread,
Jun 28, 2010, 1:24:16 AM6/28/10
to papercli...@googlegroups.com
Yep, i have changed the owner of the home/ct9a/myApp/public/ system/infos directory to "nobody" and it works.

Yet,
  1. the directory,  "home/ct9a/myApp/public/ system/infos" my development server (running on production mode)  doesn't have the owner set to "nobody"
  2. both development and production servers run on paperclip 2.3.3.
I think there's a bigger problem lurking somewhere. I just don't know what is it.
Reply all
Reply to author
Forward
0 new messages