Skip to content

Handle GSS_C_NO_OID_SET when creating sets #150

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

Merged
merged 2 commits into from
Mar 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .travis/lib-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ setup::debian::install() {
if [ x"$KRB5_VER" = "xheimdal" ]; then
apt-get -y install heimdal-dev
else
apt-get -y install krb5-{user,kdc,admin-server,multidev} libkrb5-dev
apt-get -y install krb5-{user,kdc,admin-server,multidev} libkrb5-dev \
gss-ntlmssp
fi

apt-get -y install gcc virtualenv python$IS3-{virtualenv,dev} cython$IS3
Expand Down Expand Up @@ -55,7 +56,8 @@ setup::fedora::install() {
}

setup::rh::install() {
setup::rh::yuminst krb5-{devel,libs,server,workstation} which gcc findutils
setup::rh::yuminst krb5-{devel,libs,server,workstation} \
which gcc findutils gssntlmssp

if [ -f /etc/fedora-release ]; then
setup::fedora::install
Expand Down
7 changes: 7 additions & 0 deletions gssapi/raw/cython_converters.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ cdef gss_OID_set c_get_mech_oid_set(object mechs):
cdef object c_create_oid_set(gss_OID_set mech_set, bint free=True):
"""Convert a GSS OID set struct to a set of OIDs"""

if mech_set == GSS_C_NO_OID_SET:
# return the empty set if the we get passed the C equivalent
# (it could be argued that the C equivalent is closer to None,
# but returning None would make the API harder to work with,
# without much value)
return set()

Copy link
Contributor

Choose a reason for hiding this comment

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

If we ever need the distinction we may need to make an incompatible API change and start returning None, is that ok ?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, but we'll have to rev the major version. I'm curious as to what that situation might be -- you're not using this to detect errors (we have errors for that), so fundamentally, what's the difference here between "a set with no items", and "no set" from the user perspective.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

py_set = set()
cdef i
for i in range(mech_set.count):
Expand Down
4 changes: 0 additions & 4 deletions gssapi/tests/test_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,8 @@ def test_rfc5587(self):
known_mech_attrs = inquire_out.known_mech_attrs

mech_attrs.should_be_a(set)
mech_attrs.shouldnt_be_empty()

known_mech_attrs.should_be_a(set)
known_mech_attrs.shouldnt_be_empty()

# Verify that we get data for every available
# attribute. Testing the contents of a few known
Expand Down Expand Up @@ -749,12 +747,10 @@ def test_sasl_names(self):
out_mn = out.mech_name
out_mn.shouldnt_be_none()
out_mn.should_be_a(bytes)
out_mn.shouldnt_be_empty()

out_md = out.mech_description
out_md.shouldnt_be_none()
out_md.should_be_a(bytes)
out_md.shouldnt_be_empty()

cmp_mech = gb.inquire_mech_for_saslname(out_smn)
cmp_mech.shouldnt_be_none()
Expand Down