• 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: Allan Nathanson <email@hidden>
  • Date: Fri, 6 Feb 2004 21:11:01 -0500

Why can't I name my computer "admin"? Should all currently defined login names be excluded as possible host names?

And as to any conventions used for setting the BSD hostname (gethostname(3), sethostname(3))... You are correct that the standards are ambiguous. Suggesting that the name have some relevance to a hosts DNS name, while a nice idea, makes a number of assumptions including:

- the system is actually connected to a network
- the system has only one network interface
- the system has only one IP address
- only one name is associated with the one IP address

Unfortunately, you can't make any of these assumptions. The world of computers is no longer as simple as the days when all computers were large, bolted to the floor, and non-functional unless the network was accessible.

What are we (Apple) doing? Here's the algorithm that we use to set the BSD hostname:

1. if available, use the name specified in the /etc/hostconfig file (HOSTNAME=my-host-name)
... and this name need not have any association with a DNS name

2. if available, use the name provided by the DHCP/BOOTP server for the "primary" IP address
... and this name need not have any association with a DNS name

3. if available, use the [first] name returned by a reverse DNS (address-->name) query for the "primary" IP address

4. if available, use the rendezvous hostname

5. use "localhost"

In short, we "try" to set the BSD hostname to something reasonable but there are no guarantees.

- Allan

p.s. I believe that Mac OS X Server systems tend to set a fixed name in the /etc/hostconfig file.



On Feb 6, 2004, at 8:35 PM, Jason Linhart wrote:

On 2/6/04 7:47 PM Justin Walker (email@hidden) wrote:

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.

There are a great many things that a program with root access can do, but
just because they can do something, that doesn't make that behavior
either correct or useful.

There is a clear standard. gethostname() is defined both by POSIX and by
Darwin in the same way. Just because the standard is not enforced by the
kernel doesn't mean that violating the standard is not a bug.

The difficulty here is not the lack of a standard, it is the ambiguity of
the standard. The spec calls for the "standard host name". Unfortunatly,
that is ambiguous. The spec is not specific enough to require a valid DNS
name, but it is specific enough to disallow things which could not
possibly be a host name. A DNS name would be compliant, an AppleTalk name
would be compliant, a name typed into a system configuration dialog box
as "Commputer Name" would be compliant, various other things would be
compliant, but a user name would not be compliant.

Jason

-----------------
email@hidden
-----------------
Dr. Seuss books . . . can be read and enjoyed on several levels. For
example, 'One Fish Two Fish, Red Fish Blue Fish' can be deconstructed
as a searing indictment of the narrow-minded binary counting system.
-- Peter van der Linden, Expert C Programming, Deep C Secrets
_______________________________________________
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.
_______________________________________________
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.

  • Follow-Ups:
    • Re: gethostname returns loginname on "Pather Server" version
      • From: Robert MacGregor <email@hidden>
References: 
 >Re: gethostname returns loginname on "Pather Server" version (From: Jason Linhart <email@hidden>)

  • Prev by Date: Re: gethostname returns loginname on "Pather Server" version
  • 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