How to install GSSAPI Python module?

38.3k views Asked by At

I am trying to install the GSSAPI module through pip but I receive this error that I don't know how to resolve.

Could not find main GSSAPI shared library. Please try setting GSSAPI_MAIN_LIB yourself or setting ENABLE_SUPPORT_DETECTION to 'false'

I need this to work on Python 2.6 for LDAP3 authentication.

3

There are 3 answers

4
Dave On BEST ANSWER

Summary, for the impatient

$ sudo ln -s /usr/bin/krb5-config.mit /usr/bin/krb5-config
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 /usr/lib/libgssapi_krb5.so
$ sudo apt-get install python-pip libkrb5-dev
$ sudo pip install gssapi

And now the details...

I have a Debian system that uses Heimdal Kerberos. I'll take you through what I had to do to get it working for me. Hopefully, this can help someone else as well.


Problem 1 - krb5-config: command not found

setup.py for gssapi uses the krb5-config command to find the GSSAPI library to link against (see here). Because my system was installed using Heimdal instead of MIT Kerberos, the executable command has been renamed to krb5-config.mit so setup.py misses it.

$ krb5-config --libs gssapi  # doesn't work
bash: krb5-config: command not found

I created a symlink to get it to work for the install:

$ sudo ln -s /usr/bin/krb5-config.mit /usr/bin/krb5-config
$ krb5-config --libs gssapi  # does work
-L/usr/lib/x86_64-linux-gnu/mit-krb5 -Wl,-z,relro -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err

Problem 2 - libgssapi_krb5.so: cannot open shared object file: No such file or directory

setup.py is looking in /usr/lib for the gssapi library to link against. In Debian Jesse, most libs are now kept in /usr/lib/x86_64-linux-gnu. Again, a symlink can fix this:

$ sudo ln -s /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 /usr/lib/libgssapi_krb5.so

Problem 3 - error: unknown type name ‘gss_key_value_set_desc’

The build fails because it does not recognize a symbol in the library. The reason for this is that it was not able to get the right header file. Silly me, I forgot to include the -dev package for krb5 headers. Fix this with apt-get:

$ sudo apt-get install libkrb5-dev

Finally - Install gssapi

Now we should be all ready to go.

$ sudo pip install gssapi

If you want to tidy up, you can remove the symlink to the krb5-config.mit command:

$ sudo rm /usr/bin/krb5-config
1
Vijayanand On

For me, the issue got resolved after installing the package "krb5-libs" in Centos. Basically we need to have libgssapi_krb5.so file for installing gssapi.

1
Jens Timmerman On

sudo apt install libkrb5-dev actually installs /usr/bin/krb5-config and /usr/lib/libgssapi_krb5.so

so none of the symlinking was needed, just install libkrb5-dev and you should be good.