Renewed port to OpenBSD

This commit is contained in:
Gerhard Rieger 2023-10-02 19:43:13 +02:00
parent 5034b941bf
commit 8641344c73
8 changed files with 53 additions and 24 deletions

View file

@ -223,6 +223,9 @@ Porting:
PACKET_IGNORE_OUTGOING socket options when available. PACKET_IGNORE_OUTGOING socket options when available.
Test: INTERFACE_IGNOREOUTGOING Test: INTERFACE_IGNOREOUTGOING
Renewed port to OpenBSD:
Guard OPENSSL_INIT_SETTINGS; and minor changes.
Testing: Testing:
Removed obselete parts from test.sh Removed obselete parts from test.sh

View file

@ -468,6 +468,9 @@
/* Define if you have the OPENSSL_init_ssl function */ /* Define if you have the OPENSSL_init_ssl function */
#undef HAVE_OPENSSL_INIT_SSL #undef HAVE_OPENSSL_INIT_SSL
/* Define if you have the OPENSSL_INIT_SETTINGS type (guarded for OpenBSD) */
#undef HAVE_OPENSSL_INIT_SETTINGS
/* Define if you have the SSL_library_init function */ /* Define if you have the SSL_library_init function */
#undef HAVE_SSL_library_init #undef HAVE_SSL_library_init

View file

@ -687,7 +687,9 @@ if test -n "$WITH_OPENSSL"; then
fi fi
fi fi
# Guarded for OpenBSD
AC_CHECK_FUNCS(OPENSSL_init_ssl SSL_library_init OPENSSL_INIT_new) AC_CHECK_FUNCS(OPENSSL_init_ssl SSL_library_init OPENSSL_INIT_new)
AC_CHECK_TYPE(OPENSSL_INIT_SETTINGS, AC_DEFINE(HAVE_TYPE_OPENSSL_INIT_SETTINGS),,[#include "openssl.h"])
#; sc_cv_have_SSL_library_init='yes'; AC_DEFINE(HAVE_SSL_library_init) #; sc_cv_have_SSL_library_init='yes'; AC_DEFINE(HAVE_SSL_library_init)
#if test -n "$WITH_OPENSSL"; then #if test -n "$WITH_OPENSSL"; then

View file

@ -236,7 +236,7 @@ int sockname(int fd, FILE *outfile, char style) {
#endif #endif
int opttype; int opttype;
#ifdef SO_ACCEPTCONN #ifdef SO_ACCEPTCONN
int optacceptconn; int optacceptconn = 0; /* OpenBSD does not give value on unix dgram */
#endif #endif
int result /*0, i*/; int result /*0, i*/;
char socknamebuff[FDNAME_NAMELEN]; char socknamebuff[FDNAME_NAMELEN];
@ -293,9 +293,9 @@ int sockname(int fd, FILE *outfile, char style) {
protoentp = getprotobynumber_r(proto, &protoent, buffer, FILAN_GETPROTOBYNUMBER_R_BUFLEN); protoentp = getprotobynumber_r(proto, &protoent, buffer, FILAN_GETPROTOBYNUMBER_R_BUFLEN);
strncpy(protoname, protoentp->p_name, sizeof(protoname)); strncpy(protoname, protoentp->p_name, sizeof(protoname));
} }
#elif HAVE_GETPROTOBYNUMBER_R==3 /* AIX */ #elif HAVE_GETPROTOBYNUMBER_R==3 /* AIX, OpenBSD */
{ {
struct protoent_data proto_data; struct protoent_data proto_data = { 0 }; /* OpenBSD might SIGSEGV */
rc = getprotobynumber_r(proto, &protoent, &proto_data); rc = getprotobynumber_r(proto, &protoent, &proto_data);
if (rc == 0) { if (rc == 0) {
strncpy(protoname, protoent.p_name, sizeof(protoname)); strncpy(protoname, protoent.p_name, sizeof(protoname));

View file

@ -22,7 +22,8 @@
#include "sycls.h" #include "sycls.h"
#if HAVE_OPENSSL_INIT_SSL #if HAVE_OPENSSL_INIT_SSL
int sycOPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) { /* OpenBSD 7.2 does not know OPENSSL_INIT_SETTING */
int sycOPENSSL_init_ssl(uint64_t opts, const void *settings) {
int result; int result;
Debug2("OPENSSL_init_ssl("F_uint64_t", %p)", opts, settings); Debug2("OPENSSL_init_ssl("F_uint64_t", %p)", opts, settings);
result = OPENSSL_init_ssl(opts, settings); result = OPENSSL_init_ssl(opts, settings);

View file

@ -9,7 +9,7 @@
#if WITH_OPENSSL #if WITH_OPENSSL
#if HAVE_OPENSSL_INIT_SSL #if HAVE_OPENSSL_INIT_SSL
int sycOPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings); int sycOPENSSL_init_ssl(uint64_t opts, const void *settings);
#endif #endif
void sycSSL_load_error_strings(void); void sycSSL_load_error_strings(void);
int sycSSL_library_init(void); int sycSSL_library_init(void);

54
test.sh
View file

@ -6672,22 +6672,30 @@ echo "$da" |$CMD2 >>"$tf" 2>>"${te}2"
rc2=$? rc2=$?
kill "$pid1" 2>/dev/null; wait kill "$pid1" 2>/dev/null; wait
if [ $rc2 -ne 0 ]; then if [ $rc2 -ne 0 ]; then
$PRINTF "$FAILED: $TRACE $SOCAT:\n" $PRINTF "$FAILED (rc=$rc2)\n"
echo "$CMD1 &" echo "$CMD1 &"
cat "${te}1" cat "${te}1" >&2
echo "$CMD2" echo "$CMD2"
cat "${te}2" cat "${te}2" >&2
numFAIL=$((numFAIL+1)) numFAIL=$((numFAIL+1))
listFAIL="$listFAIL $N" listFAIL="$listFAIL $N"
elif ! echo "$da" |diff - "$tf" >"$tdiff"; then elif ! echo "$da" |diff - "$tf" >"$tdiff"; then
$PRINTF "$FAILED\n" $PRINTF "$FAILED (diff)\n"
cat "$tdiff" echo "$CMD1 &"
cat "${te}1" >&2
echo "$CMD2"
cat "${te}2" >&2
echo "// diff:" >&2
cat "$tdiff" >&2
numFAIL=$((numFAIL+1)) numFAIL=$((numFAIL+1))
listFAIL="$listFAIL $N" listFAIL="$listFAIL $N"
else else
$PRINTF "$OK\n" $PRINTF "$OK\n"
if [ -n "$debug" ]; then cat $te; fi if [ "$VERBOSE" ]; then echo "$CMD1 &"; fi
numOK=$((numOK+1)) if [ "$DEBUG" ]; then cat "${te}1" >&2; fi
if [ "$VERBOSE" ]; then echo "$CMD2"; fi
if [ "$DEBUG" ]; then cat "${te}2" >&2; fi
numOK=$((numOK+1))
fi fi
fi # NUMCOND fi # NUMCOND
;; ;;
@ -10525,7 +10533,7 @@ case "$TESTS" in
*%$N%*|*%functions%*|*%ip4%*|*%tcp%*|*%generic%*|*%listen%*|*%fork%*|*%$NAME%*) *%$N%*|*%functions%*|*%ip4%*|*%tcp%*|*%generic%*|*%listen%*|*%fork%*|*%$NAME%*)
TEST="$NAME: test the setsockopt option" TEST="$NAME: test the setsockopt option"
# Set the TCP_MAXSEG (MSS) option with a reasonable value, this should succeed. # Set the TCP_MAXSEG (MSS) option with a reasonable value, this should succeed.
# The try again with TCP_MAXSEG=1, this fails at least on Linux. # Then try again with TCP_MAXSEG=1, this fails at least on Linux.
# Thus: # Thus:
# process 0 provides a tcp listening,forking socket # process 0 provides a tcp listening,forking socket
# process 1 connects to this port using reasonably MSS, data transfer should # process 1 connects to this port using reasonably MSS, data transfer should
@ -11608,7 +11616,7 @@ NAME=LISTEN_KEEPALIVE
case "$TESTS" in case "$TESTS" in
*%$N%*|*%functions%*|*%bugs%*|*%listen%*|*%keepalive%*|*%socket%*|*%listen%*|*%fork%*|*%$NAME%*) *%$N%*|*%functions%*|*%bugs%*|*%listen%*|*%keepalive%*|*%socket%*|*%listen%*|*%fork%*|*%$NAME%*)
TEST="$NAME: keepalive option is applied to connection socket" TEST="$NAME: keepalive option is applied to connection socket"
# instance 0 has TCP-LISTEN with option so-keepalive and invokes filan after # Instance 0 has TCP-LISTEN with option so-keepalive and invokes filan after
# accept(). filan writes its output to the socket. instance 1 connects to # accept(). filan writes its output to the socket. instance 1 connects to
# instance 0. The value of the sockets so-keepalive option is checked, it must # instance 0. The value of the sockets so-keepalive option is checked, it must
# be 1 # be 1
@ -11631,22 +11639,28 @@ kill $pid0 2>/dev/null; wait
if [ -z "$KEEPALIVE" ]; then if [ -z "$KEEPALIVE" ]; then
$PRINTF "$NO_RESULT\n" $PRINTF "$NO_RESULT\n"
echo "$CMD0 &" echo "$CMD0 &"
cat "${te}0" >&2
echo "$CMD1" echo "$CMD1"
cat "${te}0" cat "${te}1" >&2
cat "${te}1"
numCANT=$((numCANT+1)) numCANT=$((numCANT+1))
listCANT="$listCANT $N" listCANT="$listCANT $N"
namesCANT="$namesCANT $NAME"
elif [ "$KEEPALIVE" = "1" ]; then elif [ "$KEEPALIVE" = "1" ]; then
$PRINTF "$OK\n"; $PRINTF "$OK\n";
if [ "$VERBOSE" ]; then echo "$CMD0 &"; fi
if [ "$DEBUG" ]; then cat "${te}0" >&2; fi
if [ "$VERBOSE" ]; then echo "$CMD1"; fi
if [ "$DEBUG" ]; then cat "${te}1" >&2; fi
numOK=$((numOK+1)) numOK=$((numOK+1))
else else
$PRINTF "$FAILED\n" $PRINTF "$FAILED (KEEPALIVE=$KEEPALIVE)\n"
echo "$CMD0 &" echo "$CMD0 &"
cat "${te}0" >&2
echo "$CMD1" echo "$CMD1"
cat "${te}0" cat "${te}1" >&2
cat "${te}1"
numFAIL=$((numFAIL+1)) numFAIL=$((numFAIL+1))
listFAIL="$listFAIL $N" listFAIL="$listFAIL $N"
namesFAIL="$namesFAIL $NAME"
fi fi
fi # NUMCOND fi # NUMCOND
;; ;;
@ -17871,7 +17885,7 @@ echo "$da" |$CMD1 >"${tf}1" 2>"${te}1"
rc1=$? rc1=$?
kill $pid0 2>/dev/null; wait kill $pid0 2>/dev/null; wait
if [ "$rc1" -ne 0 ]; then if [ "$rc1" -ne 0 ]; then
$PRINTF "$FAILED\n" $PRINTF "$FAILED (rc=$rc1)\n"
echo "$CMD0 &" echo "$CMD0 &"
cat "${te}0" >&2 cat "${te}0" >&2
echo "$CMD1" echo "$CMD1"
@ -17880,11 +17894,13 @@ if [ "$rc1" -ne 0 ]; then
listFAIL="$listFAIL $N" listFAIL="$listFAIL $N"
namesFAIL="$namesFAIL $NAME" namesFAIL="$namesFAIL $NAME"
elif ! echo "$da" |diff "${tf}1" - >$tdiff; then elif ! echo "$da" |diff "${tf}1" - >$tdiff; then
$PRINTF "$FAILED\n" $PRINTF "$FAILED (diff)\n"
echo "$CMD0 &" echo "$CMD0 &"
cat "${te}0" >&2 cat "${te}0" >&2
echo "$CMD1" echo "$CMD1"
cat "${te}1" >&2 cat "${te}1" >&2
echo "// diff:" >&2
cat "$tdiff" >&2
numFAIL=$((numFAIL+1)) numFAIL=$((numFAIL+1))
listFAIL="$listFAIL $N" listFAIL="$listFAIL $N"
namesFAIL="$namesFAIL $NAME" namesFAIL="$namesFAIL $NAME"

View file

@ -1025,7 +1025,11 @@ int
#if defined(HAVE_OPENSSL_INIT_SSL) && defined(HAVE_OPENSSL_INIT_new) #if defined(HAVE_OPENSSL_INIT_SSL) && defined(HAVE_OPENSSL_INIT_new)
{ {
uint64_t opts = 0; uint64_t opts = 0;
#if defined(OPENSSL_INIT_SETTINGS)
OPENSSL_INIT_SETTINGS *settings; OPENSSL_INIT_SETTINGS *settings;
#else
void *settings;
#endif
settings = OPENSSL_INIT_new(); settings = OPENSSL_INIT_new();
#ifdef OPENSSL_INIT_NO_ATEXIT #ifdef OPENSSL_INIT_NO_ATEXIT
opts |= OPENSSL_INIT_NO_ATEXIT; opts |= OPENSSL_INIT_NO_ATEXIT;