Conversation
`date -d` is GNU-only, `date -r <epoch>` is BSD-only (busybox's -r reads the timestamp of a *file*), and `date -v+1d` is BSD-only. On Alpine every branch of the existing fallback chains failed, so: - run_guest produced an empty expiry, making `guest <label> 24h` and the onboarding wizard fail outright - secret_extend and secret_bulk_extend could not compute a new date; their last resort was python3, which Alpine does not ship - voucher_redeem fell back to *now*, so a voucher expired the moment it was redeemed instead of after its stated duration - secret_check_quota_resets fell back to a hardcoded 31, firing the monthly reset on the wrong day for every month shorter than 31 days Add _epoch_to_date(), which uses bash's printf %()T so no external command is involved at all, plus _last_day_of_month() for the calendar arithmetic. Display sites keep rendering local time — only the UTC expiry maths changed, so no timezone behaviour changes. Verified on Alpine 3.20: tests/test_guest.sh goes from 6 failures to 0, and no other test changes result on Debian 12, Alpine 3.20 or Fedora 41.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The codebase builds expiry dates with
date -d ... || date -r ... || ...chains. None of those branches works on Alpine:date -dis GNU-onlydate -r <epoch>is BSD-only — busybox's-rreads the timestamp of a filedate -v+1dis BSD-onlySo on Alpine every fallback failed, with these results:
run_guestguest <label> 24hand the onboarding wizard failed outrightsecret_extend,secret_bulk_extendpython3, which Alpine does not shipvoucher_redeemsecret_check_quota_resetsFix
_epoch_to_date()uses bash'sprintf %()T, which does the conversion in-process and needs no external command at all. Thedatebranches are kept only as a fallback for bash builds without it._last_day_of_month()handles the calendar arithmetic, with proper leap-year rules.Display sites keep rendering local time — only the UTC expiry maths changed, so no timezone behaviour changes. Format strings still carry a leading
+at the call sites (thedateconvention); the helper strips it forprintfand restores it for the fallbacks.Testing
New
tests/test_date_portability.shputs a busybox-styledateonPATH— one that still formats normally but rejects-d @epoch,-d "+N days",-rand-v, which is precisely the busybox gap. It asserts expiries are not just well-formed but land on the correct calendar day, and covers leap years including the 1900/2000 century cases.Verified on Alpine 3.20:
tests/test_guest.shgoes from 6 failures to 0. This fix is not required and does not change anything on the following tested machines: Debian 12, Ubuntu 22.04/24.04 and Fedora 41.