Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 29a1bb1

Browse files
aiudirogfrozencemetery
authored andcommitted
Add Windows support (using MIT Kerberos for Windows)
Add casts through `char *` to prevent errors in compilation when Cython performs pointer arithmetic on buffers. [rharwood@redhat.com: squashed patches, rewrite commit message]
1 parent 2347e3f commit 29a1bb1

18 files changed

+232
-69
lines changed

‎.travis.yml‎

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@ stages:
1919
if: tag is PRESENT
2020

2121
script:
22-
- if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then sudo sed -i '1i 127.0.0.1 test.box' /etc/hosts; fi
23-
- if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then sudo hostname test.box; fi
24-
- if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then source ./.travis/lib-util.sh; fi
25-
- if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then util::docker-run $DISTRO ./.travis/build.sh; fi
26-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/build.sh; fi
22+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
23+
sudo sed -i '1i 127.0.0.1 test.box' /etc/hosts;
24+
sudo hostname test.box;
25+
source ./.travis/lib-util.sh;
26+
util::docker-run $DISTRO ./.travis/build.sh;
27+
fi
28+
- if [[ "$TRAVIS_OS_NAME" != "linux" ]]; then ./.travis/build.sh; fi
2729

2830
jobs:
2931
include:
30-
- stage: verify
32+
- &docker_verify
33+
stage: verify
3134
env: DISTRO=fedora:latest PYTHON="2"
3235
script:
3336
- source ./.travis/lib-util.sh
3437
- util::docker-run $DISTRO ./.travis/verify.sh
3538

36-
- stage: verify
39+
- <<: *docker_verify
3740
env: DISTRO=fedora:latest PYTHON="3"
38-
script:
39-
- source ./.travis/lib-util.sh
40-
- util::docker-run $DISTRO ./.travis/verify.sh
4141

4242

4343
# need to explictly define each builder for test due to different os types
@@ -59,17 +59,27 @@ jobs:
5959
- stage: test
6060
env: DISTRO=fedora:latest PYTHON="2"
6161

62-
- stage: test
62+
- &osx_test
63+
stage: test
6364
env: PYTHON="2" KRB5_VER="heimdal" PYENV="2.7.14"
6465
os: osx
6566
osx_image: xcode9.2
6667
language: generic # causes issues with pyenv installer when set to python
6768

68-
- stage: test
69+
- <<: *osx_test
6970
env: PYTHON="3" KRB5_VER="heimdal" PYENV="3.6.3"
70-
os: osx
71-
osx_image: xcode9.2
72-
language: generic # causes issues with pyenv installer when set to python
71+
72+
- &win_test
73+
stage: test
74+
env: PYTHON="2" PYENV="2.7.16" EXTRA_BUILDEXT="--compiler=mingw32"
75+
os: windows
76+
language: sh # Windows not supported yet
77+
78+
- <<: *win_test
79+
env: PYTHON="3" PYENV="3.6.8"
80+
81+
- <<: *win_test
82+
env: PYTHON="3" PYENV="3.7.3"
7383

7484

7585
- stage: deploy latest docs
@@ -129,3 +139,27 @@ jobs:
129139
skip_cleanup: true
130140
on:
131141
all_branches: true
142+
143+
- &win_deploy
144+
stage: deploy
145+
os: windows
146+
script: skip
147+
env: PYTHON="2" PYENV="2.7.16" EXTRA_BUILDEXT="--compiler=mingw32"
148+
before_deploy:
149+
- ./.travis/before-deploy-windows-wheels.sh
150+
deploy:
151+
- provider: pypi
152+
user:
153+
secure: "jUAMucBq+9xH8x9u0I0LOwrs3Zb++KN7FwIIwz2CyAt/+TyyrJzeGJaV+dTiJ1OqcUIFqQG6jopzpnAe4biL1O68PEwz9BphKetFLpLHiFNm/n67LYno6NFonWmxndIy99pOP6NZu29nzSNeYq/KgEHo/5OkqEGOxk//lh7X/OY="
154+
password:
155+
secure: "ZqywwnR+G5VeM2sStwfLeutOvqbULHtnStjrdYc8WcC/FBVwmH/W48fTlvxrnswmfKx7Eljv0nN4VcBpoFf1tvz4O2oK/tCRpf0N8SvpT0jBx8bLGUxJ1/3Po6rFgBRWgSb/mzKHPKI6fLlQNcNg8lrd9e1j/zgbVRSwNeMUOR8="
156+
skip_cleanup: true
157+
on:
158+
all_branches: true
159+
distributions: "check" # Hack, see above
160+
161+
- <<: *win_deploy
162+
env: PYTHON="3" PYENV="3.6.8"
163+
164+
- <<: *win_deploy
165+
env: PYTHON="3" PYENV="3.7.3"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash -ex
2+
3+
# See before-deploy.sh for anything unexplained
4+
5+
source ./.travis/lib-setup.sh
6+
source ./.travis/lib-deploy.sh
7+
8+
./.travis/build.sh
9+
10+
# build the wheel
11+
python -m pip install wheel
12+
python setup.py bdist_wheel
13+
14+
cd dist
15+
16+
# Rename and checksum the wheel
17+
if [ x"${TRAVIS_TAG#v[0-9]}" = "x${TRAVIS_TAG}" ]; then
18+
PYTHON_GSSAPI_VERSION=${TRAVIS_TAG}
19+
else
20+
PYTHON_GSSAPI_VERSION=${TRAVIS_TAG#v}
21+
fi
22+
23+
PKG_NAME_VER=$(ls *.whl | sed "s/gssapi-[^-]*-\(.*\)\.whl/python-gssapi-${PYTHON_GSSAPI_VERSION}-1円/")
24+
25+
cp *.whl "${PKG_NAME_VER}.whl"
26+
27+
sha512sum --binary ./${PKG_NAME_VER}.whl > ./${PKG_NAME_VER}.sha512sum
28+
29+
cd ..

‎.travis/build.sh‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@ source ./.travis/lib-setup.sh
55
setup::install
66

77
# always build in-place so that Sphinx can find the modules
8-
python setup.py build_ext --inplace
8+
python setup.py build_ext --inplace$EXTRA_BUILDEXT
99
BUILD_RES=$?
1010

1111
if [ x"$KRB5_VER" = "xheimdal" ]; then
1212
# heimdal can't run the tests yet, so just exit
1313
exit $BUILD_RES
1414
fi
1515

16+
if [ "$TRAVIS_OS_NAME" == "windows" ]; then
17+
# Windows can't run tests yet, so just exit
18+
exit $BUILD_RES
19+
fi
20+
1621
if [ $BUILD_RES -ne 0 ]; then
1722
# if the build failed, don't run the tests
1823
exit $BUILD_RES

‎.travis/lib-setup.sh‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,33 @@ setup::macos::install() {
7575
pip install --install-option='--no-cython-compile' cython
7676
}
7777

78+
setup::windows::install() {
79+
# Install the right Python version and MIT Kerberos
80+
choco install python"${PYENV:0:1}" --version $PYENV
81+
choco install mitkerberos --install-arguments "'ADDLOCAL=ALL'" || true
82+
PYPATH="/c/Python${PYENV:0:1}${PYENV:2:1}"
83+
# Update path to include them
84+
export PATH="$PYPATH:$PYPATH/Scripts:/c/Program Files/MIT/Kerberos/bin:$PATH"
85+
86+
if [ "${PYENV:0:1}" == "2" ]; then
87+
choco install vcredist2008
88+
# Skip dotnet dependency:
89+
# https://github.com/fredrikaverpil/vcpython27/pull/3
90+
choco install --ignore-dependencies vcpython27
91+
fi
92+
93+
python -m pip install --upgrade pip
94+
}
95+
7896
setup::install() {
7997
if [ -f /etc/debian_version ]; then
8098
setup::debian::install
8199
elif [ -f /etc/redhat-release ]; then
82100
setup::rh::install
83101
elif [ "$(uname)" == "Darwin" ]; then
84102
setup::macos::install
103+
elif [ "$TRAVIS_OS_NAME" == "windows" ]; then
104+
setup::windows::install
85105
else
86106
echo "Distro not found!"
87107
false

‎gssapi/raw/ext_cred_imp_exp.pyx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def export_cred(Creds creds not None):
4848
maj_stat = gss_export_cred(&min_stat, creds.raw_creds, &exported_creds)
4949

5050
if maj_stat == GSS_S_COMPLETE:
51-
res = exported_creds.value[:exported_creds.length]
51+
res = (<char*>exported_creds.value)[:exported_creds.length]
5252
gss_release_buffer(&min_stat, &exported_creds)
5353
return res
5454
else:

‎gssapi/raw/ext_dce.pyx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ cdef class IOV:
209209
new_val = b'\x00' * new_len
210210
else:
211211
new_len = self._iov[i].buffer.length
212-
new_val = self._iov[i].buffer.value[:new_len]
212+
new_val = (<char*>self._iov[i].buffer.value)[:new_len]
213213

214214
alloc = False
215215
if self._iov[i].type & GSS_IOV_BUFFER_FLAG_ALLOCATE:
@@ -503,7 +503,7 @@ def wrap_aead(SecurityContext context not None, bytes message not None,
503503
&conf_used, &output_buffer)
504504

505505
if maj_stat == GSS_S_COMPLETE:
506-
output_message = output_buffer.value[:output_buffer.length]
506+
output_message = (<char*>output_buffer.value)[:output_buffer.length]
507507
gss_release_buffer(&min_stat, &output_buffer)
508508
return WrapResult(output_message, <bint>conf_used)
509509
else:
@@ -553,7 +553,7 @@ def unwrap_aead(SecurityContext context not None, bytes message not None,
553553
&conf_state, &qop_state)
554554

555555
if maj_stat == GSS_S_COMPLETE:
556-
output_message = output_buffer.value[:output_buffer.length]
556+
output_message = (<char*>output_buffer.value)[:output_buffer.length]
557557
gss_release_buffer(&min_stat, &output_buffer)
558558
return UnwrapResult(output_message, <bint>conf_state, qop_state)
559559
else:

‎gssapi/raw/ext_ggf.pyx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def inquire_cred_by_oid(Creds cred_handle not None,
7474
if data_set != GSS_C_NO_BUFFER_SET:
7575
for i in range(data_set.count):
7676
token = data_set.elements[i]
77-
py_tokens.append(token.value[:token.length])
77+
py_tokens.append((<char*>token.value)[:token.length])
7878

7979
gss_release_buffer_set(&min_stat, &data_set)
8080

@@ -124,7 +124,7 @@ def inquire_sec_context_by_oid(SecurityContext context not None,
124124
if data_set != GSS_C_NO_BUFFER_SET:
125125
for i in range(data_set.count):
126126
token = data_set.elements[i]
127-
py_tokens.append(token.value[:token.length])
127+
py_tokens.append((<char*>token.value)[:token.length])
128128

129129
gss_release_buffer_set(&min_stat, &data_set)
130130

‎gssapi/raw/ext_rfc5587.pyx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ def display_mech_attr(OID attr):
140140
&long_desc)
141141

142142
if maj_stat == GSS_S_COMPLETE:
143-
out_name = name.value[:name.length]
144-
out_short = short_desc.value[:short_desc.length]
145-
out_long = long_desc.value[:long_desc.length]
143+
out_name = (<char*>name.value)[:name.length]
144+
out_short = (<char*>short_desc.value)[:short_desc.length]
145+
out_long = (<char*>long_desc.value)[:long_desc.length]
146146

147147
gss_release_buffer(&min_stat, &name)
148148
gss_release_buffer(&min_stat, &short_desc)

‎gssapi/raw/ext_rfc5801.pyx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def inquire_saslname_for_mech(OID mech not None):
5050
&mech_name, &mech_desc)
5151

5252
if maj_stat == GSS_S_COMPLETE:
53-
out_smn = sasl_mech_name.value[:sasl_mech_name.length]
54-
out_mn = mech_name.value[:mech_name.length]
55-
out_md = mech_desc.value[:mech_desc.length]
53+
out_smn = (<char*>sasl_mech_name.value)[:sasl_mech_name.length]
54+
out_mn = (<char*>mech_name.value)[:mech_name.length]
55+
out_md = (<char*>mech_desc.value)[:mech_desc.length]
5656

5757
gss_release_buffer(&min_stat, &sasl_mech_name)
5858
gss_release_buffer(&min_stat, &mech_name)

‎gssapi/raw/ext_rfc6680.pyx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def display_name_ext(Name name not None, OID name_type not None):
6767
&name_type.raw_oid, &output_name)
6868

6969
if maj_stat == GSS_S_COMPLETE:
70-
name_text = output_name.value[:output_name.length]
70+
name_text = (<char*>output_name.value)[:output_name.length]
7171
gss_release_buffer(&min_stat, &output_name)
7272
return name_text
7373
else:
@@ -126,7 +126,9 @@ def inquire_name(Name name not None, mech_name=True, attrs=True):
126126
if attr_names != GSS_C_NO_BUFFER_SET:
127127
for i in range(attr_names.count):
128128
attr_name = attr_names.elements[i]
129-
py_attr_names.append(attr_name.value[:attr_name.length])
129+
py_attr_names.append(
130+
(<char*>attr_name.value)[:attr_name.length]
131+
)
130132

131133
gss_release_buffer_set(&min_stat, &attr_names)
132134

@@ -233,9 +235,9 @@ def get_name_attribute(Name name not None, attr not None, more=None):
233235
&more_val)
234236

235237
if maj_stat == GSS_S_COMPLETE:
236-
py_vals.append(val_buff.value[:val_buff.length])
238+
py_vals.append((<char*>val_buff.value)[:val_buff.length])
237239
py_displ_vals.append(
238-
displ_val_buff.value[:displ_val_buff.length])
240+
(<char*>displ_val_buff.value)[:displ_val_buff.length])
239241

240242
gss_release_buffer(&min_stat, &val_buff)
241243
gss_release_buffer(&min_stat, &displ_val_buff)
@@ -310,7 +312,7 @@ def export_name_composite(Name name not None):
310312
maj_stat = gss_export_name_composite(&min_stat, name.raw_name, &res)
311313

312314
if maj_stat == GSS_S_COMPLETE:
313-
py_res = res.value[:res.length]
315+
py_res = (<char*>res.value)[:res.length]
314316
gss_release_buffer(&min_stat, &res)
315317
return py_res
316318
else:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /