O contexto do SELinux foi definido incorretamente na pasta "pia_ovpn"
restorecon -R /etc/openvpn/client
Estou tentando iniciar o OpenVPN automaticamente (que se conectará à VPN de acesso à Internet privada) quando minha conexão ethernet for ativada.
Eu tenho /etc/NetworkManager/disaptcher.d/99-custom_script_handler
#!/bin/bash
if [ "$1" = "eth0" ] && [ "$2" = "up" ]
then
echo "$(date): Starting tunnel script" >> /root/tunnel.log
/bin/bash /root/start_tunnel_script
else
echo No action for this combination
fi
Isso é executado corretamente e inicia o "start_tunnel_script"
/ root / start_tunnel_script
#!/bin/bash
echo "$(date): Running tunnel script as $(whoami)" >> /root/tunnel.log
LOCATION="Netherlands"
openvpn --echo --daemon --cd /etc/openvpn/client/pia_ovpn/ --config "$LOCATION.ovpn" --auth-user-pass /root/.pia_credentials --script-security 2 --syslog --up /root/bootstrap
Mas o OpenVPN relata que não consegue encontrar o arquivo de configuração
Sep 3 15:12:39 test openvpn[4056]: Options error: In [CMD-LINE]:1: Error opening configuration file: Netherlands.ovpn
Sep 3 15:12:39 test openvpn[4056]: Use --help for more information.
Sep 3 15:12:39 test nm-dispatcher: req:4 'up' [eth0], "/etc/NetworkManager/dispatcher.d/99-custom_script_handler": complete: failed with Script '/etc/NetworkManager/dispatcher.d/99-custom_script_handler' exited with error status 1.
Sep 3 15:12:39 test NetworkManager[645]: <warn> [1504465959.2123] dispatcher: (40) 99-custom_script_handler failed (failed): Script '/etc/NetworkManager/dispatcher.d/99-custom_script_handler' exited with error status 1.
Sep 3 15:12:40 test NetworkManager[645]: <info> [1504465960.9892] policy: set 'eth0' (eth0) as default for IPv6 routing and DNS
Mas o arquivo de configuração existe claramente:
# ls -al /etc/openvpn/client/pia_ovpn/
total 160
drwxr-xr-x. 2 root root 4096 Sep 2 14:37 .
drwxr-x---. 3 root root 22 Sep 2 14:37 ..
-rw-r--r--. 1 root root 295 Feb 6 2017 AU Melbourne.ovpn
-rw-r--r--. 1 root root 285 Feb 6 2017 AU Sydney.ovpn
-rw-r--r--. 1 root root 288 Feb 6 2017 Brazil.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 CA Montreal.ovpn
-rw-r--r--. 1 root root 2025 Feb 6 2017 ca.rsa.2048.crt
-rw-r--r--. 1 root root 292 Feb 6 2017 CA Toronto.ovpn
-rw-r--r--. 1 root root 869 Feb 6 2017 crl.rsa.2048.pem
-rw-r--r--. 1 root root 289 Feb 6 2017 Denmark.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 Finland.ovpn
-rw-r--r--. 1 root root 288 Feb 6 2017 France.ovpn
-rw-r--r--. 1 root root 289 Feb 6 2017 Germany.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 Hong Kong.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 India.ovpn
-rw-r--r--. 1 root root 289 Feb 6 2017 Ireland.ovpn
-rw-r--r--. 1 root root 288 Feb 6 2017 Israel.ovpn
-rw-r--r--. 1 root root 287 Feb 6 2017 Italy.ovpn
-rw-r--r--. 1 root root 287 Feb 6 2017 Japan.ovpn
-rw-r--r--. 1 root root 288 Feb 6 2017 Mexico.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 Netherlands.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 New Zealand.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 Norway.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 Romania.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 Singapore.ovpn
-rw-r--r--. 1 root root 284 Feb 6 2017 South Korea.ovpn
-rw-r--r--. 1 root root 288 Feb 6 2017 Sweden.ovpn
-rw-r--r--. 1 root root 287 Feb 6 2017 Switzerland.ovpn
-rw-r--r--. 1 root root 288 Feb 6 2017 Turkey.ovpn
-rw-r--r--. 1 root root 291 Feb 6 2017 UK London.ovpn
-rw-r--r--. 1 root root 296 Feb 6 2017 UK Southampton.ovpn
-rw-r--r--. 1 root root 295 Feb 6 2017 US California.ovpn
-rw-r--r--. 1 root root 292 Feb 6 2017 US Chicago.ovpn
-rw-r--r--. 1 root root 289 Feb 6 2017 US East.ovpn
-rw-r--r--. 1 root root 292 Feb 6 2017 US Florida.ovpn
-rw-r--r--. 1 root root 292 Feb 6 2017 US Midwest.ovpn
-rw-r--r--. 1 root root 296 Feb 6 2017 US New York City.ovpn
-rw-r--r--. 1 root root 292 Feb 6 2017 US Seattle.ovpn
-rw-r--r--. 1 root root 298 Feb 6 2017 US Silicon Valley.ovpn
-rw-r--r--. 1 root root 290 Feb 6 2017 US Texas.ovpn
-rw-r--r--. 1 root root 289 Feb 6 2017 US West.ovpn
Se eu executo o "start_tunnel_script" do shell como root, ele funciona bem - esse é o kicker. O problema está em como o start_tunnel_script está sendo lançado, mas eu não posso - para a vida de mim - descobrir o que é diferente.
O contexto do SELinux foi definido incorretamente na pasta "pia_ovpn"
restorecon -R /etc/openvpn/client