Skip to content

libutil: use GetUserNameExW to query user name on windows#1778

Merged
Flow86 merged 1 commit into
Return-To-The-Roots:masterfrom
tehKaiN:better-query-user-name-on-windows
Jun 13, 2025
Merged

libutil: use GetUserNameExW to query user name on windows#1778
Flow86 merged 1 commit into
Return-To-The-Roots:masterfrom
tehKaiN:better-query-user-name-on-windows

Conversation

@tehKaiN

@tehKaiN tehKaiN commented Jun 11, 2025

Copy link
Copy Markdown
Contributor

Updates libutil submodule with Return-To-The-Roots/libutil#26

I guess this needs further updating after libutil is merged so that it points to proper commit hash

@Flow86

Flow86 commented Jun 12, 2025

Copy link
Copy Markdown
Member

Secur32.dll needs to be added to the blacklist

@Flamefire

Copy link
Copy Markdown
Member

I guess this needs further updating after libutil is merged so that it points to proper commit hash

You are right. Let's get that one merged

@Flow86

Flow86 commented Jun 12, 2025

Copy link
Copy Markdown
Member

ok rebase here on the master submodule, and its good to go

@tehKaiN tehKaiN force-pushed the better-query-user-name-on-windows branch from 24bfc7b to a1762a3 Compare June 12, 2025 14:10
@tehKaiN

tehKaiN commented Jun 12, 2025

Copy link
Copy Markdown
Contributor Author

the test failures don't look good - perhaps github actions don't like using that api function? perhaps System::getUserName() should fall back to non-ex version?

@Flamefire

Flamefire commented Jun 12, 2025

Copy link
Copy Markdown
Member

I've found hints that this fails if the VM isn't fully set up. I guess you already tested it locally where it works?

Other fall back to first and lastname: https://github.com/ubuntu/WSL/blob/cd4e23dfd0967745d46bb5d42302bf17f91e703c/DistroLauncher/WindowsUserInfo.cpp#L78-L101

I guess for us the old variant is good enough.

@tehKaiN

tehKaiN commented Jun 13, 2025

Copy link
Copy Markdown
Contributor Author

Using commit on my private fork once again, so can't be merged until Return-To-The-Roots/libutil#36 gets merged and this PR updated. Let's see if new code helps.

Other fall back to first and lastname: https://github.com/ubuntu/WSL/blob/cd4e23dfd0967745d46bb5d42302bf17f91e703c/DistroLauncher/WindowsUserInfo.cpp#L78-L101

I dunno, I get the feeling that if some environments don't support display names, then first/last names might be empty too. I think it's best to fall back to old stuff in case of failure.

I've split it to separate fns to make the System::getUserName() as least convoluted as possible - if you say that's too much I can remove the extra static fns and make the code more concise, but it won't be pretty.

@Flamefire

Copy link
Copy Markdown
Member

Agreed. Pr merged, can you update the submodule here?

@tehKaiN tehKaiN force-pushed the better-query-user-name-on-windows branch from 265686b to 2591322 Compare June 13, 2025 15:48
@Flamefire Flamefire enabled auto-merge (rebase) June 13, 2025 15:48
@Flow86 Flow86 disabled auto-merge June 13, 2025 19:11
@Flow86 Flow86 enabled auto-merge (rebase) June 13, 2025 19:14
@Flow86 Flow86 disabled auto-merge June 13, 2025 19:14
@Flow86 Flow86 merged commit 5cc1ddb into Return-To-The-Roots:master Jun 13, 2025
17 checks passed
@tehKaiN tehKaiN deleted the better-query-user-name-on-windows branch June 13, 2025 19:56
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.

3 participants