Check for struct cmsgcred with AC_CHECK_TYPES (#13507)

The AC_CHECK_TYPES can be used to check for the struct cmsgcred. By
default it defines the symbol HAVE_STRUCT_CMSGCRED instead of
ANC_CREDS_CMSGCRED.
This commit is contained in:
Peter Kokot 2024-02-25 22:33:44 +01:00 committed by GitHub
parent 035a5fdf8c
commit c1d6cf37e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 14 deletions

View file

@ -68,19 +68,7 @@ if test "$PHP_SOCKETS" != "no"; then
AC_DEFINE(ANC_CREDS_UCRED,1,[Uses ucred struct])
fi
dnl Check for struct cmsgcred
AC_CACHE_CHECK([if ancillary credentials uses cmsgcred],[ac_cv_cmsgcred],
[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/socket.h>
]], [[struct cmsgcred c = {0};]])],
[ac_cv_cmsgcred=yes], [ac_cv_cmsgcred=no])
])
if test "$ac_cv_cmsgcred" = yes; then
AC_DEFINE(ANC_CREDS_CMSGCRED,1,[Uses cmsgcred struct])
fi
AC_CHECK_TYPES([struct cmsgcred],,,[#include <sys/socket.h>])
PHP_SOCKETS_CFLAGS=-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1
case $host_alias in

View file

@ -1330,7 +1330,7 @@ static const field_descriptor descriptors_ucred[] = {
{"uid", sizeof("uid"), 1, offsetof(struct sockcred, sc_euid), from_zval_write_uid_t, to_zval_read_uid_t},
/* the type gid_t is the same as uid_t: */
{"gid", sizeof("gid"), 1, offsetof(struct sockcred, sc_egid), from_zval_write_uid_t, to_zval_read_uid_t},
#elif defined(ANC_CREDS_CMSGCRED)
#elif defined(HAVE_STRUCT_CMSGCRED)
{"pid", sizeof("pid"), 1, offsetof(struct cmsgcred, cmcred_pid), from_zval_write_pid_t, to_zval_read_pid_t},
{"uid", sizeof("uid"), 1, offsetof(struct cmsgcred, cmcred_uid), from_zval_write_uid_t, to_zval_read_uid_t},
/* assume the type gid_t is the same as uid_t: */