Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hostname behavior for Windows does not match Unix #121

Open
meop opened this issue Oct 22, 2024 · 1 comment
Open

hostname behavior for Windows does not match Unix #121

meop opened this issue Oct 22, 2024 · 1 comment
Assignees
Labels
Milestone

Comments

@meop
Copy link

meop commented Oct 22, 2024

Describe the bug
This project's hostname value for Windows has changed from being formatted to all uppercase, to all lowercase, back to all uppercase over the last couple of years, but I think the behavior is still incorrect.

In 2022, it was all uppercase, which was marked as an issue: (#39)
In 2023, it had been coerced into all lowercase, which was again marked as an issue: (#82)

After that, whoami was changed to use the NetBIOS formatted hostname, so back to being all uppercase, which I believe is still incorrect.

Consider this example:

On MacOS:

system:
hostname: soDIum

whoami:
hostname: soDIum
devicename: My MacBook Air

On Windows:

system:
hostname: soDIum

whoami:
hostname: SODIUM
devicename: soDIum

To Reproduce
Steps to reproduce the behavior:
Use the latest release of whoami on Windows.
Check the output of hostname and devicename functions.

Expected behavior
I think that whoami's hostname result should try to identically match what the OS system CLI tool hostname reports.. which itself preserves casing.

Yes DNS itself is case insensitive, but people do often use mixed case styling in their hostnames, so reflecting that in whoami's output accurately does makes sense.

Currently whoami's behavior matches this expectation for Linux and MacOS, but not Windows.

I believe a good fix would be to reverse the use of ComputerNameFormat::NetBIOS and ComputerNameFormat::DnsHostname in the hostname and devicename functions in whoami/src/os/windows.rs

NetBIOS (and also the COMPUTERNAME env var) will always be uppercase, and seems to me to be more of a 'fancy' naming, or at least aligns better with being a 'device' name than a 'host' name.

Also, not sure the order of precedence for ComputerNameFormat::PhysicalNetBIOS and ComputerNameFormat::PhysicalDnsHostname over the respective non-physical versions, but one level could be incorporated as a fallback over the other too, if desired.

Thank you!

@AldaronLau
Copy link
Member

@meop Thanks for opening this issue, I will take a look!

@AldaronLau AldaronLau self-assigned this Oct 25, 2024
@AldaronLau AldaronLau added the bug label Oct 25, 2024
@AldaronLau AldaronLau added this to the 1.6.0 milestone Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants