feat(libkernel): implement getlogin_r using the host account name #3606
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3606"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Lorkydey on 2026-10-11T14:10:01Z.
What
VLC (PPSA85300) and PShare (PPSA99773) stop on
maina11c8f7fwithFAIL: unresolved ELF import 78FiHequa9U (getlogin_r) from libkernel.prx. babyhuey's VLC comparison and PShare comparison confirm that the original PR gets both titles past this import on Windows and Linux. PS5MC also imports it, but was only inspected, not launched.Implement the signed 32-bit buffer-length ABI from the PS5 payload SDK. The buffer must hold the complete name and its NUL: short or nonpositive lengths return guest
ERANGE(34), null output with a positive length returnsEFAULT(14), and returned errors preserve errno and the caller's buffer. The buffer contract follows FreeBSD getlogin_r.In response to review, the guest receives the host effective account name regardless of login-session availability:
GetUserNameWconverted to UTF-8 on Windows, andgetpwuid_r(geteuid())on POSIX. POSIX no longer calls hostgetlogin_r, so starting without a login session does not turn the result intoENXIOorENOENT. There is no environment-variable lookup, replacement username or retry. Account lookup/encoding failures and missing account records throw; the POSIX record buffer is bounded at 16 KiB and insufficient storage also throws.TechnicalDebt records this host-account policy and that the actual console login name and session semantics remain unknown. Windows account lookup follows GetUserNameW. Calls use independent storage.
Tested
Rebased onto
mainbca7a29d, which includes the WindowsHostPollbuild fix from #4021. Tested PR head:f88be06a. The two getlogin commits are unchanged by the rebase;Socket.cppis identical to the base.BUILD_TESTING=ON,ANYPS5_ENABLE_SPIRV_TOOLS=OFF: the full default build and thelibstarget pass (cmake --build build --parallel 6, thencmake --build build --target libs --parallel 6). The previously reportedHostPollerror no longer blocks this revision.guest_getlogin,guest_process_arguments,guest_parent_process,guest_errors,guest_sce_net,guest_poll,guest_socket_pair,guest_socket_read_writeandguest_socket_events. Command:ctest --test-dir build --output-on-failure --no-tests=error --repeat until-fail:5 --parallel 1 --timeout 30 -R '^guest_(getlogin|process_arguments|parent_process|errors|sce_net|poll|socket_pair|socket_read_write|socket_events)$'.guest_getlogincovers the native account name, exact-fit and short buffers, NUL termination, canaries, unchanged short-buffer output, invalid lengths, null output, preserved errno and concurrent readers. The local Windows account name is ASCII; non-ASCII account names were not exercised.guest_sce_netalso exercisesselect, including immediate/timed waits and invalid inputs, to check the integration with #4021.libkernel/libclibraries and focused test targets on the same rebased source. All five CTest tests passed five consecutive runs each:guest_getlogin,guest_getlogin_no_session,guest_process_arguments,guest_parent_processandguest_errors. Linux CI, including the failing-before/passing-after check. The CI-only workflow is on a separate fork branch and is not part of this PR.guest_getlogin_no_sessiontest links the actualLogin.cppwith a controlled hostgetlogin_rreturningENXIO,ENOENT, or a different session name. All three must yield the effective account name. The previous implementation fails this test with guest result 6; the updated implementation passes. The normalguest_getlogintest now requires successful account lookup and no longer exits successfully without testing the buffer and concurrency cases when no session exists.The full CTest suite was not run. Earlier independent title runs above used the original
187fd853implementation; titles were not rerun for this revision. No console-hardware comparison is claimed.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T14:10:35Z.
Progress report (
bca7a29→f88be06)📈 System libraries: 86.48% (+0.01%, +1 implemented functions)
✅ 1 implemented
getlogin_r_nid_postfixImported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T14:46:11Z.
Checked on Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release, with this PR (187fd853) merged onto
maina11c8f7f.guest_getloginpasses 5/5 on both (--repeat until-fail:5); no warnings in the changed files on Windows.getlogin_ron both. OnmainWindows stops atFAIL: unresolved ELF import 78FiHequa9U (getlogin_r) from libkernel.prx; with this PR it stops atFAIL: unresolved ELF import J0kng1yac3M (readdir_r) from libSceLibcInternal.prx(#3635). Linux gives the same:undefined symbol: J0kng1yac3M.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T15:00:02Z.
Cross-linking for the review: this implements half of the fix tracked in #3556 (
getlogin_r; thereaddir_rhalf is in #3635), which has an independent Linux verification on that issue — full suite 832/832 (CachyOS, GCC 16.2.1, including the Vulkan suites on AMD RX 9070 XT / RADV), conventions check clean.Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T17:36:57Z.
One more title for this PR: PShare (PPSA99773, 1.0, new in the catalog) also stops at
getlogin_ronmaina11c8f7f, and with this PR (187fd853) it loads all its imports. Same setups as above.main, Windows:FAIL: unresolved ELF import 78FiHequa9U (getlogin_r) from libkernel.prx; Linux:undefined symbol: 78FiHequa9UsceVideoOutOpenbecause the run is headless.app.exe+0x12f1b, read of0x240). That is past anythinggetlogin_rtouches.Imported from boykopovar/AnyPS5. Originally posted by Lorkydey on 2026-10-11T18:02:57Z.
Thanks for the detailed report @babyhuey ! I reproduced the exact PShare crash and opened #3855 with a proposed fix and regression test.
sceKernelConvertUtcToLocaltime writes 8 bytes into PShares 4byte DST output, overwriting the saved model pointer. With #3606 plus #3855, it gets past that crash locally. It then stops at AGC graphics: last provoking vertex with explicit per vertex flat interpolation is unsupported.
Could you retest the two PRs together on your setups ?? The PR includes the ABI evidence and limitations; I haven’t verified this on a physical PS5.
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T18:33:27Z.
Retested #3606 together with #3855 on Linux and Windows and got the same as you: the null read is gone and PShare stops at the AGC flat interpolation throw. Details on #3855.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T23:15:28Z.
Please add a TechnicalDebt entry for
getlogin_r: it returns the host account name, and what the console returns isn't known.On Linux the host call also fails with
ENXIOorENOENTwhen the process has no login session, so the same title gets a name or an error depending on how it was started. Say in the entry which of the two a guest should see, and make the code do that on every host.Imported from boykopovar/AnyPS5. Originally posted by Lorkydey on 2026-10-11T23:34:15Z.
@oneandonlydean thanks for catching this! Updated in
3a1f44c8.The chosen behavior is to return the effective host account name even without a login session. POSIX now uses
getpwuid_r(geteuid())directlyWindows uses GetUserNameW. TechnicalDebt documents this policy and the unknown console behavior.
Added a regression test covering ENXIO, ENOENT and a different session name.
It fails before the change and passes afterward.
The focused Linux tests pass, and the Windows getlogin test passes 5/5.
The full Windows build is blocked by an existing HostPoll error on main, detailed in the PR.
Imported from boykopovar/AnyPS5. Originally posted by Lorkydey on 2026-10-11T23:54:39Z.
@oneandonlydean Quick update: #4021 was merged while I was writing my earlier comment fixing the unrelated HostPoll Windows build error.
I've rebased this PR onto the updated main and retested. The full Windows build now passes, and all focused tests pass on both Windows and Linux, with five consecutive runs each.
The PR description is updated with the results.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T00:34:00Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/TechnicalDebt.mdL52Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-12T00:36:32Z.
Windows validation with title evidence (Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
BUILD_TESTING=ON, full build includinglibs): PR head187fd853merged cleanly ontomainbca7a29d(which already includes #4021).guest_getlogin3/3;ctest -j8 -E "^agc_driver_|^video_out_flip"583/585, the two failures being the knownagc_write_tracking(#4087) andguest_kernel_stack_protect(#4088), no new failure against themainbaseline; conventions andgit diff --checkpass.VLC (PPSA85300 0.3.1) relinked against this build: before,
FAIL: unresolved ELF import 78FiHequa9U from libkernel.prx(getlogin_r); after,FAIL: unresolved ELF import J0kng1yac3M from libSceLibcInternal.prx(readdir_r, open #3635), exactly the next stop predicted from its import order.