Skip to content
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

Fix compilation issues on OpenBSD #3661

Merged
merged 4 commits into from
May 6, 2021
Merged

Fix compilation issues on OpenBSD #3661

merged 4 commits into from
May 6, 2021

Conversation

millert
Copy link
Contributor

@millert millert commented Apr 28, 2021

This PR fixes the following issues that prevent building syslog-ng on OpenBSD:

  • OpenBSD uses a different flavor of reentrant getent functions
  • OpenBSD doesn't support IPv4-mapped IPv6 addresses (they are considered harmful)
  • OpenBSD uses IP_RECVDSTADDR for UDP dest-IP like FreeBSD does
  • tlscontext.c uses AF_INET and AF_INET6 but doesn't include sys/socket.h where they are defined.

@kira-syslogng
Copy link
Contributor

This user does not have permission to start the build. Can one of the admins verify this patch and start the build?
(admin: you have the next options (make sure you checked the code):
"ok to test" to accept this pull request (and further changes) for testing
"test this please" for a one time test run
"add to whitelist" add author of a Pull Request to whitelist (globally, be careful, it means this user can trigger kira for any PR)
do nothing -> CI won't start)

1 similar comment
@kira-syslogng
Copy link
Contributor

This user does not have permission to start the build. Can one of the admins verify this patch and start the build?
(admin: you have the next options (make sure you checked the code):
"ok to test" to accept this pull request (and further changes) for testing
"test this please" for a one time test run
"add to whitelist" add author of a Pull Request to whitelist (globally, be careful, it means this user can trigger kira for any PR)
do nothing -> CI won't start)

@Kokan
Copy link
Collaborator

Kokan commented Apr 29, 2021

@kira-syslogng ok to test

@Kokan Kokan added this to the syslog-ng-3.32 milestone Apr 29, 2021
@kira-syslogng
Copy link
Contributor

Build SUCCESS

Copy link
Collaborator

@Kokan Kokan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patches.

lib/compat/getent-openbsd.c Outdated Show resolved Hide resolved
lib/host-resolve.c Show resolved Hide resolved
@millert millert force-pushed the openbsd branch 2 times, most recently from e516511 to 2004b54 Compare April 29, 2021 14:13
@kira-syslogng
Copy link
Contributor

Build SUCCESS

Kokan
Kokan previously approved these changes Apr 30, 2021
@MrAnno MrAnno self-requested a review May 5, 2021 12:13
Copy link
Collaborator

@MrAnno MrAnno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this pull request!

One thing I noticed is that getent-openbsd.c is not built, the following lines seem to be missing from our build files:

diff --git a/lib/compat/CMakeLists.txt b/lib/compat/CMakeLists.txt
index 92330189d..2e2511c65 100644
--- a/lib/compat/CMakeLists.txt
+++ b/lib/compat/CMakeLists.txt
@@ -11,6 +11,7 @@ set(COMPAT_HEADERS
     compat/pcre.h
     compat/getent.h
     compat/getent-sun.h
+    compat/getent-openbsd.h
     compat/getent-generic.h
     compat/un.h
     PARENT_SCOPE)
@@ -27,6 +28,7 @@ set(COMPAT_SOURCES
     compat/time.c
     compat/openssl_support.c
     compat/getent-sun.c
+    compat/getent-openbsd.c
     compat/getent-generic.c
     PARENT_SCOPE)

diff --git a/lib/compat/Makefile.am b/lib/compat/Makefile.am
index d537b3914..968e154fe 100644
--- a/lib/compat/Makefile.am
+++ b/lib/compat/Makefile.am
@@ -17,6 +17,7 @@ compatinclude_HEADERS         =       \
        lib/compat/pcre.h               \
        lib/compat/getent.h             \
        lib/compat/getent-sun.h         \
+       lib/compat/getent-openbsd.h \
        lib/compat/getent-generic.h     \
        lib/compat/un.h

@@ -32,6 +33,7 @@ compat_sources                        =       \
        lib/compat/time.c               \
        lib/compat/openssl_support.c    \
        lib/compat/getent-sun.c         \
+       lib/compat/getent-openbsd.c \
        lib/compat/getent-generic.c

 include lib/compat/tests/Makefile.am

@MrAnno
Copy link
Collaborator

MrAnno commented May 6, 2021

I was able to compile this PR with the above Makefile patch on OpenBSD 6.9 (bison 3.7.6 compiled from source, gmake).

NULL was undeclared, but including stddef.h fixed it:

../lib/compat/getent-openbsd.c: In function '_compat_openbsd__getprotobynumber_r':
../lib/compat/getent-openbsd.c:38: error: 'NULL' undeclared (first use in this function)
diff --git a/lib/compat/getent-openbsd.c b/lib/compat/getent-openbsd.c
index 1b1af9eaf..ca36fb07b 100644
--- a/lib/compat/getent-openbsd.c
+++ b/lib/compat/getent-openbsd.c
@@ -25,6 +25,7 @@

 #ifdef __OpenBSD__
 #include <errno.h>
+#include <stddef.h>

 int
 _compat_openbsd__getprotobynumber_r(int proto,

…okup

OpenBSD uses struct protoent_data and struct servent_data to store
state information instead of a char buffer with an associated length.

Signed-off-by: Todd C. Miller <[email protected]>
OpenBSD intentionally does not support IPv4-mapped IPv6 addresses.

Signed-off-by: Todd C. Miller <[email protected]>
OpenBSD supports IP_RECVDSTADDR just like FreeBSD does.

Signed-off-by: Todd C. Miller <[email protected]>
On some systems sys/socket.h is implicitly included, but on OpenBSD
with LibreSSL it is not.

Signed-off-by: Todd C. Miller <[email protected]>
@millert
Copy link
Contributor Author

millert commented May 6, 2021

@MrAnno Thanks, I came up with an identical fix for the compilation error.

@kira-syslogng
Copy link
Contributor

Build SUCCESS

Copy link
Collaborator

@MrAnno MrAnno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@MrAnno MrAnno merged commit 632d623 into syslog-ng:master May 6, 2021
MrAnno added a commit to MrAnno/syslog-ng that referenced this pull request May 6, 2021
Signed-off-by: László Várady <[email protected]>
alltilla added a commit that referenced this pull request May 6, 2021
@millert millert deleted the openbsd branch May 24, 2021 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants