Skip to content

Fix sysconf functions in FreeBSD #12995

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

Closed
wants to merge 240 commits into from
Closed

Conversation

5u623l20
Copy link
Contributor

@5u623l20 5u623l20 commented Dec 21, 2023

All FreeBSD do not implement the function sysconf with arguments _SC_GETGR_R_SIZE_MAX , _SC_TTY_NAME_MAX:_SC_GETPW_R_SIZE_MAX.

php use this sysconf() in:

  • main/main.c php_get_current_user()
  • main/fopen_wrappers.c php_fopen_primary_script()
  • ext/posix/posix.c posix_getpwnam(), posix_getpwuid(), posix_getgrnam(), posix_getgrgid()
  • ext/standard/filestat.c php_get_uid_by_name(), php_get_gid_by_name()

All FreeBSD do not implement the function sysconf with arguments
_SC_GETGR_R_SIZE_MAX , _SC_GETPW_R_SIZE_MAX.

php use this sysconf() in:
- main/main.c php_get_current_user()
- main/fopen_wrappers.c php_fopen_primary_script()
- ext/posix/posix.c posix_getpwnam(), posix_getpwuid(),
  posix_getgrnam(), posix_getgrgid()
- ext/standard/filestat.c php_get_uid_by_name(), php_get_gid_by_name()
All FreeBSD do not implement the function sysconf with arguments
_SC_GETGR_R_SIZE_MAX , _SC_GETPW_R_SIZE_MAX.

php use this sysconf() in:
- main/main.c php_get_current_user()
- main/fopen_wrappers.c php_fopen_primary_script()
- ext/posix/posix.c posix_getpwnam(), posix_getpwuid(),
  posix_getgrnam(), posix_getgrgid()
- ext/standard/filestat.c php_get_uid_by_name(), php_get_gid_by_name()
Copy link
Member

@bukka bukka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few questions - please note that they apply on some other parts as they are done in the same way (just commented on the first one)

@@ -476,6 +476,9 @@ PHP_FUNCTION(posix_ttyname)
}
#if defined(ZTS) && defined(HAVE_TTYNAME_R) && defined(_SC_TTY_NAME_MAX)
buflen = sysconf(_SC_TTY_NAME_MAX);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is _SC_TTY_NAME_MAX also problematic on FreeBSD (you haven't listed it in description...)? If so, is that even defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the description.

@@ -783,6 +786,9 @@ PHP_FUNCTION(posix_getgrnam)

#if defined(ZTS) && defined(HAVE_GETGRNAM_R) && defined(_SC_GETGR_R_SIZE_MAX)
buflen = sysconf(_SC_GETGR_R_SIZE_MAX);
#if defined(__FreeBSD__) && defined(_SC_PAGESIZE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's not supported on all FreeBSD, why do you still try to use _SC_GETGR_R_SIZE_MAX and then just fall back?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what bukka meant is why bothering with _SC_GETGR_R_SIZE_MAX if it returns -1 anyway (means no hard limit on the getgrnam_r buffer in theory).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I looked a bit around, also dragonflybsd and linux/musl returns -1 too, so would checking -1 and no errno set do the trick ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Give me some times to recheck. At least in one circumstances with FreeBSD 12 I can see that:
<?php var_dump(posix_getpwuid(0)); ?> just returns bool(false) where not on recent FreeBSD versions. I will need to recheck the codebase updates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it looks like that when ZTS is enabled this issue occurs returns bool(false). And when ZTS is not enabled this issue does not occur. So setting no errno should resolve the problem.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I still don't understand why it needs to fail first?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing this in lieu of #13187

@bukka bukka requested a review from devnexen December 21, 2023 20:32
All FreeBSD do not implement the function sysconf with arguments
_SC_GETGR_R_SIZE_MAX , _SC_GETPW_R_SIZE_MAX.

php use this sysconf() in:
- main/main.c php_get_current_user()
- main/fopen_wrappers.c php_fopen_primary_script()
- ext/posix/posix.c posix_getpwnam(), posix_getpwuid(),
  posix_getgrnam(), posix_getgrgid()
- ext/standard/filestat.c php_get_uid_by_name(), php_get_gid_by_name()
5u623l20 and others added 21 commits December 21, 2023 22:11
All FreeBSD do not implement the function sysconf with arguments
_SC_GETGR_R_SIZE_MAX , _SC_GETPW_R_SIZE_MAX , _SC_TTY_NAME_MAX.

php use this sysconf() in:
- main/main.c php_get_current_user()
- main/fopen_wrappers.c php_fopen_primary_script()
- ext/posix/posix.c posix_getpwnam(), posix_getpwuid(),
  posix_getgrnam(), posix_getgrgid()
- ext/standard/filestat.c php_get_uid_by_name(), php_get_gid_by_name()
* PHP-8.2:
  Fix phpGH-12969: Fixed PDO::getAttribute() to get PDO::ATTR_STRINGIFY_FETCHES
* PHP-8.3:
  Fix phpGH-12969: Fixed PDO::getAttribute() to get PDO::ATTR_STRINGIFY_FETCHES
Autotools emits warning if 3rd argument is empty. Call is wrapped in the
AC_CACHE_CHECK with php_cv_* cache variable name according to the docs.

Closes phpGH-12966
macOs CI update.

since sonoma (14) had been released since few months, we could afford to
upgrade to its previous release.
* PHP-8.2:
  Add cross-compiling 3rd argument to AC_RUN_IFELSE
* PHP-8.3:
  Add cross-compiling 3rd argument to AC_RUN_IFELSE
* PHP-8.2:
  Fix phpGH-12980: tidynode.props.attribute is missing "Boolean Attributes" and empty attributes
* PHP-8.3:
  Fix phpGH-12980: tidynode.props.attribute is missing "Boolean Attributes" and empty attributes
* PHP-8.3:
  Fix crash when toggleAttribute() is used without a document
I forgot to also update the document reference of attributes, so when
there is no document reference anymore from a variable, but still an
attribute, this can crash. Fix it by also updating the document
references for attributes.

Closes phpGH-13002.
There's two issues here:
- freeing of predefined entity declaration crashes (unique to 8.3 & master)
- using multiple entity references for a single entity declaration crashes
  (since forever)

The fix for the last issue is fairly easy to do on 8.3, but may require a
slightly different approach on 8.2. Therefore, for now this is 8.3-only.

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

Successfully merging this pull request may close these issues.