1

I have configured a dradis.service file in /lib/systemd/system, it is called dradis.service. And it is its content:

[Unit]
Description=Dradis web application

[Install]
WantedBy=multi-user.target

[Service]
WorkingDirectory=/usr/lib/dradis
ExecStart=/usr/bin/bundle exec rails server
Type=simple
User=user
Group=user

user is in the sudoers group.

The problem is when i try to start the service with sudo service start dradis command

Observing log with sudo journalctl -u dradis -f:

Started Dradis web application.

Faraday::Builder is now Faraday::RackBuilder.

Rails Error: Unable to access log file. Please ensure that /usr/lib/dradis

/log/development.log exists and is writable (ie, make it writable for user and group: chmod 0664 /usr/lib/dradis/log/development.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.

/usr/lib/dradis/config/initializers/resque.rb:3:in `initialize': Permission denied @ rb_sysopen - /usr/lib/dradis/log/resque.log (Errno::EACCES)

Taking in example the command specified in dradis.service file, /usr/bin/bundle exec rails server:

  1. If in the /usr/lib/dradis as user i will execute sudo /usr/bin/bundle exec rails server all it is going well;
  2. If in the /usr/lib/dradis as user i will execute /usr/bin/bundle exec rails server i am obtaining the same error;

Where is my error in configuration file dradis.service in order to use sudo service start dradis? Where am i falling in a wrong think?

1 Answer 1

1

Since you apparently need to run this as root (using sudo), why don't you remove:

User=user
Group=user

From your service file? System D service files are run as root if not told otherwise.

3
  • Ok it is working thanks, if i am using User=root. Instead removing User and Group parameters it gives the same error. But user is a sudoers, is it not enough? My question is to understand where i did not comprise clearly, thanks.
    – Hoper
    Oct 11, 2016 at 9:32
  • 2
    You shouldn't need User=root either. See above. But with regards to sudo I think it is better to ask a new question on that subject. Oct 11, 2016 at 9:40
  • If systemd is told to run a service as a specific user, it tries to do just that. Systemd does not look in the sudoers file to check that it should try to rerun the program as root. The sudoers file is private to the sudo program. In the general case, systemd does not even know the program fails if not run as root. The program may start ok, but fail much later on when root privilege is needed. If the program is supposed to be run as root, you should tell systemd so. Oct 11, 2016 at 11:30

You must log in to answer this question.

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