{admin_uri} substitution

Michael Sweet mike at easysw.com
Fri Sep 9 07:10:09 PDT 2005


Rafal wrote:
>>Rafal wrote:
>>
>>>...
>>>So I assume, that I have my configuration *exactly* as the command
>>>'hostname' expects. It spills out FQDN only when requested
>>>explicitly.
>>
>>But what does "gethostname()" produce?
> 
> 
> ----------------t.c------------------
> main() {
>         if (gethostname(buff, BSIZE) == 0) {
>                 printf("%s\n", buff);
>         }
> }
> ------------------------------------
> anonymous at model:~/work/tmp$ ./a.out
> model
> -----------------------------------
> 
> This output is quite obvious to me. The FQDN is only returned by hostname when it's called with "--fqdn" option. That option makes it do some extra resolver calls (apart from plain gethostname). And I think the intention really was to have `hostname --fqdn` return more then plain `hostname` -- otherwise the option would be spuriuse. Presumably to have gethostname() return none-FQDN (just host part) -- but the explanation of that in `hostname` manpages, although visible, is not so clear to me.

Right, but gethostname() is how we get the name of the local system.

I grabbed the net-tools source and looked at the implementation of
the hostname command - it looks like it does a gethostbyname() to
gather the FQDN, but that will only work if you have DNS or the
proper entries in your hosts file...

Go ahead and submit the STR with these notes - I'll do some testing
on different OS's to see if that is a portable way to get the local
FQDN and any aliases for that machine.

-- 
______________________________________________________________________
Michael Sweet, Easy Software Products           mike at easysw dot com
Internet Printing and Document Software          http://www.easysw.com




More information about the cups mailing list