From 29e2421368da58fc49e721488c77a786981989ec Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Mon, 23 Apr 2018 16:25:56 +0900 Subject: [PATCH] Imported Upstream version 3.18 Change-Id: I51fe3d479ae56612cc71d6bde05e19fdc97fbcdf Signed-off-by: DongHun Kwak --- Makefile | 4 ++-- debian/changelog | 29 +++++++++++++++++++++++++++++ debian/compat | 2 +- debian/control | 4 ++-- debian/rules | 2 +- hostname.1 | 2 +- hostname.c | 23 ++++++++++------------- 7 files changed, 46 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 4aa664b..c473641 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ MANDIR:=/usr/share/man 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 --git a/debian/changelog b/debian/changelog index 2cd375d..40962dc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,32 @@ +hostname (3.18) unstable; urgency=medium + + * Make sure memory is initialized to zero before attempting to read hostname. + Thanks to Marko Dimjašević (Closes: #829010) + * Bumped Standards-Version to 3.9.8, no changes needed. + * Updated to debhelper 9. + + -- Michael Meskes Sun, 03 Jul 2016 21:26:17 +0200 + +hostname (3.17) unstable; urgency=medium + + * Applied patch by Szabolcs Nagy (Ccloses: #787780) to: + * 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. + * Replace 'dh-clean -k' with 'dh-prep' + + -- Michael Meskes Fri, 19 Feb 2016 13:00:23 +0100 + +hostname (3.16) unstable; urgency=medium + + * Changed buffer size to the recommended 255 character when working with + names instead of IPs. (Closes: #796922) + * Bumped Standards-Version to 3.9.6, no changes needed. + + -- Michael Meskes Tue, 01 Sep 2015 12:32:18 +0200 + hostname (3.15) unstable; urgency=low * Applied patch to make it possible to install binaries and man pages into diff --git a/debian/compat b/debian/compat index 7ed6ff8..ec63514 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -5 +9 diff --git a/debian/control b/debian/control index 5533a75..0cbbb9e 100644 --- a/debian/control +++ b/debian/control @@ -3,8 +3,8 @@ Section: admin Priority: required Maintainer: Debian Hostname Team Uploaders: Michael Meskes -Standards-Version: 3.9.4 -Build-Depends: debhelper (>= 5) +Standards-Version: 3.9.8 +Build-Depends: debhelper (>= 9) Package: hostname Architecture: any diff --git a/debian/rules b/debian/rules index 09b46a3..83d8be9 100755 --- a/debian/rules +++ b/debian/rules @@ -45,7 +45,7 @@ clean: install: build dh_testdir dh_testroot - dh_clean -k + dh_prep dh_installdirs # Installing package diff --git a/hostname.1 b/hostname.1 index 38c0a35..5e345e7 100644 --- a/hostname.1 +++ b/hostname.1 @@ -70,7 +70,7 @@ function, while and .BR nisdomainname use the -.BR yp_get_default_domain (3). +.BR getdomainname (2). .LP .B dnsdomainname will print the domain part of the FQDN (Fully Qualified Domain Name). The diff --git a/hostname.c b/hostname.c index 167e918..823ba82 100644 --- a/hostname.c +++ b/hostname.c @@ -37,35 +37,32 @@ #include #include #include -#define __USE_GNU 1 #include #include #include #include #include -#include -#define VERSION "3.15" +#define VERSION "3.18" enum type_t { DEFAULT, DNS, FQDN, SHORT, ALIAS, IP, NIS, NIS_DEF, ALL_FQDNS, ALL_IPS }; 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)") == 0) { + printf("%s: Local domain name not set\n", progname); exit (1); } @@ -279,7 +276,7 @@ show_name(enum type_t type) break; case ALL_IPS: case ALL_FQDNS: { - char buf[INET6_ADDRSTRLEN]; + char buf[255]; int flags, ret, family, addrlen; /* What kind of information do we want from getnameinfo()? */ @@ -410,7 +407,7 @@ read_file(char *filename, int boot) } if (fstat(fileno(fp), &st) == -1 - || (buf = (char *) malloc(st.st_size + 1)) == NULL) + || (buf = (char *) calloc(st.st_size + 1, sizeof(char))) == NULL) err(1, NULL); while (fgets(buf, st.st_size + 1, fp) != NULL) { -- 2.7.4