Skip to content
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

ipa-kdb: support KDB DAL version 6.1 #410

Closed
wants to merge 1 commit into from

Conversation

abbra
Copy link
Contributor

@abbra abbra commented Jan 24, 2017

DAL version 6.0 removed support for a callback to free principal.
This broke KDB drivers which had complex e_data structure within
the principal structure. As result, FreeIPA KDB driver was leaking
memory with DAL version 6.0 (krb5 1.15).

DAL version 6.1 added a special callback for freeing e_data structure.
See details at krb5/krb5#596

Restructure KDB driver code to provide this callback in case
we are built against DAL version that supports it. For DAL version
prior to 6.0 use this callback in the free_principal callback to
tidy the code.

https://fedorahosted.org/freeipa/ticket/6619

On Fedora the required interface is available in krb5-1.15-5.fc26 package.

@sumit-bose
Copy link
Contributor

Are there any plans how to handle 6.0? Should configure at least show a warning if KRB5_KDB_DAL_MAJOR_VERSION == 6 but no free e_data callback was found?

Should the .min_ver in the kdb_function_table be set to '1' if there is a free e_data callback?

@abbra
Copy link
Contributor Author

abbra commented Jan 24, 2017

Thanks for the suggestions. I've updated the configure check to explicitly warn when both .free_principal and .free_principal_e_data are missing. DAL version 5 had .free_principal and we do not support any other DAL versions yet, so this should be enough.

I also merged definitions of the kdb_function_table for both DAL versions by adding corresponding initializers in the right places wrapped with the #ifdef-s. I think it will be better than the current duplication, considering we need to support three different API variations.

@simo5
Copy link
Contributor

simo5 commented Jan 24, 2017

abbra, we should also change how spec deps work
I asked @RHarwood to add a provides that is the dal version number
we should stop having a dep on the krb5 major version number and instead have a dependecy on this provide

@simo5
Copy link
Contributor

simo5 commented Jan 24, 2017

Also I know you can use ifdefs to avoid copy&pasting large parts of the structure initialization but I would prefer 3 separate full inits based only on ifdefs on the DAL version numbers.
in pseudo:
if v5:
vtable = { ... }
elif v6.0:
vtable = { ... }
elid v6.1:
vtable = { ... }
else:
error!

Those tables cannot change so using ifdefs in them can only risk to introduce bugs in one of the versions rather than help reduce code duplication.

@abbra
Copy link
Contributor Author

abbra commented Jan 24, 2017

@simo5 spec dependencies are separate from the code -- the spec will not help on Debian, for example.
We need both the spec dependencies and the proper checks in the code.

@simo5
Copy link
Contributor

simo5 commented Jan 24, 2017

Doesn't kdb.h also export a MINOR version to test against ?

@simo5
Copy link
Contributor

simo5 commented Jan 24, 2017

I checked and can't find it ... facepalm

@abbra
Copy link
Contributor Author

abbra commented Jan 24, 2017

No, no minor DAL version. That's why I had to resort to structure member checks in autoconf.

@frozencemetery
Copy link
Contributor

There was talk of exporting a minor dal version but I think upstream explicitly doesn't want it.

freeipa.spec.in should be modified if I understand correctly; otherwise this looks good.

@abbra
Copy link
Contributor Author

abbra commented Feb 6, 2017

I split the tables into separate ones and also made independent #if/#endif blocks for them. Finally, I added a spec file guard to force using 1.15-5 or later version on Fedora 26 or later.

Copy link
Contributor

@simo5 simo5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to use the provide added to the Fedora spec file, otherwise LGTM

freeipa.spec.in Outdated
@@ -57,8 +57,12 @@ Source0: freeipa-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires: openldap-devel
%if 0%{?fedora} > 25
BuildRequires: krb5-devel >= 1.15-5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frozencemetery introduced a provides that expicitly marks DAL versions, can we use that provide instead of a version number ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Field is named krb5-kdb-version, and 1.15.5 sets it to 6.1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simo5 @frozencemetery unfortunately, the provide of "krb5-kdb-version = 6.1" is on krb5-libs, not on krb5-devel, so I cannot do a buildrequires dependency this way.

@abbra
Copy link
Contributor Author

abbra commented Feb 7, 2017

@simo5 @frozencemetery unfortunately, the provide of "krb5-kdb-version = 6.1" is on krb5-libs, not on krb5-devel, so I cannot do a buildrequires dependency this way.

@simo5
Copy link
Contributor

simo5 commented Feb 7, 2017

@frozencemetery Should we provide krb5-kdb-version-devel from krb5-devel ?

@frozencemetery
Copy link
Contributor

frozencemetery commented Feb 7, 2017

@simo5 @abbra I'll move it over, but it won't break anything to pull in krb5-devel and krb5-kdb-version as far as I can tell since you're getting krb5-libs pulled in anyway.

@abbra abbra force-pushed the krb5-1-15-DAL-changes branch 2 times, most recently from 1d1fcf7 to a08f150 Compare February 7, 2017 19:09
@abbra
Copy link
Contributor Author

abbra commented Feb 7, 2017

Updated the spec file and the commit message.

Copy link
Contributor

@frozencemetery frozencemetery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, you're faster than the fedora builders. krb5-1.15-6 has it as part of krb5-devel.

# DAL version change may cause code crash or memory leaks, it is better to fail early.
%if 0%{?fedora} > 25
BuildRequires: krb5-devel >= 1.15-5
BuildRequires: krb5-kdb-version = 6.1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we add this to Requires ad well ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. krb5-kdb-version is in krb5-devel now, requiring krb5-devel to installed system is not needed. However, when building the package we'll get krb5 >= 1.15-5 due to 'krb5-kdb-version = 6.1' BuildRequire and, as result, Requires(post): krb5-server >= %{krb5_base_version} will be set which will force use of 1.15.

Granted, this could be not enough but released version of F26 will have krb5-server 1.15-6 or later, so I think it is OK.

DAL version 6.0 removed support for a callback to free principal.
This broke KDB drivers which had complex e_data structure within
the principal structure. As result, FreeIPA KDB driver was leaking
memory with DAL version 6.0 (krb5 1.15).

DAL version 6.1 added a special callback for freeing e_data structure.
See details at krb5/krb5#596

Restructure KDB driver code to provide this callback in case
we are built against DAL version that supports it. For DAL version
prior to 6.0 use this callback in the free_principal callback to
tidy the code.

Use explicit KDB version dependency in Fedora 26+ via BuildRequires.

With new DAL version, freeipa package will fail to build and
we'll have to add a support for new DAL version explicitly.

https://fedorahosted.org/freeipa/ticket/6619
@abbra
Copy link
Contributor Author

abbra commented Feb 13, 2017

I've rebased against master and added responses to inline comments in the PR.

Copy link
Contributor

@simo5 simo5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@simo5 simo5 added the ack Pull Request approved, can be merged label Feb 14, 2017
@MartinBasti MartinBasti added the pushed Pull Request has already been pushed label Feb 15, 2017
@MartinBasti
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Pull Request approved, can be merged pushed Pull Request has already been pushed
Projects
None yet
5 participants