Problem starting vpnserver with systemd on xubuntu

Post your questions about SoftEther VPN software here. Please answer questions if you can afford.
Post Reply
Mada
Posts: 102
Joined: Sat Jun 20, 2015 9:40 am

Problem starting vpnserver with systemd on xubuntu

Post by Mada » Wed Jan 04, 2017 8:50 am

I am using the vpnserver.service supplied from github. The paths are for debian som I changed them to suit xubuntu.

The vpnserver starts if I call it manually but when systemd tries to start it it fails. vpnserver complains about hamcore.se2

That file is in the same directory as vpnserver.

How do I make it find the file when starting as systemd?

moatazelmasry
Posts: 336
Joined: Sat Aug 15, 2015 7:41 pm

Re: Problem starting vpnserver with systemd on xubuntu

Post by moatazelmasry » Wed Jan 04, 2017 1:40 pm

Are you using the same init script as on this page?
https://www.softether.org/4-docs/1-manu ... igurations

Also instead of:
./vpnserver start
try:
./vpnserver execsvc

Mada
Posts: 102
Joined: Sat Jun 20, 2015 9:40 am

Re: Problem starting vpnserver with systemd on xubuntu

Post by Mada » Wed Jan 04, 2017 2:18 pm

No, that is for systemV/upstart. I thought, since a systemd script is now provided, it would be better to use systemd for a newer Ubuntu distro. This is the scrip:

[Unit]
Description=SoftEther VPN Server
After=network.target auditd.service
ConditionPathExists=!/opt/vpnserver/do_not_run

[Service]
Type=forking
EnvironmentFile=-/opt/vpnserver
ExecStart=/opt/vpnserver/vpnserver start
ExecStop=/opt/vpnserver/vpnserver stop
KillMode=process
Restart=on-failure

# Hardening
PrivateTmp=yes
ProtectHome=yes
ProtectSystem=full
ReadOnlyDirectories=/
ReadWriteDirectories=-/opt/vpnserver
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SYS_NICE CAP_SYS_ADMIN CAP_SETUID

[Install]
WantedBy=multi-user.target

I have changed the path to /usr/local instead of /opt.

I am planing to add a WorkingDirectory= to se if that helps.

moatazelmasry
Posts: 336
Joined: Sat Aug 15, 2015 7:41 pm

Re: Problem starting vpnserver with systemd on xubuntu

Post by moatazelmasry » Wed Jan 04, 2017 4:18 pm

Your script looks fine.

How did you obtain SoftEther. Did you compile the source yourself or downloaded the binaries?

Mada
Posts: 102
Joined: Sat Jun 20, 2015 9:40 am

Solved: Problem starting vpnserver with systemd on xubuntu

Post by Mada » Wed Jan 04, 2017 9:32 pm

I was unable to compile the source downloaded from softether.com. And I don think there is binarys to download? ppa:s are old. Instead i used git clone and compiled from there. Thats where I got the sytemd script.

This was the error log:
jan 04 22:17:32 berto vpnserver[1982]: -- Alert: SoftEther VPN Kernel --
jan 04 22:17:32 berto vpnserver[1982]: Fatal Error: The file "hamcore.se2" is missing or broken.
jan 04 22:17:32 berto vpnserver[1982]: Please check hamcore.se2.
jan 04 22:17:32 berto vpnserver[1982]: [1B blob data]
jan 04 22:17:32 berto vpnserver[1982]: (First, reboot the computer. If this problem occurs again, please reinstall VPN software files.)
jan 04 22:17:32 berto systemd[1]: softether-vpnserver.service: Control process exited, code=exited status=255
jan 04 22:17:32 berto systemd[1]: Failed to start SoftEther VPN Server.

This is my script:
[Unit]
Description=SoftEther VPN Server
After=network.target auditd.service
ConditionPathExists=!/usr/vpnserver/do_not_run

[Service]
Type=forking
EnvironmentFile=-/usr/vpnserver
ExecStart=/usr/vpnserver/vpnserver start
ExecStop=/usr/vpnserver/vpnserver stop
KillMode=process
Restart=on-failure
WorkingDirectory=/usr/vpnserver
# Hardening
PrivateTmp=yes
ProtectHome=yes
ProtectSystem=full
ReadOnlyDirectories=/
ReadWriteDirectories=-/usr/vpnserver
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SYS_NICE CAP_SYS_ADMIN CAP_SETUID

[Install]
WantedBy=multi-user.target

-- Unit softether-vpnserver.service has begun starting up.
jan 04 22:29:54 berto vpnserver[2097]: The SoftEther VPN Server service has been started.
jan 04 22:29:54 berto systemd[1]: Started SoftEther VPN Server.
-- Subject: Unit softether-vpnserver.service has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit softether-vpnserver.service has finished starting up.
--
-- The start-up result is done.

moatazelmasry
Posts: 336
Joined: Sat Aug 15, 2015 7:41 pm

Re: Problem starting vpnserver with systemd on xubuntu

Post by moatazelmasry » Sat Jan 07, 2017 3:06 pm

It might be that the script is not able to find the .so libraries of SoftEther for some reason.
Maybe you can try preloading them in the script using:
LD_PRELOAD="/path/to/each/so /anotherpath"

Mada
Posts: 102
Joined: Sat Jun 20, 2015 9:40 am

Re: Problem starting vpnserver with systemd on xubuntu

Post by Mada » Tue Jan 10, 2017 8:55 am

Thanks,

adding the WorkingDirectory=/usr/vpnserver seems to do the trick. Now working.

Post Reply