Skip to content

ext/ldap: Use FCC for rebind_proc callback #17369

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

Merged
merged 3 commits into from
Jan 8, 2025
Merged

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Jan 5, 2025

The tests seem to be somewhat pointless, as they don't actually trigger the callback.

I don't know enough about LDAP (nor know how to set up a server) to improve them.

@Girgias Girgias marked this pull request as ready for review January 5, 2025 21:22
@Girgias Girgias requested a review from nielsdos January 8, 2025 10:46
Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, to test this we would need two LDAP servers (unless you can refer to the same server again?)
I learned what this method does via https://www.ibm.com/docs/da/zos/2.4.0?topic=routines-ldap-set-rebind-proc
I'm also a bit uneasy about changing code that we didn't test... It looks more or less right, but experience also tells me that users report regressions waaaay later than when they're initially introduced

}

$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, 3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version option seems pointless?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay sure, can't harm I guess.

@@ -0,0 +1,63 @@
--TEST--
ldap_set_rebind_proc() with a trampoline
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the test seems kinda pointless, but it would also be a shame to get rid of this effort...

ext/ldap/ldap.c Outdated
/* Free old FCC */
if (!ZEND_FCC_INITIALIZED(ld->rebind_proc_fcc)) {
zend_fcc_dtor(&ld->rebind_proc_fcc);
memcpy(&ld->rebind_proc_fcc, &empty_fcall_info_cache, sizeof(zend_fcall_info_cache));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this copy, zend_fcc_dtor already does this for you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes I forget that I design APIs in a reasonable way

ext/ldap/ldap.c Outdated
ldap_set_rebind_proc(ld->link, _ldap_rebind_proc, (void *) link);
zend_fcc_dup(&ld->rebind_proc_fcc, &fcc);
/* Clear potential trampoline */
zend_release_fcall_info_cache(&fcc);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, are you sure this is actually necessary?

Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see obvious mistakes.
Please add a comment to the test you added such that people won't be confused why nothing is being called.
Also a bit uneasy that this can't be tested, but I hope that there's enough time between now and the official release that issues will get noticed if there are any.

@Girgias Girgias merged commit 915feea into php:master Jan 8, 2025
1 check passed
@Girgias Girgias deleted the ldap-use-fcc branch January 8, 2025 20:52
@iluuu1994
Copy link
Member

Please check the failures in nightly. https://github.com/php/php-src/actions/runs/12682222932/job/35347262817

/* register rebind procedure */
if (Z_ISUNDEF(ld->rebindproc)) {
/* Free old FCC */
if (!ZEND_FCC_INITIALIZED(ld->rebind_proc_fcc)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably the nightly issue: the condition seems inverted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants