inejge / ldap3

A pure-Rust LDAP library using the Tokio stack
Apache License 2.0
220 stars 38 forks source link

Regression in Windows functionality #127

Closed jschpp closed 2 months ago

jschpp commented 3 months ago

Between version 0.11.3 and 0.11.4 the added libgssapi seems to break the build under windows.

0.11.3 ```plain > cat .\Cargo.toml [package] name = "laps-rs" version = "0.1.0" edition = "2021" [dependencies] chrono = { version = "0.4.38", features = ["serde"] } ldap3 = { version = "=0.11.3", features = ["gssapi", "tls", "sync"] } rstest = "0.19.0" serde = { version = "1.0.201", features = ["derive"] } serde_json = "1.0.117" thiserror = "1.0.60" tracing = "0.1.40" tracing-subscriber = "0.3.18" windows-sys = { version = "0.52.0", features = [ "Win32_Security", "Win32_Foundation", ] } > cargo clean Removed 1608 files, 632.1MiB total > cargo build Blocking waiting for file lock on build directory Compiling pin-project-lite v0.2.14 Compiling futures-core v0.3.30 Compiling bytes v1.6.0 Compiling memchr v2.7.2 Compiling futures-sink v0.3.30 Compiling pin-utils v0.1.0 Compiling futures-task v0.3.30 Compiling windows_x86_64_msvc v0.52.5 Compiling windows_x86_64_msvc v0.48.5 Compiling slab v0.4.9 Compiling once_cell v1.19.0 Compiling tinyvec_macros v0.1.1 Compiling windows-targets v0.52.5 Compiling windows-targets v0.48.5 Compiling futures-channel v0.3.30 Compiling futures-io v0.3.30 Compiling tinyvec v1.6.0 Compiling cfg-if v1.0.0 Compiling windows-sys v0.52.0 Compiling windows-sys v0.48.0 Compiling windows_x86_64_msvc v0.34.0 Compiling tracing-core v0.1.32 Compiling lazy_static v1.4.0 Compiling unicode-bidi v0.3.15 Compiling percent-encoding v2.3.1 Compiling log v0.4.21 Compiling minimal-lexical v0.2.1 Compiling windows v0.34.0 Compiling serde v1.0.201 Compiling futures-util v0.3.30 Compiling nom v7.1.3 Compiling form_urlencoded v1.2.1 Compiling winapi v0.3.9 Compiling anyhow v1.0.83 Compiling unicode-normalization v0.1.23 Compiling bitflags v1.3.2 Compiling overload v0.1.1 Compiling rstest_macros v0.19.0 Compiling thiserror v1.0.60 Compiling tracing-log v0.2.0 Compiling idna v0.5.0 Compiling num-traits v0.2.19 Compiling sharded-slab v0.1.7 Compiling thread_local v1.1.8 Compiling nu-ansi-term v0.46.0 Compiling url v2.5.0 Compiling mio v0.8.11 Compiling lber v0.4.2 Compiling futures-timer v3.0.3 Compiling smallvec v1.13.2 Compiling itoa v1.0.11 Compiling ryu v1.0.18 Compiling tracing v0.1.40 Compiling tracing-subscriber v0.3.18 Compiling serde_json v1.0.117 Compiling futures-executor v0.3.30 Compiling chrono v0.4.38 Compiling futures v0.3.30 Compiling rstest v0.19.0 Compiling socket2 v0.5.7 Compiling schannel v0.1.23 Compiling tokio v1.37.0 Compiling native-tls v0.2.11 Compiling tokio-stream v0.1.15 Compiling tokio-native-tls v0.3.1 Compiling tokio-util v0.7.11 Compiling cross-krb5 v0.3.0 Compiling ldap3 v0.11.3 Compiling laps-rs v0.1.0 (G:\laps) Finished `dev` profile [unoptimized + debuginfo] target(s) in 32.78s ```
0.11.4 ```plain > cat .\Cargo.toml [package] name = "laps-rs" version = "0.1.0" edition = "2021" [dependencies] chrono = { version = "0.4.38", features = ["serde"] } ldap3 = { version = "=0.11.4", features = ["gssapi", "tls", "sync"] } rstest = "0.19.0" serde = { version = "1.0.201", features = ["derive"] } serde_json = "1.0.117" thiserror = "1.0.60" tracing = "0.1.40" tracing-subscriber = "0.3.18" windows-sys = { version = "0.52.0", features = [ "Win32_Security", "Win32_Foundation", ] } > cargo clean Removed 1634 files, 627.1MiB total > cargo build Blocking waiting for file lock on build directory Compiling once_cell v1.19.0 Compiling pin-project-lite v0.2.14 Compiling minimal-lexical v0.2.1 Compiling windows_x86_64_msvc v0.52.5 Compiling windows_x86_64_msvc v0.48.5 Compiling bytes v1.6.0 Compiling futures-core v0.3.30 Compiling lazy_static v1.4.0 Compiling memchr v2.7.2 Compiling futures-sink v0.3.30 Compiling slab v0.4.9 Compiling futures-task v0.3.30 Compiling windows-targets v0.52.5 Compiling windows-targets v0.48.5 Compiling windows-sys v0.52.0 Compiling libloading v0.8.3 Compiling windows-sys v0.48.0 Compiling futures-channel v0.3.30 Compiling futures-io v0.3.30 Compiling tinyvec_macros v0.1.1 Compiling pin-utils v0.1.0 Compiling nom v7.1.3 Compiling clang-sys v1.7.0 Compiling tinyvec v1.6.0 Compiling cfg-if v1.0.0 Compiling tracing-core v0.1.32 Compiling windows-core v0.52.0 Compiling percent-encoding v2.3.1 Compiling futures-util v0.3.30 Compiling bitflags v2.5.0 Compiling log v0.4.21 Compiling unicode-bidi v0.3.15 Compiling windows v0.52.0 Compiling unicode-normalization v0.1.23 Compiling form_urlencoded v1.2.1 Compiling serde v1.0.201 Compiling cexpr v0.6.0 Compiling idna v0.5.0 Compiling winapi v0.3.9 Compiling mio v0.8.11 Compiling errno v0.3.9 Compiling home v0.5.9 Compiling rustix v0.38.34 Compiling anyhow v1.0.83 Compiling which v4.4.2 Compiling overload v0.1.1 Compiling rstest_macros v0.19.0 Compiling bindgen v0.69.4 Compiling futures-executor v0.3.30 Compiling thiserror v1.0.60 Compiling futures v0.3.30 Compiling lber v0.4.2 Compiling nu-ansi-term v0.46.0 Compiling url v2.5.0 Compiling num-traits v0.2.19 Compiling tracing-log v0.2.0 Compiling thread_local v1.1.8 Compiling sharded-slab v0.1.7 Compiling smallvec v1.13.2 Compiling futures-timer v3.0.3 Compiling ryu v1.0.18 Compiling itoa v1.0.11 Compiling socket2 v0.5.7 Compiling schannel v0.1.23 Compiling serde_json v1.0.117 Compiling chrono v0.4.38 Compiling tokio v1.37.0 Compiling native-tls v0.2.11 Compiling tracing-subscriber v0.3.18 Compiling tracing v0.1.40 Compiling rstest v0.19.0 Compiling libgssapi-sys v0.3.1 Compiling cross-krb5 v0.4.0 Compiling tokio-util v0.7.11 Compiling tokio-stream v0.1.15 Compiling tokio-native-tls v0.3.1 error: failed to run custom build command for `libgssapi-sys v0.3.1` Caused by: process didn't exit successfully: `G:\laps\target\debug\build\libgssapi-sys-074d95fda8379567\build-script-build` (exit code: 101) --- stdout cargo:rerun-if-env-changed=MIT_KRB5_GSSAPI_NO_PKG_CONFIG cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG cargo:rerun-if-env-changed=PKG_CONFIG cargo:rerun-if-env-changed=MIT_KRB5_GSSAPI_STATIC cargo:rerun-if-env-changed=MIT_KRB5_GSSAPI_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=MIT_KRB5_GSSAPI_STATIC cargo:rerun-if-env-changed=MIT_KRB5_GSSAPI_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=HEIMDAL_GSSAPI_NO_PKG_CONFIG cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG cargo:rerun-if-env-changed=PKG_CONFIG cargo:rerun-if-env-changed=HEIMDAL_GSSAPI_STATIC cargo:rerun-if-env-changed=HEIMDAL_GSSAPI_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=HEIMDAL_GSSAPI_STATIC cargo:rerun-if-env-changed=HEIMDAL_GSSAPI_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR --- stderr thread 'main' panicked at C:\Users\jscho\.cargo\registry\src\index.crates.io-6f17d22bba15001f\libgssapi-sys-0.3.1\build.rs:41:9: use SSPI on windows note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace warning: build failed, waiting for other jobs to finish... ```

I think the current version differs here: https://github.com/inejge/ldap3/blob/4ba12397bc49e83dfe0400bed3df5578f14eec15/Cargo.toml#L48-L49

from the published version grafik

Not sure why this breaks though 🤷

inejge commented 3 months ago

The published version differs because a) it doesn't have any NTLM support, which is WIP on the master branch, b) it tries to force the version of libgssapi(0.7.1+) which has the fix for the runtime panic when the crate is compiled with Rust 1.78+. It's the latter which breaks the Windows build, since libgssapi is not needed there.

Unfortunately, I'm not sure that a satisfactory cross-platform fix is possible with the crate versions as they are at the moment. You can continue pinning the version to 0.11.3 for Windows builds, and I'll submit a PR for cross-krb5 that ought to resolve the problem.

I won't have access to my Windows testing system for the rest of the week, so I can't test any changes, but if you're comfortable with directly editing the files in the package cache, you can try replacing

gssapi = ["cross-krb5", "libgssapi"]

with

gssapi = ["cross-krb5", "libgssapi?/iov"]

in ldap3-0.11.4's Cargo.toml, doing cargo clean, and recompiling your project. It's a rather gross hack, but maybe it works.

jschpp commented 3 months ago

Ok. I see where the problem is now.

I think it would be preferable to handle the problem with the runtime panic by importing the libgssapi only in the case of compiling for unix while sitll keeping the old behaviour for windows builds, since those don't use libgssapi anyway.

I think the cleanest solution is getting cross-krb5 to up the dependencies.

For the moment I'll simply keep 0.11.3 pinned. Since the lib I'm building needs to be deployed to prod sometime soonish i'll keep away from manual editing the cache^^

inejge commented 3 months ago

@jschpp Could you try using revision b3683893852c94eb8a19bfbad5f17f7bcfbe92e2 as the dependency for your build? I managed a quick test of the hack mentioned in my previous reply, and it worked; I would like an independent confirmation before publishing it in the next patch version.

jschpp commented 3 months ago

LGTM grafik It builds without error 👍

inejge commented 3 months ago

Great! I'll publish the fix as 0.11.5 shortly.

inejge commented 2 months ago

Published. Closing this issue, but I'll nevertheless try proposing the fix for cross-krb5.

jschpp commented 2 months ago

Published. Closing this issue, but I'll nevertheless try proposing the fix for cross-krb5.

I misread your comment 😅 and opened an issue already. https://github.com/estokes/cross-krb5/issues/11