From: "Benjamin R. Haskell" <zsh@benizi.com>
To: "William G. Scott" <wgscott@chemistry.ucsc.edu>
Cc: zsh-users@zsh.org
Subject: Re: $HOST on OS X
Date: Sat, 5 Jun 2010 11:45:26 -0400 (EDT) [thread overview]
Message-ID: <alpine.LNX.2.01.1006051142290.5029@hp.internal> (raw)
In-Reply-To: <alpine.LNX.2.01.1006051125040.5029@hp.internal>
On Sat, 5 Jun 2010, Benjamin R. Haskell wrote:
> On Sat, 5 Jun 2010, William G. Scott wrote:
>
> > Dear citizens:
> >
> > I just noticed odd behavior for how $HOST is getting set on OS X v.
> > 10.6.3.
> >
> > One one home machine connected to a wireless router and ADSL modem:
> >
> > % print $HOST
> > internalcheck.apple.com
> >
> > On another -- This one worries me more:
> >
> > % print $HOST
> > e3191.c.akamaiedge.net
> >
> > The manual says $HOST is automatically set by the shell, but I wonder
> > how this is happening? I don't have anything weird in /etc/hosts for
> > example...
>
> $HOST is set by the following lines in Src/params.c:
>
> 682 hostnam = (char *)zalloc(256);
> 683 gethostname(hostnam, 256);
> 684 setsparam("HOST", ztrdup(hostnam));
>
> If gethostname is defined in unistd.h, it's a standard library call that
> fills its char* first parameter with your hostname. Otherwise, there's
> a compatibility replacement in Src/compat.c that basically gets the node
> name via uname. Omitting error-checking, it's:
>
> int gethostname(char*name, size_t namelen) {
> struct utsname uts;
> uname(&uts);
> strcpy(name,uts.nodename);
> }
>
> So, either way, it follows a pretty standard path to getting a hostname.
>
> I'm not sure whether OS X would have gethostname, but what does `uname
> -n` return? Or `hostname`?
I also neglected to mention that $HOST can be inherited from the
environment.
e.g.:
$ HOST=whatever zsh -c 'echo $HOST'
whatever
$
So, maybe there was some script you/someone ran that set
HOST=e3191.c.akamaiedge.net, for convenience. (For uploading things to
Akamai's CDN, maybe? Seems a bit of a stretch.)
--
Best,
Ben
next prev parent reply other threads:[~2010-06-05 15:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <A31BDCF6-D2C6-4674-B4D5-86B60347A0B2@chemistry.ucsc.edu>
2010-06-05 14:24 ` William G. Scott
2010-06-05 15:37 ` Benjamin R. Haskell
2010-06-05 15:45 ` Benjamin R. Haskell [this message]
2010-06-05 16:55 ` François Revol
2010-06-05 18:52 ` Benjamin R. Haskell
2010-06-05 19:46 ` François Revol
2010-06-06 15:34 ` Vincent Lefevre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LNX.2.01.1006051142290.5029@hp.internal \
--to=zsh@benizi.com \
--cc=wgscott@chemistry.ucsc.edu \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).