Skip to content

Fix dynamic GSSAPI lib path detection on macOS for kerberos #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

VikasShavi
Copy link

@VikasShavi VikasShavi commented Mar 9, 2025

Description

This PR fixes an issue where the GSSAPI library path for kerberos auth was hardcoded to /usr/lib/libgssapi_krb5.dylib on macOS in lib_gssapi_loader.rb.
This caused failures when GSSAPI was installed via Homebrew, as the actual path differs or does not come by default.

Issue

When using the GSSAPI library for Kerberos authentication with WinRM, authentication fails due to the hardcoded libgssapi_krb5.dylib path.
The error occurs because users with Homebrew-installed Kerberos have the library in /opt/homebrew/Cellar/krb5/....

Error Screenshot

errorbundle

errorproxychains

Fix

  • Instead of a hardcoded path in lib_gssapi_loader.rb, this PR dynamically detects the correct GSSAPI library location:
    • Uses brew --prefix to find the Homebrew installation directory.
    • Falls back to /usr/lib/ if Homebrew is not installed.
  • This ensures compatibility across both system-installed and Homebrew-installed Kerberos libraries.
when /darwin/
  brew_lib = `brew --prefix krb5 2>/dev/null`.chomp
  gssapi_lib = File.exist?("#{brew_lib}/lib/libgssapi_krb5.dylib") ? "#{brew_lib}/lib/libgssapi_krb5.dylib" : '/usr/lib/libgssapi_krb5.dylib'
  ffi_lib gssapi_lib, FFI::Library::LIBC

After fixing code

successbundle

successproxychains

Why This Fix is Needed

  • Recent macOS versions do not include libgssapi_krb5.dylib by default.
  • Users installing Kerberos via Homebrew (krb5 package) have libgssapi_krb5.dylib in /opt/homebrew/Cellar/....
  • The previous hardcoded path caused FFI::Library::ffi_lib to fail, making GSSAPI unusable.
  • This fix allows the library to work seamlessly on macOS regardless of installation method.

Notes for Users

📌 If you are on macOS and do not have libgssapi_krb5.dylib, install it using:

brew install krb5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant