Skip to content

Commit

Permalink
Merge pull request #120 from isi-mfurer/krb-py2
Browse files Browse the repository at this point in the history
pykerb support for py2.7 and py3.10
  • Loading branch information
isi-mfurer committed Jul 7, 2022
2 parents 0399f02 + c9883a6 commit 4f9dd44
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
26 changes: 9 additions & 17 deletions build_all_wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,21 @@

# ensure system build requirements are met (see README.md)

# any additional arguments supplied will be passed to the final
# `setup.py bdist_wheel` command and may be used to upload the
# packages to artifactory
# ./build_all_wheels.sh upload -r http://artifactory01.prod.sea1.west.isilon.com/artifactory/api/pypi/pypi-local

# recommend the use of `pyenv` to install and activate
# multiple python versions before running the script.

set -euo pipefail

# XXX: py3.9 not supported by internal artifactory
versions=(python2 python3.6 python3.7 python3.8)
versions=(python2 python3.6 python3.7 python3.8 python3.9 python3.10)

rm -rf dist
for v in ${versions[@]}
do
rm -rf .build/$v && \
virtualenv -p $v .build/$v && \
.build/$v/bin/pip install 'build' && \
.build/$v/bin/python -m build && \
.build/$v/bin/python setup.py bdist_wheel $*
# FIXME: ISILONEAT-1456, ISILONQE-3348
# Code fix to let twine upload to local artifactory
#.build/$v/bin/python -m build --outdir dist/ .
#.build/$v/bin/pip install twine
#.build/$v/bin/twine $* dist/*
$v -m pip install --user 'build[virtualenv]' && $v -m build
done

cat <<EOF
To upload packages run:
python3 -m pip install --user twine
python3 -m twine upload dist/* --repository-url "<my-private-repo>"'
EOF
25 changes: 19 additions & 6 deletions pykerb/kerberos.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@
* Modified by EMC Corporation.
*/

#define PY_SSIZE_T_CLEAN 1
#include <Python.h>
#include <py3c.h>
#include "kerberosbasic.h"
#include "kerberospw.h"
#include "kerberosgss.h"

#if PY_MAJOR_VERSION >= 3
#define RO_BYTEARRAY "y#"
#else
#define RO_BYTEARRAY "s#"
#endif

PyObject *KrbException_class;
PyObject *BasicAuthException_class;
PyObject *PwdChangeException_class;
Expand Down Expand Up @@ -161,7 +168,7 @@ static PyObject *authGSSClientStep(PyObject *self, PyObject *args)
{
gss_client_state *state;
PyObject *pystate;
int challenge_length = 0;
Py_ssize_t challenge_length = 0;
char *challenge;
int result = 0;

Expand Down Expand Up @@ -201,7 +208,7 @@ static PyObject *authGSSClientResponse(PyObject *self, PyObject *args)
if (state == NULL)
return NULL;

return Py_BuildValue("y#", state->response, state->response_length);
return Py_BuildValue(RO_BYTEARRAY, state->response, (Py_ssize_t) state->response_length);
}

static PyObject *authGSSClientUserName(PyObject *self, PyObject *args)
Expand All @@ -228,7 +235,7 @@ static PyObject *authGSSClientUnwrap(PyObject *self, PyObject *args)
{
gss_client_state *state;
PyObject *pystate;
int challenge_length = 0;
Py_ssize_t challenge_length = 0;
char *challenge;
int result = 0;

Expand All @@ -255,7 +262,7 @@ static PyObject *authGSSClientWrap(PyObject *self, PyObject *args)
{
gss_client_state *state;
PyObject *pystate;
int challenge_length = 0;
Py_ssize_t challenge_length = 0;
char *challenge, *user = NULL;
int result = 0;

Expand Down Expand Up @@ -353,7 +360,7 @@ static PyObject *authGSSServerStep(PyObject *self, PyObject *args)
{
gss_server_state *state;
PyObject *pystate;
int challenge_length = 0;
Py_ssize_t challenge_length = 0;
char *challenge;
int result = 0;

Expand Down Expand Up @@ -393,7 +400,7 @@ static PyObject *authGSSServerResponse(PyObject *self, PyObject *args)
if (state == NULL)
return NULL;

return Py_BuildValue("s#", state->response, state->response_length);
return Py_BuildValue(RO_BYTEARRAY, state->response, (Py_ssize_t) state->response_length);
}

static PyObject *authGSSServerUserName(PyObject *self, PyObject *args)
Expand Down Expand Up @@ -480,14 +487,20 @@ static struct PyModuleDef moduledef = {
.m_doc = NULL,
.m_size = sizeof(struct module_state),
.m_methods = KerberosMethods,
#if PY_MAJOR_VERSION >= 3
.m_slots = NULL,
.m_traverse = myextension_traverse,
.m_clear = myextension_clear,
.m_free = NULL
#endif
};


#if PY_MAJOR_VERSION >= 3
PyMODINIT_FUNC PyInit_kerberos(void)
#else
PyMODINIT_FUNC initkerberos(void)
#endif
{
PyObject *m,*d;

Expand Down

0 comments on commit 4f9dd44

Please sign in to comment.