rjancewicz / python-kadmin

Python module for kerberos admin (kadm5)
MIT License
35 stars 40 forks source link

Compile fails on Fedora 22 #37

Open ghost opened 9 years ago

ghost commented 9 years ago

Hello,

Great project, I've been looking for something like this for a long time.

Unfortunately, compiling fails on Fedora 22 with this:

    src/PyKAdminObject.c:365:16: error: too few arguments to function ‘krb5_db_iterate’
             code = krb5_db_iterate(self->context, match, kdb_iter_princs, (void *)self);

The /usr/include/kdb.h in krb5-devel-1.13.2-3 (the version that comes with Fedora 22) defines krb5_db_iterate as:

krb5_error_code krb5_db_iterate ( krb5_context kcontext,                        
                                  char *match_entry,                            
                                  int (*func) (krb5_pointer, krb5_db_entry *),  
                                  krb5_pointer func_arg, krb5_flags iterflags );

I assume that this was an API break that happened at a major version (not sure which one). In kdb.h, there is a #define KRB5_KDB_API_VERSION 8, so it should be fixable with something like:

#if KRB5_KDB_API_VERSION > [whatever]
// call with 5 arguments
#else
// call with 4 arguments
#endif

Unfortunately, I don't know exactly which version that change was made at.

ghost commented 9 years ago

Upon further investigation, RHEL7's libkrb5-devel uses #define KRB5_KDB_API_VERSION 7, and has the 4 argument version of krb5_db_iterate. So, the pre-processor conditional should look like:

#if (KRB5_KDB_API_VERSION > 7)
// call krb5_db_iterate with 5 arguments
#else
// call krb5_db_iterate with 4 arguments
#endif
michaelweiser commented 8 years ago

Just ran into the same thing. Here's the commit, confirming that

https://github.com/krb5/krb5/commit/ab009b8568d9b64b7e992ecdb98114e895b4a7ff