Skip to content

checkdnsrr/dns_check_record works in CLI but not in mod_php on macOS #18548

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

Open
VanessaPhippsCfa opened this issue May 13, 2025 · 3 comments
Open

Comments

@VanessaPhippsCfa
Copy link

VanessaPhippsCfa commented May 13, 2025

Description

The following code:

<?php
$result = checkdnsrr('google.com', 'A');
var_dump($result);

Resulted in this output:

bool(false)

But I expected this output instead:

bool(true)

3v4l link: https://3v4l.org/mchKq

3v4l also seems unable to get "true" out of this. However, this works fine on my machine:

/opt/homebrew/bin/php -r '$result = checkdnsrr("google.com", "A"); var_dump($result);'

My Rocky 6 production server (yes we're upgrading) also gets true for this code, even in mod_php.

I initially spotted this behavior in 7.4, but verified it's present on 8.4 as well.

PHP Version

PHP 8.4.7 (cli) (built: May  6 2025 12:31:58) (NTS)
Copyright (c) The PHP Group
Built by Homebrew
Zend Engine v4.4.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.7, Copyright (c), by Zend Technologies

Here's the top of the mod_php phpinfo() output:

PHP Version 8.4.7

System Darwin Vanessas-MacBook-Pro.local 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6030 arm64
Build Date May 6 2025 12:31:58
Build System Darwin Sequoia-arm64.local 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:24 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_VMAPPLE arm64
Build Provider Homebrew

Operating System

macOS Sequoia 15.4.1 on ARM (Apple M3 Pro)

@VanessaPhippsCfa VanessaPhippsCfa changed the title checkdnsrr works in CLI but not in mod_php on macOS checkdnsrr/dns_check_record works in CLI but not in mod_php on macOS May 13, 2025
@Suv-P
Copy link

Suv-P commented May 27, 2025

Adding further details to help narrow down issue

Works as expected on

ProductName: macOS
ProductVersion: 15.5
BuildVersion: 24F74

PHP 8.4.2 (cli) (built: Dec 17 2024 15:31:31) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.2, Copyright (c) Zend Technologies
with Zend OPcache v8.4.2, Copyright (c), by Zend Technologies

bool(true)

Work on CLI using php -r as well as script run using php cli

@staabm
Copy link
Contributor

staabm commented May 27, 2025

I can confirm it works as expected on my setup, too.

➜  ~ /opt/homebrew/bin/php -r '$result = checkdnsrr("google.com", "A"); var_dump($result);'
bool(true)
➜  ~ php -v
PHP 8.4.7 (cli) (built: May  6 2025 12:31:58) (NTS)
Copyright (c) The PHP Group
Built by Homebrew
Zend Engine v4.4.7, Copyright (c) Zend Technologies

Apple M4 Pro
ProductName: macOS
ProductVersion: 15.5


did you make sure checkdnsrr is not forbidden via php.ini disable_functions directive ?

@VanessaPhippsCfa
Copy link
Author

Thanks for the tests @Suv-P and @staabm . Can you test on mod_php as well? My CLI works, same as yours. It's only with mod_php that I see the problem.

Script (both CLI and mod_php)

At /opt/homebrew/var/www/checkdnsrrtest.php.

<?php
$result = checkdnsrr('google.com', 'A');
var_dump($result);

CLI

% /opt/homebrew/bin/php /opt/homebrew/var/www/checkdnsrrtest.php
bool(true)

mod_php

Browser location: http://localhost:8080/checkdnsrrtest.php

Result:

bool(false)

Re: disable_functions

That part of my /opt/homebrew/etc/php/8.4/php.ini is empty, and it is not set elsewhere in the file.

; This directive allows you to disable certain functions.
; It receives a comma-delimited list of function names.
; http://php.net/disable-functions
disable_functions =

More installation details

I'm on macOS 15.5 now. Still having this problem.

I'm using the Homebrew Apache on port 8080.

% /opt/homebrew/bin/httpd -v
Server version: Apache/2.4.63 (Unix)
Server built:   Jan 20 2025 19:35:41

I'm loading mod_php like this, in /opt/homebrew/etc/httpd/httpd.conf.

LoadModule php_module /opt/homebrew/Cellar/php/8.4.7/lib/httpd/modules/libphp.so

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

No branches or pull requests

3 participants