Skip to content

Guard POSIX UID/GID lookups and fix getGid() implementation#7

Merged
lhridley merged 1 commit into
codementality:mainfrom
ddowell617:fix/posixuid-fallback
Jul 3, 2026
Merged

Guard POSIX UID/GID lookups and fix getGid() implementation#7
lhridley merged 1 commit into
codementality:mainfrom
ddowell617:fix/posixuid-fallback

Conversation

@ddowell617

Copy link
Copy Markdown
Contributor

Fixes #6

This PR:

  • guards calls to posix_getuid()
  • guards calls to posix_getgid()
  • falls back to getmyuid() / getmygid()
  • returns 0 if neither function exists
  • fixes getGid() incorrectly calling posix_getuid()

This change was validated during a production Drupal 11.4 migration from S3FS to Flysystem.

The issue was observed under PHP-FPM where POSIX functions were unavailable, resulting in HTTP 500 errors until the guard logic was added.

Guard POSIX UID/GID lookups and fix getGid() implementation

Add graceful fallbacks for environments where POSIX functions are unavailable.
@ddowell617

Copy link
Copy Markdown
Contributor Author

One small thought after reflecting on the implementation and the production testing: while the current fallback to getmyuid() / getmygid() is more defensive and supports environments where those functions are available but the POSIX extension is not, another possible approach would be to simplify the implementation to only guard the posix_*() calls and return 0 if they are unavailable. I chose the more defensive implementation because it preserves additional functionality where possible, but if you'd prefer the simpler approach for consistency or maintainability, I'd be happy to update the PR accordingly.

@lhridley

lhridley commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Thank you for the patch. Since the dependency of the Flysystem Drupal module (which is the only reason this library exists) on this library has been written out of version 3.0.x as of late last month, I think we can keep this patch as it (I’ve tested and verified that it is working). My expectation is that versions 2.2 and 2.3 will be deprecated once Drupal 12 is released, unless some of the other module maintainers want to continue supporting those versions. My focus will be on supporting 3.0.x going forward.

@lhridley lhridley merged commit 5b81f84 into codementality:main Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PosixUid assumes POSIX functions are always available under PHP-FPM

2 participants