saving files and permissions

having a file saving permissions problem from within a controller...

    f = File.new("/home/path/to/I-A-files.txt", "w")     f.syswrite(output)     f.close

The error...

Errno::EACCES (Permission denied - /home/path/to/I-A-files.txt):

this file path is not within RAILS path but rather outside of it.

files saved without a path are clearly saved in the RAILS_ROOT directory as user 'craig'

user 'craig' clearly has permissions to save files in that path (actually, the path is an NFS mounted path but I don't see why that should matter)

Obviously I am missing some bit of information that would tell me why this fails.

TIA

Craig

how are you running rails? Through mongrel? Is your mongrel instance running as user craig?

Mike

how are you running rails? Through mongrel?

having a file saving permissions problem from within a controller...

    f = File.new("/home/path/to/I-A-files.txt", "w")     f.syswrite(output)     f.close

The error...

Errno::EACCES (Permission denied - /home/path/to/I-A-files.txt):

this file path is not within RAILS path but rather outside of it.

files saved without a path are clearly saved in the RAILS_ROOT directory as user 'craig'

user 'craig' clearly has permissions to save files in that path (actually, the path is an NFS mounted path but I don't see why that should matter)

Obviously I am missing some bit of information that would tell me why this fails.

are you absolutely sure mongrel is running as you? have you tried printing `whoami` from one of your controllers to see who your code is executing as?

Good thought...I am just starting to tinker with backticks and executing shell commands.

thus, in contoller code, flash[:notice] = `whoami`

just confirmed it is me, which I had to believe was the case since a simple `ps aux |grep mongrel` also tells me the same thing.

The issue is somewhat confusing...

I am using various NFS mounts including my $HOME directory and I can save files in that tree but not on other mounts. The curious thing is that what works in script/console does not work in controller code so I'm gathering that it has something to do with mongrel.

mongrel_cluster (1.0.2)     Mongrel plugin that provides commands and Capistrano tasks for     managing multiple Mongrel processes.

checking to see if there's an update but I don't hold out much hope for it changing things

Craig

sort of solved anyway...I ended up making symbolic links from the target directory into a directory inside my RAILS_ROOT path and I can now save files, etc.

this is strange behavior...

Anyway, I wanted to leave tracks in case anyone follows down my path.

Craig

Maybe mongrel is running in a chroot jail? Have you checked what \ is for it?

Doesn't seem to be a chroot jail because I can save files on the out of the RAILS_ROOT tree but I had to symlink the NFS mount into my RAILS_ROOT to simplify the matter...it worked. I don't know why and I had to move on.

Craig

is your machine running SELinux? I've run into some very strange behaviour on my server machine which runs Redhat with SELinux enabled.

Mike

On my development system, it's disabled

Craig