How to install gssapi python module?

G3tinmybelly picture G3tinmybelly · Jun 17, 2015 · Viewed 12.8k times · Source

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.

Answer

Dave picture Dave · Jun 19, 2015

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