• 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: gethostid problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gethostid problem


  • Subject: Re: gethostid problem
  • From: Stan Sieler <email@hidden>
  • Date: Wed, 16 Feb 2011 12:07:40 -0800

Re:

>> Is gethostid() supposed to work in X86 64-bit mode?
>
> This sounds like a bug.  Please file it.
>

Done, bug report 9011532

thanks for the reminder!

(In the bug report I pointed to what might be the root cause, mentioned below.)

> However, what is your goal with getting the host ID?  Not only is this API deprecated, so is the entire concept.


It's a quick/cheap/easy and (mostly) portable method of getting something we can use for software licensing.

We use a fairly simple-minded license scheme that works across many platforms.  It requires that we be able to
generate a reasonably unique 32-bit number on a given machine.  (On a machine without gethostid()
(or uname's idnumber / __idnumber field), we just hash the hostname.)
(We're not trying to stop every potential pirate ... just the casual / low-tech / accidental ones.)

We were testing a new product on a Linux system and I said "hey, we really like the Mac, can we port
it to it?"  It uses our software license mechanism, so I tested that and saw that (usually) gethostid()
was returning 0 (that, in itself, is enough to make us switch to some other 32-bit number :)
...except for when it returned a value way out of range (gethostid() is documented as returning
a 32-bit number ... and I suspect that's where the bug is, in the 32/64 bit interface, because
the bad value does 0 in the bottom 32 bits.

So, a minor but annoying problem ... and one that can lead a developer down the wrong path.
(E.g., what if I'd seen the non-0 value the first time, and said "darn, the doc's wrong, and
Mac OS X returns a value that requires 64 bits ... let's go change our licensing software
to adapt to this" ... then the next time we ran it, we get a 0 :)

>  You might want to look at <x-man-page://2/gethostuuid> instead.

Got it, thanks.

Of course, the man page for it has this troublesome "wait" parameter ... why should a process
have to wait to get the UUID for the host?

Stan
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: gethostid problem
      • From: "Quinn \"The Eskimo!\"" <email@hidden>
References: 
 >gethostid problem (From: Stan Sieler <email@hidden>)
 >Re: gethostid problem (From: "Quinn \"The Eskimo!\"" <email@hidden>)

  • Prev by Date: Re: gethostid problem
  • Next by Date: Re: gethostid problem
  • Previous by thread: Re: gethostid problem
  • Next by thread: Re: gethostid problem
  • Index(es):
    • Date
    • Thread