From 0039446fee48a48896e63d978ba3ac531fd4c859 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sun, 25 Feb 2024 23:02:17 +0100 Subject: [PATCH] Check for struct ucred with AC_CHECK_TYPES (#13510) The AC_CHECK_TYPES can be used to check for the struct ucred. By default it defines the symbol HAVE_STRUCT_UCRED instead of ANC_CREDS_UCRED. --- ext/sockets/config.m4 | 22 ++++++---------------- ext/sockets/sendrecvmsg.c | 2 +- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/ext/sockets/config.m4 b/ext/sockets/config.m4 index 38b177959ba..74fe477f308 100644 --- a/ext/sockets/config.m4 +++ b/ext/sockets/config.m4 @@ -51,22 +51,12 @@ if test "$PHP_SOCKETS" != "no"; then AC_DEFINE(HAVE_AI_IDN,1,[Whether you have AI_IDN]) fi - dnl Check for struct ucred - dnl checking the header is not enough (eg DragonFlyBSD) - AC_CACHE_CHECK([if ancillary credentials uses ucred],[ac_cv_ucred], - [ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#include - ]], [[struct ucred u = {.gid = 0};]])], - [ac_cv_ucred=yes], [ac_cv_ucred=no]) - ]) - - if test "$ac_cv_ucred" = yes; then - AC_DEFINE(ANC_CREDS_UCRED,1,[Uses ucred struct]) - fi + dnl Check for struct ucred. Checking the header is not enough (DragonFlyBSD). + AC_CHECK_TYPES([struct ucred],,, + [#ifndef _GNU_SOURCE + # define _GNU_SOURCE + #endif + #include ]) AC_CHECK_TYPES([struct cmsgcred],,,[#include ]) diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c index 466643ceaf4..f5e6802ff3a 100644 --- a/ext/sockets/sendrecvmsg.c +++ b/ext/sockets/sendrecvmsg.c @@ -123,7 +123,7 @@ static void init_ancillary_registry(void) #endif #ifdef SO_PASSCRED -#ifdef ANC_CREDS_UCRED +#ifdef HAVE_STRUCT_UCRED PUT_ENTRY(sizeof(struct ucred), 0, 0, from_zval_write_ucred, to_zval_read_ucred, SOL_SOCKET, SCM_CREDENTIALS); #else