Skip to content

Check for struct ucred with AC_CHECK_TYPES #13510

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

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions ext/sockets/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sys/socket.h>
]], [[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 <sys/socket.h>])

dnl Check for struct cmsgcred
AC_CACHE_CHECK([if ancillary credentials uses cmsgcred],[ac_cv_cmsgcred],
Expand Down
2 changes: 1 addition & 1 deletion ext/sockets/sendrecvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down