Source: hostname
Version: 3.15+nmu1
Tag: patch

The hostname tool depends on libnsl and associated headers
which prevents it from compiling on musl (and possibly on
other systems).  The observable behaviour of the tool should
not change with the attached patch on a glibc based system.
diff -Nru hostname-3.15/Makefile hostname-3.15+nmu1/Makefile
--- hostname-3.15/Makefile      2013-11-03 14:25:42.000000000 +0000
+++ hostname-3.15+nmu1/Makefile 2015-06-04 22:12:11.000000000 +0000
@@ -1,4 +1,4 @@
-CFLAGS+=-O2 -Wall
+CFLAGS+=-O2 -Wall -D_GNU_SOURCE
 
 # uncomment the following line if you want to install to a different base dir.
 #BASEDIR=/mnt/test
@@ -9,7 +9,7 @@
 OBJS=hostname.o
 
 hostname: $(OBJS)
-       $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) -lnsl
+       $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)
        ln -fs hostname dnsdomainname
        ln -fs hostname domainname
        ln -fs hostname ypdomainname
diff -Nru hostname-3.15/debian/changelog hostname-3.15+nmu1/debian/changelog
--- hostname-3.15/debian/changelog      2013-11-03 14:41:12.000000000 +0000
+++ hostname-3.15+nmu1/debian/changelog 2015-06-04 22:44:17.000000000 +0000
@@ -1,3 +1,15 @@
+hostname (3.15+nmu1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fixes build on musl libc.
+  * Use _GNU_SOURCE feature test macro, instead of glibc internal __USE_GNU.
+  * Use getdomainname instead of yp_get_default_domain because it is more
+    widely available and avoids the -lnsl dependency.
+  * localnisdomain is kept, even though it should be the same as localdomain,
+    so the behaviour is not changed in case of an error.
+
+ -- Szabolcs Nagy <n...@port70.net>  Thu, 04 Jun 2015 22:13:09 +0000
+
 hostname (3.15) unstable; urgency=low
 
   * Applied patch to make it possible to install binaries and man pages into
diff -Nru hostname-3.15/hostname.c hostname-3.15+nmu1/hostname.c
--- hostname-3.15/hostname.c    2013-11-03 14:26:51.000000000 +0000
+++ hostname-3.15+nmu1/hostname.c       2015-06-04 22:37:59.000000000 +0000
@@ -37,13 +37,11 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <getopt.h>
-#define __USE_GNU 1
 #include <string.h>
 #include <netdb.h>
 #include <errno.h>
 #include <ctype.h>
 #include <err.h>
-#include <rpcsvc/ypclnt.h>
 
 #define VERSION "3.15"
 
@@ -52,20 +50,19 @@
 char *progname;
 
 /*
- * Return the name of the nis default domain. This is just a wrapper for
- * yp_get_default_domain.  If something goes wrong, program exits.
+ * Return the name of the nis default domain. Same as localdomain below,
+ * but reports failure for unset domain.
  */
 char *
 localnisdomain()
 {
-       char *buf = 0;
+       /* The historical NIS limit is 1024, the limit on Linux is 64.  */
+       static char buf[1025];
        int myerror = 0;
 
-       myerror = yp_get_default_domain(&buf);
-
-       /* yp_get_default_domain failed, abort. */
-       if (myerror) {
-               printf("%s: %s\n", progname, yperr_string(myerror));
+       myerror = getdomainname(buf, sizeof buf);
+       if (myerror || strcmp(buf, "(none)")) {
+               printf("%s: Local domain name not set\n", progname);
                exit (1);
        }
 

Reply via email to