8000 Use IPGlobalProperties on all platforms by iSazonov · Pull Request #9530 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Use IPGlobalProperties on all platforms#9530

Merged
adityapatwardhan merged 2 commits intoPowerShell:masterfrom
iSazonov:cleanup-pinvoke-gethostname
May 8, 2019
Merged

Use IPGlobalProperties on all platforms#9530
adityapatwardhan merged 2 commits intoPowerShell:masterfrom
iSazonov:cleanup-pinvoke-gethostname

Conversation

@iSazonov
Copy link
Collaborator
@iSazonov iSazonov commented May 4, 2019

PR Summary

On Windows we use System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties to get computer name and domain name. The API was ported so we can remove P/Invokes for Unix-es.

On Unix CoreFX (then and then) calls GLibc getdomainname() which returns "(none)" if a domain name is not set by setdomainname(). (See https://access.redhat.com/solutions/352963) So we ignore the value.

PR Context

Related #9526.

PR Checklist

@iSazonov iSazonov added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label May 4, 2019
@iSazonov iSazonov added this to the 7.0-Consider milestone May 4, 2019
@iSazonov
Copy link
Collaborator Author
iSazonov commented May 4, 2019

It seems it is impossible to create useful test for the API.

@adityapatwardhan Could you please check Ubuntu container?

@adityapatwardhan
Copy link
Member

The change looks good to me. I verified the code on an Unbuntu 18.04 container:

PowerShell 6.2.0
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /> cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
PS /> [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties() | sv x
PS /> $x

DhcpScopeName :
DomainName    : (none)
HostName      : 7af9466760d8
IsWinsProxy   :
NodeType      : Unknown


PS />
8000

@adityapatwardhan
Copy link
Member

I also agree adding a test for this is useless.

@adityapatwardhan adityapatwardhan self-assigned this May 8, 2019
@adityapatwardhan adityapatwardhan merged commit 78d6466 into PowerShell:master May 8, 2019
@adityapatwardhan
Copy link
Member

@iSazonov Thank you for your contribution!

@iSazonov iSazonov deleted the cleanup-pinvoke-gethostname branch May 9, 2019 18:53
7CF7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0