cross-posted from: https://reddthat.com/post/21668140

I have a VPN daemon that needs to run before the client will work. Normally, this would have been set up automatically by its install script, but the system is immutable.

I’ve created the systemd service via sysyemctl edit --force --full daemon.service with the following parameters:

[Unit] 
Description=Blah
After=network-online.target

[Service]
User=root
Group=root
ExecStart=/usr/bin/env /path/to/daemon

[Install]
WantedBy=multi-user.target

I’ve verified that the daemon is actually executable, and it runs fine when I manually call it via sudo daemon. When I try to run it with sudo systemctl enable --now daemon.service, it exits with error code 126.

What am I missing?

Edit: Typo, and added the relevant user and group to the Service section. Still throwing a 126.

Solution: the system wanted /usr/bin/env in ExecStart to launch the binary. The .service file above has been edited to show the working solution.

3 points
*

If that is your full .service file you are missing the directive to tell the daemon what user to run under. Under service try adding

User=root

Group=root

Before the ExecStart command line.

permalink
report
reply
4 points
*

Is that necessary for processes running as root? AfaIk, root is default.

Keywords should be in CamelCase format, thus the space in Wanted By is wrong.

permalink
report
parent
reply
3 points

Honestly can’t believe I completely missed the space in Wanted By. This is likely the bigger culprit to the failed to run error. Poster above me is correct should read

WantedBy

permalink
report
parent
reply
2 points

It’s an autocorrect typo. It’s actually WantedBy in the file.

permalink
report
parent
reply
2 points

Foiled by autocorrect! There’s no space in the original file, and I’ve edited my post to reflect that.

permalink
report
parent
reply
4 points
*

On that, make sure it’s in the root systemd path. Something like /etc/systemd/system/blah.service, placing it in the user systemd service path (~/.config/systemd/user/) will cause permission errors as it’ll try accessing the root user from the current user.

permalink
report
parent
reply
2 points
*

Thanks, I verified that it’s in the correct place. Still throwing a 126 (see the modifications in the edit).

permalink
report
parent
reply
1 point
*

What’s the specific VPN service? I’ll check their docs.

permalink
report
parent
reply
2 points

I added the relevant user and group, and it’s still throwing a 126. I checked the daemon itself, and it looks like it’s a pre-compiled binary. Manually running /bin/bash /path/to/daemon gives the same error, but sudo /path/to/daemon starts the daemon.

permalink
report
parent
reply
1 point
*

Does the command in ExecStart work in a root environment, e.g. sudo -i?

permalink
report
parent
reply

Linux Questions

!linuxquestions@lemmy.zip

Create post

Linux questions Rules (in addition of the Lemmy.zip rules)

  • stay on topic
  • be nice (no name calling)
  • do not post long blocks of text such as logs
  • do not delete your posts
  • only post questions (no information posts)

Tips for giving and receiving help

  • be as clear and specific
  • say thank you if a solution works
  • verify your solutions before posting them as facts.

Any rule violations will result in disciplinary actions

Community stats

  • 85

    Monthly active users

  • 62

    Posts

  • 106

    Comments

Community moderators