linuxUsesMusl globs the filesystem for a musl loader, which reports whether
the machine has musl available rather than whether this process runs on it.
glibc distributions package musl for cross compilation, so on such a host
the musllinux libunicorn is selected and dlopened into a glibc process.
That load succeeds, because the musl libc really is installed, and symbol
resolution then splits across both libcs: glibc exports __sigsetjmp but not
sigsetjmp, so libunicorn's sigsetjmp binds to musl and stores the jump
buffer unmangled, while siglongjmp binds to glibc and applies PTR_DEMANGLE
to it. The restored stack pointer and program counter come out
non-canonical, so the process dies with SIGSEGV (si_code SI_KERNEL) inside
cgo as soon as the SAP machine initializes.
Read PT_INTERP of /proc/self/exe instead, which names the loader this
process was linked against. Statically linked builds have no PT_INTERP and
keep the existing host probe.
Apple's account bag now returns the authentication endpoint as
https://auth.itunes.apple.com/auth/v1/native/fast. That endpoint only
responds correctly when the path has a trailing slash; posting to it
without the slash makes Apple's edge return a 301/204 with an empty or
HTML body, so 'ipatool auth login' fails to parse the response and
silently dies (observed as the 'plist: unexpected hex digit' error or a
-5000 with no usable message).
Also improve http client diagnostics: when an XML response body is not a
property list, return 'unexpected response from Apple (HTTP <code>):
<snippet>' instead of the opaque plist parse error.
* Fix purchase retry to resolve auth endpoint via Bag() before re-login
The retry logic in purchase, download, get-version-metadata, and
list-versions called Login() without an Endpoint when re-authenticating
after a password token expiry. This caused silent failures because the
auth endpoint was empty.
- Add Bag() call before Login() in all retry blocks to resolve the auth
endpoint dynamically
- Fall back to hardcoded auth endpoint when bag.xml omits
authenticateAccount
- Detect "Your password has changed." customer message as a token expiry
trigger alongside failure type 2034
- Increase download retry attempts to 3 to handle license-required then
token-expired chain
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Address PR review: make auth path constant consistent, add password-changed test
- Rename PrivateAppStoreAPIPathAuthenticate to store only the path
(consistent with other *APIPath* constants), constructing the full
URL in the Bag() fallback
- Add test for CustomerMessagePasswordChanged triggering
ErrPasswordTokenExpired in purchaseWithParams
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix purchase "already purchased" detection for Apple API changes
Apple now returns HTTP 200 with FailureType "5002" for already-purchased
apps instead of HTTP 500. Also treat FailureType "1008" (device
verification failed) as a stale token that triggers re-authentication.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix download retry to handle new Apple failure types (5002, 1008)
Map FailureType "5002" (license already exists) and "1008" (device
verification failed) to ErrPasswordTokenExpired in the download flow,
triggering re-auth retry consistent with the purchase fix in 438e8e8.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix zip corruption on re-download when .ipa already exists
applyPatches opened the destination file with O_CREATE|O_WRONLY but no
O_TRUNC. On re-download, the existing .ipa (which includes sinf data
from ReplicateSinf) is larger than what applyPatches writes (zip entries
+ metadata, no sinf yet). The leftover bytes at the end corrupt the ZIP
end-of-central-directory record, causing ReplicateSinf's zip.OpenReader
to fail with "failed to open zip reader".
Fix: add O_TRUNC to truncate the file before writing, and add a missing
defer dstFile.Close() to prevent file descriptor leaks.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Treat "license already exists" as success in purchase and download
When the user already owns an app, purchase should report success
(with alreadyOwned=true) instead of failing with an error. Applied
to both the standalone purchase command and the --purchase flag in
the download command.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Remove Bag() fallback in retry paths, use DefaultAuthEndpoint directly
The bag response from init.itunes.apple.com/bag.xml does not contain
an authenticateAccount key, so the fallback was firing 100% of the time.
Replace the Bag()+Login() pattern in retry paths with Login() using a
DefaultAuthEndpoint constant directly, avoiding an unnecessary network
round-trip. The cmd/auth.go login flow still uses Bag() as before.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Use bag auth endpoint for retry login
---------
Co-authored-by: Barnabas Birmacher <birmacher@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>