Skip to content
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
134 changes: 78 additions & 56 deletions docs/bootstrap-inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Regenerate: `php script/bootstrap-inventory.php`

| Metric | Count |
|--------|------:|
| PHP files on vm.php path | 6563 |
| Phase A inventory files (M2 ratio SSOT) | 6563 |
| PHP files on vm.php path | 6564 |
| Phase A inventory files (M2 ratio SSOT) | 6564 |
| Phase A ratio-deferred paths | 0 |
| Source constructs flagged (blockers) | 0 |
| Source constructs flagged (warnings) | 21140 |
| Source constructs flagged (warnings) | 21157 |

## Compiler CFG gaps (`lib/Compiler.php`)

Expand Down Expand Up @@ -1180,7 +1180,7 @@ Rank live CFG gaps across inventory files: `php script/bootstrap-inventory-triag
| `ext/ldap/LdapEscapeJitHelper.php` | 0 | 1 |
| `ext/ldap/LdapExtensionPolicy.php` | 0 | 1 |
| `ext/ldap/LdapSerializeDeny.php` | 0 | 3 |
| `ext/ldap/Module.php` | 0 | 47 |
| `ext/ldap/Module.php` | 0 | 54 |
| `ext/ldap/VmLdapArg.php` | 0 | 1 |
| `ext/ldap/VmLdapConnection.php` | 0 | 4 |
| `ext/ldap/VmLdapCore.php` | 0 | 4 |
Expand All @@ -1196,6 +1196,7 @@ Rank live CFG gaps across inventory files: `php script/bootstrap-inventory-triag
| `ext/ldap/ldap_exop_builtins.php` | 0 | 6 |
| `ext/ldap/ldap_link_builtins.php` | 0 | 11 |
| `ext/ldap/ldap_modify_builtins.php` | 0 | 7 |
| `ext/ldap/ldap_result_builtins.php` | 0 | 10 |
| `ext/ldap/ldap_search_builtins.php` | 0 | 8 |
| `ext/libxml/BuiltinClasses.php` | 0 | 1 |
| `ext/libxml/LibxmlConstants.php` | 0 | 1 |
Expand Down Expand Up @@ -15802,51 +15803,58 @@ Rank live CFG gaps across inventory files: `php script/bootstrap-inventory-triag

**Warnings** (review for bootstrap subset):
- new VM\Variable (line 31)
- new ldap_escape (line 57)
- new ldap_dn2ufn (line 58)
- new ldap_explode_dn (line 59)
- new ldap_connect (line 60)
- new ldap_bind (line 61)
- new ldap_bind_ext (line 62)
- new ldap_unbind (line 63)
- new ldap_close (line 64)
- new ldap_errno (line 65)
- new ldap_error (line 66)
- new ldap_err2str (line 67)
- new ldap_set_option (line 68)
- new ldap_get_option (line 69)
- new ldap_start_tls (line 70)
- new ldap_search (line 71)
- new ldap_list (line 72)
- new ldap_read (line 73)
- new ldap_count_entries (line 74)
- new ldap_get_entries (line 75)
- new ldap_first_entry (line 76)
- new ldap_next_entry (line 77)
- new ldap_get_attributes (line 78)
- new ldap_free_result (line 79)
- new ldap_exop (line 80)
- new ldap_exop_sync (line 81)
- new ldap_parse_exop (line 82)
- new ldap_exop_whoami (line 83)
- new ldap_exop_refresh (line 84)
- new ldap_exop_passwd (line 85)
- new ldap_mod_add (line 86)
- new ldap_mod_replace (line 87)
- new ldap_mod_del (line 88)
- new ldap_modify (line 89)
- new ldap_add (line 90)
- new ldap_delete (line 91)
- new ldap_modify_batch (line 92)
- new ldap_mod_batch (line 93)
- new ldap_add_ext (line 94)
- new ldap_delete_ext (line 95)
- new ldap_rename_ext (line 96)
- new ldap_mod_add_ext (line 97)
- new ldap_mod_del_ext (line 98)
- new ldap_mod_replace_ext (line 99)
- new ldap_rename (line 100)
- new ldap_connect_wallet (line 104)
- new ldap_escape (line 58)
- new ldap_dn2ufn (line 59)
- new ldap_explode_dn (line 60)
- new ldap_connect (line 61)
- new ldap_bind (line 62)
- new ldap_bind_ext (line 63)
- new ldap_unbind (line 64)
- new ldap_close (line 65)
- new ldap_errno (line 66)
- new ldap_error (line 67)
- new ldap_err2str (line 68)
- new ldap_set_option (line 69)
- new ldap_get_option (line 70)
- new ldap_start_tls (line 71)
- new ldap_search (line 72)
- new ldap_list (line 73)
- new ldap_read (line 74)
- new ldap_count_entries (line 75)
- new ldap_get_entries (line 76)
- new ldap_first_entry (line 77)
- new ldap_next_entry (line 78)
- new ldap_get_attributes (line 79)
- new ldap_free_result (line 80)
- new ldap_compare (line 81)
- new ldap_parse_result (line 82)
- new ldap_get_dn (line 83)
- new ldap_first_attribute (line 84)
- new ldap_next_attribute (line 85)
- new ldap_get_values (line 86)
- new ldap_get_values_len (line 87)
- new ldap_exop (line 88)
- new ldap_exop_sync (line 89)
- new ldap_parse_exop (line 90)
- new ldap_exop_whoami (line 91)
- new ldap_exop_refresh (line 92)
- new ldap_exop_passwd (line 93)
- new ldap_mod_add (line 94)
- new ldap_mod_replace (line 95)
- new ldap_mod_del (line 96)
- new ldap_modify (line 97)
- new ldap_add (line 98)
- new ldap_delete (line 99)
- new ldap_modify_batch (line 100)
- new ldap_mod_batch (line 101)
- new ldap_add_ext (line 102)
- new ldap_delete_ext (line 103)
- new ldap_rename_ext (line 104)
- new ldap_mod_add_ext (line 105)
- new ldap_mod_del_ext (line 106)
- new ldap_mod_replace_ext (line 107)
- new ldap_rename (line 108)
- new ldap_connect_wallet (line 112)
- 3 class method(s)

### `ext/ldap/VmLdapArg.php`
Expand All @@ -15865,10 +15873,10 @@ Rank live CFG gaps across inventory files: `php script/bootstrap-inventory-triag
### `ext/ldap/VmLdapCore.php`

**Warnings** (review for bootstrap subset):
- new HashTable (line 178)
- new Variable (line 190)
- new Variable (line 201)
- 9 class method(s)
- new HashTable (line 320)
- new Variable (line 332)
- new Variable (line 343)
- 15 class method(s)

### `ext/ldap/VmLdapDn.php`

Expand All @@ -15892,7 +15900,7 @@ Rank live CFG gaps across inventory files: `php script/bootstrap-inventory-triag
### `ext/ldap/VmLdapNative.php`

**Warnings** (review for bootstrap subset):
- 42 class method(s)
- 46 class method(s)

### `ext/ldap/VmLdapResult.php`

Expand All @@ -15902,8 +15910,8 @@ Rank live CFG gaps across inventory files: `php script/bootstrap-inventory-triag
- new ObjectEntry (line 48)
- new Variable (line 55)
- new ObjectEntry (line 64)
- new Variable (line 71)
- 9 class method(s)
- new Variable (line 72)
- 11 class method(s)

### `ext/ldap/ldap_connect.php`

Expand Down Expand Up @@ -15966,6 +15974,20 @@ Rank live CFG gaps across inventory files: `php script/bootstrap-inventory-triag
- new ArgumentCountError (line 467)
- 43 class method(s)

### `ext/ldap/ldap_result_builtins.php`

**Warnings** (review for bootstrap subset):
- new ArgumentCountError (line 31)
- new ArgumentCountError (line 69)
- new HashTable (line 99)
- new Variable (line 101)
- new ArgumentCountError (line 128)
- new ArgumentCountError (line 163)
- new ArgumentCountError (line 198)
- new ArgumentCountError (line 233)
- new ArgumentCountError (line 270)
- 14 class method(s)

### `ext/ldap/ldap_search_builtins.php`

**Warnings** (review for bootstrap subset):
Expand Down
8 changes: 8 additions & 0 deletions ext/ldap/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function getFunctions(): array
require_once __DIR__.'/ldap_exop_builtins.php';
require_once __DIR__.'/ldap_modify_builtins.php';
require_once __DIR__.'/ldap_dn_builtins.php';
require_once __DIR__.'/ldap_result_builtins.php';

$fns = [
new ldap_escape(),
Expand All @@ -77,6 +78,13 @@ public function getFunctions(): array
new ldap_next_entry(),
new ldap_get_attributes(),
new ldap_free_result(),
new ldap_compare(),
new ldap_parse_result(),
new ldap_get_dn(),
new ldap_first_attribute(),
new ldap_next_attribute(),
new ldap_get_values(),
new ldap_get_values_len(),
new ldap_exop(),
new ldap_exop_sync(),
new ldap_parse_exop(),
Expand Down
142 changes: 142 additions & 0 deletions ext/ldap/VmLdapCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,148 @@ public static function getAttributesMap(ObjectEntry $connection, ObjectEntry $en
return self::importPhpArray($out);
}

/**
* ldap_compare → true / false / -1 (php-src; #22177).
*/
public static function compare(
ObjectEntry $connection,
string $dn,
string $attribute,
string $value
): bool|int {
$ld = VmLdapConnection::native($connection);
$rc = VmLdapNative::compareExtSync($ld, $dn, $attribute, $value);
VmLdapConnection::setErrno($connection, $rc);
if (VmLdapNative::LDAP_COMPARE_TRUE === $rc) {
return true;
}
if (VmLdapNative::LDAP_COMPARE_FALSE === $rc) {
return false;
}
@\trigger_error('ldap_compare(): Compare: '.VmLdapNative::err2string($rc), \E_USER_WARNING);

return -1;
}

/**
* @return string|false
*/
public static function getDn(ObjectEntry $connection, ObjectEntry $entry): string|false
{
$ld = VmLdapConnection::native($connection);
$dn = VmLdapNative::getDn($ld, VmLdapResult::entryNative($entry));
if (null === $dn) {
return false;
}

return $dn;
}

/**
* php-src ldap_get_values / ldap_get_values_len array shape.
*
* @return Variable|false
*/
public static function getValues(ObjectEntry $connection, ObjectEntry $entry, string $attribute): Variable|false
{
$ld = VmLdapConnection::native($connection);
$values = VmLdapNative::getValuesLen($ld, VmLdapResult::entryNative($entry), $attribute);
// OpenLDAP returns NULL on missing attr — treat empty as failure like php-src when errno set.
if ([] === $values) {
$errno = VmLdapNative::getOptionInt($ld, VmLdapNative::LDAP_OPT_ERROR_NUMBER)['value'];
if (VmLdapNative::LDAP_SUCCESS !== $errno && 0 !== $errno) {
@\trigger_error(
'ldap_get_values(): Cannot get the value(s) of attribute '.VmLdapNative::err2string($errno),
\E_USER_WARNING
);

return false;
}
}
$out = ['count' => \count($values)];
foreach ($values as $i => $val) {
$out[$i] = $val;
}

return self::importPhpArray($out);
}

/**
* @return string|false
*/
public static function firstAttribute(ObjectEntry $connection, ObjectEntry $entry): string|false
{
$ld = VmLdapConnection::native($connection);
$info = VmLdapNative::firstAttribute($ld, VmLdapResult::entryNative($entry));
VmLdapResult::setEntryBer($entry, $info['ber']);
if (null === $info['attr']) {
return false;
}

return $info['attr'];
}

/**
* @return string|false
*/
public static function nextAttribute(ObjectEntry $connection, ObjectEntry $entry): string|false
{
$ber = VmLdapResult::entryBer($entry);
if (null === $ber) {
@\trigger_error(
'ldap_next_attribute(): Called before calling ldap_first_attribute() or no attributes found in result entry',
\E_USER_WARNING
);

return false;
}
$ld = VmLdapConnection::native($connection);
$attr = VmLdapNative::nextAttribute($ld, VmLdapResult::entryNative($entry), $ber);
if (null === $attr) {
return false;
}

return $attr;
}

/**
* @param list<string> $referralsOut filled when wanted
* @return array{ok: bool, errcode: int, matched_dn: string, error_message: string, referrals: list<string>}|false
*/
public static function parseResult(
ObjectEntry $connection,
ObjectEntry $result,
bool $wantMatched,
bool $wantErrmsg,
bool $wantReferrals
): array|false {
$ld = VmLdapConnection::native($connection);
$parsed = VmLdapNative::parseResult(
$ld,
VmLdapResult::resultNative($result),
$wantMatched,
$wantErrmsg,
$wantReferrals
);
VmLdapConnection::setErrno($connection, $parsed['errno']);
if (!$parsed['ok']) {
@\trigger_error(
'ldap_parse_result(): Unable to parse result: '.VmLdapNative::err2string($parsed['errno']),
\E_USER_WARNING
);

return false;
}

return [
'ok' => true,
'errcode' => $parsed['errcode'],
'matched_dn' => $parsed['matched_dn'],
'error_message' => $parsed['error_message'],
'referrals' => $parsed['referrals'],
];
}

/**
* @param array<int|string, mixed> $value
*/
Expand Down
Loading
Loading