glesage
glesage

Reputation: 975

nodejs fs eacces permission

I've just run into a strange problem with fs reading a file.

I have node application run from a deployment manager (strongloop strong-pm) as the following user "strong-pm".

No matter what permissions I give to the file I'm trying to open throug the node app, I get

return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);

worker:1 Error: EACCES, permission denied '/root/my_dir/file.txt'
    at Object.fs.openSync (fs.js:432:18)
    at Object.fs.readFileSync (fs.js:286:15)

I've tried everything:
sudo chown -R strong-pm:strong-pm /root/my_dir
sudo chmod -R 777 /root/my_dir
sudo chmod 777 /root/my_dir/file.txt
adding the strong-pm to a group
then adding that group to the directory...

Still no luck.. any ideas?

Thanks!


System: Ubuntu 14.04 x64 on DigitalOcean

Upvotes: 6

Views: 5836

Answers (3)

glesage
glesage

Reputation: 975

It seemed like the issue was that the /root directory was protected and so subdirectories were not accessible by node somehow

Upvotes: 0

dcasalrodriguez
dcasalrodriguez

Reputation: 1

Try this:

.{otherPATH}/root/my_dir/file.txt

Upvotes: 0

arboreal84
arboreal84

Reputation: 2154

Rather than trying it inside node, try to switch to that user and read the file:

su strong-pm
cat /root/my_dir/file.txt

If that works, make sure node is running using that user.

Upvotes: 0

Related Questions