# Umask in tmp/{cache|pids|sessions|sockets}? / rails in AFS

**URL:** <https://www.ruby-forum.com/t/umask-in-tmp-cache-pids-sessions-sockets-rails-in-afs/89545>\
**Category:** Deployment\
**Created:** [March 21, 2007, 3:25am UTC](https://www.ruby-forum.com/t/umask-in-tmp-cache-pids-sessions-sockets-rails-in-afs/89545 "2007-03-21T03:25:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![liamr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecae2f/32.png) [@liamr](https://www.ruby-forum.com/u/liamr)\
**Post date:** [March 21, 2007, 3:25am UTC](https://www.ruby-forum.com/t/umask-in-tmp-cache-pids-sessions-sockets-rails-in-afs/89545/1 "2007-03-21T03:25:57Z")

</div>

Is it possible to change the umask on the files created in the “tmp”  
directory via some mechanism present in rails itself? I tried adding  
“File.umask 0000” to  
config/enviroment.rb and no go.

Here’s the situation. We’re trying to set up a RoR development  
environment (Apache 2.2.x, fastcgi), but the files for most of our web  
development are located in AFS (a networked file system). AFS doesn’t  
really use normal unix file permissions the way that a local file system  
does. So, on a local disk, I’d probably have done like…

chown www:www tmp/sessions

But in AFS, I still own the directory, but have to give the webserver  
principal rights to it…

fs sa tmp/sessions www rliwdk

Rails is happy to create files in directories permitted in these  
directories, but claims not to be able to read them.

Processing InfoController#properties (for xxx.xxx.xxx.xxx at 2007-03-20  
16:37:58  
) [GET]  
Session ID: ebf3af9d4b0849d55d948c6790f76567  
Parameters: {“action”=\>“properties”, “controller”=\>“rails/info”}  
Completed in 0.00105 (949 reqs/sec) | Rendering: 0.00006 (5%) | 500  
[[http://blah.umich.edu/rails-afs/rails/info/properties](http://blah.umich.edu/rails-afs/rails/info/properties)]  
file /afs/umich.edu/user/blah/rails/public/…/config/…/tmp/session  
s//ruby\_sess.916337a4b4cd819c not readable^M

It seems to be linked to the initialize() function in  
/usr/lib/ruby/1.8/pstore.rb ~ line  
94:

if File::exist? file and not File::readable? file  
raise PStore::Error, format(“file %s not readable”, file)  
end

if I change File::readable? to File::readable\_real?, it works… but I’d  
rather not change this code. It seems like the wrong way to handle it.

So… I was wondering if there was something I could set in my rails  
environment such that the files in tmp/cache, tmp/sessions and  
tmp/sockets are permitted 0666?

Suggestions?

---

<div class="post-metadata">

**Author:** ![liamr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecae2f/32.png) [@liamr](https://www.ruby-forum.com/u/liamr)\
**Post date:** [March 21, 2007, 4:29pm UTC](https://www.ruby-forum.com/t/umask-in-tmp-cache-pids-sessions-sockets-rails-in-afs/89545/2 "2007-03-21T16:29:45Z")

</div>

[http://weblog.textdrive.com/article/196/on-rails-sessions](http://weblog.textdrive.com/article/196/on-rails-sessions)

```
http://mongrel.rubyforge.org/docs/apache.html

```

---

<div class="post-metadata">

**Author:** ![liamr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecae2f/32.png) [@liamr](https://www.ruby-forum.com/u/liamr)\
**Post date:** [March 21, 2007, 6:52pm UTC](https://www.ruby-forum.com/t/umask-in-tmp-cache-pids-sessions-sockets-rails-in-afs/89545/3 "2007-03-21T18:52:06Z")

</div>

Admittedly this is a non-answer, but why not use the database session  
store? You side-step this problem and get better performance plus the  
potential to scale across hosts…

---

<div class="post-metadata">

**Author:** ![liamr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecae2f/32.png) [@liamr](https://www.ruby-forum.com/u/liamr)\
**Post date:** [March 21, 2007, 7:35pm UTC](https://www.ruby-forum.com/t/umask-in-tmp-cache-pids-sessions-sockets-rails-in-afs/89545/4 "2007-03-21T19:35:20Z")

</div>

It’s mostly to be able to support a freshly created rails project, out  
of the box… or rather to know what we need to do support such an  
installation.

I know there are other session handlers, but I imagine that without  
fixing the umask, we’d run into the same issue with any other file  
created in the various subdirectories under “tmp” (cache, pids, sessions  
and sockets).

---

<div class="post-metadata">

**Author:** ![liamr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecae2f/32.png) [@liamr](https://www.ruby-forum.com/u/liamr)\
**Post date:** [March 21, 2007, 8:06pm UTC](https://www.ruby-forum.com/t/umask-in-tmp-cache-pids-sessions-sockets-rails-in-afs/89545/5 "2007-03-21T20:06:20Z")

</div>

On 3/21/07, Liam H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I know there are other session handlers, but I imagine that without  
> fixing the umask, we’d run into the same issue with any other file  
> created in the various subdirectories under “tmp” (cache, pids, sessions  
> and sockets).

The best way to handle this is to make your rails set up as “shared  
nothing”  
as possible. Each Rails app should be independent.

Store your sessions in the database, and then use Apache 2.2’s  
mod\_proxy\_balancer to route requests between Mongrel processes on the  
various boxes you have.

The only place you need shared storage in this set up is for user  
uploaded  
files (and even then, you could go with something like S3).

Hope this helps,  
Luke F.
