This may be an Nginx wrinkle, or it may be because I don't understand Unix permissions.
We're using Hudson CI to deploy our staging instance. So RAILS_ROOT is /var/lib/hudson/jobs/JOBNAME/workspace.
- Hudson runs as
hudsonuser - Nginx runs as
www-datauser hudsonandnginxare both members of thewwwgrouprootof my nginx conf points toRAILS_ROOT/publicas per normal.RAILS_ROOT/config/environment.rbis owned bywww-data(so Passenger runs aswww-data)RAILS_ROOTand everything in it is owned by thewwwgroup and group has r/w/x permissions
As it stood, Nginx threw 403 permission denied when requesting any url. error.log contained entries like this: public/index.html" is forbidden (13: Permission denied).
These did not fix the or change the error (each with a stop/start of Ngnix):
chmod 777 -R RAILS_ROOTchgrp www -R /var/lib/hudson
I also tried Nginx as root, and passenger complained that it could not find config/environment (despite the path displayed on the error page being correct).
The fix was to ensure everybody has read permissions on each directory in the heirachy. In this case chmod o+r /var/lib/hudson.
But if the group has read permissions on the directory, and nginx is a member of the owner group of the directory, why was it necessary to allow everyone read permissions? Is there something have not grokked about permissions?
$nginx -V
nginx version: nginx/0.7.61
built by gcc 4.4.1 (Ubuntu 4.4.1-4ubuntu8)
configure arguments: --prefix=/opt/nginx --add-module=/usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/ext/nginx --with-http_ssl_module --with-pcre=~/src/pcre-8.00/ --with-http_stub_status_module
$cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.10
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION="Ubuntu 9.10"
The usual problems are:
- only the process gid affects the ownership of files created, though the gid and the groups define what files may be accessed
- when switching 'personas' the gid and the groups are set with different system calls. Many processes only set the gid when switching from root to the target uid and the groups from /etc/group are ignored for these processes.
– Jacek Konieczny Feb 28 '10 at 10:18