Skip to content

Commit c1d6cf3

Browse files
authored
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.
1 parent 035a5fd commit c1d6cf3

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

ext/sockets/config.m4

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,7 @@ if test "$PHP_SOCKETS" != "no"; then
6868
AC_DEFINE(ANC_CREDS_UCRED,1,[Uses ucred struct])
6969
fi
7070

71-
dnl Check for struct cmsgcred
72-
AC_CACHE_CHECK([if ancillary credentials uses cmsgcred],[ac_cv_cmsgcred],
73-
[
74-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
75-
#include <sys/socket.h>
76-
]], [[struct cmsgcred c = {0};]])],
77-
[ac_cv_cmsgcred=yes], [ac_cv_cmsgcred=no])
78-
])
79-
80-
if test "$ac_cv_cmsgcred" = yes; then
81-
AC_DEFINE(ANC_CREDS_CMSGCRED,1,[Uses cmsgcred struct])
82-
fi
83-
71+
AC_CHECK_TYPES([struct cmsgcred],,,[#include <sys/socket.h>])
8472

8573
PHP_SOCKETS_CFLAGS=-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1
8674
case $host_alias in

ext/sockets/conversions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ static const field_descriptor descriptors_ucred[] = {
13301330
{"uid", sizeof("uid"), 1, offsetof(struct sockcred, sc_euid), from_zval_write_uid_t, to_zval_read_uid_t},
13311331
/* the type gid_t is the same as uid_t: */
13321332
{"gid", sizeof("gid"), 1, offsetof(struct sockcred, sc_egid), from_zval_write_uid_t, to_zval_read_uid_t},
1333-
#elif defined(ANC_CREDS_CMSGCRED)
1333+
#elif defined(HAVE_STRUCT_CMSGCRED)
13341334
{"pid", sizeof("pid"), 1, offsetof(struct cmsgcred, cmcred_pid), from_zval_write_pid_t, to_zval_read_pid_t},
13351335
{"uid", sizeof("uid"), 1, offsetof(struct cmsgcred, cmcred_uid), from_zval_write_uid_t, to_zval_read_uid_t},
13361336
/* assume the type gid_t is the same as uid_t: */

0 commit comments

Comments
 (0)