[Libreoffice] [PATCH] Replace command domainname by getdomainname() on Unix

Lionel Elie Mamane lionel at mamane.lu
Sat Nov 12 16:57:08 PST 2011


On Sat, Nov 12, 2011 at 09:00:08PM +0100, Arnaud Versini wrote:

> I have noticed some forks during valgrind check, I think it will be better
> to use functions instead of the unix command. This patch replace the fork
> and exec  domainnanme by a simple call to getdomainname(). It is faster and
> we sould have less message during valgrind and strace
> investigation's.

getdomainname() is not specified by SUS, nor POSIX. However, BSDs have
it since... a long, long time. Google tells me recent versions of
Solaris/SunOS sorta-has it, but not really: it is in -lnsl, but not in
the headers... See
http://old.nabble.com/getdomainname%3A-fix-several-problems-td30324427.html

So I guess we are happy with the portability of that, and I'm committing.

For nitpickers, note that getdomainname does *not* return the DNS
domain, but the NIS domain, which strictly speaking may or may not
coincide. The portable and strictly correct way seems to be to do a
DNS query on the result of gethostname() (gethostbyname or getaddrinfo
with AI_CANONNAME).

-- 
Lionel


More information about the LibreOffice mailing list