-
Notifications
You must be signed in to change notification settings - Fork 327
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
FreeBSD support #300
FreeBSD support #300
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You check for pppd
/ppp
at build-time. It is possible the build machine lacks either of them. They are technically required on the machine running openfortivpn only. How do you handle that?
src/tunnel.c
Outdated
#if HAVE_LIBUTIL | ||
#include <libutil.h> | ||
#endif | ||
#if HAVE_TERMIOS_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<termios.h> is POSIX and should be available on all supported platforms. While the #ifdef does't really hurt, perhaps we should remove it for simplicity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, what is <libutil.h> for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we didn't have to include termios.h explicitly on other platforms than FreeBSD so far, I have included it in the #ifdef
section, honestly without further investigations if this header should always be there.
The reason for both headers is the synopsis of forkpty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Header <termios.h> is included implicitly on Linux, it just needs to be included explicitly on all platforms. Build should fail without <termios.h>. I suggest removing the #ifdef
from the source file and having autoconf fail when <termios.h> is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build should fail when any of the required headers is missing (<stdio.h>
, <unistd.h>
, etc.). Can this be enforced in autoconf, the same way autoconf fails when a required function is missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it looks like FreeBSD is not compliant with recent versions of POSIX which specify fokrpty() is defined in <termios.h>
.
I checked FreeBSD's <termios.h>
does not define forkpty(), <libutil.h>
does.
I just see Travis build failed due to the missing runtime dependency of |
@DimitriPapadopoulos our comments just crossed... Travis has given me the same feedback and as a quick fix I have changed the code back to default behavior when |
I think it would be OK to postpone detection and switch between I don't see a security issue here because |
Perhaps build-time is better though. No need to push cross-platform code in an executable specific to a single platform. Options |
While pppd_run() can switch between |
|
I would assume that all includes that are not enclosed in an ifdef statement are required ones... |
Exactly, all headers not protected by However do we really need to check for headers that are documented in the C standard ( |
Return values of ppp are not documented. The FreeBSD source code shows that main() returns or exit() is called inconsistently with numerical values or Return values of ppp are probably less informative than those of pppd. |
the distinction between required and optional headers was quite straight forward. |
You're right, the list of header files is rather short. The list of functions is much more difficult to get right. |
concerning |
@DimitriPapadopoulos I think I have addressed all your comments now. Thanks for the input.
|
2f3ed7d
to
d66e707
Compare
Hi Martin.
Update: Section PERMISSIONS in ppp(8) clearly states that external commands ("shell" or "bg") are executed with the user id that invoked ppp. |
I didn't have time to work on the BSD port in the last two weeks. I'm stuck with the problem that logging in and establishing the tunnel seems to work but the read_thread always reads 0 bytes. My assumption is that the FD_SET didn't work as expected. With the configuration my current approach is to have a static config file that already contains the important parameters ( Maybe the problem with the file descriptor is that the device line in the ppp config is still wrong and ppp opens a separate tcp tunnel in parallel to the existing one. Probably I should pass the file descriptor of the tunnel here. This doesn't work with a static config file, of course, but that's the current area I'm looking into. |
Perhaps you should change pppd, Linux-specific (part of) PPP implementation, to ppp in user-visible text, including |
@DimitriPapadopoulos good point. Having just one letter more or less in the debug output isn't worth the hassle with extra string buffers... but I wouldn't touch the command line options now. |
You're right, in any case let's stabilize FreeBSD support and the DNS stuff first. That said it's very easy to change |
|
I have just compiled and tested my bsd_support branch on MacOS X. |
@mrbaseman Excellent work Martin! |
I confirm that compiling your branch (commit e66e1d3) on Fedora 28 works fine. 👍 |
on Scientific Linux release 6.10 (Carbon), a RHEL clone maintained at CERN I have noticed that configure fails with the following error: checking for LIBSYSTEMD... ./configure: line 4877: syntax error near unexpected token `else' ./configure: line 4877: `else' if libsystemd is not found. The empty square bracket in configure.ac: PKG_CHECK_MODULES(LIBSYSTEMD, [libsystemd], [AC_DEFINE(HAVE_SYSTEMD)], [ ]) suppresses a human readable configure error but produces invalid shell code. Printing out a message that we haven't found libsystemd solves the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Martin, note that systemd is not required. Does the build fail if systemd is missing on Linux?
Yes. I have tested the branch again on a few platforms: Ubuntu 16.04, CentOS 7.5, SLES 12.3, and SL 6.10. On the latter I have found that configure fails due to the absence of libsystemd. Maybe it's worth cherry-picking 06d3241 into a separate PR? It's a fix to the autoconf system, but it's unrelated to FreeBSD and it fixes an issue which is already present on the current master. I'm not sure if "absence of libsystemd on linux" is the correct condition. Maybe also a particular version of autoconf is needed to reproduce this. (in this case it was autoconf (GNU Autoconf) 2.63) |
Indeed a separate PR would be better. Please pull it directly. I seem to recall I tried on a Linux machine without systemd and that it worked for me: build didn't fail, simply |
shall we merge this now? |
OK for me, I trust you and Dimitri's review! |
Will you squash the commits? Other than that I suggest you merge. I'll test the master branch myself for a few days. Then perhaps we can publish a new version in a few weeks :-) |
Ah, just one general remark. It looks the build system now checks whether some files that are needed at run time on the production machine are available at build time on the build machine ( |
There are overrides for almost all of them. If
|
Yes, adding the option/checks you suggest could fix some edge cases (production machine very different from build machine). I would even suggest getting rid of I don't know if this makes sense. What do you think? Either way the current situation is OK with me if you'd rather stay with |
command line arguments (--with-... and --enable-...) are processed first, so it is clearer to move their definition more to the top of configure.ac. existence of files is processed later, so we have to put additional if- statements around so that the already processed overrides are not touched. we may not assign an empty value to the with_... and enable_... shell variables in configure.ac, because that would also override the values from command line
the travis workaround must come later than the check for file existence also the with_... values are empty now, instead of containing "no"
I would like to stay with the configure mechanism. We don't have a reliable mechanism to detect a specific platform. At compile time we used to have some I have re-worked the override options now, because they were not working in both directions. I have added comments in I have also added a few runtime checks for the compiled in paths. I have also hard-coded the absolute path to the |
I have re-tested with the current state on Ubuntu 16.04, CentOS 7, SL 6, SLES 12, FreeBSD 11, OSX 10.11. Building works fine on all of them, as client I could test Ubuntu, OSX, and FreeBSD. I'd merge it now. I it turns out that it needs further adjustment, then we can improve the code in separate pull requests. |
Agreed. |
👍 |
I have started this work some time ago. At the current stage I have managed to configure, compile and run openfortivpn on FreeBSD 11.
The last remaining issue is that FreeBSD doesn't have
pppd
anymore and uses a user-space tool calledppp
. It doesn't take many options from the command line but rather from STDIN or from a config file. To my understanding of the man page it should be possible to put all necessary parameters into/etc/ppp/ppp.conf
and openfortivpn should work with this. If this works, the only missing bit is to provide a working sample configuration and perhaps an update of the man page.Many command line options of openfortivpn concerning how
pppd
is called are currently not supported on BSD. At a later stage one can modify the wayppp
is called and pipe setup commands into the client before sending it to the background. I just haven't figured out to do this correctly in combination withforkpty
, but we can keep this as a separate task, onceppp
has successfully opened a connection by feeding it with appropriate parameters from a config file.