[PATCH 1/2] properly detect availability of gethostname() on Solaris

Sean McGovern gseanmcg at gmail.com
Wed Mar 13 14:07:00 EDT 2013


---
 lib/saslutil.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/saslutil.c b/lib/saslutil.c
index 6174124..b3c9683 100644
--- a/lib/saslutil.c
+++ b/lib/saslutil.c
@@ -80,8 +80,8 @@
  * sasl_erasebuffer
  */
 
-#ifdef sun
-/* gotta define gethostname ourselves on suns */
+#if defined(sun) && !defined(HAVE_GETHOSTNAME)
+/* On some versions of Solaris, gethostname() is available but has no proto */
 extern int gethostname(char *, int);
 #endif
 
@@ -533,6 +533,7 @@ int get_fqhostname(
     struct addrinfo hints;
     struct addrinfo *result;
 
+#ifdef HAVE_GETHOSTNAME
     return_value = gethostname (name, namelen);
     if (return_value != 0) {
 	return (return_value);
@@ -541,6 +542,7 @@ int get_fqhostname(
     if (strchr (name, '.') != NULL) {
 	goto LOWERCASE;
     }
+#endif
 
 /* gethostname hasn't returned a FQDN, we have to canonify it ourselves */
     hints.ai_family = PF_UNSPEC;
-- 
1.8.0.2



More information about the Cyrus-devel mailing list