[SOLVED] UP script in client config files fails "No such file or directory"

Need help configuring your VPN? Just post here and you'll get that help.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Forum rules
Please use the [oconf] BB tag for openvpn Configurations. See viewtopic.php?f=30&t=21589 for an example.
Post Reply
User avatar
NiMing8
OpenVpn Newbie
Posts: 19
Joined: Tue Jul 25, 2017 2:02 am

[SOLVED] UP script in client config files fails "No such file or directory"

Post by NiMing8 » Sat Sep 11, 2021 7:45 am

OpenVPN 2.7.4 running on Rasberry PI OS "Butch" (current and up to date as of today).

Setting up a client config file with these lines in it:

Code: Select all

script-security 2
up "/usr/bin/python /root/nexthops.py 10.11.0.105 +tun1"
down "/usr/bin/python /root/nexthops.py 10.11.0.105 -tun1"
And OCCASIONALLY I get this in the /var/log/openvpn.log file:

Code: Select all

Sat Sep 11 14:50:30 2021 /usr/bin/python /root/nexthops.py 10.11.0.105 +tun1 tun1 1500 1603 10.11.0.106 10.11.0.105 init
/usr/bin/python: can't open file '/root/nexthops.py': [Errno 2] No such file or directory
Sat Sep 11 14:50:30 2021 WARNING: Failed running command (--up/--down): external program exited with error status: 2
On an older Stretch version of Rasberry PI OS and OpenVPN 2.4.0, this never occurs and a did not need the /usr/bin/python path in the up or down entries.

If I remove the /usr/bin/python from the up / down entries, then I get the Errno 2 all the time.

The first line of the nexthops.py script has:

#!/usr/bin/python

So I don't understand why I need to fully qualify the path to python in the first place (again, didn't have to do this on an older version of Rasbian OS

Any ideas what's going wrong / things for me to check / references?

Thanks!

UPDATE: I was wrong: It''s NOT running the UP or DOWN scripts at all. It's like OpenVPN cannot access the /root folder. But I thought OpenVPN runs under ROOT user by default?
Last edited by NiMing8 on Sat Sep 11, 2021 11:05 am, edited 1 time in total.

User avatar
NiMing8
OpenVpn Newbie
Posts: 19
Joined: Tue Jul 25, 2017 2:02 am

Re: UP script in client config files fails "No such file or directory"

Post by NiMing8 » Sat Sep 11, 2021 10:16 am

Just a bit more info:
If I remove the /usr/bin/python from the up / down entries, this is the error I receive:

Code: Select all

Options error: --up script fails with '/root/nexthops.py': No such file or directory (errno=2)
Options error: Please correct this error.
Use --help for more information.
but I can copy/paste that into the $ prompt and it works when running under root (sudo -s)

User avatar
NiMing8
OpenVpn Newbie
Posts: 19
Joined: Tue Jul 25, 2017 2:02 am

Re: UP script in client config files fails "No such file or directory"

Post by NiMing8 » Sat Sep 11, 2021 11:05 am

OK. Found the solution.
https://www.linuxquestions.org/question ... 175637168/

New parameter in OpenVPN: ProtectHome
Set this to false in /lib/systemd/system/openvpn@.service and reboot.

User avatar
NiMing8
OpenVpn Newbie
Posts: 19
Joined: Tue Jul 25, 2017 2:02 am

Re: [SOLVED] UP script in client config files fails "No such file or directory"

Post by NiMing8 » Sat Sep 11, 2021 11:07 am

P.S. A better error message would have made this MUCH easier to solve:

"/root folder access is denied"

Post Reply