Repository navigation
fix(php): a function this PHP-FPM build does not have is no longer shown as Allowed — GH #1701 - #2002
Merged
Merged
Conversation
…own as Allowed — GH #1701 The reporter found that the read-only "Disabled functions and paths" section listed pcntl_exec, pcntl_fork and dl as Allowed when the hosting package allowed them. Yet function_exists() returned false for all three in the site's PHP (8.3, fpm-fcgi). The section read only the configuration (disable_functions, PHP Defense rules), not what PHP-FPM actually provides: - Debian builds the pcntl extension into the CLI only; php-fpm8.3 -m does not list it (verified on the test box). - dl() is registered by the command-line SAPI itself (php-src PHP-8.3 sapi/cli/php_cli.c additional_functions, registered into "standard"), never by FPM. php.pool.effective now also returns unavailable_functions. It covers the lockdown list plus every disabled or banned name, checked against PHP-FPM's own module list (php-fpm -m, with the pool's ini layering) and each function's extension as the CLI reports it. The CLI SAPI's own functions count as missing, and FPM's own (fastcgi_finish_request, getallheaders, …) as present. A php.ini-disabled function is never called missing, since PHP drops it from the function table. When the check cannot run, availability_error says so and the list stays empty. Names go to PHP as arguments, never into the script. The page shows such a function as "Allowed, not in this PHP build", with a note on why and that a later PHP build that includes it makes it Allowed without a package change. Disabled and blocked keep their status; unavailable only qualifies Allowed (and allowed-but-logged). The API passes the new fields through (unavailable_functions is always a list). A test now fails if the API's typed struct drops a field the agent sends. The operator and user PHP docs describe the new status. Claude-Session: https://claude.ai/code/session_0173PcNd4h6NceYPc4FuhvXj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GH #1701 (lxsdevcode, follow-up on #1990). The read-only Disabled functions and paths section showed
pcntl_exec,pcntl_forkanddlas Allowed when the hosting package allowed them. Butfunction_exists()returned false for all three in the site's PHP (8.3, fpm-fcgi). The section read only the configuration (disable_functions, PHP Defense rules), not what PHP-FPM actually provides.Why those three are missing
pcntl_*: Debian builds the pcntl extension into the CLI only.php-fpm8.3 -mdoesn't list it, while the CLI resolvespcntl_exectopcntl(checked on the test box).dl(): the command-line SAPI registers it itself (php-src PHP-8.3sapi/cli/php_cli.cadditional_functions;main/main.cregisters them intostandard). FPM never does: it setsadditional_functions = NULLand adds only its owncgi-fcgifunctions (fpm_main_arginfo.h).What changes
php.pool.effective) returnsunavailable_functions:php-fpm<ver> -m, with the pool's ini layering), plus each function's extension as the CLI reports it with the same layering.dl,cli_set_process_title,cli_get_process_title) count as missing. FPM's own (fastcgi_finish_request,apache_request_headers,getallheaders,fpm_get_status) count as present.availability_errorsays so and the list stays empty rather than guessed.^[a-z_][a-z0-9_]{0,99}$are checked.unavailable_functions(always a list,[]when an agent sends none) andavailability_errorthrough. A new test fails if the API's typed response struct drops a field the agent sends.pcntl_anddl()as examples, and says a later PHP build that includes the function makes it Allowed with no package change.docs/site/php.mdanddocs/site/user/php-settings.md.Verification
php.pool.effectivewith a throwaway binary (since trashed) against two pools. It returnedunavailable_functions: ["dl","pcntl_exec","pcntl_fork"]with no errors, matching the reporter's runtime probe.proc_niceandexecwere not listed.TestUnavailableInFPM(pure decision: CLI-SAPI function, FPM-SAPI function, php.ini-disabled, no such function, extension FPM doesn't load);TestReadPHPPoolEffectiveUnavailable(end to end with stubbed probes, including which names get checked);TestReadPHPPoolEffectiveAvailabilityError, and the existing no-ini test asserting nothing is called unavailable without php.ini;[]normalization, and the agent ↔ API response mirror test;[]normalization failed the owner test.go test ./panel-agent/internal/commands/ ./panel-api/internal/api/;go vet;tsc -band eslint on the touched files;detect-changes: 10 files, 0 affected processes, risk LOW.readPHPPoolEffectivehas one caller.https://claude.ai/code/session_0173PcNd4h6NceYPc4FuhvXj