Re: gethostname returns loginname on "Pather Server" version
Re: gethostname returns loginname on "Pather Server" version
- Subject: Re: gethostname returns loginname on "Pather Server" version
- From: Allan Nathanson <email@hidden>
- Date: Fri, 6 Feb 2004 14:19:46 -0500
Here's a question. You say that gethostname() returns "admin" (as in
the login name). Does this name change if you login as another user?
I would guess that the name "admin" was entered into some text field
when the system was originally configured and has remained the same
ever since.
- Allan
On Feb 6, 2004, at 1:53 PM, 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.
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.
gethostname() has a long and checkered history. In some systems it was
specifically defined to return a valid DNS name for the current
machine.
That concept never made it into POSIX, but the convention that
gethostname() returns a usable network (DNS) name has survived in
practice more often than not.
As Quinn is so fond of pointing out, there is no way to know what the
"official" IP address, or DNS name, for the current machine is. The
name
you want might vary depending on where you are attempting to contact
the
machine from. However, in practice, most machines actually only have
one
name that matters. Historically, gethostname() has been used in many
systems to find out what that "one true" name is.
Partly as a result of the whole concept of "the one true name" being
inconsistent, and partly as a result of there being more than one kind
of
network (TCP/IP vs. AppleTalk for example) and thus more than one name
in
a different sense, the usage of gethostname() has been inconsistent and
never really standardized. Still, no interpretation of the definition
that I have ever heard of can be stretched so far as to allow the login
name to be a valid setting of that field. If some piece of Apple
software
is setting the host name to the login name, that is a bug.
Jason
_______________________________________________
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.