this post was submitted on 04 Jul 2024
7 points (88.9% liked)
Linux Questions
1063 readers
2 users here now
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
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
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.
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.Thanks, I verified that it's in the correct place. Still throwing a 126 (see the modifications in the edit).
What's the specific VPN service? I'll check their docs.
Private Internet Access
I assume so, but just to be sure, have you run
sudo systemctl enable blah.service
then reboot? It'll symbolic link to the systemd auto start service and run it at boot.Also, make sure everything is marked as executable; especially whatever you have "/path/to/daemon" set as.
sudo chmod +x /path/to/daemon
Restart the service or reboot then :
sudo systemctl status blah.service
Yep, more specifically I tried
sudo systemctl enable --now daemon.service
. Gives the same error, and maybe that's because it's some kind of binary.sudo /bin/bash /path/to/daemon
throws the same error, butsudo /path/to/daemon
does not. However, if I drop ,/bin/bash
from the service file, it throws a 203 error instead.Is the daemon a binary? If so drop the bash part and try
sudo chmod 755 /path/to/daemon
.Tried that, back to 203/Exec error. It's like ExecStart wants me to specify a program to launch it, and bash clearly isn't it.
Try
ExecStart=/usr/bin/env /path/to/daemon
Also what's the output of
ldd /path/to/daemon
&sudo systemd-run /path/to/daemon
? Maybe checksystemctl show-environment
. Maybe try addingType=simple
, this tells systemd that the service will fork.If that fails, we could try
ExecStart=/usr/bin/strace -f -o /tmp/daemon_strace.log /path/to/daemon
for stactrace &ExecStart=/bin/sh -c '/path/to/daemon > /tmp/daemon.log 2>&1'
to log the daemon.Omg, adding
/usr/bin/env
worked. Launched the daemon, and the client is able to launch and connect a WireGuard tunnel.systemctl show-environment
lists/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
on the PATH, so maybe that's why that worked...? (I'm going to have to go read up onenv
).Either way, I did a reboot to verify, and it's definitely running. Now I just need to tweak it a bit so it tries to reconnect if the network drops out, but holy shit, I appreciate the help.
Good to hear that it worked.
To explain env, typically when systemd is running a service it only provides a very minimal environment. When using env it passes more of the environment variables and whatnot from userspace, so it's likely that the binary daemon was looking for specific environment variables and it returned an empty string and that's what caused error, it's also useful if the daemon's location changes during runtime or if it's not in a standard location.
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.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
It's an autocorrect typo. It's actually
WantedBy
in the file.Would have been nice if this would have been the error.
Foiled by autocorrect! There's no space in the original file, and I've edited my post to reflect that.
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, butsudo /path/to/daemon
starts the daemon.Does the command in
ExecStart
work in a root environment, e.g.sudo -i
?