New upstream version 1.6.0
Michael Biebl
4 years ago
0 | ---------------------------------------------------------------------- | |
1 | Version 1.6.0 - 2020-04-21 | |
2 | - fix namespace pollution - some non-API functions were exported | |
3 | While fixing this, also some internal inconsistencies in function | |
4 | visibility were fixed as well. | |
5 | closes https://github.com/rsyslog/librelp/issues/179 | |
6 | - replsess: fix double free of sendbuf in some cases. | |
7 | In iRet handler of relpSessSendResponse, the sendbuf | |
8 | was freed if iRet returned a failure. | |
9 | However if error RELP_RET_IO_ERR happened in relpSendqAddBuf, | |
10 | sendbuf was already assigned to relpSendqe_t. As a result | |
11 | sendbuf was double freed in relpSendqDestruct. | |
12 | see also | |
13 | https://github.com/rsyslog/rsyslog/issues/4184 | |
14 | https://github.com/rsyslog/rsyslog/issues/4005 | |
15 | closes https://github.com/rsyslog/librelp/issues/183 | |
16 | - improve support for libressl | |
17 | LibreSSL has no support for @SECLEVEL and SSL_CONF_CTX_set_flags(). | |
18 | LibreSSL is now detected and some functionality disabled if it is | |
19 | used. | |
20 | Thanks to Remi Locherer for the patch. | |
21 | - Modified GnuTLS priority according to standard crypto-policy guideline | |
22 | Edited TLS priority string default to conform to system-wide default | |
23 | and align librelp behavior with other crypto-utilizing packages. | |
24 | Note: this may be different from what the openSSL driver does. | |
25 | Thanks to Jiri Vymazal for the patch. | |
26 | - tcp: Missing pUsr Copy to relpTcp Pointer fixed in relpTcpAcceptConnReq | |
27 | The userpointer was not copied into the relpTcp object. | |
28 | Also fixed core dump crash in receive / send helpers when userpointer | |
29 | is returned NULL from librelp. | |
30 | - report io errors for plain tcp connections | |
31 | this already happens with TLS, but not with plain tcp. Error messages | |
32 | are a useful troubleshooting tool. | |
0 | 33 | ---------------------------------------------------------------------- |
1 | 34 | Version 1.5.0 - 2020-01-14 |
2 | 35 | - bugfix: too late termination of relp Engine on shutdown |
0 | 0 | #! /bin/sh |
1 | 1 | # Guess values for system-dependent variables and create Makefiles. |
2 | # Generated by GNU Autoconf 2.69 for librelp 1.5.0. | |
2 | # Generated by GNU Autoconf 2.69 for librelp 1.6.0. | |
3 | 3 | # |
4 | 4 | # Report bugs to <rgerhards@adiscon.com>. |
5 | 5 | # |
589 | 589 | # Identity of this package. |
590 | 590 | PACKAGE_NAME='librelp' |
591 | 591 | PACKAGE_TARNAME='librelp' |
592 | PACKAGE_VERSION='1.5.0' | |
593 | PACKAGE_STRING='librelp 1.5.0' | |
592 | PACKAGE_VERSION='1.6.0' | |
593 | PACKAGE_STRING='librelp 1.6.0' | |
594 | 594 | PACKAGE_BUGREPORT='rgerhards@adiscon.com' |
595 | 595 | PACKAGE_URL='' |
596 | 596 | |
1367 | 1367 | # Omit some internal or obsolete options to make the list less imposing. |
1368 | 1368 | # This message is too long to be a string in the A/UX 3.1 sh. |
1369 | 1369 | cat <<_ACEOF |
1370 | \`configure' configures librelp 1.5.0 to adapt to many kinds of systems. | |
1370 | \`configure' configures librelp 1.6.0 to adapt to many kinds of systems. | |
1371 | 1371 | |
1372 | 1372 | Usage: $0 [OPTION]... [VAR=VALUE]... |
1373 | 1373 | |
1438 | 1438 | |
1439 | 1439 | if test -n "$ac_init_help"; then |
1440 | 1440 | case $ac_init_help in |
1441 | short | recursive ) echo "Configuration of librelp 1.5.0:";; | |
1441 | short | recursive ) echo "Configuration of librelp 1.6.0:";; | |
1442 | 1442 | esac |
1443 | 1443 | cat <<\_ACEOF |
1444 | 1444 | |
1567 | 1567 | test -n "$ac_init_help" && exit $ac_status |
1568 | 1568 | if $ac_init_version; then |
1569 | 1569 | cat <<\_ACEOF |
1570 | librelp configure 1.5.0 | |
1570 | librelp configure 1.6.0 | |
1571 | 1571 | generated by GNU Autoconf 2.69 |
1572 | 1572 | |
1573 | 1573 | Copyright (C) 2012 Free Software Foundation, Inc. |
2093 | 2093 | This file contains any messages produced by compilers while |
2094 | 2094 | running configure, to aid debugging if configure makes a mistake. |
2095 | 2095 | |
2096 | It was created by librelp $as_me 1.5.0, which was | |
2096 | It was created by librelp $as_me 1.6.0, which was | |
2097 | 2097 | generated by GNU Autoconf 2.69. Invocation command line was |
2098 | 2098 | |
2099 | 2099 | $ $0 $@ |
2959 | 2959 | |
2960 | 2960 | # Define the identity of the package. |
2961 | 2961 | PACKAGE='librelp' |
2962 | VERSION='1.5.0' | |
2962 | VERSION='1.6.0' | |
2963 | 2963 | |
2964 | 2964 | |
2965 | 2965 | cat >>confdefs.h <<_ACEOF |
15320 | 15320 | # report actual input values of CONFIG_FILES etc. instead of their |
15321 | 15321 | # values after options handling. |
15322 | 15322 | ac_log=" |
15323 | This file was extended by librelp $as_me 1.5.0, which was | |
15323 | This file was extended by librelp $as_me 1.6.0, which was | |
15324 | 15324 | generated by GNU Autoconf 2.69. Invocation command line was |
15325 | 15325 | |
15326 | 15326 | CONFIG_FILES = $CONFIG_FILES |
15386 | 15386 | cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 |
15387 | 15387 | ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" |
15388 | 15388 | ac_cs_version="\\ |
15389 | librelp config.status 1.5.0 | |
15389 | librelp config.status 1.6.0 | |
15390 | 15390 | configured by $0, generated by GNU Autoconf 2.69, |
15391 | 15391 | with options \\"\$ac_cs_config\\" |
15392 | 15392 |
1 | 1 | # Process this file with autoconf to produce a configure script. |
2 | 2 | |
3 | 3 | AC_PREREQ(2.61) |
4 | AC_INIT([librelp], [1.5.0], [rgerhards@adiscon.com]) | |
4 | AC_INIT([librelp], [1.6.0], [rgerhards@adiscon.com]) | |
5 | 5 | |
6 | 6 | # change to the one below if Travis has a timeout |
7 | 7 | #AM_INIT_AUTOMAKE([subdir-objects serial-tests]) |
47 | 47 | librelp_la_LIBADD = $(rt_libs) $(GNUTLS_LIBS) $(OPENSSL_LIBS) |
48 | 48 | # info on version-info: |
49 | 49 | # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html |
50 | librelp_la_LDFLAGS = -version-info 5:0:5 -export-symbols-regex '^relp' | |
50 | librelp_la_LDFLAGS = -version-info 5:0:5 -export-symbols-regex '^relp[^_]*$$' | |
51 | 51 | |
52 | 52 | include_HEADERS = librelp.h |
377 | 377 | librelp_la_LIBADD = $(rt_libs) $(GNUTLS_LIBS) $(OPENSSL_LIBS) |
378 | 378 | # info on version-info: |
379 | 379 | # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html |
380 | librelp_la_LDFLAGS = -version-info 5:0:5 -export-symbols-regex '^relp' | |
380 | librelp_la_LDFLAGS = -version-info 5:0:5 -export-symbols-regex '^relp[^_]*$$' | |
381 | 381 | include_HEADERS = librelp.h |
382 | 382 | all: all-am |
383 | 383 |
328 | 328 | callOnErr(pThis, "io error, session broken", RELP_RET_SESSION_BROKEN); |
329 | 329 | pThis->pEngine->dbgprint("relp session %p is broken, io error\n", (void*)pThis); |
330 | 330 | pThis->sessState = eRelpSessState_BROKEN; |
331 | } | |
332 | ||
333 | if(pSendbuf != NULL) | |
334 | relpSendbufDestruct(&pSendbuf); | |
331 | } else { | |
332 | /* alorbach, 2020-04-08: | |
333 | * Only free sendbuf if error is not RELP_RET_IO_ERR! | |
334 | * otherwise the buffer is double freed in relpSendbufDestruct() (sendbuf.c) | |
335 | */ | |
336 | if(pSendbuf != NULL) | |
337 | relpSendbufDestruct(&pSendbuf); | |
338 | } | |
339 | ||
335 | 340 | } |
336 | 341 | |
337 | 342 | LEAVE_RELPFUNC; |
651 | 651 | |
652 | 652 | |
653 | 653 | #if defined(ENABLE_TLS) |
654 | relpRetVal LIBRELP_ATTR_NONNULL() | |
654 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
655 | 655 | relpTcpDestructTLS_gtls(relpTcp_t *pThis) |
656 | 656 | { |
657 | 657 | int sslRet; |
666 | 666 | LEAVE_RELPFUNC; |
667 | 667 | } |
668 | 668 | #else |
669 | relpRetVal LIBRELP_ATTR_NONNULL() | |
669 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
670 | 670 | relpTcpDestructTLS_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *pThis) |
671 | 671 | { |
672 | 672 | return RELP_RET_ERR_INTERNAL; |
673 | 673 | } |
674 | 674 | #endif /* defined(ENABLE_TLS) */ |
675 | 675 | #if defined(ENABLE_TLS_OPENSSL) |
676 | relpRetVal LIBRELP_ATTR_NONNULL() | |
676 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
677 | 677 | relpTcpDestructTLS_ossl(relpTcp_t *pThis) |
678 | 678 | { |
679 | 679 | ENTER_RELPFUNC; |
709 | 709 | LEAVE_RELPFUNC; |
710 | 710 | } |
711 | 711 | #else |
712 | relpRetVal LIBRELP_ATTR_NONNULL() | |
712 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
713 | 713 | relpTcpDestructTLS_ossl(LIBRELP_ATTR_UNUSED relpTcp_t *pThis) |
714 | 714 | { |
715 | 715 | return RELP_RET_ERR_INTERNAL; |
1152 | 1152 | char pristringBuf[4096]; |
1153 | 1153 | char *pristring; |
1154 | 1154 | ENTER_RELPFUNC; |
1155 | /* Compute priority string (in simple cases where the user does not care...) */ | |
1155 | /* Set default priority string (in simple cases where the user does not care...) */ | |
1156 | 1156 | if(pThis->pristring == NULL) { |
1157 | if(pThis->bEnableTLSZip) { | |
1158 | strncpy(pristringBuf, "NORMAL:+ANON-DH:+COMP-ALL", sizeof(pristringBuf)); | |
1157 | if (pThis->authmode == eRelpAuthMode_None) { | |
1158 | if(pThis->bEnableTLSZip) { | |
1159 | strncpy(pristringBuf, "NORMAL:+ANON-DH:+COMP-ALL", sizeof(pristringBuf)); | |
1160 | } else { | |
1161 | strncpy(pristringBuf, "NORMAL:+ANON-DH:+COMP-NULL", sizeof(pristringBuf)); | |
1162 | } | |
1163 | pristringBuf[sizeof(pristringBuf)-1] = '\0'; | |
1164 | pristring = pristringBuf; | |
1165 | r = gnutls_priority_set_direct(pThis->session, pristring, NULL); | |
1159 | 1166 | } else { |
1160 | strncpy(pristringBuf, "NORMAL:+ANON-DH:+COMP-NULL", sizeof(pristringBuf)); | |
1161 | } | |
1162 | pristringBuf[sizeof(pristringBuf)-1] = '\0'; | |
1163 | pristring = pristringBuf; | |
1167 | r = gnutls_set_default_priority(pThis->session); | |
1168 | strncpy(pristringBuf, "to recommended system default", sizeof(pristringBuf)); | |
1169 | pristringBuf[sizeof(pristringBuf)-1] = '\0'; | |
1170 | pristring = pristringBuf; | |
1171 | } | |
1172 | ||
1164 | 1173 | } else { |
1165 | 1174 | pristring = pThis->pristring; |
1166 | } | |
1167 | ||
1168 | r = gnutls_priority_set_direct(pThis->session, pristring, NULL); | |
1175 | r = gnutls_priority_set_direct(pThis->session, pristring, NULL); | |
1176 | } | |
1177 | ||
1169 | 1178 | if(r == GNUTLS_E_INVALID_REQUEST) { |
1170 | 1179 | ABORT_FINALIZE(RELP_RET_INVLD_TLS_PRIO); |
1171 | 1180 | } else if(r != GNUTLS_E_SUCCESS) { |
1181 | 1190 | LEAVE_RELPFUNC; |
1182 | 1191 | } |
1183 | 1192 | #else /* #ifdef ENABLE_TLS */ |
1184 | relpRetVal LIBRELP_ATTR_NONNULL() | |
1193 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
1185 | 1194 | relpTcpTLSSetPrio_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) |
1186 | 1195 | { |
1187 | 1196 | return RELP_RET_ERR_INTERNAL; |
1199 | 1208 | /* Compute priority string (in simple cases where the user does not care...) */ |
1200 | 1209 | if(pThis->pristring == NULL) { |
1201 | 1210 | if (pThis->authmode == eRelpAuthMode_None) { |
1202 | #if OPENSSL_VERSION_NUMBER >= 0x10100000L | |
1211 | #if OPENSSL_VERSION_NUMBER >= 0x10100000L \ | |
1212 | && !defined(LIBRESSL_VERSION_NUMBER) | |
1203 | 1213 | /* NOTE: do never use: +eNULL, it DISABLES encryption! */ |
1204 | 1214 | strncpy(pristringBuf, "ALL:+COMPLEMENTOFDEFAULT:+ADH:+ECDH:+aNULL@SECLEVEL=0", |
1205 | 1215 | sizeof(pristringBuf)); |
1295 | 1305 | #endif |
1296 | 1306 | |
1297 | 1307 | #else /* #ifdef ENABLE_TLS */ |
1298 | relpRetVal LIBRELP_ATTR_NONNULL() | |
1308 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
1299 | 1309 | relpTcpAcceptConnReqInitTLS_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis, LIBRELP_ATTR_UNUSED relpSrv_t *const pSrv) |
1300 | 1310 | { |
1301 | 1311 | return RELP_RET_ERR_INTERNAL; |
1501 | 1511 | |
1502 | 1512 | /* Perform all necessary actions for Handshake |
1503 | 1513 | */ |
1504 | relpRetVal | |
1514 | static relpRetVal | |
1505 | 1515 | relpTcpRtryHandshake_ossl(relpTcp_t *const pThis) |
1506 | 1516 | { |
1507 | 1517 | int res, resErr; |
1577 | 1587 | } else { |
1578 | 1588 | pThis->pEngine->dbgprint("relpTcpSetSslConfCmd_ossl: set to '%s'\n", tlsConfigCmd); |
1579 | 1589 | char errmsg[1424]; |
1580 | #if OPENSSL_VERSION_NUMBER >= 0x10020000L | |
1590 | #if OPENSSL_VERSION_NUMBER >= 0x10020000L && !defined(LIBRESSL_VERSION_NUMBER) | |
1581 | 1591 | char *pCurrentPos; |
1582 | 1592 | char *pNextPos; |
1583 | 1593 | char *pszCmd; |
1858 | 1868 | return RELP_RET_ERR_INTERNAL; |
1859 | 1869 | } |
1860 | 1870 | |
1861 | relpRetVal LIBRELP_ATTR_NONNULL() | |
1871 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
1862 | 1872 | relpTcpGetRtryDirection_ossl(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) |
1863 | 1873 | { |
1864 | 1874 | return RELP_RET_ERR_INTERNAL; |
1865 | 1875 | } |
1866 | 1876 | |
1867 | relpRetVal LIBRELP_ATTR_NONNULL() | |
1877 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
1868 | 1878 | relpTcpRtryHandshake_ossl(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) |
1869 | 1879 | { |
1870 | 1880 | return RELP_RET_ERR_INTERNAL; |
1871 | 1881 | } |
1872 | 1882 | |
1873 | relpRetVal LIBRELP_ATTR_NONNULL() | |
1883 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
1874 | 1884 | relpTcpLstnInitTLS_ossl(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) |
1875 | 1885 | { |
1876 | 1886 | return RELP_RET_ERR_INTERNAL; |
1877 | 1887 | } |
1878 | 1888 | |
1879 | relpRetVal LIBRELP_ATTR_NONNULL() | |
1889 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
1880 | 1890 | relpTcpAcceptConnReqInitTLS_ossl(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis, LIBRELP_ATTR_UNUSED relpSrv_t *const pSrv) |
1881 | 1891 | { |
1882 | 1892 | return RELP_RET_ERR_INTERNAL; |
1883 | 1893 | } |
1884 | 1894 | |
1885 | relpRetVal LIBRELP_ATTR_NONNULL() | |
1895 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
1886 | 1896 | relpTcpConnectTLSInit_ossl(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) |
1887 | 1897 | { |
1888 | 1898 | return RELP_RET_ERR_INTERNAL; |
2004 | 2014 | |
2005 | 2015 | /* construct our object so that we can use it... */ |
2006 | 2016 | CHKRet(relpTcpConstruct(&pThis, pEngine, RELP_SRV_CONN, pSrv)); |
2017 | pThis->pUsr = pSrv->pUsr; | |
2007 | 2018 | |
2008 | 2019 | if(pSrv->bKeepAlive) |
2009 | 2020 | EnableKeepAlive(pThis, pSrv, iNewSock); |
2648 | 2659 | LEAVE_RELPFUNC; |
2649 | 2660 | } |
2650 | 2661 | #else /* #ifdef ENABLE_TLS */ |
2651 | relpRetVal LIBRELP_ATTR_NONNULL() | |
2662 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
2652 | 2663 | relpTcpLstnInitTLS_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) |
2653 | 2664 | { |
2654 | 2665 | return RELP_RET_ERR_INTERNAL; |
2939 | 2950 | |
2940 | 2951 | /* -- first TLS-lib specific versions -- */ |
2941 | 2952 | #if defined(ENABLE_TLS) |
2942 | relpRetVal LIBRELP_ATTR_NONNULL() | |
2953 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
2943 | 2954 | relpTcpRcv_gtls(relpTcp_t *const pThis, relpOctet_t *const pRcvBuf, ssize_t *const pLenBuf) |
2944 | 2955 | { |
2945 | 2956 | ENTER_RELPFUNC; |
2963 | 2974 | LEAVE_RELPFUNC; |
2964 | 2975 | } |
2965 | 2976 | #else |
2966 | relpRetVal LIBRELP_ATTR_NONNULL() | |
2977 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
2967 | 2978 | relpTcpRcv_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis, LIBRELP_ATTR_UNUSED relpOctet_t *const pRcvBuf, |
2968 | 2979 | LIBRELP_ATTR_UNUSED ssize_t *const pLenBuf) |
2969 | 2980 | { |
2971 | 2982 | } |
2972 | 2983 | #endif /* defined(ENABLE_TLS) */ |
2973 | 2984 | #if defined(ENABLE_TLS_OPENSSL) |
2974 | relpRetVal LIBRELP_ATTR_NONNULL() | |
2985 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
2975 | 2986 | relpTcpRcv_ossl(relpTcp_t *const pThis, relpOctet_t *const pRcvBuf, ssize_t *const pLenBuf) |
2976 | 2987 | { |
2977 | 2988 | ENTER_RELPFUNC; |
3007 | 3018 | LEAVE_RELPFUNC; |
3008 | 3019 | } |
3009 | 3020 | #else |
3010 | relpRetVal LIBRELP_ATTR_NONNULL() | |
3021 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
3011 | 3022 | relpTcpRcv_ossl(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis, LIBRELP_ATTR_UNUSED relpOctet_t *const pRcvBuf, |
3012 | 3023 | LIBRELP_ATTR_UNUSED ssize_t *const pLenBuf) |
3013 | 3024 | { |
3093 | 3104 | |
3094 | 3105 | /* -- first TLS-lib specific versions -- */ |
3095 | 3106 | #if defined(ENABLE_TLS) |
3096 | relpRetVal LIBRELP_ATTR_NONNULL() | |
3107 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
3097 | 3108 | relpTcpSend_gtls(relpTcp_t *const pThis, relpOctet_t *const pBuf, ssize_t *const pLenBuf) |
3098 | 3109 | { |
3099 | 3110 | ssize_t written; |
3118 | 3129 | LEAVE_RELPFUNC; |
3119 | 3130 | } |
3120 | 3131 | #else |
3121 | relpRetVal LIBRELP_ATTR_NONNULL() | |
3132 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
3122 | 3133 | relpTcpSend_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis, LIBRELP_ATTR_UNUSED relpOctet_t *const pBuf, |
3123 | 3134 | LIBRELP_ATTR_UNUSED ssize_t *const pLenBuf) |
3124 | 3135 | { |
3126 | 3137 | } |
3127 | 3138 | #endif /* defined(ENABLE_TLS) */ |
3128 | 3139 | #if defined(ENABLE_TLS_OPENSSL) |
3129 | relpRetVal LIBRELP_ATTR_NONNULL() | |
3140 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
3130 | 3141 | relpTcpSend_ossl(relpTcp_t *const pThis, relpOctet_t *const pBuf, ssize_t *const pLenBuf) |
3131 | 3142 | { |
3132 | 3143 | ssize_t written; |
3166 | 3177 | LEAVE_RELPFUNC; |
3167 | 3178 | } |
3168 | 3179 | #else |
3169 | relpRetVal LIBRELP_ATTR_NONNULL() | |
3180 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
3170 | 3181 | relpTcpSend_ossl(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis, LIBRELP_ATTR_UNUSED relpOctet_t *const pBuf, |
3171 | 3182 | LIBRELP_ATTR_UNUSED ssize_t *const pLenBuf) |
3172 | 3183 | { |
3206 | 3217 | /* this is fine, just retry... */ |
3207 | 3218 | written = 0; |
3208 | 3219 | break; |
3209 | default: | |
3220 | default: { | |
3221 | char msgbuf[900]; | |
3222 | char errStr[800]; | |
3223 | _relpEngine_strerror_r(errno, errStr, sizeof(errStr)); | |
3224 | snprintf(msgbuf, sizeof(msgbuf), "error sending relp: %s", errStr); | |
3225 | msgbuf[sizeof(msgbuf)-1] = '\0'; | |
3226 | callOnErr(pThis, msgbuf, RELP_RET_IO_ERR); | |
3210 | 3227 | ABORT_FINALIZE(RELP_RET_IO_ERR); |
3228 | } | |
3211 | 3229 | break; |
3212 | 3230 | } |
3213 | 3231 | } |
3347 | 3365 | #endif |
3348 | 3366 | |
3349 | 3367 | #else /* #ifdef ENABLE_TLS */ |
3350 | relpRetVal LIBRELP_ATTR_NONNULL() | |
3368 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
3351 | 3369 | relpTcpConnectTLSInit_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) |
3352 | 3370 | { |
3353 | 3371 | return RELP_RET_ERR_INTERNAL; |
3563 | 3581 | #endif /* #ifdef ENABLE_TLS */ |
3564 | 3582 | |
3565 | 3583 | #ifdef ENABLE_TLS |
3566 | relpRetVal LIBRELP_ATTR_NONNULL() | |
3584 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
3567 | 3585 | relpTcpRtryHandshake_gtls(relpTcp_t *const pThis) |
3568 | 3586 | { |
3569 | 3587 | int r; |
3585 | 3603 | LEAVE_RELPFUNC; |
3586 | 3604 | } |
3587 | 3605 | #else /* #ifdef ENABLE_TLS */ |
3588 | relpRetVal LIBRELP_ATTR_NONNULL() | |
3606 | static relpRetVal LIBRELP_ATTR_NONNULL() | |
3589 | 3607 | relpTcpRtryHandshake_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) |
3590 | 3608 | { |
3591 | 3609 | return RELP_RET_ERR_INTERNAL; |
157 | 157 | onErr(void *pUsr, char *objinfo, char* errmesg, LIBRELP_ATTR_UNUSED relpRetVal errcode) |
158 | 158 | { |
159 | 159 | struct usrdata *pThis = (struct usrdata*) pUsr; |
160 | if(pUsr != userdata) { | |
161 | fprintf(stderr, "receive: pUsr NOT pointing to usrdata!\n"); | |
162 | } | |
163 | if(pThis->magic != USR_MAGIC) { | |
164 | fprintf(stderr, "receive: pUsr magic incorrect in onErr, magic %8.8x " | |
165 | "pUsr %p\n", pThis->magic, (void*) pThis); | |
166 | } | |
167 | fprintf(stderr, "%s: error '%s', object '%s'\n", pThis->progname, errmesg, objinfo); | |
160 | if(pUsr != NULL) { | |
161 | if(pUsr != userdata) { | |
162 | fprintf(stderr, "receive: pUsr %p NOT pointing to userdata %p!\n", pUsr, (void*)userdata); | |
163 | } | |
164 | if(pThis->magic != USR_MAGIC) { | |
165 | fprintf(stderr, "receive: pUsr magic incorrect in onErr, magic %8.8x " | |
166 | "pUsr %p\n", pThis->magic, (void*) pThis); | |
167 | } | |
168 | fprintf(stderr, "%s: error '%s', object '%s'\n", pThis->progname, errmesg, objinfo); | |
169 | } else { | |
170 | fprintf(stderr, "receive: [pUsr==NULL] error '%s', object '%s'\n", errmesg, objinfo); | |
171 | } | |
168 | 172 | if(errFile != NULL) { |
169 | 173 | fprintf(errFile, "receive: error '%s', object '%s'\n", errmesg, objinfo); |
170 | 174 | } |
405 | 409 | TRY(relpEngineSetDnsLookupMode(pRelpEngine, 0)); /* 0=disable */ |
406 | 410 | |
407 | 411 | TRY(relpEngineListnerConstruct(pRelpEngine, &pRelpSrv)); |
408 | TRY(relpSrvSetLstnPort(pRelpSrv, port)); | |
412 | // Create userdata pointer as soon as possible for error callbacks | |
409 | 413 | userdata = calloc(1, sizeof(struct usrdata)); |
410 | 414 | userdata->magic = USR_MAGIC; |
411 | 415 | userdata->progname = strdup("receive"); |
412 | 416 | relpSrvSetUsrPtr(pRelpSrv, userdata); |
417 | ||
418 | TRY(relpSrvSetLstnPort(pRelpSrv, port)); | |
413 | 419 | if(maxDataSize != 0) { |
414 | 420 | TRY(relpSrvSetMaxDataSize(pRelpSrv, maxDataSize)); |
415 | 421 | } |
91 | 91 | onErr(void *pUsr, char *objinfo, char* errmesg, LIBRELP_ATTR_UNUSED relpRetVal errcode) |
92 | 92 | { |
93 | 93 | struct usrdata *pThis = (struct usrdata*) pUsr; |
94 | if(pUsr != userdata) { | |
95 | fprintf(stderr, "send: pUsr NOT pointing to usrdata!\n"); | |
96 | } | |
97 | if(pThis->magic != USR_MAGIC) { | |
98 | fprintf(stderr, "send: pUsr magic incorrect in onErr, magic %8.8x " | |
99 | "pUsr %p\n", pThis->magic, (void*) pThis); | |
100 | } | |
101 | printf("%s: error '%s', object '%s'\n", pThis->progname, errmesg, objinfo); | |
94 | if(pUsr != NULL) { | |
95 | if(pUsr != userdata) { | |
96 | fprintf(stderr, "send: pUsr %p NOT pointing to userdata %p!\n", pUsr, (void*)userdata); | |
97 | } | |
98 | if(pThis->magic != USR_MAGIC) { | |
99 | fprintf(stderr, "send: pUsr magic incorrect in onErr, magic %8.8x " | |
100 | "pUsr %p\n", pThis->magic, (void*) pThis); | |
101 | } | |
102 | printf("%s: error '%s', object '%s'\n", pThis->progname, errmesg, objinfo); | |
103 | } else { | |
104 | fprintf(stderr, "send: [pUsr==NULL] error '%s', object '%s'\n", errmesg, objinfo); | |
105 | } | |
106 | ||
102 | 107 | if(errFile != NULL) { |
103 | 108 | fprintf(errFile, "send: error '%s', object '%s'\n", errmesg, objinfo); |
104 | 109 | } |
409 | 414 | |
410 | 415 | TRY(relpEngineSetEnableCmd(pRelpEngine, (unsigned char*)"syslog", eRelpCmdState_Required)); |
411 | 416 | TRY(relpEngineCltConstruct(pRelpEngine, &pRelpClt)); |
412 | TRY(relpCltSetTimeout(pRelpClt, timeout)); | |
417 | // Create userdata pointer as soon as possible for error callbacks | |
413 | 418 | userdata = calloc(1, sizeof(struct usrdata)); |
414 | 419 | userdata->magic = USR_MAGIC; |
415 | 420 | userdata->progname = strdup("send"); |
416 | 421 | TRY(relpCltSetUsrPtr(pRelpClt, userdata)); |
417 | 422 | |
423 | TRY(relpCltSetTimeout(pRelpClt, timeout)); | |
418 | 424 | if(bEnableTLS) { |
419 | 425 | TRY(relpCltEnableTLS(pRelpClt)); |
420 | 426 | TRY(relpCltSetTlsConfigCmd(pRelpClt, tlsConfigCmd)); |