-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move routing and name resolution changes into an external script? #678
Comments
Hey Dimitri, thanks for sharing the idea! |
Indeed external helper programs with SUID set may help limit the part of the code that runs as root. I think that's what FortiClient does. Of course external helper programs don't have to be scripts. Like you, I feel uneasy about running SUID scripts (they actually require a C wrapper). However they're really much easier to write, maintain and adapt to each Linux distribution. It would also help with macOS: the DNS part is currently broken because changes to The real obstacle is spawning |
I'm sorry, I have no idea... |
An alternative (and better method) to this set up is to use the sudo program. This offers superior security andwill allow you to set things up so that any (authorised) user can activate/deactivate the link using the scripts.Using sudo will allow an authorised user to activate/deactivate the PPP link cleanly and securely. |
@zez3 Indeed using
|
Yassou Dimitri, what I've meant is that openfortivpn should do all the necessary steps during initial install and check at every new connection that pppd has still the right permissions: http://www.iitk.ac.in/LDP/HOWTO/PPP-HOWTO/x1569.html openfortivpn should not need to do those routing changes directly. That should be handled by pppd I will post more in the appropriate issue This still does not solve the noauth root need. For an pppd connection to work without noauth we probably need the tunnel server to authenticate itself by writing an password in the /etc/ppp/pap-secrets or chap-secrets I've just tried this: # OUTBOUND connections # Here you should add your userid password to connect to your providers via # * password and when I am calling my peer I no longer get the |
Actually openfortivpn should not always let ppp modify routing and name resolution parameters for multiple reasons:
The alternatives options are:
See #600. This part of the discussion should be moved there. In any case I understand you have come to the same conclusion that |
First of all sorry, that I didn't comment here for a longer time. We are currently discussing scenarios that involve IPv6 at work. I stumbled across this proposal. Actually, it might help a lot for the IPv6 support. The external tools (route, ip, netstat, ...) already support ipv6. We "simply" have to extract the ipv6 routes from the config that the fortigate pushes and find a way to use the tools in a portable way. On Mac OS X and FreeBSD we already use them, but ignore IPv6 so far. Parsing text output might be even more complicated for IPv6 addresses than for IPv4 ones. So an external library might help in this context, too. As I have learned today, in a high level picture it doesn't make a difference which IP protocol is used.in which place. If our name resolution and the socket connections support IPv6 we should be able to establish a tunnel to an IPv6 gateway. If we can handle IPv6 addresses and IPv6 routes we should be able to enable IPv6 traffic through the tunnel. Using tools that already support IPv6 seems to be an easier task than rewriting the whole IP-C-code for IPv6 . |
I'd recommend using vpnc-script. It handles IP and DNS configuration on a whole bunch of operating systems including Mac OS, Solaris, *BSD, various Linux setups. Just set the appropriate environment variables and spawn it, and it should do the right thing. |
@dwmw2 Thank you for the hint about |
Most Linux distributions ship it already; we moved it out of the vpnc package itself so it could be a dependency for openconnect too. Even NetworkManager has a tool which 'collects' the environment variables and feeds the information back to NM for when the actual VPN client is running without root privs etc. |
Continuing from PR #986 @DimitriPapadopoulos I've read a bunch of the related issue discussion yesterday and those left me asking the same question. if there was a way for ppp ip-{up,down}.d scripts to fetch information about the tunnel (e.g. DNS and IP routes pushed by the server, could be as simple as having a file), then I don't think there would be any benefit to a solution in openfortivpn directly. I'm doing routing and DNS like this for a while now because I don't agree with a few things the server pushes. It would be need if I could filter over what the server tries to push instead of replicating the list. currently I do this: #!/bin/bash
routes=(...)
dns_servers=(...)
search_domains=(...)
resolvectl dns "$1" "${dns_servers[@]}"
resolvectl domain "$1" "${search_domains[@]}"
for route in "${routes[@]}"
do
ip route add "$route" dev "$1"
done What I'm wondering: If the information is available before ppp's ip-up, then why bother to implement your own up/down hooks? The script could just fetch the information from e.g. a json file and e.g. filter it with jq (#960). If the information is not available before ppp's ip-up, then I guess it is necessary to at least provide some hook for the point in time when ppp is up and details about the tunnel are known. I'm not familiar with the protocol, can anyone clarify? |
That's exactly what vpnc-scripts does: get information DNS and IP routes pushed by the server from the calling program. There are multiple ways to achieve that:
If I were to choose, I would choose the latter - to avoid re-inventing the wheel. |
Additionally, the routing and DNS suggestions sent by the VPN server are parsed and known by openfortivpn, before even establishing the PPP tunnel. Most of the routing and DNS changes are performed directly by openfortivpn in It should be conceptually "straightforward" to change the code in there into calls to vpnc-scripts. |
It is true that Moving to vpnc-scripts should remove any need to have |
Ideally, we would also get rid of |
I'm wondering whether moving the code that changes routing and name resolution parameters to an external script would help write and maintain openfortivpn. Typically most of
ipv4.h
/ipv4.c
would move to that script. Additionally an option should be provided to run an alternative script.Cons:
Pros:
pppd
). See Revisit running openfortivpn as root? #650.The text was updated successfully, but these errors were encountered: