1

I have an Ubuntu staging server on AWS which runs a tiny Sinatra app using Thin webserver.
The sinatra app runs some git clone commands when invoked and everything works great when I run rackup from my user.
Naturally I want to run the server as a daemon, for this I used rackup -D and invoked the app. This time, I got an exception from git which tells the daemon is not authorized to write to the target folder:

could not create work tree dir 'path/to/clone': Permission denied

As I understand it, daemons have the same privileges as the user who run them so how come the task fails? I also tried chmod -R 777 the directory but it didn't work..

2
  • 1
    Please don't give 777 to anything
    – Zanna
    Jul 25, 2017 at 16:29
  • @Zanna of course not, but it's the go-to command to start the elimination process Jul 26, 2017 at 8:49

2 Answers 2

2

My problem ended up being rack itself. Turns out (as explained here) that rack, when run with the rackup -D command (as a daemon) changes the working dir to /.

0

Check if the executable has the setuid bit set. That would make it run as the owner of the file, not the user that launched it. You can check by running ls -l appname and looking at the fourth character in the permissions mask (in place of the owner executable bit). If it is an s then the setuid bit is set.

Daemons are usually set to run with setuid, so they are expected to not have the permissions of the user that started them. This is in contrast to non-daemon apps, which are expected to have the user's permissions. You will need to add the daemon's use r to the group of the files that you would like affected, and ensure that the group permissions allow the actions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .