Skip to content

Commit f1c702e

Browse files
committed
Implement OPT_X_SASL_SSF_EXTERNAL setter
The option flag ``OPT_X_SASL_SSF_EXTERNAL`` never worked because the set_option code didn't handle the flag correctly. Fixes: python-ldap#423 Signed-off-by: Christian Heimes <cheimes@redhat.com>
1 parent d9ded15 commit f1c702e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Modules/options.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ LDAP_set_option(LDAPObject *self, int option, PyObject *value)
115115
#ifdef HAVE_SASL
116116
case LDAP_OPT_X_SASL_SSF_MIN:
117117
case LDAP_OPT_X_SASL_SSF_MAX:
118+
case LDAP_OPT_X_SASL_SSF_EXTERNAL:
118119
if (!PyArg_Parse(value, "k:set_option", &blen))
119120
return 0;
120121
ptr = &blen;
@@ -261,6 +262,12 @@ LDAP_get_option(LDAPObject *self, int option)
261262
Py_ssize_t i, num_extensions;
262263

263264
switch (option) {
265+
#ifdef HAVE_SASL
266+
case LDAP_OPT_X_SASL_SSF_EXTERNAL:
267+
/* Write-only options */
268+
PyErr_SetString(PyExc_ValueError, "write-only option");
269+
return NULL;
270+
#endif
264271
case LDAP_OPT_API_INFO:
265272
apiinfo.ldapai_info_version = LDAP_API_INFO_VERSION;
266273
res = LDAP_int_get_option(self, option, &apiinfo);

Tests/t_ldapobject.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@ def test006_sasl_options(self):
362362
self.assertEqual(l.get_option(ldap.OPT_X_SASL_SSF_MAX), 256)
363363

364364
l.sasl_external_bind_s()
365+
with self.assertRaisesRegex(ValueError, "write-only option"):
366+
l.get_option(ldap.OPT_X_SASL_SSF_EXTERNAL)
367+
l.set_option(ldap.OPT_X_SASL_SSF_EXTERNAL, 256)
365368
self.assertEqual(l.whoami_s(), 'dn:' + self.server.root_dn.lower())
366369

367370
def test007_timeout(self):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy