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

Fix freebsd #232

Merged
merged 3 commits into from
Nov 19, 2020
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: 5 additions & 1 deletion gssapi/raw/types.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ class RequirementFlag(IntEnum, metaclass=ExtendableEnum):
anonymity = GSS_C_ANON_FLAG
protection_ready = GSS_C_PROT_READY_FLAG
transferable = GSS_C_TRANS_FLAG
ok_as_delegate = GSS_C_DELEG_POLICY_FLAG

# GSS_C_DELEG_POLICY_FLAG. cython can't do compile-time detection of
# this, so take the value from RFC 5896. Implementations that don't
# support it will ignore it.
ok_as_delegate = 32768


class AddressType(IntEnum, metaclass=ExtendableEnum):
Expand Down
32 changes: 29 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def get_output(*args, **kwargs):


# get the compile and link args
kc = "krb5-config"
posix = os.name != 'nt'
link_args, compile_args = [
shlex.split(os.environ[e], posix=posix) if e in os.environ else None
Expand Down Expand Up @@ -71,6 +72,26 @@ def get_output(*args, **kwargs):
except ValueError:
cygwinccompiler.get_msvcr = lambda *a, **kw: []

if sys.platform.startswith("freebsd"):
# FreeBSD does $PATH backward, for our purposes. That is, the package
# manager's version of the software is in /usr/local, which is in PATH
# *after* the version in /usr. We prefer the package manager's version
# because the Heimdal in base is truly ancient, but this can be overridden
# - either in the "normal" fashion by putting something in PATH in front
# of it, or by removing /usr/local from PATH.

bins = []
for b in os.environ["PATH"].split(":"):
p = f"{b}/krb5-config"
if not os.path.exists(p):
continue
bins.append(p)

if len(bins) > 1 and bins[0] == "/usr/bin/krb5-config" and \
"/usr/local/bin/krb5-config" in bins:
kc = "/usr/local/bin/krb5-config"
print(f"Detected: {kc}")

if link_args is None:
if osx_has_gss_framework:
link_args = ['-framework', 'GSS']
Expand All @@ -85,7 +106,7 @@ def get_output(*args, **kwargs):
elif os.environ.get('MINGW_PREFIX'):
link_args = ['-lgss']
else:
link_args = shlex.split(get_output('krb5-config --libs gssapi'))
link_args = shlex.split(get_output(f"{kc} --libs gssapi"))

if compile_args is None:
if osx_has_gss_framework:
Expand All @@ -98,14 +119,14 @@ def get_output(*args, **kwargs):
elif os.environ.get('MINGW_PREFIX'):
compile_args = ['-fPIC']
else:
compile_args = shlex.split(get_output('krb5-config --cflags gssapi'))
compile_args = shlex.split(get_output(f"{kc} --cflags gssapi"))

# add in the extra workarounds for different include structures
if winkrb_path:
prefix = winkrb_path
else:
try:
prefix = get_output('krb5-config gssapi --prefix')
prefix = get_output(f"{kc} gssapi --prefix")
except Exception:
print("WARNING: couldn't find krb5-config; assuming prefix of %s"
% str(sys.prefix))
Expand Down Expand Up @@ -165,6 +186,11 @@ def get_output(*args, **kwargs):
# To support Heimdal on Debian, read the linker path.
if opt.startswith('-Wl,/'):
main_path = opt[4:] + "/"
if main_path == "":
for d in library_dirs:
if os.path.exists(os.path.join(d, main_lib)):
main_path = d
break

if main_lib is None:
raise Exception("Could not find main GSSAPI shared library. Please "
Expand Down