diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2024-02-13 07:58:30 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2024-02-13 08:10:43 +0300 |
commit | 8ee6bfd26b9e90e07e530906f5a5d4b198db6ead (patch) | |
tree | 23a6f725f21b389d874b2a0fb66342e06f6b60a5 | |
parent | 9bb0e697690361fd000af1b1939ca4a688c812e0 (diff) | |
download | ydb-8ee6bfd26b9e90e07e530906f5a5d4b198db6ead.tar.gz |
Update contrib/libs/openldap to 2.6.7
20 files changed, 269 insertions, 186 deletions
diff --git a/contrib/libs/openldap/CHANGES b/contrib/libs/openldap/CHANGES index a7e969973a..0f58ed3550 100644 --- a/contrib/libs/openldap/CHANGES +++ b/contrib/libs/openldap/CHANGES @@ -1,5 +1,42 @@ OpenLDAP 2.6 Change Log +OpenLDAP 2.6.7 Release (2024/01/29) + Added slapo-dynlist option to disable filter support (ITS#10025) + Fixed liblber missing newline on long msg (ITS#10105) + Fixed libldap exit handling with OpenSSL3 (ITS#9952) + Fixed libldap with TLS and multiple ldap URIs (ITS#10101) + Fixed libldap OpenSSL cipher suite handling (ITS#10094) + Fixed libldap OpenSSL 3.0 and Diffie-Hellman param files (ITS#10124) + Fixed libldap timestamps on Windows (ITS#10100) + Fixed lloadd to work when resolv.conf is missing (ITS#10070) + Fixed lloadd handling of closing connection (ITS#10083) + Fixed lloadd tiers to be correctly linked on startup (ITS#10142) + Fixed slapd to honour disclose in matchedDN handling (ITS#10139) + Fixed slapd handling of regex testing in ACLs (ITS#10089) + Fixed slapd sync replication with glued database (ITS#10080) + Fixed slapd local logging on Windows (ITS#10092) + Fixed slapd-asyncmeta when remote suffix is empty (ITS#10076) + Fixed slapo-dynlist so it can't be global (ITS#10091) + Build + Fixed lloadd type mismatches (ITS#10074) + Fixed builds for Windows (ITS#10117) + Fixed build with clang16 (ITS#10123) + Documentation + Fixed slapo-homedir(5) attribute name for olcHomedirArchivePath (ITS#10057) + Minor Cleanup + ITS#10059 + ITS#10068 + ITS#10098 + ITS#10109 + ITS#10110 + ITS#10129 + ITS#10130 + ITS#10135 + ITS#10143 + ITS#10144 + ITS#10145 + ITS#10153 + OpenLDAP 2.6.6 Release (2023/07/31) Fixed slapd cn=config incorrect handling of paused (ITS#10045) Fixed slapd-meta to account for MOD ops being optional (ITS#10067) diff --git a/contrib/libs/openldap/include/ac/string.h b/contrib/libs/openldap/include/ac/string.h index c4c135410e..20a68d76bc 100644 --- a/contrib/libs/openldap/include/ac/string.h +++ b/contrib/libs/openldap/include/ac/string.h @@ -58,7 +58,7 @@ LDAP_F(char *) ldap_pvt_strtok LDAP_P(( char *str, #elif !defined(_WIN32) /* some systems fail to declare strdup */ /* Windows does not require this declaration */ - LDAP_LIBC_F(char *) (strdup)(); + LDAP_LIBC_F(char *) (strdup) LDAP_P((const char *s)); #endif /* @@ -68,8 +68,8 @@ LDAP_F(char *) ldap_pvt_strtok LDAP_P(( char *str, /* we don't want these declared for Windows or Mingw */ #ifndef _WIN32 -int (strcasecmp)(); -int (strncasecmp)(); +LDAP_LIBC_F(int) (strcasecmp) LDAP_P((const char *s1, const char *s2)); +LDAP_LIBC_F(int) (strncasecmp) LDAP_P((const char *s1, const char *s2, size_t n)); #endif #ifndef SAFEMEMCPY diff --git a/contrib/libs/openldap/include/ldap_config.h b/contrib/libs/openldap/include/ldap_config.h index 2f58b1620c..160eb63bcc 100644 --- a/contrib/libs/openldap/include/ldap_config.h +++ b/contrib/libs/openldap/include/ldap_config.h @@ -52,10 +52,10 @@ #define LDAP_SBINDIR "/var/empty/tmp/out/sbin" #endif #ifndef LDAP_DATADIR -#define LDAP_DATADIR "/var/empty/openldap-2.6.6/share/openldap" +#define LDAP_DATADIR "/var/empty/openldap-2.6.7/share/openldap" #endif #ifndef LDAP_SYSCONFDIR -#define LDAP_SYSCONFDIR "/var/empty/openldap-2.6.6/etc/openldap" +#define LDAP_SYSCONFDIR "/var/empty/openldap-2.6.7/etc/openldap" #endif #ifndef LDAP_LIBEXECDIR #define LDAP_LIBEXECDIR "/var/empty/tmp/out/libexec" @@ -64,7 +64,7 @@ #define LDAP_MODULEDIR "/var/empty/tmp/out/libexec/openldap" #endif #ifndef LDAP_RUNDIR -#define LDAP_RUNDIR "/var/empty/openldap-2.6.6/var" +#define LDAP_RUNDIR "/var/empty/openldap-2.6.7/var" #endif #ifndef LDAP_LOCALEDIR #define LDAP_LOCALEDIR "" diff --git a/contrib/libs/openldap/include/ldap_features.h b/contrib/libs/openldap/include/ldap_features.h index e8d9676c22..009eef31fe 100644 --- a/contrib/libs/openldap/include/ldap_features.h +++ b/contrib/libs/openldap/include/ldap_features.h @@ -22,10 +22,10 @@ #define _LDAP_FEATURES_H 1 /* OpenLDAP API version macros */ -#define LDAP_VENDOR_VERSION 20606 +#define LDAP_VENDOR_VERSION 20607 #define LDAP_VENDOR_VERSION_MAJOR 2 #define LDAP_VENDOR_VERSION_MINOR 6 -#define LDAP_VENDOR_VERSION_PATCH 6 +#define LDAP_VENDOR_VERSION_PATCH 7 /* ** WORK IN PROGRESS! diff --git a/contrib/libs/openldap/include/portable-linux.h b/contrib/libs/openldap/include/portable-linux.h index b1b7269060..a28fd48d6d 100644 --- a/contrib/libs/openldap/include/portable-linux.h +++ b/contrib/libs/openldap/include/portable-linux.h @@ -847,7 +847,7 @@ #define LDAP_SYSLOG 1 /* Version */ -#define LDAP_VENDOR_VERSION 20606 +#define LDAP_VENDOR_VERSION 20607 /* Major */ #define LDAP_VENDOR_VERSION_MAJOR 2 @@ -856,7 +856,7 @@ #define LDAP_VENDOR_VERSION_MINOR 6 /* Patch */ -#define LDAP_VENDOR_VERSION_PATCH 6 +#define LDAP_VENDOR_VERSION_PATCH 7 /* Define to the sub-directory where libtool stores uninstalled libraries. */ #define LT_OBJDIR ".libs/" @@ -874,7 +874,7 @@ #define OPENLDAP_PACKAGE "OpenLDAP" /* Version */ -#define OPENLDAP_VERSION "2.6.6" +#define OPENLDAP_VERSION "2.6.7" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "" diff --git a/contrib/libs/openldap/libraries/liblber/debug.c b/contrib/libs/openldap/libraries/liblber/debug.c index 1744e58a33..1f4fdbb61a 100644 --- a/contrib/libs/openldap/libraries/liblber/debug.c +++ b/contrib/libs/openldap/libraries/liblber/debug.c @@ -43,12 +43,15 @@ void (lutil_debug)( int debug, int level, const char *fmt, ... ) { char buffer[4096]; va_list vl; + int len; if ( !(level & debug ) ) return; va_start( vl, fmt ); - vsnprintf( buffer, sizeof(buffer), fmt, vl ); + len = vsnprintf( buffer, sizeof(buffer), fmt, vl ); va_end( vl ); + if ( len >= sizeof(buffer)-2 ) + buffer[sizeof(buffer)-2] = '\n'; ber_pvt_log_print( buffer ); } diff --git a/contrib/libs/openldap/libraries/liblber/version.c b/contrib/libs/openldap/libraries/liblber/version.c index ee83d02705..2d24ed04e7 100644 --- a/contrib/libs/openldap/libraries/liblber/version.c +++ b/contrib/libs/openldap/libraries/liblber/version.c @@ -17,6 +17,6 @@ static const char copyright[] = "COPYING RESTRICTIONS APPLY\n"; static const char __Version[] = -"@(#) $OpenLDAP: liblber.la 2.6.6 (" __DATE__ " " __TIME__ ") $\n" +"@(#) $OpenLDAP: liblber.la 2.6.7 (" __DATE__ " " __TIME__ ") $\n" "\topenldap\n"; diff --git a/contrib/libs/openldap/libraries/libldap/getdn.c b/contrib/libs/openldap/libraries/libldap/getdn.c index 617059621f..7d8b52f1e4 100644 --- a/contrib/libs/openldap/libraries/libldap/getdn.c +++ b/contrib/libs/openldap/libraries/libldap/getdn.c @@ -2562,6 +2562,8 @@ rdn2strlen( LDAPRDN rdn, unsigned flags, ber_len_t *len, l += vl; } } + if ( !iAVA ) + return( -1 ); /* RDN ::= SET SIZE (1..MAX) OF AVA */ *len = l; @@ -2635,6 +2637,8 @@ rdn2DCEstrlen( LDAPRDN rdn, unsigned flags, ber_len_t *len ) l += vl; } } + if ( !iAVA ) + return( -1 ); /* RDN ::= SET SIZE (1..MAX) OF AVA */ *len = l; @@ -2716,6 +2720,8 @@ rdn2UFNstrlen( LDAPRDN rdn, unsigned flags, ber_len_t *len ) l += vl; } } + if ( !iAVA ) + return( -1 ); /* RDN ::= SET SIZE (1..MAX) OF AVA */ *len = l; @@ -2794,6 +2800,8 @@ rdn2ADstrlen( LDAPRDN rdn, unsigned flags, ber_len_t *len ) l += vl; } } + if ( !iAVA ) + return( -1 ); /* RDN ::= SET SIZE (1..MAX) OF AVA */ *len = l; diff --git a/contrib/libs/openldap/libraries/libldap/init.c b/contrib/libs/openldap/libraries/libldap/init.c index 3a81790dcf..b9915533bd 100644 --- a/contrib/libs/openldap/libraries/libldap/init.c +++ b/contrib/libs/openldap/libraries/libldap/init.c @@ -544,9 +544,6 @@ ldap_int_destroy_global_options(void) gopts->ldo_def_sasl_authcid = NULL; } #endif -#ifdef HAVE_TLS - ldap_int_tls_destroy( gopts ); -#endif } /* diff --git a/contrib/libs/openldap/libraries/libldap/open.c b/contrib/libs/openldap/libraries/libldap/open.c index bfdbb2575d..93720ebc91 100644 --- a/contrib/libs/openldap/libraries/libldap/open.c +++ b/contrib/libs/openldap/libraries/libldap/open.c @@ -543,6 +543,7 @@ ldap_int_open_connection( LDAP_MUTEX_UNLOCK( &lo->ldo_mutex ); } ber_int_sb_close( conn->lconn_sb ); + ber_int_sb_destroy( conn->lconn_sb ); return -1; } } diff --git a/contrib/libs/openldap/libraries/libldap/tls2.c b/contrib/libs/openldap/libraries/libldap/tls2.c index dff845bc10..4bfc346c70 100644 --- a/contrib/libs/openldap/libraries/libldap/tls2.c +++ b/contrib/libs/openldap/libraries/libldap/tls2.c @@ -160,6 +160,14 @@ ldap_pvt_tls_destroy( void ) tls_imp->ti_tls_destroy(); } +static void +ldap_exit_tls_destroy( void ) +{ + struct ldapoptions *lo = LDAP_INT_GLOBAL_OPT(); + + ldap_int_tls_destroy( lo ); +} + /* * Initialize a particular TLS implementation. * Called once per implementation. @@ -168,6 +176,7 @@ static int tls_init(tls_impl *impl, int do_threads ) { static int tls_initialized = 0; + int rc; if ( !tls_initialized++ ) { #ifdef LDAP_R_COMPILE @@ -183,7 +192,10 @@ tls_init(tls_impl *impl, int do_threads ) #endif } - return impl->ti_tls_init(); + rc = impl->ti_tls_init(); + + atexit( ldap_exit_tls_destroy ); + return rc; } /* diff --git a/contrib/libs/openldap/libraries/libldap/tls_o.c b/contrib/libs/openldap/libraries/libldap/tls_o.c index 8f1d84efa1..6847ef33b4 100644 --- a/contrib/libs/openldap/libraries/libldap/tls_o.c +++ b/contrib/libs/openldap/libraries/libldap/tls_o.c @@ -296,7 +296,7 @@ tlso_stecpy( char *dst, const char *src, const char *end ) * Try to find any TLS1.3 ciphers in the given list of suites. */ static void -tlso_ctx_cipher13( tlso_ctx *ctx, char *suites ) +tlso_ctx_cipher13( tlso_ctx *ctx, char *suites, char **oldsuites ) { char tls13_suites[1024], *ts = tls13_suites, *te = tls13_suites + sizeof(tls13_suites); char *ptr, *colon, *nptr; @@ -305,6 +305,8 @@ tlso_ctx_cipher13( tlso_ctx *ctx, char *suites ) SSL *s = SSL_new( ctx ); int ret; + *oldsuites = NULL; + if ( !s ) return; @@ -336,8 +338,15 @@ tlso_ctx_cipher13( tlso_ctx *ctx, char *suites ) if ( tls13_suites[0] ) ts = tlso_stecpy( ts, ":", te ); ts = tlso_stecpy( ts, nptr, te ); + } else if (! *oldsuites) { + /* should never happen, set_ciphersuites should + * only succeed for TLSv1.3 and above + */ + *oldsuites = ptr; } } + } else if (! *oldsuites) { + *oldsuites = ptr; } if ( !colon || ts >= te ) break; @@ -417,10 +426,11 @@ tlso_ctx_init( struct ldapoptions *lo, struct ldaptls *lt, int is_server, char * } if ( lo->ldo_tls_ciphersuite ) { + char *oldsuites = lt->lt_ciphersuite; #if OPENSSL_VERSION_NUMBER >= 0x10101000 - tlso_ctx_cipher13( ctx, lt->lt_ciphersuite ); + tlso_ctx_cipher13( ctx, lt->lt_ciphersuite, &oldsuites ); #endif - if ( !SSL_CTX_set_cipher_list( ctx, lt->lt_ciphersuite ) ) + if ( oldsuites && !SSL_CTX_set_cipher_list( ctx, oldsuites ) ) { Debug1( LDAP_DEBUG_ANY, "TLS: could not set cipher list %s.\n", @@ -553,7 +563,7 @@ tlso_ctx_init( struct ldapoptions *lo, struct ldaptls *lt, int is_server, char * if ( is_server && lo->ldo_tls_dhfile ) { #if OPENSSL_VERSION_MAJOR >= 3 EVP_PKEY *dh; -#define bio_params( bio, dh ) dh = PEM_read_bio_Parameters( bio, &dh ) +#define bio_params( bio, dh ) dh = PEM_read_bio_Parameters( bio, NULL ) #else DH *dh; #define bio_params( bio, dh ) dh = PEM_read_bio_DHparams( bio, NULL, NULL, NULL ) diff --git a/contrib/libs/openldap/libraries/libldap/url.c b/contrib/libs/openldap/libraries/libldap/url.c index 493fd7ce47..a56af3093c 100644 --- a/contrib/libs/openldap/libraries/libldap/url.c +++ b/contrib/libs/openldap/libraries/libldap/url.c @@ -867,6 +867,10 @@ ldap_url_parse_ext( LDAP_CONST char *url_in, LDAPURLDesc **ludpp, unsigned flags } if ( enclosed ) { + if ( ! *url ) { + LDAP_FREE( url ); + return LDAP_URL_ERR_BADENCLOSURE; + } p = &url[strlen(url)-1]; if( *p != '>' ) { diff --git a/contrib/libs/openldap/libraries/libldap/util-int.c b/contrib/libs/openldap/libraries/libldap/util-int.c index 57c6523381..7cab9ea3e5 100644 --- a/contrib/libs/openldap/libraries/libldap/util-int.c +++ b/contrib/libs/openldap/libraries/libldap/util-int.c @@ -182,116 +182,65 @@ static int _ldap_pvt_gt_subs; * This is pretty clunky. */ static LARGE_INTEGER _ldap_pvt_gt_freq; -static LARGE_INTEGER _ldap_pvt_gt_prev; -static int _ldap_pvt_gt_offset; +static LARGE_INTEGER _ldap_pvt_gt_start_count; +static long _ldap_pvt_gt_start_sec; +static long _ldap_pvt_gt_start_nsec; +static double _ldap_pvt_gt_nanoticks; #define SEC_TO_UNIX_EPOCH 11644473600LL #define TICKS_PER_SECOND 10000000 #define BILLION 1000000000L static int -ldap_pvt_gettimensec(int *sec) +ldap_pvt_gettimensec(long *sec) { LARGE_INTEGER count; + LARGE_INTEGER freq; + int nsec; - QueryPerformanceCounter( &count ); - - /* It shouldn't ever go backwards, but multiple CPUs might - * be able to hit in the same tick. - */ - LDAP_MUTEX_LOCK( &ldap_int_gettime_mutex ); + QueryPerformanceFrequency( &freq ); /* We assume Windows has at least a vague idea of * when a second begins. So we align our nanosecond count - * with the Windows millisecond count using this offset. - * We retain the submillisecond portion of our own count. - * - * Note - this also assumes that the relationship between - * the PerformanceCounter and SystemTime stays constant; - * that assumption breaks if the SystemTime is adjusted by - * an external action. + * with the Windows millisecond count. */ - if ( !_ldap_pvt_gt_freq.QuadPart ) { - LARGE_INTEGER c2; + if ( freq.QuadPart != _ldap_pvt_gt_freq.QuadPart ) { ULARGE_INTEGER ut; FILETIME ft0, ft1; - long long t; - int nsec; - - /* Initialize our offset */ - QueryPerformanceFrequency( &_ldap_pvt_gt_freq ); - + /* initialize */ + LDAP_MUTEX_LOCK( &ldap_int_gettime_mutex ); /* Wait for a tick of the system time: 10-15ms */ GetSystemTimeAsFileTime( &ft0 ); do { GetSystemTimeAsFileTime( &ft1 ); } while ( ft1.dwLowDateTime == ft0.dwLowDateTime ); + QueryPerformanceCounter( &_ldap_pvt_gt_start_count ); ut.LowPart = ft1.dwLowDateTime; ut.HighPart = ft1.dwHighDateTime; - QueryPerformanceCounter( &c2 ); - - /* get second and fraction portion of counter */ - t = c2.QuadPart % (_ldap_pvt_gt_freq.QuadPart*10); - - /* convert to nanoseconds */ - t *= BILLION; - nsec = t / _ldap_pvt_gt_freq.QuadPart; - - ut.QuadPart /= 10; - ut.QuadPart %= (10 * BILLION); - _ldap_pvt_gt_offset = nsec - ut.QuadPart; - count = c2; + _ldap_pvt_gt_start_nsec = ut.QuadPart % TICKS_PER_SECOND * 100; + _ldap_pvt_gt_start_sec = ut.QuadPart / TICKS_PER_SECOND - SEC_TO_UNIX_EPOCH; + _ldap_pvt_gt_freq = freq; + _ldap_pvt_gt_nanoticks = (double)BILLION / freq.QuadPart; + LDAP_MUTEX_UNLOCK( &ldap_int_gettime_mutex ); } - if ( count.QuadPart <= _ldap_pvt_gt_prev.QuadPart ) { - _ldap_pvt_gt_subs++; - } else { - _ldap_pvt_gt_subs = 0; - _ldap_pvt_gt_prev = count; + QueryPerformanceCounter( &count ); + count.QuadPart -= _ldap_pvt_gt_start_count.QuadPart; + *sec = _ldap_pvt_gt_start_sec + count.QuadPart / freq.QuadPart; + nsec = _ldap_pvt_gt_start_nsec + (double)(count.QuadPart % freq.QuadPart) * _ldap_pvt_gt_nanoticks; + if ( nsec > BILLION) { + nsec -= BILLION; + (*sec)++; } - LDAP_MUTEX_UNLOCK( &ldap_int_gettime_mutex ); - - /* convert to nanoseconds */ - count.QuadPart %= _ldap_pvt_gt_freq.QuadPart*10; - count.QuadPart *= BILLION; - count.QuadPart /= _ldap_pvt_gt_freq.QuadPart; - count.QuadPart -= _ldap_pvt_gt_offset; - - /* We've extracted the 1s and nanoseconds. - * The 1sec digit is used to detect wraparound in nanosecnds. - */ - if (count.QuadPart < 0) - count.QuadPart += (10 * BILLION); - else if (count.QuadPart >= (10 * BILLION)) - count.QuadPart -= (10 * BILLION); - - *sec = count.QuadPart / BILLION; - return count.QuadPart % BILLION; + return nsec; } - /* emulate POSIX clock_gettime */ int ldap_pvt_clock_gettime( int clk_id, struct timespec *tv ) { - FILETIME ft; - ULARGE_INTEGER ut; - int sec, sec0; - - GetSystemTimeAsFileTime( &ft ); - ut.LowPart = ft.dwLowDateTime; - ut.HighPart = ft.dwHighDateTime; - - /* convert to sec */ - ut.QuadPart /= TICKS_PER_SECOND; - - tv->tv_nsec = ldap_pvt_gettimensec(&sec); - tv->tv_sec = ut.QuadPart - SEC_TO_UNIX_EPOCH; - - /* check for carry from microseconds */ - sec0 = tv->tv_sec % 10; - if (sec0 < sec || (sec0 == 9 && !sec)) - tv->tv_sec++; - + long sec; + tv->tv_nsec = ldap_pvt_gettimensec( &sec ); + tv->tv_sec = sec; return 0; } @@ -306,6 +255,8 @@ ldap_pvt_gettimeofday( struct timeval *tv, void *unused ) return 0; } +static long _ldap_pvt_gt_prevsec; +static int _ldap_pvt_gt_prevnsec; /* return a broken out time, with nanoseconds */ @@ -313,17 +264,18 @@ void ldap_pvt_gettime( struct lutil_tm *tm ) { SYSTEMTIME st; - int sec, sec0; - static const char daysPerMonth[] = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + LARGE_INTEGER ft; + long sec; - GetSystemTime( &st ); + /* Convert sec/nsec to Windows FILETIME, + * then turn that into broken out SYSTEMTIME */ tm->tm_nsec = ldap_pvt_gettimensec(&sec); - tm->tm_usub = _ldap_pvt_gt_subs; + ft.QuadPart = sec; + ft.QuadPart += SEC_TO_UNIX_EPOCH; + ft.QuadPart *= TICKS_PER_SECOND; + ft.QuadPart += tm->tm_nsec / 100; + FileTimeToSystemTime( (FILETIME *)&ft, &st ); - /* any difference larger than nanoseconds is - * already reflected in st - */ tm->tm_sec = st.wSecond; tm->tm_min = st.wMinute; tm->tm_hour = st.wHour; @@ -331,42 +283,18 @@ ldap_pvt_gettime( struct lutil_tm *tm ) tm->tm_mon = st.wMonth - 1; tm->tm_year = st.wYear - 1900; - /* check for carry from nanoseconds */ - sec0 = tm->tm_sec % 10; - if (sec0 < sec || (sec0 == 9 && !sec)) { - tm->tm_sec++; - /* FIXME: we don't handle leap seconds */ - if (tm->tm_sec > 59) { - tm->tm_sec = 0; - tm->tm_min++; - if (tm->tm_min > 59) { - tm->tm_min = 0; - tm->tm_hour++; - if (tm->tm_hour > 23) { - int days = daysPerMonth[tm->tm_mon]; - tm->tm_hour = 0; - tm->tm_mday++; - - /* if it's February of a leap year, - * add 1 day to this month - */ - if (tm->tm_mon == 1 && - ((!(st.wYear % 4) && (st.wYear % 100)) || - !(st.wYear % 400))) - days++; - - if (tm->tm_mday > days) { - tm->tm_mday = 1; - tm->tm_mon++; - if (tm->tm_mon > 11) { - tm->tm_mon = 0; - tm->tm_year++; - } - } - } - } - } + LDAP_MUTEX_LOCK( &ldap_int_gettime_mutex ); + if ( tm->tm_sec < _ldap_pvt_gt_prevsec + || ( tm->tm_sec == _ldap_pvt_gt_prevsec + && tm->tm_nsec <= _ldap_pvt_gt_prevnsec )) { + _ldap_pvt_gt_subs++; + } else { + _ldap_pvt_gt_subs = 0; + _ldap_pvt_gt_prevsec = sec; + _ldap_pvt_gt_prevnsec = tm->tm_nsec; } + LDAP_MUTEX_UNLOCK( &ldap_int_gettime_mutex ); + tm->tm_usub = _ldap_pvt_gt_subs; } #else diff --git a/contrib/libs/openldap/libraries/libldap/version.c b/contrib/libs/openldap/libraries/libldap/version.c index fad5f1a830..4346e79546 100644 --- a/contrib/libs/openldap/libraries/libldap/version.c +++ b/contrib/libs/openldap/libraries/libldap/version.c @@ -17,6 +17,6 @@ static const char copyright[] = "COPYING RESTRICTIONS APPLY\n"; static const char __Version[] = -"@(#) $OpenLDAP: libldap.la 2.6.6 (" __DATE__ " " __TIME__ ") $\n" +"@(#) $OpenLDAP: libldap.la 2.6.7 (" __DATE__ " " __TIME__ ") $\n" "\topenldap\n"; diff --git a/contrib/libs/openldap/libraries/liblmdb/CHANGES b/contrib/libs/openldap/libraries/liblmdb/CHANGES index 76dd591db7..10e81d5bd3 100644 --- a/contrib/libs/openldap/libraries/liblmdb/CHANGES +++ b/contrib/libs/openldap/libraries/liblmdb/CHANGES @@ -1,5 +1,11 @@ LMDB 0.9 Change Log +LMDB 0.9.32 Release (2024/01/29) + ITS#9378 - Add ability to replay log and replay log tool + ITS#10095 - partial revert of ITS#9278. The patch was incorrect and introduced numerous race conditions. + ITS#10125 - mdb_load: fix cursor reinit in Append mode + ITS#10137 - Allow users to define MDB_IDL_LOGN + LMDB 0.9.31 Release (2023/07/10) ITS#8447 - Fix cursor_put(MDB_CURRENT) on DUPSORT DB with different sized data diff --git a/contrib/libs/openldap/libraries/liblmdb/lmdb.h b/contrib/libs/openldap/libraries/liblmdb/lmdb.h index ff03c224f2..d638a678a8 100644 --- a/contrib/libs/openldap/libraries/liblmdb/lmdb.h +++ b/contrib/libs/openldap/libraries/liblmdb/lmdb.h @@ -200,7 +200,7 @@ typedef int mdb_filehandle_t; /** Library minor version */ #define MDB_VERSION_MINOR 9 /** Library patch version */ -#define MDB_VERSION_PATCH 31 +#define MDB_VERSION_PATCH 32 /** Combine args a,b,c into a single integer for easy version comparisons */ #define MDB_VERINT(a,b,c) (((a) << 24) | ((b) << 16) | (c)) @@ -210,7 +210,7 @@ typedef int mdb_filehandle_t; MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH) /** The release date of this library version */ -#define MDB_VERSION_DATE "July 10, 2023" +#define MDB_VERSION_DATE "January 29, 2024" /** A stringifier for the version info */ #define MDB_VERSTR(a,b,c,d) "LMDB " #a "." #b "." #c ": (" d ")" diff --git a/contrib/libs/openldap/libraries/liblmdb/mdb.c b/contrib/libs/openldap/libraries/liblmdb/mdb.c index deb6779640..0570deab23 100644 --- a/contrib/libs/openldap/libraries/liblmdb/mdb.c +++ b/contrib/libs/openldap/libraries/liblmdb/mdb.c @@ -481,18 +481,26 @@ typedef MDB_ID txnid_t; #define MDB_DEBUG 0 #endif +#define MDB_DBG_INFO 1 +#define MDB_DBG_TRACE 2 + #if MDB_DEBUG -static int mdb_debug; +static int mdb_debug = MDB_DBG_TRACE; static txnid_t mdb_debug_start; /** Print a debug message with printf formatting. * Requires double parenthesis around 2 or more args. */ -# define DPRINTF(args) ((void) ((mdb_debug) && DPRINTF0 args)) +# define DPRINTF(args) ((void) ((mdb_debug & MDB_DBG_INFO) && DPRINTF0 args)) # define DPRINTF0(fmt, ...) \ fprintf(stderr, "%s:%d " fmt "\n", mdb_func_, __LINE__, __VA_ARGS__) + /** Trace info for replaying */ +# define MDB_TRACE(args) ((void) ((mdb_debug & MDB_DBG_TRACE) && DPRINTF1 args)) +# define DPRINTF1(fmt, ...) \ + fprintf(stderr, ">%d:%s: " fmt "\n", getpid(), mdb_func_, __VA_ARGS__) #else # define DPRINTF(args) ((void) 0) +# define MDB_TRACE(args) ((void) 0) #endif /** Print a debug string. * The string is printed literally, with no format processing. @@ -589,6 +597,11 @@ static txnid_t mdb_debug_start; * This is used for printing a hex dump of a key's contents. */ #define DKBUF char kbuf[DKBUF_MAXKEYSIZE*2+1] + /** A data value buffer. + * @ingroup debug + * This is used for printing a hex dump of a #MDB_DUPSORT value's contents. + */ +#define DDBUF char dbuf[DKBUF_MAXKEYSIZE*2+1+2] /** Display a key in hex. * @ingroup debug * Invoke a function to display a key in hex. @@ -596,6 +609,7 @@ static txnid_t mdb_debug_start; #define DKEY(x) mdb_dkey(x, kbuf) #else #define DKBUF +#define DDBUF #define DKEY(x) 0 #endif @@ -1423,6 +1437,9 @@ static int mdb_update_key(MDB_cursor *mc, MDB_val *key); static void mdb_cursor_pop(MDB_cursor *mc); static int mdb_cursor_push(MDB_cursor *mc, MDB_page *mp); +static int _mdb_cursor_del(MDB_cursor *mc, unsigned int flags); +static int _mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data, unsigned int flags); + static int mdb_cursor_del0(MDB_cursor *mc); static int mdb_del0(MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data, unsigned flags); static int mdb_cursor_sibling(MDB_cursor *mc, int move_right); @@ -1614,6 +1631,18 @@ mdb_dkey(MDB_val *key, char *buf) return buf; } +static char * +mdb_dval(MDB_txn *txn, MDB_dbi dbi, MDB_val *data, char *buf) +{ + if (txn->mt_dbs[dbi].md_flags & MDB_DUPSORT) { + mdb_dkey(data, buf+1); + *buf = '['; + strcpy(buf + data->mv_size * 2 + 1, "]"); + } else + *buf = '\0'; + return buf; +} + static const char * mdb_leafnode_type(MDB_node *n) { @@ -2786,7 +2815,7 @@ mdb_txn_renew0(MDB_txn *txn) txn->mt_txnid++; #if MDB_DEBUG if (txn->mt_txnid == mdb_debug_start) - mdb_debug = 1; + mdb_debug = MDB_DBG_INFO; #endif txn->mt_child = NULL; txn->mt_loose_pgs = NULL; @@ -2945,6 +2974,7 @@ renew: txn->mt_txnid, (flags & MDB_RDONLY) ? 'r' : 'w', (void *) txn, (void *) env, txn->mt_dbs[MAIN_DBI].md_root)); } + MDB_TRACE(("%p, %p, %u = %p", env, parent, flags, txn)); return rc; } @@ -3080,18 +3110,25 @@ mdb_txn_reset(MDB_txn *txn) mdb_txn_end(txn, MDB_END_RESET); } -void -mdb_txn_abort(MDB_txn *txn) +static void +_mdb_txn_abort(MDB_txn *txn) { if (txn == NULL) return; if (txn->mt_child) - mdb_txn_abort(txn->mt_child); + _mdb_txn_abort(txn->mt_child); mdb_txn_end(txn, MDB_END_ABORT|MDB_END_SLOT|MDB_END_FREE); } +void +mdb_txn_abort(MDB_txn *txn) +{ + MDB_TRACE(("%p", txn)); + _mdb_txn_abort(txn); +} + /** Save the freelist as of this transaction to the freeDB. * This changes the freelist. Keep trying until it stabilizes. */ @@ -3182,7 +3219,7 @@ mdb_freelist_save(MDB_txn *txn) pglast = head_id = *(txnid_t *)key.mv_data; total_room = head_room = 0; mdb_tassert(txn, pglast <= env->me_pglast); - rc = mdb_cursor_del(&mc, 0); + rc = _mdb_cursor_del(&mc, 0); if (rc) return rc; } @@ -3202,7 +3239,7 @@ mdb_freelist_save(MDB_txn *txn) do { freecnt = free_pgs[0]; data.mv_size = MDB_IDL_SIZEOF(free_pgs); - rc = mdb_cursor_put(&mc, &key, &data, MDB_RESERVE); + rc = _mdb_cursor_put(&mc, &key, &data, MDB_RESERVE); if (rc) return rc; /* Retry if mt_free_pgs[] grew during the Put() */ @@ -3251,7 +3288,7 @@ mdb_freelist_save(MDB_txn *txn) key.mv_size = sizeof(head_id); key.mv_data = &head_id; data.mv_size = (head_room + 1) * sizeof(pgno_t); - rc = mdb_cursor_put(&mc, &key, &data, MDB_RESERVE); + rc = _mdb_cursor_put(&mc, &key, &data, MDB_RESERVE); if (rc) return rc; /* IDL is initially empty, zero out at least the length */ @@ -3306,7 +3343,7 @@ mdb_freelist_save(MDB_txn *txn) data.mv_data = mop -= len; save = mop[0]; mop[0] = len; - rc = mdb_cursor_put(&mc, &key, &data, MDB_CURRENT); + rc = _mdb_cursor_put(&mc, &key, &data, MDB_CURRENT); mop[0] = save; if (rc || !(mop_len -= len)) break; @@ -3467,8 +3504,8 @@ done: return MDB_SUCCESS; } -int -mdb_txn_commit(MDB_txn *txn) +static int +_mdb_txn_commit(MDB_txn *txn) { int rc; unsigned int i, end_mode; @@ -3481,7 +3518,7 @@ mdb_txn_commit(MDB_txn *txn) end_mode = MDB_END_EMPTY_COMMIT|MDB_END_UPDATE|MDB_END_SLOT|MDB_END_FREE; if (txn->mt_child) { - rc = mdb_txn_commit(txn->mt_child); + rc = _mdb_txn_commit(txn->mt_child); if (rc) goto fail; } @@ -3661,7 +3698,7 @@ mdb_txn_commit(MDB_txn *txn) goto fail; } data.mv_data = &txn->mt_dbs[i]; - rc = mdb_cursor_put(&mc, &txn->mt_dbxs[i].md_name, &data, + rc = _mdb_cursor_put(&mc, &txn->mt_dbxs[i].md_name, &data, F_SUBDATA); if (rc) goto fail; @@ -3692,10 +3729,17 @@ done: return MDB_SUCCESS; fail: - mdb_txn_abort(txn); + _mdb_txn_abort(txn); return rc; } +int +mdb_txn_commit(MDB_txn *txn) +{ + MDB_TRACE(("%p", txn)); + return _mdb_txn_commit(txn); +} + /** Read the environment parameters of a DB environment before * mapping it into memory. * @param[in] env the environment handle @@ -3992,6 +4036,7 @@ mdb_env_create(MDB_env **env) GET_PAGESIZE(e->me_os_psize); VGMEMP_CREATE(e,0,0); *env = e; + MDB_TRACE(("%p", e)); return MDB_SUCCESS; } @@ -4115,6 +4160,7 @@ mdb_env_set_mapsize(MDB_env *env, size_t size) env->me_mapsize = size; if (env->me_psize) env->me_maxpg = env->me_mapsize / env->me_psize; + MDB_TRACE(("%p, %"Yu"", env, size)); return MDB_SUCCESS; } @@ -4124,6 +4170,7 @@ mdb_env_set_maxdbs(MDB_env *env, MDB_dbi dbs) if (env->me_map) return EINVAL; env->me_maxdbs = dbs + CORE_DBS; + MDB_TRACE(("%p, %u", env, dbs)); return MDB_SUCCESS; } @@ -4133,6 +4180,7 @@ mdb_env_set_maxreaders(MDB_env *env, unsigned int readers) if (env->me_map || readers < 1) return EINVAL; env->me_maxreaders = readers; + MDB_TRACE(("%p, %u", env, readers)); return MDB_SUCCESS; } @@ -5076,6 +5124,7 @@ mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode } leave: + MDB_TRACE(("%p, %s, %u, %04o", env, path, flags & (CHANGEABLE|CHANGELESS), mode)); if (rc) { mdb_env_close0(env, excl); } @@ -5162,17 +5211,6 @@ mdb_env_close0(MDB_env *env, int excl) sem_unlink(env->me_txns->mti_wmname); } } -#elif defined(MDB_ROBUST_SUPPORTED) - /* If we have the filelock: If we are the - * only remaining user, clean up robust - * mutexes. - */ - if (excl == 0) - mdb_env_excl_lock(env, &excl); - if (excl > 0) { - pthread_mutex_destroy(env->me_txns->mti_rmutex); - pthread_mutex_destroy(env->me_txns->mti_wmutex); - } #endif munmap((void *)env->me_txns, (env->me_maxreaders-1)*sizeof(MDB_reader)+sizeof(MDB_txninfo)); } @@ -5199,6 +5237,7 @@ mdb_env_close(MDB_env *env) if (env == NULL) return; + MDB_TRACE(("%p", env)); VGMEMP_DESTROY(env); while ((dp = env->me_dpages) != NULL) { VGMEMP_DEFINED(&dp->mp_next, sizeof(dp->mp_next)); @@ -6570,8 +6609,8 @@ mdb_cursor_touch(MDB_cursor *mc) /** Do not spill pages to disk if txn is getting full, may fail instead */ #define MDB_NOSPILL 0x8000 -int -mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data, +static int +_mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data, unsigned int flags) { MDB_env *env; @@ -7034,7 +7073,7 @@ put_sub: new_dupdata = (int)dkey.mv_size; /* converted, write the original data first */ if (dkey.mv_size) { - rc = mdb_cursor_put(&mc->mc_xcursor->mx_cursor, &dkey, &xdata, xflags); + rc = _mdb_cursor_put(&mc->mc_xcursor->mx_cursor, &dkey, &xdata, xflags); if (rc) goto bad_sub; /* we've done our job */ @@ -7062,7 +7101,7 @@ put_sub: ecount = mc->mc_xcursor->mx_db.md_entries; if (flags & MDB_APPENDDUP) xflags |= MDB_APPEND; - rc = mdb_cursor_put(&mc->mc_xcursor->mx_cursor, data, &xdata, xflags); + rc = _mdb_cursor_put(&mc->mc_xcursor->mx_cursor, data, &xdata, xflags); if (flags & F_SUBDATA) { void *db = NODEDATA(leaf); memcpy(db, &mc->mc_xcursor->mx_db, sizeof(MDB_db)); @@ -7103,7 +7142,20 @@ bad_sub: } int -mdb_cursor_del(MDB_cursor *mc, unsigned int flags) +mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data, + unsigned int flags) +{ + DKBUF; + DDBUF; + int rc = _mdb_cursor_put(mc, key, data, flags); + MDB_TRACE(("%p, %"Z"u[%s], %"Z"u%s, %u", + mc, key ? key->mv_size:0, DKEY(key), data ? data->mv_size:0, + data ? mdb_dval(mc->mc_txn, mc->mc_dbi, data, dbuf):"", flags)); + return rc; +} + +static int +_mdb_cursor_del(MDB_cursor *mc, unsigned int flags) { MDB_node *leaf; MDB_page *mp; @@ -7141,7 +7193,7 @@ mdb_cursor_del(MDB_cursor *mc, unsigned int flags) if (!F_ISSET(leaf->mn_flags, F_SUBDATA)) { mc->mc_xcursor->mx_cursor.mc_pg[0] = NODEDATA(leaf); } - rc = mdb_cursor_del(&mc->mc_xcursor->mx_cursor, MDB_NOSPILL); + rc = _mdb_cursor_del(&mc->mc_xcursor->mx_cursor, MDB_NOSPILL); if (rc) return rc; /* If sub-DB still has entries, we're done */ @@ -7205,6 +7257,14 @@ fail: return rc; } +int +mdb_cursor_del(MDB_cursor *mc, unsigned int flags) +{ + MDB_TRACE(("%p, %u", + mc, flags)); + return _mdb_cursor_del(mc, flags); +} + /** Allocate and initialize new pages for a database. * Set #MDB_TXN_ERROR on failure. * @param[in] mc a cursor on the database being added to. @@ -7698,6 +7758,7 @@ mdb_cursor_open(MDB_txn *txn, MDB_dbi dbi, MDB_cursor **ret) return ENOMEM; } + MDB_TRACE(("%p, %u = %p", txn, dbi, mc)); *ret = mc; return MDB_SUCCESS; @@ -7761,6 +7822,7 @@ mdb_cursor_count(MDB_cursor *mc, size_t *countp) void mdb_cursor_close(MDB_cursor *mc) { + MDB_TRACE(("%p", mc)); if (mc && !mc->mc_backup) { /* remove from txn, if tracked */ if ((mc->mc_flags & C_UNTRACK) && mc->mc_txn->mt_cursors) { @@ -8570,6 +8632,8 @@ int mdb_del(MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data) { + DKBUF; + DDBUF; if (!key || !TXN_DBI_EXIST(txn, dbi, DB_USRVALID)) return EINVAL; @@ -8581,6 +8645,9 @@ mdb_del(MDB_txn *txn, MDB_dbi dbi, data = NULL; } + MDB_TRACE(("%p, %u, %"Z"u[%s], %"Z"u%s", + txn, dbi, key ? key->mv_size:0, DKEY(key), data ? data->mv_size:0, + data ? mdb_dval(txn, dbi, data, dbuf):"")); return mdb_del0(txn, dbi, key, data, 0); } @@ -8621,7 +8688,7 @@ mdb_del0(MDB_txn *txn, MDB_dbi dbi, mc.mc_flags |= C_UNTRACK; mc.mc_next = txn->mt_cursors[dbi]; txn->mt_cursors[dbi] = &mc; - rc = mdb_cursor_del(&mc, flags); + rc = _mdb_cursor_del(&mc, flags); txn->mt_cursors[dbi] = mc.mc_next; } return rc; @@ -9063,6 +9130,8 @@ mdb_put(MDB_txn *txn, MDB_dbi dbi, MDB_cursor mc; MDB_xcursor mx; int rc; + DKBUF; + DDBUF; if (!key || !data || !TXN_DBI_EXIST(txn, dbi, DB_USRVALID)) return EINVAL; @@ -9073,10 +9142,12 @@ mdb_put(MDB_txn *txn, MDB_dbi dbi, if (txn->mt_flags & (MDB_TXN_RDONLY|MDB_TXN_BLOCKED)) return (txn->mt_flags & MDB_TXN_RDONLY) ? EACCES : MDB_BAD_TXN; + MDB_TRACE(("%p, %u, %"Z"u[%s], %"Z"u%s, %u", + txn, dbi, key ? key->mv_size:0, DKEY(key), data->mv_size, mdb_dval(txn, dbi, data, dbuf), flags)); mdb_cursor_init(&mc, txn, dbi, &mx); mc.mc_next = txn->mt_cursors[dbi]; txn->mt_cursors[dbi] = &mc; - rc = mdb_cursor_put(&mc, key, data, flags); + rc = _mdb_cursor_put(&mc, key, data, flags); txn->mt_cursors[dbi] = mc.mc_next; return rc; } @@ -9479,7 +9550,7 @@ finish: my.mc_error = rc; mdb_env_cthr_toggle(&my, 1 | MDB_EOF); rc = THREAD_FINISH(thr); - mdb_txn_abort(txn); + _mdb_txn_abort(txn); done: #ifdef _WIN32 @@ -9591,7 +9662,7 @@ mdb_env_copyfd0(MDB_env *env, HANDLE fd) } leave: - mdb_txn_abort(txn); + _mdb_txn_abort(txn); return rc; } @@ -9806,6 +9877,7 @@ int mdb_dbi_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *db } } mdb_default_cmp(txn, MAIN_DBI); + MDB_TRACE(("%p, (null), %u = %u", txn, flags, MAIN_DBI)); return MDB_SUCCESS; } @@ -9867,7 +9939,7 @@ int mdb_dbi_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *db dummy.md_root = P_INVALID; dummy.md_flags = flags & PERSISTENT_FLAGS; WITH_CURSOR_TRACKING(mc, - rc = mdb_cursor_put(&mc, &key, &data, F_SUBDATA)); + rc = _mdb_cursor_put(&mc, &key, &data, F_SUBDATA)); dbflag |= DB_DIRTY; } @@ -9892,6 +9964,7 @@ int mdb_dbi_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *db if (!unused) { txn->mt_numdbs++; } + MDB_TRACE(("%p, %s, %u = %u", txn, name, flags, slot)); } return rc; @@ -9923,6 +9996,7 @@ void mdb_dbi_close(MDB_env *env, MDB_dbi dbi) ptr = env->me_dbxs[dbi].md_name.mv_data; /* If there was no name, this was already closed */ if (ptr) { + MDB_TRACE(("%p, %u", env, dbi)); env->me_dbxs[dbi].md_name.mv_data = NULL; env->me_dbxs[dbi].md_name.mv_size = 0; env->me_dbflags[dbi] = 0; @@ -10057,6 +10131,7 @@ int mdb_drop(MDB_txn *txn, MDB_dbi dbi, int del) if (rc) return rc; + MDB_TRACE(("%u, %d", dbi, del)); rc = mdb_drop0(mc, mc->mc_db->md_flags & MDB_DUPSORT); /* Invalidate the dropped DB's cursors */ for (m2 = txn->mt_cursors[dbi]; m2; m2 = m2->mc_next) diff --git a/contrib/libs/openldap/libraries/liblmdb/midl.h b/contrib/libs/openldap/libraries/liblmdb/midl.h index 2075206bd5..ff740aee82 100644 --- a/contrib/libs/openldap/libraries/liblmdb/midl.h +++ b/contrib/libs/openldap/libraries/liblmdb/midl.h @@ -56,7 +56,9 @@ typedef MDB_ID *MDB_IDL; /* IDL sizes - likely should be even bigger * limiting factors: sizeof(ID), thread stack size */ +#ifndef MDB_IDL_LOGN #define MDB_IDL_LOGN 16 /* DB_SIZE is 2^16, UM_SIZE is 2^17 */ +#endif #define MDB_IDL_DB_SIZE (1<<MDB_IDL_LOGN) #define MDB_IDL_UM_SIZE (1<<(MDB_IDL_LOGN+1)) diff --git a/contrib/libs/openldap/ya.make b/contrib/libs/openldap/ya.make index 11e8379f48..d1d7f31660 100644 --- a/contrib/libs/openldap/ya.make +++ b/contrib/libs/openldap/ya.make @@ -14,9 +14,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(2.6.6) +VERSION(2.6.7) -ORIGINAL_SOURCE(https://gitlab.com/api/v4/projects/openldap%2Fopenldap/repository/archive.tar.gz?sha=OPENLDAP_REL_ENG_2_6_6) +ORIGINAL_SOURCE(https://gitlab.com/api/v4/projects/openldap%2Fopenldap/repository/archive.tar.gz?sha=OPENLDAP_REL_ENG_2_6_7) PEERDIR( contrib/libs/openldap/libraries/liblber |