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

Python winkerberos #4746

Merged
merged 2 commits into from
Dec 5, 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
111 changes: 111 additions & 0 deletions mingw-w64-python-winkerberos/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Maintainer: J. Peter Mugaas <[email protected]>

_realname=winkerberos
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=0.7.0
pkgrel=1
pkgdesc="High level interface to SSPI for Kerberos client auth (mingw-w64)"
arch=('any')
url='https://github.com/mongodb-labs/winkerbero'
license=('Apache')
makedepends=("${MINGW_PACKAGE_PREFIX}-python2"
"${MINGW_PACKAGE_PREFIX}-python3"
"${MINGW_PACKAGE_PREFIX}-python2-sphinx"
"${MINGW_PACKAGE_PREFIX}-python3-sphinx"
"${MINGW_PACKAGE_PREFIX}-python2-setuptools"
"${MINGW_PACKAGE_PREFIX}-python3-setuptools")
#checkdepends=("${MINGW_PACKAGE_PREFIX}-python2-pymongo"
# "${MINGW_PACKAGE_PREFIX}-python3-pymongo")
options=('staticlibs' 'strip' '!debug')
_dtoken="85/b2/c5a66595bb477f1939596d80fa308e357c28abe22d3d6ce6cc2208c324ee"
source=("https://files.pythonhosted.org/packages/${_dtoken}/winkerberos-0.7.0.zip"
mingw-fixes.patch)
sha256sums=('e304c28de838a48206edfe58b8deb5209a3fd8c6a755bd521c1ee6e656b06e27'
'2a3fe6e90b8ab3ead000e831878e089880d4402a7df7bca8e8615666b78b090d')

# Helper macros to help make tasks easier #
apply_patch_with_msg() {
for _patch in "$@"
do
msg2 "Applying $_patch"
patch -Nbp1 -i "${srcdir}/$_patch"
done
}

del_file_exists() {
for _fname in "$@"
do
if [ -f $_fname ]; then
rm -rf $_fname
fi
done
}
# =========================================== #

prepare() {
cd "${srcdir}"
pushd "${_realname}-${pkgver}"
apply_patch_with_msg mingw-fixes.patch
popd
for builddir in python{2,3}-build-${CARCH}; do
rm -rf ${builddir} | true
cp -r "${_realname}-${pkgver}" "${builddir}"
done
# Set version for setuptools_scm
export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
}

build() {
for pver in {2,3}; do
msg "Python ${pver} build for ${CARCH}"
cd "${srcdir}/python${pver}-build-${CARCH}"
${MINGW_PREFIX}/bin/python${pver} setup.py build
done
}

#check() {
# for pver in {2,3}; do
# msg "Python ${pver} test for ${CARCH}"
# cd "${srcdir}/python${pver}-build-${CARCH}"
# ${MINGW_PREFIX}/bin/python${pver} setup.py test
# done
#}

package_python3-winkerberos() {
depends=("${MINGW_PACKAGE_PREFIX}-python3")

cd "${srcdir}/python3-build-${CARCH}"
MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} \
--root="${pkgdir}" --optimize=1 --skip-build

install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE"
}

package_python2-winkerberos() {
depends=("${MINGW_PACKAGE_PREFIX}-python2")

cd "${srcdir}/python2-build-${CARCH}"
MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
--root="${pkgdir}" --optimize=1 --skip-build

install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE"
}

package_mingw-w64-i686-python2-winkerberos() {
package_python2-winkerberos
}

package_mingw-w64-i686-python3-winkerberos() {
package_python3-winkerberos
}

package_mingw-w64-x86_64-python2-winkerberos() {
package_python2-winkerberos
}

package_mingw-w64-x86_64-python3-winkerberos() {
package_python3-winkerberos
}
48 changes: 48 additions & 0 deletions mingw-w64-python-winkerberos/mingw-fixes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--- winkerberos-0.7.0/setup.py.orig 2018-12-04 04:08:15.913271100 -0500
+++ winkerberos-0.7.0/setup.py 2018-12-04 04:09:06.008470300 -0500
@@ -82,6 +82,16 @@ if sys.version_info[:2] == (2, 6):
else:
test_suite = "test"

+if 'GCC' in sys.version:
+ _extra_link_args = ['-lcrypt32',
+ '-lsecur32',
+ '-lShlwapi']
+else:
+ _extra_link_args = ['crypt32.lib',
+ 'secur32.lib',
+ 'Shlwapi.lib',
+ '/NXCOMPAT',
+ '/DYNAMICBASE']
setup(
name="winkerberos",
version="0.7.0",
@@ -114,11 +124,7 @@ setup(
ext_modules = [
Extension(
"winkerberos",
- extra_link_args=['crypt32.lib',
- 'secur32.lib',
- 'Shlwapi.lib',
- '/NXCOMPAT',
- '/DYNAMICBASE'],
+ extra_link_args=_extra_link_args,
sources = [
"src/winkerberos.c",
"src/kerberos_sspi.c"
--- winkerberos-0.7.0/src/kerberos_sspi.h.orig 2018-12-04 04:37:07.485511200 -0500
+++ winkerberos-0.7.0/src/kerberos_sspi.h 2018-12-04 04:38:53.197331100 -0500
@@ -39,6 +39,13 @@ typedef struct {
ULONG qop;
} sspi_client_state;

+#ifdef __MINGW32__
+typedef struct _SecPkgContext_Bindings {
+ unsigned long BindingsLength;
+ SEC_CHANNEL_BINDINGS *Bindings;
+} SecPkgContext_Bindings, *PSecPkgContext_Bindings;
+#endif
+
VOID set_gsserror(DWORD errCode, const SEC_CHAR* msg);
VOID destroy_sspi_client_state(sspi_client_state* state);
INT auth_sspi_client_init(WCHAR* service,