• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: gethostname returns loginname on "Pather Server" version
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gethostname returns loginname on "Pather Server" version


  • Subject: Re: gethostname returns loginname on "Pather Server" version
  • From: Justin Walker <email@hidden>
  • Date: Fri, 6 Feb 2004 16:47:09 -0800

On Friday, February 6, 2004, at 10:53 AM, Jason Linhart wrote:

On 2/6/04 12:26 PM Justin Walker (email@hidden) wrote:

My point about gethostname() is that this value is totally unrelated to
the information provided by gethostbyname(). The former is just some
string. It has no relation to DNS.

gethostname() is defined to be the "standard host name for the current
machine", which the current login name most certainly is not.

Au contraire: 'sethostname()' is a procedure which takes an argument, a string, from an undefined source, and plants it in the kernel for later retrieval by 'gethostname()'. Yours is a common misconception, but one which can cause problems, as we've seen.

Bottom line: don't use gethostname(); anyone with root access on that machine can set the 'hostname' to be anything he wants. It is not related to any "standard", except by convention.

and the kernel thinks that is the hostname because some
other piece of code ran earlier to 'sethostname()' to "admin".

Whatever piece of software that was, presumably provided by Apple, has a
bug. It should not be calling sethostname() with the current login name
(which I assume it is doing based on what others have said). If Apple
would fix their bug, then Sanjay Arora's code would work.

You are making a string of assumptions that have not been validated.

gethostname() has a long and checkered history.

Amen.

As for the remainder of your message, you are correct in quoting Quinn, but you are not correct in the leap from there to the use of 'hostname'.

Sanjay, in any case, should look into getnameinfo/getaddrinfo, to see what they can do for his project. Reliance on 'gethostname()' will just lead him back to this small quagmire.

Regards,

Justin

--
Justin C. Walker, Curmudgeon-At-Large *
Institute for General Semantics | "Weaseling out of things is what
| separates us from the animals.
| Well, except the weasel."
| - Homer J Simpson
*--------------------------------------*-------------------------------*
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.
References: 
 >Re: gethostname returns loginname on "Pather Server" version (From: Jason Linhart <email@hidden>)

  • Prev by Date: Re: Activating/deactivating a network interface
  • Next by Date: Re: gethostname returns loginname on "Pather Server" version
  • Previous by thread: Re: gethostname returns loginname on "Pather Server" version
  • Next by thread: Re: gethostname returns loginname on "Pather Server" version
  • Index(es):
    • Date
    • Thread