Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 527
glesage Avatar asked Dec 17 '14 01:12

glesage


1 Answers

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.

like image 154
arboreal84 Avatar answered Nov 03 '22 13:11

arboreal84