diff --git a/configure b/configure index 0c3a2316..0e9c0af5 100755 --- a/configure +++ b/configure @@ -27225,7 +27225,8 @@ $as_echo "#define USE_LIBSSL 1" >>confdefs.h $as_echo "#define HAVE_SSL_TS 1" >>confdefs.h fi - if test -z "$CROSS_ENVIRONMENT" -a x_$PKG_CONFIG != x_no; then + ssl_version=$($ssldir/bin/openssl version 2>/dev/null) + if test -z "${ssl_version}"-a -z "$CROSS_ENVIRONMENT" -a x_$PKG_CONFIG != x_no; then ssl_version=$(pkg-config --modversion openssl 2>/dev/null) fi if test -z "$OPENSSL_LINK"; then @@ -27468,7 +27469,7 @@ $as_echo "yes" >&6; } $as_echo "#define USE_LIBCURL 1" >>confdefs.h libcurl_version=$($curldir/bin/curl-config --version 2>/dev/null | sed -e "s/libcurl //g") - if test -z "${libcurl_version}" -a x_$PKG_CONFIG != x_no; then + if test -z "${libcurl_version}" -a -z "$CROSS_ENVIRONMENT" -a x_$PKG_CONFIG != x_no; then libcurl_version=$(pkg-config --modversion libcurl 2>/dev/null) fi if test -z "${libcurl_version}"; then diff --git a/include/ulib/examples/wi_auth_declaration.h b/include/ulib/examples/wi_auth_declaration.h index 009d1932..77ab303b 100644 --- a/include/ulib/examples/wi_auth_declaration.h +++ b/include/ulib/examples/wi_auth_declaration.h @@ -94,6 +94,7 @@ static UCache* policy_cache; static UPing* sockp; static UFile* file_LOG; +static UFile* file_INFO; static UFile* file_WARNING; static UFile* file_RECOVERY; static UFile* file_UTILIZZO; @@ -1209,9 +1210,9 @@ public: } } - void writeToLOG(const char* op) + void writeTo(int fd, const char* op) { - U_TRACE(5, "WiAuthUser::writeToLOG(%S)", op) + U_TRACE(5, "WiAuthUser::writeTo(%d,%S)", fd, op) U_INTERNAL_ASSERT_POINTER(op) @@ -1228,10 +1229,12 @@ public: U_INTERNAL_ASSERT(*time_done) U_INTERNAL_ASSERT(*traffic_done) - ULog::log(file_LOG->getFd(), U_CONSTANT_TO_PARAM("op: %s, uid: %v, ap: %v, ip: %v, mac: %v, time: %v, traffic: %v, policy: %v"), - op, uid->rep, getAP().rep, _ip.rep, _mac.rep, time_done->rep, traffic_done->rep, getPolicy().rep); + ULog::log(fd, U_CONSTANT_TO_PARAM("op: %s, uid: %v, ap: %v, ip: %v, mac: %v, time: %v, traffic: %v, policy: %v"), + op, uid->rep, getAP().rep, _ip.rep, _mac.rep, time_done->rep, traffic_done->rep, getPolicy().rep); } + void writeToLOG(const char* op) { writeTo(file_LOG->getFd(), op); } + const char* updateCounter(const UString& logout, long time_connected, uint64_t traffic, bool& ask_logout) { U_TRACE(5, "WiAuthUser::updateCounter(%V,%ld,%llu,%b)", logout.rep, time_connected, traffic, ask_logout) @@ -1244,7 +1247,7 @@ public: _time_done = time_connected; _traffic_done = traffic; - writeToLOG("INFO"); + writeTo(file_INFO->getFd(), "INFO"); _time_done += time_done_save; _traffic_done += traffic_done_save; @@ -1953,7 +1956,7 @@ static int quitUserConnected(UStringRep* key, UStringRep* data) (void) db_user->putDataStorage(*uid); - user_rec->writeToLOG("QUIT"); + if (user_rec->setNodogReference()) user_rec->writeToLOG("QUIT"); } U_RETURN(1); @@ -1972,7 +1975,11 @@ static int checkForUserPolicy(UStringRep* key, UStringRep* data) { *uid = db_user->getKeyID(); - if (user_rec->connected) user_rec->writeToLOG("RST_POLICY"); + if (user_rec->connected && + user_rec->setNodogReference()) + { + user_rec->writeToLOG("RST_POLICY"); + } user_rec->_time_done = user_rec->_time_consumed = 0; @@ -2444,6 +2451,7 @@ static void usp_init_wi_auth() UString dir = UStringExt::dirname(file_LOG->getPath()); + U_NEW(UFile, file_INFO, UFile(dir + U_STRING_FROM_CONSTANT("/wifi-info"))); U_NEW(UFile, file_WARNING, UFile(dir + U_STRING_FROM_CONSTANT("/wifi-warning"))); U_NEW(UFile, file_RECOVERY, UFile(dir + U_STRING_FROM_CONSTANT("/wifi-recovery"))); U_NEW(UFile, file_UTILIZZO, UFile(dir + U_STRING_FROM_CONSTANT("/wifi-utilizzo"))); @@ -2452,6 +2460,7 @@ static void usp_init_wi_auth() UServer_Base::update_date1 = true; (void) UServer_Base::addLog(file_LOG); + (void) UServer_Base::addLog(file_INFO); (void) UServer_Base::addLog(file_WARNING); (void) UServer_Base::addLog(file_RECOVERY, O_APPEND | O_RDWR); (void) UServer_Base::addLog(file_UTILIZZO, O_APPEND | O_RDWR); @@ -5576,10 +5585,10 @@ static void GET_stato_utente() if (result.empty() || U_IS_HTTP_ERROR(U_http_info.nResponseCode)) { - user_rec->writeToLOG("QUIT"); - user_rec->setConnected(false); + user_rec->writeToLOG("QUIT"); + U_INTERNAL_ASSERT_EQUALS(UServer_Base::bssl, false) (void) db_user->putDataStorage(*uid); @@ -5600,10 +5609,10 @@ error: if (user_rec->connected == false) { - user_rec->writeToLOG("RESYNC"); - user_rec->setConnected(true); + user_rec->writeToLOG("RESYNC"); + U_INTERNAL_ASSERT_EQUALS(UServer_Base::bssl, false) (void) db_user->putDataStorage(*uid); @@ -7410,7 +7419,7 @@ static int checkStatusUserOnNodog(UStringRep* key, UStringRep* data) (void) db_user->putDataStorage(*uid); - user_rec->writeToLOG(status_nodog_and_user_resync ? "RESYNC" : "QUIT"); + if (user_rec->setNodogReference()) user_rec->writeToLOG(status_nodog_and_user_resync ? "RESYNC" : "QUIT"); } } diff --git a/m4/ac_check_package.m4 b/m4/ac_check_package.m4 index 9342909f..be3f8f90 100644 --- a/m4/ac_check_package.m4 +++ b/m4/ac_check_package.m4 @@ -202,7 +202,8 @@ AC_DEFUN([AC_CHECK_PACKAGE],[ HAVE_SSL_TS="yes"; AC_DEFINE(HAVE_SSL_TS, 1, [Define if we have time stamp support in openssl]) fi - if test -z "$CROSS_ENVIRONMENT" -a x_$PKG_CONFIG != x_no; then + ssl_version=$($ssldir/bin/openssl version 2>/dev/null) + if test -z "${ssl_version}"-a -z "$CROSS_ENVIRONMENT" -a x_$PKG_CONFIG != x_no; then ssl_version=$(pkg-config --modversion openssl 2>/dev/null) fi if test -z "$OPENSSL_LINK"; then @@ -394,7 +395,7 @@ AC_DEFUN([AC_CHECK_PACKAGE],[ USE_LIBCURL=yes AC_DEFINE(USE_LIBCURL, 1, [Define if enable libcurl support]) libcurl_version=$($curldir/bin/curl-config --version 2>/dev/null | sed -e "s/libcurl //g") - if test -z "${libcurl_version}" -a x_$PKG_CONFIG != x_no; then + if test -z "${libcurl_version}" -a -z "$CROSS_ENVIRONMENT" -a x_$PKG_CONFIG != x_no; then libcurl_version=$(pkg-config --modversion libcurl 2>/dev/null) fi if test -z "${libcurl_version}"; then diff --git a/src/ulib/base/base.c b/src/ulib/base/base.c index 0f51114e..4d923f2f 100644 --- a/src/ulib/base/base.c +++ b/src/ulib/base/base.c @@ -2226,7 +2226,7 @@ case_D: /* extension: print date and time in various format */ * with flag '10' => format: %d/%b/%Y:%T %z */ - len = + bp += (width == 0 ? u_strftime2(bp, 36, U_CONSTANT_TO_PARAM("%d/%m/%y"), t) : width <= 2 ? u_strftime2(bp, 36, U_CONSTANT_TO_PARAM("%T"), t) : width == 3 ? u_strftime2(bp, 36, U_CONSTANT_TO_PARAM("%d/%m/%Y %T"), t) : @@ -2243,18 +2243,15 @@ case_D: /* extension: print date and time in various format */ if ((flags & ALT) != 0 && t > U_ONE_DAY_IN_SECOND) { - bp += len; - u_put_unalignedp16(bp, U_MULTICHAR_CONSTANT16(' ','+')); - bp += 2; + bp += 2 + u_num2str32(t / U_ONE_DAY_IN_SECOND, bp+2); - len = u_num2str32(t / U_ONE_DAY_IN_SECOND, bp); + u_put_unalignedp32(bp, U_MULTICHAR_CONSTANT32(' ','d','a','y')); - u_put_unalignedp32(bp+len, U_MULTICHAR_CONSTANT32(' ','d','a','y')); + bp[4] = 's'; - bp += 4; - *bp++ = 's'; + bp += 5; } } else if (width == 4) /* _millisec */ @@ -2265,15 +2262,9 @@ case_D: /* extension: print date and time in various format */ if (old_ms >= ms) ms = (old_ms >= 999 ? 0 : old_ms+1); old_ms = ms; - bp += len; - - len = sprintf(bp, "_%03ld", ms); - - U_INTERNAL_ASSERT_EQUALS(len, strlen(bp)) + bp += sprintf(bp, "_%03ld", ms); } - bp += len; - continue; case_H: /* extension: print host name */