Skip to content

Allow setting permissions on downloaded databases - #101

Merged
peter-gribanov merged 2 commits into
gpslab:masterfrom
peter-gribanov:chmod
Aug 7, 2026
Merged

peter-gribanov merged 2 commits into
gpslab:masterfrom
peter-gribanov:chmod

Conversation

@peter-gribanov

Copy link
Copy Markdown
Member

Closes #88

Adds a permissions option that replaces the hardcoded 0755 mode applied to a downloaded database.

gpslab_geoip:
    license: 'XXXXXXXXXXXXXXXX'
    edition: 'GeoLite2-City'
    permissions: '0644'

Notes

  • The default stays 0755, so the behaviour without the option is unchanged.
  • Quote the value. The YAML parser does not treat 0644 as an octal number since Symfony 5, it returns the '0644' string. The option accepts the string form as well as an integer, which is what the YAML 0o644 and a PHP config give. An integer outside of the 0000–0777 range is rejected, which catches a decimal value written instead of an octal one.
  • The directory of the database is still created with 0755, it has to stay traversable.

Backward compatibility

Nothing is broken:

  • the Downloader interface is untouched, so third party implementations keep working;
  • MaxMindDownloader gets the mode as an optional third constructor argument;
  • the new config option defaults to the previously hardcoded value.

Tests

165 tests (was 135). Verified locally on the stacks the CI matrix resolves: PHP 7.2 + Symfony 2.8, PHP 8.0 + Symfony 5.2, PHP 8.3 + Symfony 7.4 and PHP 8.5 + Symfony 8.1 — tests and PHPStan green on all of them, PHP CS Fixer clean.

🤖 Generated with Claude Code

peter-gribanov and others added 2 commits August 7, 2026 17:18
Add the "permissions" option, it replaces the hardcoded 0755 mode of a
downloaded database. The default keeps the previous 0755 value.

The YAML parser does not treat "0644" as an octal number since Symfony 5,
it returns a string, so the option accepts both the "0644" string and an
integer. An integer out of the 0000-0777 range is rejected to catch a
decimal value written instead of an octal one.

The Downloader interface is untouched, the mode is an optional constructor
argument of MaxMindDownloader.

The directory of the database is still created with the 0755 permissions,
it has to stay traversable.

Closes gpslab#88

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@peter-gribanov
peter-gribanov merged commit d81915b into gpslab:master Aug 7, 2026
26 of 27 checks passed
@peter-gribanov
peter-gribanov deleted the chmod branch August 7, 2026 15:29
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.

Allow setting permissions on downloaded databases

1 participant